diff mbox series

wcn36xx: Fix software-driven scan

Message ID 1597680075-18723-1-git-send-email-loic.poulain@linaro.org
State Superseded
Headers show
Series wcn36xx: Fix software-driven scan | expand

Commit Message

Loic Poulain Aug. 17, 2020, 4:01 p.m. UTC
For software-driven scan, rely on mac80211 software scan instead
of internal driver implementation. The internal implementation
cause connection trouble since it keep the antenna busy during
the entire scan duration, moreover it's only a passive scanning
(no probe request). Therefore, let mac80211 manages sw scan.

Note: we fallback to software scan if firmware does not report
scan offload support or if we need to scan the 5Ghz band (currently
not supported by the offload scan...).

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

---
 drivers/net/wireless/ath/wcn36xx/main.c    | 165 ++++++++++++++++-------------
 drivers/net/wireless/ath/wcn36xx/smd.c     |  23 +++-
 drivers/net/wireless/ath/wcn36xx/smd.h     |   8 +-
 drivers/net/wireless/ath/wcn36xx/txrx.c    |  11 +-
 drivers/net/wireless/ath/wcn36xx/wcn36xx.h |   6 +-
 5 files changed, 120 insertions(+), 93 deletions(-)

-- 
2.7.4


_______________________________________________
wcn36xx mailing list
wcn36xx@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/wcn36xx

Comments

Kalle Valo Aug. 18, 2020, 6:15 a.m. UTC | #1
Loic Poulain <loic.poulain@linaro.org> writes:

> For software-driven scan, rely on mac80211 software scan instead

> of internal driver implementation. The internal implementation

> cause connection trouble since it keep the antenna busy during

> the entire scan duration, moreover it's only a passive scanning

> (no probe request). Therefore, let mac80211 manages sw scan.

>

> Note: we fallback to software scan if firmware does not report

> scan offload support or if we need to scan the 5Ghz band (currently

> not supported by the offload scan...).

>

> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>


What changed since v2? Please always include a changelog so that I don't
need to guess what you have changed in the patch. No need to resend, a
reply is enough.

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches#changelog_missing

-- 
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Loic Poulain Aug. 18, 2020, 1:34 p.m. UTC | #2
On Tue, 18 Aug 2020 at 08:15, Kalle Valo <kvalo@codeaurora.org> wrote:
>

> Loic Poulain <loic.poulain@linaro.org> writes:

>

> > For software-driven scan, rely on mac80211 software scan instead

> > of internal driver implementation. The internal implementation

> > cause connection trouble since it keep the antenna busy during

> > the entire scan duration, moreover it's only a passive scanning

> > (no probe request). Therefore, let mac80211 manages sw scan.

> >

> > Note: we fallback to software scan if firmware does not report

> > scan offload support or if we need to scan the 5Ghz band (currently

> > not supported by the offload scan...).

> >

> > Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

> > Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

>

> What changed since v2? Please always include a changelog so that I don't

> need to guess what you have changed in the patch. No need to resend, a

> reply is enough.


Yes sorry, this patch has been rebased on ath master and squashed with
Bryan's fix:
     wcn36xx: Set sw-scan chan to 0 when not associated
No additional changes have been made on top of the initial patches.

Regards,
Loic
Bryan O'Donoghue Aug. 18, 2020, 6:01 p.m. UTC | #3
On 18/08/2020 14:34, Loic Poulain wrote:
> On Tue, 18 Aug 2020 at 08:15, Kalle Valo <kvalo@codeaurora.org> wrote:

>>

>> Loic Poulain <loic.poulain@linaro.org> writes:

>>

>>> For software-driven scan, rely on mac80211 software scan instead

>>> of internal driver implementation. The internal implementation

>>> cause connection trouble since it keep the antenna busy during

>>> the entire scan duration, moreover it's only a passive scanning

>>> (no probe request). Therefore, let mac80211 manages sw scan.

>>>

>>> Note: we fallback to software scan if firmware does not report

>>> scan offload support or if we need to scan the 5Ghz band (currently

>>> not supported by the offload scan...).

>>>

>>> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

>>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

>>

>> What changed since v2? Please always include a changelog so that I don't

>> need to guess what you have changed in the patch. No need to resend, a

>> reply is enough.

> 

> Yes sorry, this patch has been rebased on ath master and squashed with

> Bryan's fix:

>       wcn36xx: Set sw-scan chan to 0 when not associated

> No additional changes have been made on top of the initial patches.

> 

> Regards,

> Loic

> 


This is excruciatingly slow on Android.

Android I'm finding unlike Debian where this stuff was tested, merrily 
issues scan requests every 30 seconds.

For me this ends up looking like this

[  162.296995] wcn36xx: mac config changed 0x00000040
[  162.297001] wcn36xx: wcn36xx_config channel switch=1
[  162.297005] wcn36xx: hal init scan mode 2
[  162.300011] wcn36xx: indication arrived
[  162.300525] wcn36xx: SMD command (req 4, rsp 5) completed in 4ms
[  162.300529] wcn36xx: hal start scan channel 1
[  162.306930] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

Big gap here

[  162.368198] wcn36xx: mac config changed 0x00000040
[  162.368205] wcn36xx: wcn36xx_config channel switch=40
[  162.368209] wcn36xx: hal finish scan mode 2
[  162.379085] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  162.382218] wcn36xx: indication arrived
[  162.583396] wcn36xx: indication arrived
[  162.684336] wcn36xx: mac config changed 0x00000040
[  162.684344] wcn36xx: wcn36xx_config channel switch=2
[  162.684348] wcn36xx: hal init scan mode 2
[  162.687547] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  162.687552] wcn36xx: hal start scan channel 2
[  162.693935] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  162.756359] wcn36xx: mac config changed 0x00000040
[  162.756367] wcn36xx: wcn36xx_config channel switch=40
[  162.756371] wcn36xx: hal finish scan mode 2
[  162.767361] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  162.770445] wcn36xx: indication arrived
[  162.971533] wcn36xx: indication arrived
[  163.072318] wcn36xx: mac config changed 0x00000040
[  163.072325] wcn36xx: wcn36xx_config channel switch=3
[  163.072329] wcn36xx: hal init scan mode 2
[  163.075449] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  163.075453] wcn36xx: hal start scan channel 3
[  163.081648] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  163.144202] wcn36xx: mac config changed 0x00000040
[  163.144210] wcn36xx: wcn36xx_config channel switch=40
[  163.144214] wcn36xx: hal finish scan mode 2
[  163.155103] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  163.158219] wcn36xx: indication arrived
[  163.359477] wcn36xx: indication arrived
[  163.460428] wcn36xx: mac config changed 0x00000040
[  163.460435] wcn36xx: wcn36xx_config channel switch=4
[  163.460439] wcn36xx: hal init scan mode 2
[  163.463572] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  163.463576] wcn36xx: hal start scan channel 4
[  163.469851] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  163.532373] wcn36xx: mac config changed 0x00000040
[  163.532381] wcn36xx: wcn36xx_config channel switch=40
[  163.532384] wcn36xx: hal finish scan mode 2
[  163.543736] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  163.546987] wcn36xx: indication arrived
[  163.747577] wcn36xx: indication arrived
[  163.848431] wcn36xx: mac config changed 0x00000040
[  163.848439] wcn36xx: wcn36xx_config channel switch=5
[  163.848442] wcn36xx: hal init scan mode 2
[  163.851668] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  163.851672] wcn36xx: hal start scan channel 5
[  163.857929] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  163.920386] wcn36xx: mac config changed 0x00000040
[  163.920394] wcn36xx: wcn36xx_config channel switch=40
[  163.920398] wcn36xx: hal finish scan mode 2
[  163.931279] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  163.934460] wcn36xx: indication arrived
[  164.135411] wcn36xx: indication arrived
[  164.236376] wcn36xx: mac config changed 0x00000040
[  164.236383] wcn36xx: wcn36xx_config channel switch=6
[  164.236387] wcn36xx: hal init scan mode 2
[  164.239669] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  164.239673] wcn36xx: hal start scan channel 6
[  164.245868] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  164.308339] wcn36xx: mac config changed 0x00000040
[  164.308347] wcn36xx: wcn36xx_config channel switch=40
[  164.308351] wcn36xx: hal finish scan mode 2
[  164.319240] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  164.322405] wcn36xx: indication arrived
[  164.523510] wcn36xx: indication arrived
[  164.624238] wcn36xx: mac config changed 0x00000040
[  164.624245] wcn36xx: wcn36xx_config channel switch=7
[  164.624249] wcn36xx: hal init scan mode 2
[  164.627352] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  164.627356] wcn36xx: hal start scan channel 7
[  164.633425] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  164.696365] wcn36xx: mac config changed 0x00000040
[  164.696374] wcn36xx: wcn36xx_config channel switch=40
[  164.696378] wcn36xx: hal finish scan mode 2
[  164.707355] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  164.710683] wcn36xx: indication arrived
[  164.911285] wcn36xx: indication arrived
[  165.012228] wcn36xx: mac config changed 0x00000040
[  165.012236] wcn36xx: wcn36xx_config channel switch=8
[  165.012240] wcn36xx: hal init scan mode 2
[  165.015434] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  165.015439] wcn36xx: hal start scan channel 8
[  165.021509] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  165.084204] wcn36xx: mac config changed 0x00000040
[  165.084212] wcn36xx: wcn36xx_config channel switch=40
[  165.084217] wcn36xx: hal finish scan mode 2
[  165.095164] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  165.098269] wcn36xx: indication arrived
[  165.299691] wcn36xx: indication arrived
[  165.400304] wcn36xx: mac config changed 0x00000040
[  165.400309] wcn36xx: wcn36xx_config channel switch=9
[  165.400313] wcn36xx: hal init scan mode 2
[  165.403424] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  165.403428] wcn36xx: hal start scan channel 9
[  165.409695] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  165.472378] wcn36xx: mac config changed 0x00000040
[  165.472386] wcn36xx: wcn36xx_config channel switch=40
[  165.472390] wcn36xx: hal finish scan mode 2
[  165.483390] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  165.486478] wcn36xx: indication arrived
[  165.687641] wcn36xx: indication arrived
[  165.788548] wcn36xx: mac config changed 0x00000040
[  165.788556] wcn36xx: wcn36xx_config channel switch=10
[  165.788561] wcn36xx: hal init scan mode 2
[  165.791729] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  165.791734] wcn36xx: hal start scan channel 10
[  165.797986] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  165.860337] wcn36xx: mac config changed 0x00000040
[  165.860346] wcn36xx: wcn36xx_config channel switch=40
[  165.860349] wcn36xx: hal finish scan mode 2
[  165.871185] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  165.874560] wcn36xx: indication arrived
[  166.075631] wcn36xx: indication arrived
[  166.176336] wcn36xx: mac config changed 0x00000040
[  166.176344] wcn36xx: wcn36xx_config channel switch=11
[  166.176348] wcn36xx: hal init scan mode 2
[  166.179753] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  166.179758] wcn36xx: hal start scan channel 11
[  166.186033] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  166.248204] wcn36xx: mac config changed 0x00000040
[  166.248211] wcn36xx: wcn36xx_config channel switch=40
[  166.248216] wcn36xx: hal finish scan mode 2
[  166.259127] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  166.262339] wcn36xx: indication arrived
[  166.463387] wcn36xx: indication arrived
[  166.564353] wcn36xx: mac config changed 0x00000040
[  166.564362] wcn36xx: wcn36xx_config channel switch=12
[  166.564366] wcn36xx: hal init scan mode 2
[  166.567517] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  166.567522] wcn36xx: hal start scan channel 12
[  166.573823] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  166.684383] wcn36xx: mac config changed 0x00000040
[  166.684390] wcn36xx: wcn36xx_config channel switch=40
[  166.684394] wcn36xx: hal finish scan mode 2
[  166.695665] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  166.698857] wcn36xx: indication arrived
[  166.899623] wcn36xx: indication arrived
[  167.000265] wcn36xx: mac config changed 0x00000040
[  167.000273] wcn36xx: wcn36xx_config channel switch=13
[  167.000277] wcn36xx: hal init scan mode 2
[  167.003459] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  167.003463] wcn36xx: hal start scan channel 13
[  167.009787] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  167.120339] wcn36xx: mac config changed 0x00000040
[  167.120348] wcn36xx: wcn36xx_config channel switch=40
[  167.120351] wcn36xx: hal finish scan mode 2
[  167.131208] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  167.134376] wcn36xx: indication arrived
[  167.335469] wcn36xx: indication arrived
[  167.436335] wcn36xx: mac config changed 0x00000040
[  167.436343] wcn36xx: wcn36xx_config channel switch=14
[  167.436347] wcn36xx: hal init scan mode 2
[  167.439492] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  167.439497] wcn36xx: hal start scan channel 14
[  167.446075] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  167.556358] wcn36xx: mac config changed 0x00000040
[  167.556367] wcn36xx: wcn36xx_config channel switch=40
[  167.556372] wcn36xx: hal finish scan mode 2
[  167.567787] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  167.570712] wcn36xx: indication arrived
[  167.771184] wcn36xx: indication arrived
[  167.872093] wcn36xx: mac config changed 0x00000040
[  167.872104] wcn36xx: wcn36xx_config channel switch=36
[  167.872110] wcn36xx: hal init scan mode 2
[  167.875463] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  167.875469] wcn36xx: hal start scan channel 36
[  167.880887] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  167.944229] wcn36xx: mac config changed 0x00000040
[  167.944238] wcn36xx: wcn36xx_config channel switch=40
[  167.944243] wcn36xx: hal finish scan mode 2
[  167.953262] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  167.956751] wcn36xx: indication arrived
[  168.159485] wcn36xx: indication arrived
[  168.260233] wcn36xx: mac config changed 0x00000040
[  168.260243] wcn36xx: wcn36xx_config channel switch=40
[  168.260248] wcn36xx: hal finish scan mode 2
[  168.268055] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  168.332250] wcn36xx: mac config changed 0x00000040
[  168.332259] wcn36xx: wcn36xx_config channel switch=40
[  168.332264] wcn36xx: hal finish scan mode 2
[  168.340018] wcn36xx: SMD command (req 10, rsp 11) completed in 4ms
[  168.343231] wcn36xx: indication arrived
[  168.547404] wcn36xx: indication arrived
[  168.652662] wcn36xx: mac config changed 0x00000040
[  168.652666] wcn36xx: wcn36xx_config channel switch=44
[  168.652670] wcn36xx: hal init scan mode 2
[  168.655732] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  168.655736] wcn36xx: hal start scan channel 44
[  168.660968] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  168.772327] wcn36xx: mac config changed 0x00000040
[  168.772334] wcn36xx: wcn36xx_config channel switch=40
[  168.772338] wcn36xx: hal finish scan mode 2
[  168.781369] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  168.784371] wcn36xx: indication arrived
[  168.987575] wcn36xx: indication arrived
[  169.088390] wcn36xx: mac config changed 0x00000040
[  169.088398] wcn36xx: wcn36xx_config channel switch=48
[  169.088402] wcn36xx: hal init scan mode 2
[  169.091527] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  169.091532] wcn36xx: hal start scan channel 48
[  169.097022] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  169.208455] wcn36xx: mac config changed 0x00000040
[  169.208463] wcn36xx: wcn36xx_config channel switch=40
[  169.208467] wcn36xx: hal finish scan mode 2
[  169.218407] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  169.221568] wcn36xx: indication arrived
[  169.423420] wcn36xx: indication arrived
[  169.524402] wcn36xx: mac config changed 0x00000040
[  169.524409] wcn36xx: wcn36xx_config channel switch=52
[  169.524413] wcn36xx: hal init scan mode 2
[  169.527559] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  169.527563] wcn36xx: hal start scan channel 52
[  169.532973] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  169.644216] wcn36xx: mac config changed 0x00000040
[  169.644223] wcn36xx: wcn36xx_config channel switch=40
[  169.644227] wcn36xx: hal finish scan mode 2
[  169.653367] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  169.656579] wcn36xx: indication arrived
[  169.859998] wcn36xx: indication arrived
[  169.960478] wcn36xx: mac config changed 0x00000040
[  169.960489] wcn36xx: wcn36xx_config channel switch=56
[  169.960494] wcn36xx: hal init scan mode 2
[  169.963757] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  169.963762] wcn36xx: hal start scan channel 56
[  169.969107] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  170.080126] wcn36xx: mac config changed 0x00000040
[  170.080136] wcn36xx: wcn36xx_config channel switch=40
[  170.080141] wcn36xx: hal finish scan mode 2
[  170.089183] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  170.092346] wcn36xx: indication arrived
[  170.295765] wcn36xx: indication arrived
[  170.396072] wcn36xx: mac config changed 0x00000040
[  170.396079] wcn36xx: wcn36xx_config channel switch=60
[  170.396083] wcn36xx: hal init scan mode 2
[  170.399139] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  170.399144] wcn36xx: hal start scan channel 60
[  170.404547] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  170.516260] wcn36xx: mac config changed 0x00000040
[  170.516268] wcn36xx: wcn36xx_config channel switch=40
[  170.516272] wcn36xx: hal finish scan mode 2
[  170.525323] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  170.528989] wcn36xx: indication arrived
[  170.731306] wcn36xx: indication arrived
[  170.832258] wcn36xx: mac config changed 0x00000040
[  170.832266] wcn36xx: wcn36xx_config channel switch=64
[  170.832270] wcn36xx: hal init scan mode 2
[  170.835453] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  170.835457] wcn36xx: hal start scan channel 64
[  170.840746] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  170.952490] wcn36xx: mac config changed 0x00000040
[  170.952497] wcn36xx: wcn36xx_config channel switch=40
[  170.952501] wcn36xx: hal finish scan mode 2
[  170.961563] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  170.964663] wcn36xx: indication arrived
[  171.167256] wcn36xx: indication arrived
[  171.268465] wcn36xx: mac config changed 0x00000040
[  171.268474] wcn36xx: wcn36xx_config channel switch=100
[  171.268478] wcn36xx: hal init scan mode 2
[  171.271622] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  171.271626] wcn36xx: hal start scan channel 100
[  171.277068] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  171.388309] wcn36xx: mac config changed 0x00000040
[  171.388316] wcn36xx: wcn36xx_config channel switch=40
[  171.388320] wcn36xx: hal finish scan mode 2
[  171.397462] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  171.400449] wcn36xx: indication arrived
[  171.603380] wcn36xx: indication arrived
[  171.704307] wcn36xx: mac config changed 0x00000040
[  171.704315] wcn36xx: wcn36xx_config channel switch=104
[  171.704318] wcn36xx: hal init scan mode 2
[  171.707472] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  171.707476] wcn36xx: hal start scan channel 104
[  171.712907] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  171.824322] wcn36xx: mac config changed 0x00000040
[  171.824330] wcn36xx: wcn36xx_config channel switch=40
[  171.824334] wcn36xx: hal finish scan mode 2
[  171.833404] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  171.836577] wcn36xx: indication arrived
[  172.039628] wcn36xx: indication arrived
[  172.140321] wcn36xx: mac config changed 0x00000040
[  172.140329] wcn36xx: wcn36xx_config channel switch=108
[  172.140333] wcn36xx: hal init scan mode 2
[  172.143442] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  172.143447] wcn36xx: hal start scan channel 108
[  172.149071] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  172.260211] wcn36xx: mac config changed 0x00000040
[  172.260219] wcn36xx: wcn36xx_config channel switch=40
[  172.260222] wcn36xx: hal finish scan mode 2
[  172.269482] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  172.272333] wcn36xx: indication arrived
[  172.475588] wcn36xx: indication arrived
[  172.576210] wcn36xx: mac config changed 0x00000040
[  172.576217] wcn36xx: wcn36xx_config channel switch=112
[  172.576221] wcn36xx: hal init scan mode 2
[  172.579357] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  172.579362] wcn36xx: hal start scan channel 112
[  172.584763] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  172.696318] wcn36xx: mac config changed 0x00000040
[  172.696325] wcn36xx: wcn36xx_config channel switch=40
[  172.696329] wcn36xx: hal finish scan mode 2
[  172.705421] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  172.708542] wcn36xx: indication arrived
[  172.911501] wcn36xx: indication arrived
[  173.012248] wcn36xx: mac config changed 0x00000040
[  173.012255] wcn36xx: wcn36xx_config channel switch=116
[  173.012259] wcn36xx: hal init scan mode 2
[  173.015521] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  173.015532] wcn36xx: hal start scan channel 116
[  173.020870] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  173.132338] wcn36xx: mac config changed 0x00000040
[  173.132346] wcn36xx: wcn36xx_config channel switch=40
[  173.132350] wcn36xx: hal finish scan mode 2
[  173.141388] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  173.144426] wcn36xx: indication arrived
[  173.347588] wcn36xx: indication arrived
[  173.448338] wcn36xx: mac config changed 0x00000040
[  173.448347] wcn36xx: wcn36xx_config channel switch=120
[  173.448350] wcn36xx: hal init scan mode 2
[  173.451499] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  173.451503] wcn36xx: hal start scan channel 120
[  173.456889] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  173.568336] wcn36xx: mac config changed 0x00000040
[  173.568344] wcn36xx: wcn36xx_config channel switch=40
[  173.568348] wcn36xx: hal finish scan mode 2
[  173.577465] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  173.580602] wcn36xx: indication arrived
[  173.783414] wcn36xx: indication arrived
[  173.884494] wcn36xx: mac config changed 0x00000040
[  173.884504] wcn36xx: wcn36xx_config channel switch=124
[  173.884508] wcn36xx: hal init scan mode 2
[  173.887627] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  173.887633] wcn36xx: hal start scan channel 124
[  173.892978] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  174.004293] wcn36xx: mac config changed 0x00000040
[  174.004303] wcn36xx: wcn36xx_config channel switch=40
[  174.004308] wcn36xx: hal finish scan mode 2
[  174.013188] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  174.017060] wcn36xx: indication arrived
[  174.219812] wcn36xx: indication arrived
[  174.320551] wcn36xx: mac config changed 0x00000040
[  174.320559] wcn36xx: wcn36xx_config channel switch=128
[  174.320563] wcn36xx: hal init scan mode 2
[  174.324192] wcn36xx: SMD command (req 4, rsp 5) completed in 4ms
[  174.324197] wcn36xx: hal start scan channel 128
[  174.329545] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  174.440367] wcn36xx: mac config changed 0x00000040
[  174.440374] wcn36xx: wcn36xx_config channel switch=40
[  174.440378] wcn36xx: hal finish scan mode 2
[  174.449705] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  174.452983] wcn36xx: indication arrived
[  174.655452] wcn36xx: indication arrived
[  174.756428] wcn36xx: mac config changed 0x00000040
[  174.756438] wcn36xx: wcn36xx_config channel switch=132
[  174.756443] wcn36xx: hal init scan mode 2
[  174.759554] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  174.759560] wcn36xx: hal start scan channel 132
[  174.764959] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  174.876237] wcn36xx: mac config changed 0x00000040
[  174.876245] wcn36xx: wcn36xx_config channel switch=40
[  174.876250] wcn36xx: hal finish scan mode 2
[  174.885310] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  174.888341] wcn36xx: indication arrived
[  175.091324] wcn36xx: indication arrived
[  175.192423] wcn36xx: mac config changed 0x00000040
[  175.192430] wcn36xx: wcn36xx_config channel switch=140
[  175.192433] wcn36xx: hal init scan mode 2
[  175.195530] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  175.195534] wcn36xx: hal start scan channel 140
[  175.200805] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  175.312321] wcn36xx: mac config changed 0x00000040
[  175.312329] wcn36xx: wcn36xx_config channel switch=40
[  175.312333] wcn36xx: hal finish scan mode 2
[  175.321295] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  175.324800] wcn36xx: indication arrived
[  175.527611] wcn36xx: indication arrived
[  175.628313] wcn36xx: mac config changed 0x00000040
[  175.628320] wcn36xx: wcn36xx_config channel switch=149
[  175.628324] wcn36xx: hal init scan mode 2
[  175.631414] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  175.631419] wcn36xx: hal start scan channel 149
[  175.636846] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  175.748358] wcn36xx: mac config changed 0x00000040
[  175.748367] wcn36xx: wcn36xx_config channel switch=40
[  175.748371] wcn36xx: hal finish scan mode 2
[  175.758146] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  175.761536] wcn36xx: indication arrived
[  175.963887] wcn36xx: indication arrived
[  176.064314] wcn36xx: mac config changed 0x00000040
[  176.064322] wcn36xx: wcn36xx_config channel switch=153
[  176.064326] wcn36xx: hal init scan mode 2
[  176.067659] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  176.067663] wcn36xx: hal start scan channel 153
[  176.072911] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  176.184091] wcn36xx: mac config changed 0x00000040
[  176.184099] wcn36xx: wcn36xx_config channel switch=40
[  176.184104] wcn36xx: hal finish scan mode 2
[  176.193195] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  176.196177] wcn36xx: indication arrived
[  176.399382] wcn36xx: indication arrived
[  176.500288] wcn36xx: mac config changed 0x00000040
[  176.500295] wcn36xx: wcn36xx_config channel switch=157
[  176.500299] wcn36xx: hal init scan mode 2
[  176.503417] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  176.503421] wcn36xx: hal start scan channel 157
[  176.508762] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  176.620389] wcn36xx: mac config changed 0x00000040
[  176.620396] wcn36xx: wcn36xx_config channel switch=40
[  176.620400] wcn36xx: hal finish scan mode 2
[  176.629516] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  176.632609] wcn36xx: indication arrived
[  176.835319] wcn36xx: indication arrived
[  176.936427] wcn36xx: mac config changed 0x00000040
[  176.936435] wcn36xx: wcn36xx_config channel switch=161
[  176.936440] wcn36xx: hal init scan mode 2
[  176.939590] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  176.939595] wcn36xx: hal start scan channel 161
[  176.945005] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  177.056380] wcn36xx: mac config changed 0x00000040
[  177.056388] wcn36xx: wcn36xx_config channel switch=40
[  177.056392] wcn36xx: hal finish scan mode 2
[  177.065466] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  177.068489] wcn36xx: indication arrived
[  177.271739] wcn36xx: indication arrived
[  177.372381] wcn36xx: mac config changed 0x00000040
[  177.372389] wcn36xx: wcn36xx_config channel switch=165
[  177.372393] wcn36xx: hal init scan mode 2
[  177.375538] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  177.375543] wcn36xx: hal start scan channel 165
[  177.380982] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
[  177.492402] wcn36xx: mac config changed 0x00000040
[  177.492409] wcn36xx: wcn36xx_config channel switch=40
[  177.492413] wcn36xx: hal finish scan mode 2

Basically it takes 15 seconds to complete.

Interleaved scan seems very slow and is IMO unusable on Android

After this change - on Android with scan interleaving

console:/ # iperf3 -c 192.168.50.167 -i 1 -t 320 

Connecting to host 192.168.50.167, port 5201
[  5] local 192.168.50.244 port 33132 connected to 192.168.50.167 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  1.09 MBytes  9.15 Mbits/sec    0   79.2 KBytes 

[  5]   1.00-2.00   sec   954 KBytes  7.82 Mbits/sec    0    116 KBytes 

[  5]   2.00-3.00   sec   891 KBytes  7.30 Mbits/sec    0    158 KBytes 

[  5]   3.00-4.00   sec   764 KBytes  6.25 Mbits/sec    0    199 KBytes 

[  5]   4.00-5.00   sec   764 KBytes  6.26 Mbits/sec    0    219 KBytes 

^C[  5]   5.00-5.09   sec   382 KBytes  33.8 Mbits/sec    0    221 
KBytes

Before this change - with Android issuing periodic scans on the same 30 
second cadence.

console:/ # iperf3 -c 192.168.50.167 -i 1 -t 320 

Connecting to host 192.168.50.167, port 5201
[  5] local 192.168.50.244 port 54378 connected to 192.168.50.167 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  4.57 MBytes  38.3 Mbits/sec    2    148 KBytes 

[  5]   1.00-2.00   sec  14.2 MBytes   119 Mbits/sec    1    164 KBytes 

[  5]   2.00-3.00   sec  14.9 MBytes   125 Mbits/sec    2    173 KBytes 

[  5]   3.00-4.00   sec  14.7 MBytes   124 Mbits/sec    2    133 KBytes 

[  5]   4.00-5.00   sec  15.0 MBytes   126 Mbits/sec    1    148 KBytes 

[  5]   5.00-6.00   sec  14.8 MBytes   124 Mbits/sec    5    164 KBytes 

[  5]   6.00-7.00   sec  15.1 MBytes   127 Mbits/sec    1    178 KBytes 

^C[  5]   7.00-7.39   sec  5.72 MBytes   124 Mbits/sec    2    147 KBytes

I wasn't seeing this on Debian because wpa_supplicant on my test system 
doesn't behave this way.

I wonder would we be better off trying to serialize txrx::*tx with the 
old scan method ?

Accepted it would be a passive scan but sw_scan seems to be so very very 
slow - we might be beter off.

---
bod
Loic Poulain Aug. 19, 2020, 8:15 a.m. UTC | #4
Hi Bryan,

On Tue, 18 Aug 2020 at 20:00, Bryan O'Donoghue
<pure.logic@nexus-software.ie> wrote:
>

> On 18/08/2020 14:34, Loic Poulain wrote:

> > On Tue, 18 Aug 2020 at 08:15, Kalle Valo <kvalo@codeaurora.org> wrote:

> >>

> >> Loic Poulain <loic.poulain@linaro.org> writes:

> >>

> >>> For software-driven scan, rely on mac80211 software scan instead

> >>> of internal driver implementation. The internal implementation

> >>> cause connection trouble since it keep the antenna busy during

> >>> the entire scan duration, moreover it's only a passive scanning

> >>> (no probe request). Therefore, let mac80211 manages sw scan.

> >>>

> >>> Note: we fallback to software scan if firmware does not report

> >>> scan offload support or if we need to scan the 5Ghz band (currently

> >>> not supported by the offload scan...).

> >>>

> >>> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

> >>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

> >>

> >> What changed since v2? Please always include a changelog so that I don't

> >> need to guess what you have changed in the patch. No need to resend, a

> >> reply is enough.

> >

> > Yes sorry, this patch has been rebased on ath master and squashed with

> > Bryan's fix:

> >       wcn36xx: Set sw-scan chan to 0 when not associated

> > No additional changes have been made on top of the initial patches.

> >

> > Regards,

> > Loic

> >

>

> This is excruciatingly slow on Android.

>

> Android I'm finding unlike Debian where this stuff was tested, merrily

> issues scan requests every 30 seconds.

>

> For me this ends up looking like this

>

> [  162.296995] wcn36xx: mac config changed 0x00000040

> [  162.297001] wcn36xx: wcn36xx_config channel switch=1

> [  162.297005] wcn36xx: hal init scan mode 2

> [  162.300011] wcn36xx: indication arrived

> [  162.300525] wcn36xx: SMD command (req 4, rsp 5) completed in 4ms

> [  162.300529] wcn36xx: hal start scan channel 1

> [  162.306930] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

>

> Big gap here

>

> [  162.368198] wcn36xx: mac config changed 0x00000040

> [  162.368205] wcn36xx: wcn36xx_config channel switch=40

> [  162.368209] wcn36xx: hal finish scan mode 2

> [  162.379085] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  162.382218] wcn36xx: indication arrived

> [  162.583396] wcn36xx: indication arrived

> [  162.684336] wcn36xx: mac config changed 0x00000040

> [  162.684344] wcn36xx: wcn36xx_config channel switch=2

> [  162.684348] wcn36xx: hal init scan mode 2

> [  162.687547] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  162.687552] wcn36xx: hal start scan channel 2

> [  162.693935] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  162.756359] wcn36xx: mac config changed 0x00000040

> [  162.756367] wcn36xx: wcn36xx_config channel switch=40

> [  162.756371] wcn36xx: hal finish scan mode 2

> [  162.767361] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  162.770445] wcn36xx: indication arrived

> [  162.971533] wcn36xx: indication arrived

> [  163.072318] wcn36xx: mac config changed 0x00000040

> [  163.072325] wcn36xx: wcn36xx_config channel switch=3

> [  163.072329] wcn36xx: hal init scan mode 2

> [  163.075449] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  163.075453] wcn36xx: hal start scan channel 3

> [  163.081648] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  163.144202] wcn36xx: mac config changed 0x00000040

> [  163.144210] wcn36xx: wcn36xx_config channel switch=40

> [  163.144214] wcn36xx: hal finish scan mode 2

> [  163.155103] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  163.158219] wcn36xx: indication arrived

> [  163.359477] wcn36xx: indication arrived

> [  163.460428] wcn36xx: mac config changed 0x00000040

> [  163.460435] wcn36xx: wcn36xx_config channel switch=4

> [  163.460439] wcn36xx: hal init scan mode 2

> [  163.463572] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  163.463576] wcn36xx: hal start scan channel 4

> [  163.469851] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  163.532373] wcn36xx: mac config changed 0x00000040

> [  163.532381] wcn36xx: wcn36xx_config channel switch=40

> [  163.532384] wcn36xx: hal finish scan mode 2

> [  163.543736] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  163.546987] wcn36xx: indication arrived

> [  163.747577] wcn36xx: indication arrived

> [  163.848431] wcn36xx: mac config changed 0x00000040

> [  163.848439] wcn36xx: wcn36xx_config channel switch=5

> [  163.848442] wcn36xx: hal init scan mode 2

> [  163.851668] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  163.851672] wcn36xx: hal start scan channel 5

> [  163.857929] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  163.920386] wcn36xx: mac config changed 0x00000040

> [  163.920394] wcn36xx: wcn36xx_config channel switch=40

> [  163.920398] wcn36xx: hal finish scan mode 2

> [  163.931279] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  163.934460] wcn36xx: indication arrived

> [  164.135411] wcn36xx: indication arrived

> [  164.236376] wcn36xx: mac config changed 0x00000040

> [  164.236383] wcn36xx: wcn36xx_config channel switch=6

> [  164.236387] wcn36xx: hal init scan mode 2

> [  164.239669] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  164.239673] wcn36xx: hal start scan channel 6

> [  164.245868] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  164.308339] wcn36xx: mac config changed 0x00000040

> [  164.308347] wcn36xx: wcn36xx_config channel switch=40

> [  164.308351] wcn36xx: hal finish scan mode 2

> [  164.319240] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  164.322405] wcn36xx: indication arrived

> [  164.523510] wcn36xx: indication arrived

> [  164.624238] wcn36xx: mac config changed 0x00000040

> [  164.624245] wcn36xx: wcn36xx_config channel switch=7

> [  164.624249] wcn36xx: hal init scan mode 2

> [  164.627352] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  164.627356] wcn36xx: hal start scan channel 7

> [  164.633425] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  164.696365] wcn36xx: mac config changed 0x00000040

> [  164.696374] wcn36xx: wcn36xx_config channel switch=40

> [  164.696378] wcn36xx: hal finish scan mode 2

> [  164.707355] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  164.710683] wcn36xx: indication arrived

> [  164.911285] wcn36xx: indication arrived

> [  165.012228] wcn36xx: mac config changed 0x00000040

> [  165.012236] wcn36xx: wcn36xx_config channel switch=8

> [  165.012240] wcn36xx: hal init scan mode 2

> [  165.015434] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  165.015439] wcn36xx: hal start scan channel 8

> [  165.021509] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  165.084204] wcn36xx: mac config changed 0x00000040

> [  165.084212] wcn36xx: wcn36xx_config channel switch=40

> [  165.084217] wcn36xx: hal finish scan mode 2

> [  165.095164] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  165.098269] wcn36xx: indication arrived

> [  165.299691] wcn36xx: indication arrived

> [  165.400304] wcn36xx: mac config changed 0x00000040

> [  165.400309] wcn36xx: wcn36xx_config channel switch=9

> [  165.400313] wcn36xx: hal init scan mode 2

> [  165.403424] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  165.403428] wcn36xx: hal start scan channel 9

> [  165.409695] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  165.472378] wcn36xx: mac config changed 0x00000040

> [  165.472386] wcn36xx: wcn36xx_config channel switch=40

> [  165.472390] wcn36xx: hal finish scan mode 2

> [  165.483390] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  165.486478] wcn36xx: indication arrived

> [  165.687641] wcn36xx: indication arrived

> [  165.788548] wcn36xx: mac config changed 0x00000040

> [  165.788556] wcn36xx: wcn36xx_config channel switch=10

> [  165.788561] wcn36xx: hal init scan mode 2

> [  165.791729] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  165.791734] wcn36xx: hal start scan channel 10

> [  165.797986] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  165.860337] wcn36xx: mac config changed 0x00000040

> [  165.860346] wcn36xx: wcn36xx_config channel switch=40

> [  165.860349] wcn36xx: hal finish scan mode 2

> [  165.871185] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  165.874560] wcn36xx: indication arrived

> [  166.075631] wcn36xx: indication arrived

> [  166.176336] wcn36xx: mac config changed 0x00000040

> [  166.176344] wcn36xx: wcn36xx_config channel switch=11

> [  166.176348] wcn36xx: hal init scan mode 2

> [  166.179753] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  166.179758] wcn36xx: hal start scan channel 11

> [  166.186033] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  166.248204] wcn36xx: mac config changed 0x00000040

> [  166.248211] wcn36xx: wcn36xx_config channel switch=40

> [  166.248216] wcn36xx: hal finish scan mode 2

> [  166.259127] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  166.262339] wcn36xx: indication arrived

> [  166.463387] wcn36xx: indication arrived

> [  166.564353] wcn36xx: mac config changed 0x00000040

> [  166.564362] wcn36xx: wcn36xx_config channel switch=12

> [  166.564366] wcn36xx: hal init scan mode 2

> [  166.567517] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  166.567522] wcn36xx: hal start scan channel 12

> [  166.573823] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  166.684383] wcn36xx: mac config changed 0x00000040

> [  166.684390] wcn36xx: wcn36xx_config channel switch=40

> [  166.684394] wcn36xx: hal finish scan mode 2

> [  166.695665] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  166.698857] wcn36xx: indication arrived

> [  166.899623] wcn36xx: indication arrived

> [  167.000265] wcn36xx: mac config changed 0x00000040

> [  167.000273] wcn36xx: wcn36xx_config channel switch=13

> [  167.000277] wcn36xx: hal init scan mode 2

> [  167.003459] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  167.003463] wcn36xx: hal start scan channel 13

> [  167.009787] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  167.120339] wcn36xx: mac config changed 0x00000040

> [  167.120348] wcn36xx: wcn36xx_config channel switch=40

> [  167.120351] wcn36xx: hal finish scan mode 2

> [  167.131208] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  167.134376] wcn36xx: indication arrived

> [  167.335469] wcn36xx: indication arrived

> [  167.436335] wcn36xx: mac config changed 0x00000040

> [  167.436343] wcn36xx: wcn36xx_config channel switch=14

> [  167.436347] wcn36xx: hal init scan mode 2

> [  167.439492] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  167.439497] wcn36xx: hal start scan channel 14

> [  167.446075] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  167.556358] wcn36xx: mac config changed 0x00000040

> [  167.556367] wcn36xx: wcn36xx_config channel switch=40

> [  167.556372] wcn36xx: hal finish scan mode 2

> [  167.567787] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  167.570712] wcn36xx: indication arrived

> [  167.771184] wcn36xx: indication arrived

> [  167.872093] wcn36xx: mac config changed 0x00000040

> [  167.872104] wcn36xx: wcn36xx_config channel switch=36

> [  167.872110] wcn36xx: hal init scan mode 2

> [  167.875463] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  167.875469] wcn36xx: hal start scan channel 36

> [  167.880887] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  167.944229] wcn36xx: mac config changed 0x00000040

> [  167.944238] wcn36xx: wcn36xx_config channel switch=40

> [  167.944243] wcn36xx: hal finish scan mode 2

> [  167.953262] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  167.956751] wcn36xx: indication arrived

> [  168.159485] wcn36xx: indication arrived

> [  168.260233] wcn36xx: mac config changed 0x00000040

> [  168.260243] wcn36xx: wcn36xx_config channel switch=40

> [  168.260248] wcn36xx: hal finish scan mode 2

> [  168.268055] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  168.332250] wcn36xx: mac config changed 0x00000040

> [  168.332259] wcn36xx: wcn36xx_config channel switch=40

> [  168.332264] wcn36xx: hal finish scan mode 2

> [  168.340018] wcn36xx: SMD command (req 10, rsp 11) completed in 4ms

> [  168.343231] wcn36xx: indication arrived

> [  168.547404] wcn36xx: indication arrived

> [  168.652662] wcn36xx: mac config changed 0x00000040

> [  168.652666] wcn36xx: wcn36xx_config channel switch=44

> [  168.652670] wcn36xx: hal init scan mode 2

> [  168.655732] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  168.655736] wcn36xx: hal start scan channel 44

> [  168.660968] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  168.772327] wcn36xx: mac config changed 0x00000040

> [  168.772334] wcn36xx: wcn36xx_config channel switch=40

> [  168.772338] wcn36xx: hal finish scan mode 2

> [  168.781369] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  168.784371] wcn36xx: indication arrived

> [  168.987575] wcn36xx: indication arrived

> [  169.088390] wcn36xx: mac config changed 0x00000040

> [  169.088398] wcn36xx: wcn36xx_config channel switch=48

> [  169.088402] wcn36xx: hal init scan mode 2

> [  169.091527] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  169.091532] wcn36xx: hal start scan channel 48

> [  169.097022] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  169.208455] wcn36xx: mac config changed 0x00000040

> [  169.208463] wcn36xx: wcn36xx_config channel switch=40

> [  169.208467] wcn36xx: hal finish scan mode 2

> [  169.218407] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  169.221568] wcn36xx: indication arrived

> [  169.423420] wcn36xx: indication arrived

> [  169.524402] wcn36xx: mac config changed 0x00000040

> [  169.524409] wcn36xx: wcn36xx_config channel switch=52

> [  169.524413] wcn36xx: hal init scan mode 2

> [  169.527559] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  169.527563] wcn36xx: hal start scan channel 52

> [  169.532973] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  169.644216] wcn36xx: mac config changed 0x00000040

> [  169.644223] wcn36xx: wcn36xx_config channel switch=40

> [  169.644227] wcn36xx: hal finish scan mode 2

> [  169.653367] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  169.656579] wcn36xx: indication arrived

> [  169.859998] wcn36xx: indication arrived

> [  169.960478] wcn36xx: mac config changed 0x00000040

> [  169.960489] wcn36xx: wcn36xx_config channel switch=56

> [  169.960494] wcn36xx: hal init scan mode 2

> [  169.963757] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  169.963762] wcn36xx: hal start scan channel 56

> [  169.969107] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  170.080126] wcn36xx: mac config changed 0x00000040

> [  170.080136] wcn36xx: wcn36xx_config channel switch=40

> [  170.080141] wcn36xx: hal finish scan mode 2

> [  170.089183] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  170.092346] wcn36xx: indication arrived

> [  170.295765] wcn36xx: indication arrived

> [  170.396072] wcn36xx: mac config changed 0x00000040

> [  170.396079] wcn36xx: wcn36xx_config channel switch=60

> [  170.396083] wcn36xx: hal init scan mode 2

> [  170.399139] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  170.399144] wcn36xx: hal start scan channel 60

> [  170.404547] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  170.516260] wcn36xx: mac config changed 0x00000040

> [  170.516268] wcn36xx: wcn36xx_config channel switch=40

> [  170.516272] wcn36xx: hal finish scan mode 2

> [  170.525323] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  170.528989] wcn36xx: indication arrived

> [  170.731306] wcn36xx: indication arrived

> [  170.832258] wcn36xx: mac config changed 0x00000040

> [  170.832266] wcn36xx: wcn36xx_config channel switch=64

> [  170.832270] wcn36xx: hal init scan mode 2

> [  170.835453] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  170.835457] wcn36xx: hal start scan channel 64

> [  170.840746] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  170.952490] wcn36xx: mac config changed 0x00000040

> [  170.952497] wcn36xx: wcn36xx_config channel switch=40

> [  170.952501] wcn36xx: hal finish scan mode 2

> [  170.961563] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  170.964663] wcn36xx: indication arrived

> [  171.167256] wcn36xx: indication arrived

> [  171.268465] wcn36xx: mac config changed 0x00000040

> [  171.268474] wcn36xx: wcn36xx_config channel switch=100

> [  171.268478] wcn36xx: hal init scan mode 2

> [  171.271622] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  171.271626] wcn36xx: hal start scan channel 100

> [  171.277068] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  171.388309] wcn36xx: mac config changed 0x00000040

> [  171.388316] wcn36xx: wcn36xx_config channel switch=40

> [  171.388320] wcn36xx: hal finish scan mode 2

> [  171.397462] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  171.400449] wcn36xx: indication arrived

> [  171.603380] wcn36xx: indication arrived

> [  171.704307] wcn36xx: mac config changed 0x00000040

> [  171.704315] wcn36xx: wcn36xx_config channel switch=104

> [  171.704318] wcn36xx: hal init scan mode 2

> [  171.707472] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  171.707476] wcn36xx: hal start scan channel 104

> [  171.712907] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  171.824322] wcn36xx: mac config changed 0x00000040

> [  171.824330] wcn36xx: wcn36xx_config channel switch=40

> [  171.824334] wcn36xx: hal finish scan mode 2

> [  171.833404] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  171.836577] wcn36xx: indication arrived

> [  172.039628] wcn36xx: indication arrived

> [  172.140321] wcn36xx: mac config changed 0x00000040

> [  172.140329] wcn36xx: wcn36xx_config channel switch=108

> [  172.140333] wcn36xx: hal init scan mode 2

> [  172.143442] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  172.143447] wcn36xx: hal start scan channel 108

> [  172.149071] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  172.260211] wcn36xx: mac config changed 0x00000040

> [  172.260219] wcn36xx: wcn36xx_config channel switch=40

> [  172.260222] wcn36xx: hal finish scan mode 2

> [  172.269482] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  172.272333] wcn36xx: indication arrived

> [  172.475588] wcn36xx: indication arrived

> [  172.576210] wcn36xx: mac config changed 0x00000040

> [  172.576217] wcn36xx: wcn36xx_config channel switch=112

> [  172.576221] wcn36xx: hal init scan mode 2

> [  172.579357] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  172.579362] wcn36xx: hal start scan channel 112

> [  172.584763] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  172.696318] wcn36xx: mac config changed 0x00000040

> [  172.696325] wcn36xx: wcn36xx_config channel switch=40

> [  172.696329] wcn36xx: hal finish scan mode 2

> [  172.705421] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  172.708542] wcn36xx: indication arrived

> [  172.911501] wcn36xx: indication arrived

> [  173.012248] wcn36xx: mac config changed 0x00000040

> [  173.012255] wcn36xx: wcn36xx_config channel switch=116

> [  173.012259] wcn36xx: hal init scan mode 2

> [  173.015521] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  173.015532] wcn36xx: hal start scan channel 116

> [  173.020870] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  173.132338] wcn36xx: mac config changed 0x00000040

> [  173.132346] wcn36xx: wcn36xx_config channel switch=40

> [  173.132350] wcn36xx: hal finish scan mode 2

> [  173.141388] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  173.144426] wcn36xx: indication arrived

> [  173.347588] wcn36xx: indication arrived

> [  173.448338] wcn36xx: mac config changed 0x00000040

> [  173.448347] wcn36xx: wcn36xx_config channel switch=120

> [  173.448350] wcn36xx: hal init scan mode 2

> [  173.451499] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  173.451503] wcn36xx: hal start scan channel 120

> [  173.456889] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  173.568336] wcn36xx: mac config changed 0x00000040

> [  173.568344] wcn36xx: wcn36xx_config channel switch=40

> [  173.568348] wcn36xx: hal finish scan mode 2

> [  173.577465] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  173.580602] wcn36xx: indication arrived

> [  173.783414] wcn36xx: indication arrived

> [  173.884494] wcn36xx: mac config changed 0x00000040

> [  173.884504] wcn36xx: wcn36xx_config channel switch=124

> [  173.884508] wcn36xx: hal init scan mode 2

> [  173.887627] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  173.887633] wcn36xx: hal start scan channel 124

> [  173.892978] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  174.004293] wcn36xx: mac config changed 0x00000040

> [  174.004303] wcn36xx: wcn36xx_config channel switch=40

> [  174.004308] wcn36xx: hal finish scan mode 2

> [  174.013188] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  174.017060] wcn36xx: indication arrived

> [  174.219812] wcn36xx: indication arrived

> [  174.320551] wcn36xx: mac config changed 0x00000040

> [  174.320559] wcn36xx: wcn36xx_config channel switch=128

> [  174.320563] wcn36xx: hal init scan mode 2

> [  174.324192] wcn36xx: SMD command (req 4, rsp 5) completed in 4ms

> [  174.324197] wcn36xx: hal start scan channel 128

> [  174.329545] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  174.440367] wcn36xx: mac config changed 0x00000040

> [  174.440374] wcn36xx: wcn36xx_config channel switch=40

> [  174.440378] wcn36xx: hal finish scan mode 2

> [  174.449705] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  174.452983] wcn36xx: indication arrived

> [  174.655452] wcn36xx: indication arrived

> [  174.756428] wcn36xx: mac config changed 0x00000040

> [  174.756438] wcn36xx: wcn36xx_config channel switch=132

> [  174.756443] wcn36xx: hal init scan mode 2

> [  174.759554] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  174.759560] wcn36xx: hal start scan channel 132

> [  174.764959] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  174.876237] wcn36xx: mac config changed 0x00000040

> [  174.876245] wcn36xx: wcn36xx_config channel switch=40

> [  174.876250] wcn36xx: hal finish scan mode 2

> [  174.885310] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  174.888341] wcn36xx: indication arrived

> [  175.091324] wcn36xx: indication arrived

> [  175.192423] wcn36xx: mac config changed 0x00000040

> [  175.192430] wcn36xx: wcn36xx_config channel switch=140

> [  175.192433] wcn36xx: hal init scan mode 2

> [  175.195530] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  175.195534] wcn36xx: hal start scan channel 140

> [  175.200805] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  175.312321] wcn36xx: mac config changed 0x00000040

> [  175.312329] wcn36xx: wcn36xx_config channel switch=40

> [  175.312333] wcn36xx: hal finish scan mode 2

> [  175.321295] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  175.324800] wcn36xx: indication arrived

> [  175.527611] wcn36xx: indication arrived

> [  175.628313] wcn36xx: mac config changed 0x00000040

> [  175.628320] wcn36xx: wcn36xx_config channel switch=149

> [  175.628324] wcn36xx: hal init scan mode 2

> [  175.631414] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  175.631419] wcn36xx: hal start scan channel 149

> [  175.636846] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  175.748358] wcn36xx: mac config changed 0x00000040

> [  175.748367] wcn36xx: wcn36xx_config channel switch=40

> [  175.748371] wcn36xx: hal finish scan mode 2

> [  175.758146] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  175.761536] wcn36xx: indication arrived

> [  175.963887] wcn36xx: indication arrived

> [  176.064314] wcn36xx: mac config changed 0x00000040

> [  176.064322] wcn36xx: wcn36xx_config channel switch=153

> [  176.064326] wcn36xx: hal init scan mode 2

> [  176.067659] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  176.067663] wcn36xx: hal start scan channel 153

> [  176.072911] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  176.184091] wcn36xx: mac config changed 0x00000040

> [  176.184099] wcn36xx: wcn36xx_config channel switch=40

> [  176.184104] wcn36xx: hal finish scan mode 2

> [  176.193195] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  176.196177] wcn36xx: indication arrived

> [  176.399382] wcn36xx: indication arrived

> [  176.500288] wcn36xx: mac config changed 0x00000040

> [  176.500295] wcn36xx: wcn36xx_config channel switch=157

> [  176.500299] wcn36xx: hal init scan mode 2

> [  176.503417] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  176.503421] wcn36xx: hal start scan channel 157

> [  176.508762] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  176.620389] wcn36xx: mac config changed 0x00000040

> [  176.620396] wcn36xx: wcn36xx_config channel switch=40

> [  176.620400] wcn36xx: hal finish scan mode 2

> [  176.629516] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  176.632609] wcn36xx: indication arrived

> [  176.835319] wcn36xx: indication arrived

> [  176.936427] wcn36xx: mac config changed 0x00000040

> [  176.936435] wcn36xx: wcn36xx_config channel switch=161

> [  176.936440] wcn36xx: hal init scan mode 2

> [  176.939590] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  176.939595] wcn36xx: hal start scan channel 161

> [  176.945005] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  177.056380] wcn36xx: mac config changed 0x00000040

> [  177.056388] wcn36xx: wcn36xx_config channel switch=40

> [  177.056392] wcn36xx: hal finish scan mode 2

> [  177.065466] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  177.068489] wcn36xx: indication arrived

> [  177.271739] wcn36xx: indication arrived

> [  177.372381] wcn36xx: mac config changed 0x00000040

> [  177.372389] wcn36xx: wcn36xx_config channel switch=165

> [  177.372393] wcn36xx: hal init scan mode 2

> [  177.375538] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  177.375543] wcn36xx: hal start scan channel 165

> [  177.380982] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

> [  177.492402] wcn36xx: mac config changed 0x00000040

> [  177.492409] wcn36xx: wcn36xx_config channel switch=40

> [  177.492413] wcn36xx: hal finish scan mode 2

>

> Basically it takes 15 seconds to complete.

>

> Interleaved scan seems very slow and is IMO unusable on Android



The software scan is driven by mac80211 which interleaves channels scanning
with the regular data operations. In worst case, it scans during 111ms on the
channel and switches back to the operating channel for 200ms.
So, with 35 channels to scan that would take about 11 seconds to complete...
So yes, it's quite slow...

>

> After this change - on Android with scan interleaving

>

> console:/ # iperf3 -c 192.168.50.167 -i 1 -t 320

>

> Connecting to host 192.168.50.167, port 5201

> [  5] local 192.168.50.244 port 33132 connected to 192.168.50.167 port 5201

> [ ID] Interval           Transfer     Bitrate         Retr  Cwnd

> [  5]   0.00-1.00   sec  1.09 MBytes  9.15 Mbits/sec    0   79.2 KBytes

>

> [  5]   1.00-2.00   sec   954 KBytes  7.82 Mbits/sec    0    116 KBytes

>

> [  5]   2.00-3.00   sec   891 KBytes  7.30 Mbits/sec    0    158 KBytes

>

> [  5]   3.00-4.00   sec   764 KBytes  6.25 Mbits/sec    0    199 KBytes

>

> [  5]   4.00-5.00   sec   764 KBytes  6.26 Mbits/sec    0    219 KBytes

>

> ^C[  5]   5.00-5.09   sec   382 KBytes  33.8 Mbits/sec    0    221

> KBytes

>

> Before this change - with Android issuing periodic scans on the same 30

> second cadence.

>

> console:/ # iperf3 -c 192.168.50.167 -i 1 -t 320

>

> Connecting to host 192.168.50.167, port 5201

> [  5] local 192.168.50.244 port 54378 connected to 192.168.50.167 port 5201

> [ ID] Interval           Transfer     Bitrate         Retr  Cwnd

> [  5]   0.00-1.00   sec  4.57 MBytes  38.3 Mbits/sec    2    148 KBytes

>

> [  5]   1.00-2.00   sec  14.2 MBytes   119 Mbits/sec    1    164 KBytes

>

> [  5]   2.00-3.00   sec  14.9 MBytes   125 Mbits/sec    2    173 KBytes

>

> [  5]   3.00-4.00   sec  14.7 MBytes   124 Mbits/sec    2    133 KBytes

>

> [  5]   4.00-5.00   sec  15.0 MBytes   126 Mbits/sec    1    148 KBytes

>

> [  5]   5.00-6.00   sec  14.8 MBytes   124 Mbits/sec    5    164 KBytes

>

> [  5]   6.00-7.00   sec  15.1 MBytes   127 Mbits/sec    1    178 KBytes

>

> ^C[  5]   7.00-7.39   sec  5.72 MBytes   124 Mbits/sec    2    147 KBytes

>

> I wasn't seeing this on Debian because wpa_supplicant on my test system

> doesn't behave this way.

>

> I wonder would we be better off trying to serialize txrx::*tx with the

> old scan method ?

>

> Accepted it would be a passive scan but sw_scan seems to be so very very

> slow - we might be beter off.



Well, the problem with the old method is that driver only listen
passively 30ms on each channel, so scan result can be quite
incomplete since there is a huge chance to miss AP beacons
(which are usually sent every 100ms), and you lose the
directed scanning support (for hidden AP, roaming, etc...).

Moreover, I remember the old method was causing some instabilities
due to stopping RX while the whole duration of scanning (about 1s in
your case).

Ideally, the driver should implement hardware-assisted scanning
correctly to completely get rid of software scanning. But as you
noticed it only works for 2.4Ghz AP right now. However, one remaining
thing to try would be to send an update-channel-list command to the
firmware before each offload scan (cf UPDATE_CHANNEL_LIST_REQ
in the downstream driver). That's not something I've tried yet.

Regards,
Loic
Bryan O'Donoghue Aug. 19, 2020, 10:52 a.m. UTC | #5
On 19/08/2020 09:15, Loic Poulain wrote:
> Hi Bryan,

> 

> On Tue, 18 Aug 2020 at 20:00, Bryan O'Donoghue

> <pure.logic@nexus-software.ie> wrote:

>>

>> On 18/08/2020 14:34, Loic Poulain wrote:

>>> On Tue, 18 Aug 2020 at 08:15, Kalle Valo <kvalo@codeaurora.org> wrote:

>>>>

>>>> Loic Poulain <loic.poulain@linaro.org> writes:

>>>>

>>>>> For software-driven scan, rely on mac80211 software scan instead

>>>>> of internal driver implementation. The internal implementation

>>>>> cause connection trouble since it keep the antenna busy during

>>>>> the entire scan duration, moreover it's only a passive scanning

>>>>> (no probe request). Therefore, let mac80211 manages sw scan.

>>>>>

>>>>> Note: we fallback to software scan if firmware does not report

>>>>> scan offload support or if we need to scan the 5Ghz band (currently

>>>>> not supported by the offload scan...).

>>>>>

>>>>> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

>>>>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

>>>>

>>>> What changed since v2? Please always include a changelog so that I don't

>>>> need to guess what you have changed in the patch. No need to resend, a

>>>> reply is enough.

>>>

>>> Yes sorry, this patch has been rebased on ath master and squashed with

>>> Bryan's fix:

>>>        wcn36xx: Set sw-scan chan to 0 when not associated

>>> No additional changes have been made on top of the initial patches.

>>>

>>> Regards,

>>> Loic

>>>

>>

>> This is excruciatingly slow on Android.

>>

>> Android I'm finding unlike Debian where this stuff was tested, merrily

>> issues scan requests every 30 seconds.

>>

>> For me this ends up looking like this

>>

>> [  162.296995] wcn36xx: mac config changed 0x00000040

>> [  162.297001] wcn36xx: wcn36xx_config channel switch=1

>> [  162.297005] wcn36xx: hal init scan mode 2

>> [  162.300011] wcn36xx: indication arrived

>> [  162.300525] wcn36xx: SMD command (req 4, rsp 5) completed in 4ms

>> [  162.300529] wcn36xx: hal start scan channel 1

>> [  162.306930] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

>>

>> Big gap here

>>

>> [  162.368198] wcn36xx: mac config changed 0x00000040

>> [  162.368205] wcn36xx: wcn36xx_config channel switch=40

>> [  162.368209] wcn36xx: hal finish scan mode 2

>> [  162.379085] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  162.382218] wcn36xx: indication arrived

>> [  162.583396] wcn36xx: indication arrived

>> [  162.684336] wcn36xx: mac config changed 0x00000040

>> [  162.684344] wcn36xx: wcn36xx_config channel switch=2

>> [  162.684348] wcn36xx: hal init scan mode 2

>> [  162.687547] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  162.687552] wcn36xx: hal start scan channel 2

>> [  162.693935] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  162.756359] wcn36xx: mac config changed 0x00000040

>> [  162.756367] wcn36xx: wcn36xx_config channel switch=40

>> [  162.756371] wcn36xx: hal finish scan mode 2

>> [  162.767361] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  162.770445] wcn36xx: indication arrived

>> [  162.971533] wcn36xx: indication arrived

>> [  163.072318] wcn36xx: mac config changed 0x00000040

>> [  163.072325] wcn36xx: wcn36xx_config channel switch=3

>> [  163.072329] wcn36xx: hal init scan mode 2

>> [  163.075449] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  163.075453] wcn36xx: hal start scan channel 3

>> [  163.081648] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  163.144202] wcn36xx: mac config changed 0x00000040

>> [  163.144210] wcn36xx: wcn36xx_config channel switch=40

>> [  163.144214] wcn36xx: hal finish scan mode 2

>> [  163.155103] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  163.158219] wcn36xx: indication arrived

>> [  163.359477] wcn36xx: indication arrived

>> [  163.460428] wcn36xx: mac config changed 0x00000040

>> [  163.460435] wcn36xx: wcn36xx_config channel switch=4

>> [  163.460439] wcn36xx: hal init scan mode 2

>> [  163.463572] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  163.463576] wcn36xx: hal start scan channel 4

>> [  163.469851] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  163.532373] wcn36xx: mac config changed 0x00000040

>> [  163.532381] wcn36xx: wcn36xx_config channel switch=40

>> [  163.532384] wcn36xx: hal finish scan mode 2

>> [  163.543736] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  163.546987] wcn36xx: indication arrived

>> [  163.747577] wcn36xx: indication arrived

>> [  163.848431] wcn36xx: mac config changed 0x00000040

>> [  163.848439] wcn36xx: wcn36xx_config channel switch=5

>> [  163.848442] wcn36xx: hal init scan mode 2

>> [  163.851668] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  163.851672] wcn36xx: hal start scan channel 5

>> [  163.857929] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  163.920386] wcn36xx: mac config changed 0x00000040

>> [  163.920394] wcn36xx: wcn36xx_config channel switch=40

>> [  163.920398] wcn36xx: hal finish scan mode 2

>> [  163.931279] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  163.934460] wcn36xx: indication arrived

>> [  164.135411] wcn36xx: indication arrived

>> [  164.236376] wcn36xx: mac config changed 0x00000040

>> [  164.236383] wcn36xx: wcn36xx_config channel switch=6

>> [  164.236387] wcn36xx: hal init scan mode 2

>> [  164.239669] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  164.239673] wcn36xx: hal start scan channel 6

>> [  164.245868] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  164.308339] wcn36xx: mac config changed 0x00000040

>> [  164.308347] wcn36xx: wcn36xx_config channel switch=40

>> [  164.308351] wcn36xx: hal finish scan mode 2

>> [  164.319240] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  164.322405] wcn36xx: indication arrived

>> [  164.523510] wcn36xx: indication arrived

>> [  164.624238] wcn36xx: mac config changed 0x00000040

>> [  164.624245] wcn36xx: wcn36xx_config channel switch=7

>> [  164.624249] wcn36xx: hal init scan mode 2

>> [  164.627352] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  164.627356] wcn36xx: hal start scan channel 7

>> [  164.633425] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  164.696365] wcn36xx: mac config changed 0x00000040

>> [  164.696374] wcn36xx: wcn36xx_config channel switch=40

>> [  164.696378] wcn36xx: hal finish scan mode 2

>> [  164.707355] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  164.710683] wcn36xx: indication arrived

>> [  164.911285] wcn36xx: indication arrived

>> [  165.012228] wcn36xx: mac config changed 0x00000040

>> [  165.012236] wcn36xx: wcn36xx_config channel switch=8

>> [  165.012240] wcn36xx: hal init scan mode 2

>> [  165.015434] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  165.015439] wcn36xx: hal start scan channel 8

>> [  165.021509] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  165.084204] wcn36xx: mac config changed 0x00000040

>> [  165.084212] wcn36xx: wcn36xx_config channel switch=40

>> [  165.084217] wcn36xx: hal finish scan mode 2

>> [  165.095164] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  165.098269] wcn36xx: indication arrived

>> [  165.299691] wcn36xx: indication arrived

>> [  165.400304] wcn36xx: mac config changed 0x00000040

>> [  165.400309] wcn36xx: wcn36xx_config channel switch=9

>> [  165.400313] wcn36xx: hal init scan mode 2

>> [  165.403424] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  165.403428] wcn36xx: hal start scan channel 9

>> [  165.409695] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  165.472378] wcn36xx: mac config changed 0x00000040

>> [  165.472386] wcn36xx: wcn36xx_config channel switch=40

>> [  165.472390] wcn36xx: hal finish scan mode 2

>> [  165.483390] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  165.486478] wcn36xx: indication arrived

>> [  165.687641] wcn36xx: indication arrived

>> [  165.788548] wcn36xx: mac config changed 0x00000040

>> [  165.788556] wcn36xx: wcn36xx_config channel switch=10

>> [  165.788561] wcn36xx: hal init scan mode 2

>> [  165.791729] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  165.791734] wcn36xx: hal start scan channel 10

>> [  165.797986] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  165.860337] wcn36xx: mac config changed 0x00000040

>> [  165.860346] wcn36xx: wcn36xx_config channel switch=40

>> [  165.860349] wcn36xx: hal finish scan mode 2

>> [  165.871185] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  165.874560] wcn36xx: indication arrived

>> [  166.075631] wcn36xx: indication arrived

>> [  166.176336] wcn36xx: mac config changed 0x00000040

>> [  166.176344] wcn36xx: wcn36xx_config channel switch=11

>> [  166.176348] wcn36xx: hal init scan mode 2

>> [  166.179753] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  166.179758] wcn36xx: hal start scan channel 11

>> [  166.186033] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  166.248204] wcn36xx: mac config changed 0x00000040

>> [  166.248211] wcn36xx: wcn36xx_config channel switch=40

>> [  166.248216] wcn36xx: hal finish scan mode 2

>> [  166.259127] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  166.262339] wcn36xx: indication arrived

>> [  166.463387] wcn36xx: indication arrived

>> [  166.564353] wcn36xx: mac config changed 0x00000040

>> [  166.564362] wcn36xx: wcn36xx_config channel switch=12

>> [  166.564366] wcn36xx: hal init scan mode 2

>> [  166.567517] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  166.567522] wcn36xx: hal start scan channel 12

>> [  166.573823] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  166.684383] wcn36xx: mac config changed 0x00000040

>> [  166.684390] wcn36xx: wcn36xx_config channel switch=40

>> [  166.684394] wcn36xx: hal finish scan mode 2

>> [  166.695665] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  166.698857] wcn36xx: indication arrived

>> [  166.899623] wcn36xx: indication arrived

>> [  167.000265] wcn36xx: mac config changed 0x00000040

>> [  167.000273] wcn36xx: wcn36xx_config channel switch=13

>> [  167.000277] wcn36xx: hal init scan mode 2

>> [  167.003459] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  167.003463] wcn36xx: hal start scan channel 13

>> [  167.009787] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  167.120339] wcn36xx: mac config changed 0x00000040

>> [  167.120348] wcn36xx: wcn36xx_config channel switch=40

>> [  167.120351] wcn36xx: hal finish scan mode 2

>> [  167.131208] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  167.134376] wcn36xx: indication arrived

>> [  167.335469] wcn36xx: indication arrived

>> [  167.436335] wcn36xx: mac config changed 0x00000040

>> [  167.436343] wcn36xx: wcn36xx_config channel switch=14

>> [  167.436347] wcn36xx: hal init scan mode 2

>> [  167.439492] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  167.439497] wcn36xx: hal start scan channel 14

>> [  167.446075] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  167.556358] wcn36xx: mac config changed 0x00000040

>> [  167.556367] wcn36xx: wcn36xx_config channel switch=40

>> [  167.556372] wcn36xx: hal finish scan mode 2

>> [  167.567787] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  167.570712] wcn36xx: indication arrived

>> [  167.771184] wcn36xx: indication arrived

>> [  167.872093] wcn36xx: mac config changed 0x00000040

>> [  167.872104] wcn36xx: wcn36xx_config channel switch=36

>> [  167.872110] wcn36xx: hal init scan mode 2

>> [  167.875463] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  167.875469] wcn36xx: hal start scan channel 36

>> [  167.880887] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  167.944229] wcn36xx: mac config changed 0x00000040

>> [  167.944238] wcn36xx: wcn36xx_config channel switch=40

>> [  167.944243] wcn36xx: hal finish scan mode 2

>> [  167.953262] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  167.956751] wcn36xx: indication arrived

>> [  168.159485] wcn36xx: indication arrived

>> [  168.260233] wcn36xx: mac config changed 0x00000040

>> [  168.260243] wcn36xx: wcn36xx_config channel switch=40

>> [  168.260248] wcn36xx: hal finish scan mode 2

>> [  168.268055] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  168.332250] wcn36xx: mac config changed 0x00000040

>> [  168.332259] wcn36xx: wcn36xx_config channel switch=40

>> [  168.332264] wcn36xx: hal finish scan mode 2

>> [  168.340018] wcn36xx: SMD command (req 10, rsp 11) completed in 4ms

>> [  168.343231] wcn36xx: indication arrived

>> [  168.547404] wcn36xx: indication arrived

>> [  168.652662] wcn36xx: mac config changed 0x00000040

>> [  168.652666] wcn36xx: wcn36xx_config channel switch=44

>> [  168.652670] wcn36xx: hal init scan mode 2

>> [  168.655732] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  168.655736] wcn36xx: hal start scan channel 44

>> [  168.660968] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  168.772327] wcn36xx: mac config changed 0x00000040

>> [  168.772334] wcn36xx: wcn36xx_config channel switch=40

>> [  168.772338] wcn36xx: hal finish scan mode 2

>> [  168.781369] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  168.784371] wcn36xx: indication arrived

>> [  168.987575] wcn36xx: indication arrived

>> [  169.088390] wcn36xx: mac config changed 0x00000040

>> [  169.088398] wcn36xx: wcn36xx_config channel switch=48

>> [  169.088402] wcn36xx: hal init scan mode 2

>> [  169.091527] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  169.091532] wcn36xx: hal start scan channel 48

>> [  169.097022] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  169.208455] wcn36xx: mac config changed 0x00000040

>> [  169.208463] wcn36xx: wcn36xx_config channel switch=40

>> [  169.208467] wcn36xx: hal finish scan mode 2

>> [  169.218407] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  169.221568] wcn36xx: indication arrived

>> [  169.423420] wcn36xx: indication arrived

>> [  169.524402] wcn36xx: mac config changed 0x00000040

>> [  169.524409] wcn36xx: wcn36xx_config channel switch=52

>> [  169.524413] wcn36xx: hal init scan mode 2

>> [  169.527559] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  169.527563] wcn36xx: hal start scan channel 52

>> [  169.532973] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  169.644216] wcn36xx: mac config changed 0x00000040

>> [  169.644223] wcn36xx: wcn36xx_config channel switch=40

>> [  169.644227] wcn36xx: hal finish scan mode 2

>> [  169.653367] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  169.656579] wcn36xx: indication arrived

>> [  169.859998] wcn36xx: indication arrived

>> [  169.960478] wcn36xx: mac config changed 0x00000040

>> [  169.960489] wcn36xx: wcn36xx_config channel switch=56

>> [  169.960494] wcn36xx: hal init scan mode 2

>> [  169.963757] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  169.963762] wcn36xx: hal start scan channel 56

>> [  169.969107] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  170.080126] wcn36xx: mac config changed 0x00000040

>> [  170.080136] wcn36xx: wcn36xx_config channel switch=40

>> [  170.080141] wcn36xx: hal finish scan mode 2

>> [  170.089183] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  170.092346] wcn36xx: indication arrived

>> [  170.295765] wcn36xx: indication arrived

>> [  170.396072] wcn36xx: mac config changed 0x00000040

>> [  170.396079] wcn36xx: wcn36xx_config channel switch=60

>> [  170.396083] wcn36xx: hal init scan mode 2

>> [  170.399139] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  170.399144] wcn36xx: hal start scan channel 60

>> [  170.404547] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  170.516260] wcn36xx: mac config changed 0x00000040

>> [  170.516268] wcn36xx: wcn36xx_config channel switch=40

>> [  170.516272] wcn36xx: hal finish scan mode 2

>> [  170.525323] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  170.528989] wcn36xx: indication arrived

>> [  170.731306] wcn36xx: indication arrived

>> [  170.832258] wcn36xx: mac config changed 0x00000040

>> [  170.832266] wcn36xx: wcn36xx_config channel switch=64

>> [  170.832270] wcn36xx: hal init scan mode 2

>> [  170.835453] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  170.835457] wcn36xx: hal start scan channel 64

>> [  170.840746] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  170.952490] wcn36xx: mac config changed 0x00000040

>> [  170.952497] wcn36xx: wcn36xx_config channel switch=40

>> [  170.952501] wcn36xx: hal finish scan mode 2

>> [  170.961563] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  170.964663] wcn36xx: indication arrived

>> [  171.167256] wcn36xx: indication arrived

>> [  171.268465] wcn36xx: mac config changed 0x00000040

>> [  171.268474] wcn36xx: wcn36xx_config channel switch=100

>> [  171.268478] wcn36xx: hal init scan mode 2

>> [  171.271622] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  171.271626] wcn36xx: hal start scan channel 100

>> [  171.277068] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  171.388309] wcn36xx: mac config changed 0x00000040

>> [  171.388316] wcn36xx: wcn36xx_config channel switch=40

>> [  171.388320] wcn36xx: hal finish scan mode 2

>> [  171.397462] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  171.400449] wcn36xx: indication arrived

>> [  171.603380] wcn36xx: indication arrived

>> [  171.704307] wcn36xx: mac config changed 0x00000040

>> [  171.704315] wcn36xx: wcn36xx_config channel switch=104

>> [  171.704318] wcn36xx: hal init scan mode 2

>> [  171.707472] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  171.707476] wcn36xx: hal start scan channel 104

>> [  171.712907] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  171.824322] wcn36xx: mac config changed 0x00000040

>> [  171.824330] wcn36xx: wcn36xx_config channel switch=40

>> [  171.824334] wcn36xx: hal finish scan mode 2

>> [  171.833404] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  171.836577] wcn36xx: indication arrived

>> [  172.039628] wcn36xx: indication arrived

>> [  172.140321] wcn36xx: mac config changed 0x00000040

>> [  172.140329] wcn36xx: wcn36xx_config channel switch=108

>> [  172.140333] wcn36xx: hal init scan mode 2

>> [  172.143442] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  172.143447] wcn36xx: hal start scan channel 108

>> [  172.149071] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  172.260211] wcn36xx: mac config changed 0x00000040

>> [  172.260219] wcn36xx: wcn36xx_config channel switch=40

>> [  172.260222] wcn36xx: hal finish scan mode 2

>> [  172.269482] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  172.272333] wcn36xx: indication arrived

>> [  172.475588] wcn36xx: indication arrived

>> [  172.576210] wcn36xx: mac config changed 0x00000040

>> [  172.576217] wcn36xx: wcn36xx_config channel switch=112

>> [  172.576221] wcn36xx: hal init scan mode 2

>> [  172.579357] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  172.579362] wcn36xx: hal start scan channel 112

>> [  172.584763] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  172.696318] wcn36xx: mac config changed 0x00000040

>> [  172.696325] wcn36xx: wcn36xx_config channel switch=40

>> [  172.696329] wcn36xx: hal finish scan mode 2

>> [  172.705421] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  172.708542] wcn36xx: indication arrived

>> [  172.911501] wcn36xx: indication arrived

>> [  173.012248] wcn36xx: mac config changed 0x00000040

>> [  173.012255] wcn36xx: wcn36xx_config channel switch=116

>> [  173.012259] wcn36xx: hal init scan mode 2

>> [  173.015521] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  173.015532] wcn36xx: hal start scan channel 116

>> [  173.020870] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  173.132338] wcn36xx: mac config changed 0x00000040

>> [  173.132346] wcn36xx: wcn36xx_config channel switch=40

>> [  173.132350] wcn36xx: hal finish scan mode 2

>> [  173.141388] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  173.144426] wcn36xx: indication arrived

>> [  173.347588] wcn36xx: indication arrived

>> [  173.448338] wcn36xx: mac config changed 0x00000040

>> [  173.448347] wcn36xx: wcn36xx_config channel switch=120

>> [  173.448350] wcn36xx: hal init scan mode 2

>> [  173.451499] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  173.451503] wcn36xx: hal start scan channel 120

>> [  173.456889] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  173.568336] wcn36xx: mac config changed 0x00000040

>> [  173.568344] wcn36xx: wcn36xx_config channel switch=40

>> [  173.568348] wcn36xx: hal finish scan mode 2

>> [  173.577465] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  173.580602] wcn36xx: indication arrived

>> [  173.783414] wcn36xx: indication arrived

>> [  173.884494] wcn36xx: mac config changed 0x00000040

>> [  173.884504] wcn36xx: wcn36xx_config channel switch=124

>> [  173.884508] wcn36xx: hal init scan mode 2

>> [  173.887627] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  173.887633] wcn36xx: hal start scan channel 124

>> [  173.892978] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  174.004293] wcn36xx: mac config changed 0x00000040

>> [  174.004303] wcn36xx: wcn36xx_config channel switch=40

>> [  174.004308] wcn36xx: hal finish scan mode 2

>> [  174.013188] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  174.017060] wcn36xx: indication arrived

>> [  174.219812] wcn36xx: indication arrived

>> [  174.320551] wcn36xx: mac config changed 0x00000040

>> [  174.320559] wcn36xx: wcn36xx_config channel switch=128

>> [  174.320563] wcn36xx: hal init scan mode 2

>> [  174.324192] wcn36xx: SMD command (req 4, rsp 5) completed in 4ms

>> [  174.324197] wcn36xx: hal start scan channel 128

>> [  174.329545] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

>> [  174.440367] wcn36xx: mac config changed 0x00000040

>> [  174.440374] wcn36xx: wcn36xx_config channel switch=40

>> [  174.440378] wcn36xx: hal finish scan mode 2

>> [  174.449705] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  174.452983] wcn36xx: indication arrived

>> [  174.655452] wcn36xx: indication arrived

>> [  174.756428] wcn36xx: mac config changed 0x00000040

>> [  174.756438] wcn36xx: wcn36xx_config channel switch=132

>> [  174.756443] wcn36xx: hal init scan mode 2

>> [  174.759554] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  174.759560] wcn36xx: hal start scan channel 132

>> [  174.764959] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  174.876237] wcn36xx: mac config changed 0x00000040

>> [  174.876245] wcn36xx: wcn36xx_config channel switch=40

>> [  174.876250] wcn36xx: hal finish scan mode 2

>> [  174.885310] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  174.888341] wcn36xx: indication arrived

>> [  175.091324] wcn36xx: indication arrived

>> [  175.192423] wcn36xx: mac config changed 0x00000040

>> [  175.192430] wcn36xx: wcn36xx_config channel switch=140

>> [  175.192433] wcn36xx: hal init scan mode 2

>> [  175.195530] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  175.195534] wcn36xx: hal start scan channel 140

>> [  175.200805] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  175.312321] wcn36xx: mac config changed 0x00000040

>> [  175.312329] wcn36xx: wcn36xx_config channel switch=40

>> [  175.312333] wcn36xx: hal finish scan mode 2

>> [  175.321295] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  175.324800] wcn36xx: indication arrived

>> [  175.527611] wcn36xx: indication arrived

>> [  175.628313] wcn36xx: mac config changed 0x00000040

>> [  175.628320] wcn36xx: wcn36xx_config channel switch=149

>> [  175.628324] wcn36xx: hal init scan mode 2

>> [  175.631414] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  175.631419] wcn36xx: hal start scan channel 149

>> [  175.636846] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  175.748358] wcn36xx: mac config changed 0x00000040

>> [  175.748367] wcn36xx: wcn36xx_config channel switch=40

>> [  175.748371] wcn36xx: hal finish scan mode 2

>> [  175.758146] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  175.761536] wcn36xx: indication arrived

>> [  175.963887] wcn36xx: indication arrived

>> [  176.064314] wcn36xx: mac config changed 0x00000040

>> [  176.064322] wcn36xx: wcn36xx_config channel switch=153

>> [  176.064326] wcn36xx: hal init scan mode 2

>> [  176.067659] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  176.067663] wcn36xx: hal start scan channel 153

>> [  176.072911] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  176.184091] wcn36xx: mac config changed 0x00000040

>> [  176.184099] wcn36xx: wcn36xx_config channel switch=40

>> [  176.184104] wcn36xx: hal finish scan mode 2

>> [  176.193195] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  176.196177] wcn36xx: indication arrived

>> [  176.399382] wcn36xx: indication arrived

>> [  176.500288] wcn36xx: mac config changed 0x00000040

>> [  176.500295] wcn36xx: wcn36xx_config channel switch=157

>> [  176.500299] wcn36xx: hal init scan mode 2

>> [  176.503417] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  176.503421] wcn36xx: hal start scan channel 157

>> [  176.508762] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  176.620389] wcn36xx: mac config changed 0x00000040

>> [  176.620396] wcn36xx: wcn36xx_config channel switch=40

>> [  176.620400] wcn36xx: hal finish scan mode 2

>> [  176.629516] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  176.632609] wcn36xx: indication arrived

>> [  176.835319] wcn36xx: indication arrived

>> [  176.936427] wcn36xx: mac config changed 0x00000040

>> [  176.936435] wcn36xx: wcn36xx_config channel switch=161

>> [  176.936440] wcn36xx: hal init scan mode 2

>> [  176.939590] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  176.939595] wcn36xx: hal start scan channel 161

>> [  176.945005] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  177.056380] wcn36xx: mac config changed 0x00000040

>> [  177.056388] wcn36xx: wcn36xx_config channel switch=40

>> [  177.056392] wcn36xx: hal finish scan mode 2

>> [  177.065466] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

>> [  177.068489] wcn36xx: indication arrived

>> [  177.271739] wcn36xx: indication arrived

>> [  177.372381] wcn36xx: mac config changed 0x00000040

>> [  177.372389] wcn36xx: wcn36xx_config channel switch=165

>> [  177.372393] wcn36xx: hal init scan mode 2

>> [  177.375538] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

>> [  177.375543] wcn36xx: hal start scan channel 165

>> [  177.380982] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms

>> [  177.492402] wcn36xx: mac config changed 0x00000040

>> [  177.492409] wcn36xx: wcn36xx_config channel switch=40

>> [  177.492413] wcn36xx: hal finish scan mode 2

>>

>> Basically it takes 15 seconds to complete.

>>

>> Interleaved scan seems very slow and is IMO unusable on Android

> 

> 

> The software scan is driven by mac80211 which interleaves channels scanning

> with the regular data operations. In worst case, it scans during 111ms on the

> channel and switches back to the operating channel for 200ms.

> So, with 35 channels to scan that would take about 11 seconds to complete...

> So yes, it's quite slow...


Yes looks a scheduling thing in mac80211.

> However, one remaining

> thing to try would be to send an update-channel-list command to the

> firmware before each offload scan (cf UPDATE_CHANNEL_LIST_REQ

> in the downstream driver). That's not something I've tried yet.


I've tried

1. Setting the operating frequency to a 5ghz band before the scan
2. Updating the channel list with 2g/5g channels via UPDATE_CHANNEL_LIST_REQ
3. Updating the channel list with 5g only with UPDATE_CHANNEL_LIST_REQ
4. Doing 5g channels only in the channel list of 
WCN36XX_HAL_START_SCAN_OFFLOAD_REQ

I don't think the channel list matters, if I recall rightly I've also 
tried leaving out the channel list in WCN36XX_HAL_START_SCAN_OFFLOAD_REQ 
and get back the same set of channels in the result

I guess we should take this patch anyway, since it makes wcn36xx and 
mac80211 agree on ownership of the antenna...

---
bod

_______________________________________________
wcn36xx mailing list
wcn36xx@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/wcn36xx
Bryan O'Donoghue Aug. 19, 2020, 11:55 p.m. UTC | #6
On 19/08/2020 11:52, Bryan O'Donoghue wrote:
> On 19/08/2020 09:15, Loic Poulain wrote:
>> Hi Bryan,
>>
>> On Tue, 18 Aug 2020 at 20:00, Bryan O'Donoghue
>> <pure.logic@nexus-software.ie> wrote:
>>>
>>> On 18/08/2020 14:34, Loic Poulain wrote:
>>>> On Tue, 18 Aug 2020 at 08:15, Kalle Valo <kvalo@codeaurora.org> wrote:
>>>>>
>>>>> Loic Poulain <loic.poulain@linaro.org> writes:
>>>>>
>>>>>> For software-driven scan, rely on mac80211 software scan instead
>>>>>> of internal driver implementation. The internal implementation
>>>>>> cause connection trouble since it keep the antenna busy during
>>>>>> the entire scan duration, moreover it's only a passive scanning
>>>>>> (no probe request). Therefore, let mac80211 manages sw scan.
>>>>>>
>>>>>> Note: we fallback to software scan if firmware does not report
>>>>>> scan offload support or if we need to scan the 5Ghz band (currently
>>>>>> not supported by the offload scan...).
>>>>>>
>>>>>> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
>>>>>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
>>>>>
>>>>> What changed since v2? Please always include a changelog so that I 
>>>>> don't
>>>>> need to guess what you have changed in the patch. No need to resend, a
>>>>> reply is enough.
>>>>
>>>> Yes sorry, this patch has been rebased on ath master and squashed with
>>>> Bryan's fix:
>>>>        wcn36xx: Set sw-scan chan to 0 when not associated
>>>> No additional changes have been made on top of the initial patches.
>>>>
>>>> Regards,
>>>> Loic
>>>>
>>>
>>> This is excruciatingly slow on Android.
>>>
>>> Android I'm finding unlike Debian where this stuff was tested, merrily
>>> issues scan requests every 30 seconds.
>>>
>>> For me this ends up looking like this
>>>
>>> [  162.296995] wcn36xx: mac config changed 0x00000040
>>> [  162.297001] wcn36xx: wcn36xx_config channel switch=1
>>> [  162.297005] wcn36xx: hal init scan mode 2
>>> [  162.300011] wcn36xx: indication arrived
>>> [  162.300525] wcn36xx: SMD command (req 4, rsp 5) completed in 4ms
>>> [  162.300529] wcn36xx: hal start scan channel 1
>>> [  162.306930] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
>>>
>>> Big gap here
>>>
>>> [  162.368198] wcn36xx: mac config changed 0x00000040
>>> [  162.368205] wcn36xx: wcn36xx_config channel switch=40
>>> [  162.368209] wcn36xx: hal finish scan mode 2
>>> [  162.379085] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  162.382218] wcn36xx: indication arrived
>>> [  162.583396] wcn36xx: indication arrived
>>> [  162.684336] wcn36xx: mac config changed 0x00000040
>>> [  162.684344] wcn36xx: wcn36xx_config channel switch=2
>>> [  162.684348] wcn36xx: hal init scan mode 2
>>> [  162.687547] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  162.687552] wcn36xx: hal start scan channel 2
>>> [  162.693935] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  162.756359] wcn36xx: mac config changed 0x00000040
>>> [  162.756367] wcn36xx: wcn36xx_config channel switch=40
>>> [  162.756371] wcn36xx: hal finish scan mode 2
>>> [  162.767361] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  162.770445] wcn36xx: indication arrived
>>> [  162.971533] wcn36xx: indication arrived
>>> [  163.072318] wcn36xx: mac config changed 0x00000040
>>> [  163.072325] wcn36xx: wcn36xx_config channel switch=3
>>> [  163.072329] wcn36xx: hal init scan mode 2
>>> [  163.075449] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  163.075453] wcn36xx: hal start scan channel 3
>>> [  163.081648] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  163.144202] wcn36xx: mac config changed 0x00000040
>>> [  163.144210] wcn36xx: wcn36xx_config channel switch=40
>>> [  163.144214] wcn36xx: hal finish scan mode 2
>>> [  163.155103] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  163.158219] wcn36xx: indication arrived
>>> [  163.359477] wcn36xx: indication arrived
>>> [  163.460428] wcn36xx: mac config changed 0x00000040
>>> [  163.460435] wcn36xx: wcn36xx_config channel switch=4
>>> [  163.460439] wcn36xx: hal init scan mode 2
>>> [  163.463572] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  163.463576] wcn36xx: hal start scan channel 4
>>> [  163.469851] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  163.532373] wcn36xx: mac config changed 0x00000040
>>> [  163.532381] wcn36xx: wcn36xx_config channel switch=40
>>> [  163.532384] wcn36xx: hal finish scan mode 2
>>> [  163.543736] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  163.546987] wcn36xx: indication arrived
>>> [  163.747577] wcn36xx: indication arrived
>>> [  163.848431] wcn36xx: mac config changed 0x00000040
>>> [  163.848439] wcn36xx: wcn36xx_config channel switch=5
>>> [  163.848442] wcn36xx: hal init scan mode 2
>>> [  163.851668] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  163.851672] wcn36xx: hal start scan channel 5
>>> [  163.857929] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  163.920386] wcn36xx: mac config changed 0x00000040
>>> [  163.920394] wcn36xx: wcn36xx_config channel switch=40
>>> [  163.920398] wcn36xx: hal finish scan mode 2
>>> [  163.931279] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  163.934460] wcn36xx: indication arrived
>>> [  164.135411] wcn36xx: indication arrived
>>> [  164.236376] wcn36xx: mac config changed 0x00000040
>>> [  164.236383] wcn36xx: wcn36xx_config channel switch=6
>>> [  164.236387] wcn36xx: hal init scan mode 2
>>> [  164.239669] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  164.239673] wcn36xx: hal start scan channel 6
>>> [  164.245868] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  164.308339] wcn36xx: mac config changed 0x00000040
>>> [  164.308347] wcn36xx: wcn36xx_config channel switch=40
>>> [  164.308351] wcn36xx: hal finish scan mode 2
>>> [  164.319240] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  164.322405] wcn36xx: indication arrived
>>> [  164.523510] wcn36xx: indication arrived
>>> [  164.624238] wcn36xx: mac config changed 0x00000040
>>> [  164.624245] wcn36xx: wcn36xx_config channel switch=7
>>> [  164.624249] wcn36xx: hal init scan mode 2
>>> [  164.627352] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  164.627356] wcn36xx: hal start scan channel 7
>>> [  164.633425] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  164.696365] wcn36xx: mac config changed 0x00000040
>>> [  164.696374] wcn36xx: wcn36xx_config channel switch=40
>>> [  164.696378] wcn36xx: hal finish scan mode 2
>>> [  164.707355] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  164.710683] wcn36xx: indication arrived
>>> [  164.911285] wcn36xx: indication arrived
>>> [  165.012228] wcn36xx: mac config changed 0x00000040
>>> [  165.012236] wcn36xx: wcn36xx_config channel switch=8
>>> [  165.012240] wcn36xx: hal init scan mode 2
>>> [  165.015434] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  165.015439] wcn36xx: hal start scan channel 8
>>> [  165.021509] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  165.084204] wcn36xx: mac config changed 0x00000040
>>> [  165.084212] wcn36xx: wcn36xx_config channel switch=40
>>> [  165.084217] wcn36xx: hal finish scan mode 2
>>> [  165.095164] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  165.098269] wcn36xx: indication arrived
>>> [  165.299691] wcn36xx: indication arrived
>>> [  165.400304] wcn36xx: mac config changed 0x00000040
>>> [  165.400309] wcn36xx: wcn36xx_config channel switch=9
>>> [  165.400313] wcn36xx: hal init scan mode 2
>>> [  165.403424] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  165.403428] wcn36xx: hal start scan channel 9
>>> [  165.409695] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  165.472378] wcn36xx: mac config changed 0x00000040
>>> [  165.472386] wcn36xx: wcn36xx_config channel switch=40
>>> [  165.472390] wcn36xx: hal finish scan mode 2
>>> [  165.483390] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  165.486478] wcn36xx: indication arrived
>>> [  165.687641] wcn36xx: indication arrived
>>> [  165.788548] wcn36xx: mac config changed 0x00000040
>>> [  165.788556] wcn36xx: wcn36xx_config channel switch=10
>>> [  165.788561] wcn36xx: hal init scan mode 2
>>> [  165.791729] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  165.791734] wcn36xx: hal start scan channel 10
>>> [  165.797986] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  165.860337] wcn36xx: mac config changed 0x00000040
>>> [  165.860346] wcn36xx: wcn36xx_config channel switch=40
>>> [  165.860349] wcn36xx: hal finish scan mode 2
>>> [  165.871185] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  165.874560] wcn36xx: indication arrived
>>> [  166.075631] wcn36xx: indication arrived
>>> [  166.176336] wcn36xx: mac config changed 0x00000040
>>> [  166.176344] wcn36xx: wcn36xx_config channel switch=11
>>> [  166.176348] wcn36xx: hal init scan mode 2
>>> [  166.179753] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  166.179758] wcn36xx: hal start scan channel 11
>>> [  166.186033] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  166.248204] wcn36xx: mac config changed 0x00000040
>>> [  166.248211] wcn36xx: wcn36xx_config channel switch=40
>>> [  166.248216] wcn36xx: hal finish scan mode 2
>>> [  166.259127] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  166.262339] wcn36xx: indication arrived
>>> [  166.463387] wcn36xx: indication arrived
>>> [  166.564353] wcn36xx: mac config changed 0x00000040
>>> [  166.564362] wcn36xx: wcn36xx_config channel switch=12
>>> [  166.564366] wcn36xx: hal init scan mode 2
>>> [  166.567517] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  166.567522] wcn36xx: hal start scan channel 12
>>> [  166.573823] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  166.684383] wcn36xx: mac config changed 0x00000040
>>> [  166.684390] wcn36xx: wcn36xx_config channel switch=40
>>> [  166.684394] wcn36xx: hal finish scan mode 2
>>> [  166.695665] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  166.698857] wcn36xx: indication arrived
>>> [  166.899623] wcn36xx: indication arrived
>>> [  167.000265] wcn36xx: mac config changed 0x00000040
>>> [  167.000273] wcn36xx: wcn36xx_config channel switch=13
>>> [  167.000277] wcn36xx: hal init scan mode 2
>>> [  167.003459] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  167.003463] wcn36xx: hal start scan channel 13
>>> [  167.009787] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  167.120339] wcn36xx: mac config changed 0x00000040
>>> [  167.120348] wcn36xx: wcn36xx_config channel switch=40
>>> [  167.120351] wcn36xx: hal finish scan mode 2
>>> [  167.131208] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  167.134376] wcn36xx: indication arrived
>>> [  167.335469] wcn36xx: indication arrived
>>> [  167.436335] wcn36xx: mac config changed 0x00000040
>>> [  167.436343] wcn36xx: wcn36xx_config channel switch=14
>>> [  167.436347] wcn36xx: hal init scan mode 2
>>> [  167.439492] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  167.439497] wcn36xx: hal start scan channel 14
>>> [  167.446075] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  167.556358] wcn36xx: mac config changed 0x00000040
>>> [  167.556367] wcn36xx: wcn36xx_config channel switch=40
>>> [  167.556372] wcn36xx: hal finish scan mode 2
>>> [  167.567787] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  167.570712] wcn36xx: indication arrived
>>> [  167.771184] wcn36xx: indication arrived
>>> [  167.872093] wcn36xx: mac config changed 0x00000040
>>> [  167.872104] wcn36xx: wcn36xx_config channel switch=36
>>> [  167.872110] wcn36xx: hal init scan mode 2
>>> [  167.875463] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  167.875469] wcn36xx: hal start scan channel 36
>>> [  167.880887] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  167.944229] wcn36xx: mac config changed 0x00000040
>>> [  167.944238] wcn36xx: wcn36xx_config channel switch=40
>>> [  167.944243] wcn36xx: hal finish scan mode 2
>>> [  167.953262] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  167.956751] wcn36xx: indication arrived
>>> [  168.159485] wcn36xx: indication arrived
>>> [  168.260233] wcn36xx: mac config changed 0x00000040
>>> [  168.260243] wcn36xx: wcn36xx_config channel switch=40
>>> [  168.260248] wcn36xx: hal finish scan mode 2
>>> [  168.268055] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  168.332250] wcn36xx: mac config changed 0x00000040
>>> [  168.332259] wcn36xx: wcn36xx_config channel switch=40
>>> [  168.332264] wcn36xx: hal finish scan mode 2
>>> [  168.340018] wcn36xx: SMD command (req 10, rsp 11) completed in 4ms
>>> [  168.343231] wcn36xx: indication arrived
>>> [  168.547404] wcn36xx: indication arrived
>>> [  168.652662] wcn36xx: mac config changed 0x00000040
>>> [  168.652666] wcn36xx: wcn36xx_config channel switch=44
>>> [  168.652670] wcn36xx: hal init scan mode 2
>>> [  168.655732] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  168.655736] wcn36xx: hal start scan channel 44
>>> [  168.660968] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  168.772327] wcn36xx: mac config changed 0x00000040
>>> [  168.772334] wcn36xx: wcn36xx_config channel switch=40
>>> [  168.772338] wcn36xx: hal finish scan mode 2
>>> [  168.781369] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  168.784371] wcn36xx: indication arrived
>>> [  168.987575] wcn36xx: indication arrived
>>> [  169.088390] wcn36xx: mac config changed 0x00000040
>>> [  169.088398] wcn36xx: wcn36xx_config channel switch=48
>>> [  169.088402] wcn36xx: hal init scan mode 2
>>> [  169.091527] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  169.091532] wcn36xx: hal start scan channel 48
>>> [  169.097022] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  169.208455] wcn36xx: mac config changed 0x00000040
>>> [  169.208463] wcn36xx: wcn36xx_config channel switch=40
>>> [  169.208467] wcn36xx: hal finish scan mode 2
>>> [  169.218407] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  169.221568] wcn36xx: indication arrived
>>> [  169.423420] wcn36xx: indication arrived
>>> [  169.524402] wcn36xx: mac config changed 0x00000040
>>> [  169.524409] wcn36xx: wcn36xx_config channel switch=52
>>> [  169.524413] wcn36xx: hal init scan mode 2
>>> [  169.527559] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  169.527563] wcn36xx: hal start scan channel 52
>>> [  169.532973] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  169.644216] wcn36xx: mac config changed 0x00000040
>>> [  169.644223] wcn36xx: wcn36xx_config channel switch=40
>>> [  169.644227] wcn36xx: hal finish scan mode 2
>>> [  169.653367] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  169.656579] wcn36xx: indication arrived
>>> [  169.859998] wcn36xx: indication arrived
>>> [  169.960478] wcn36xx: mac config changed 0x00000040
>>> [  169.960489] wcn36xx: wcn36xx_config channel switch=56
>>> [  169.960494] wcn36xx: hal init scan mode 2
>>> [  169.963757] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  169.963762] wcn36xx: hal start scan channel 56
>>> [  169.969107] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  170.080126] wcn36xx: mac config changed 0x00000040
>>> [  170.080136] wcn36xx: wcn36xx_config channel switch=40
>>> [  170.080141] wcn36xx: hal finish scan mode 2
>>> [  170.089183] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  170.092346] wcn36xx: indication arrived
>>> [  170.295765] wcn36xx: indication arrived
>>> [  170.396072] wcn36xx: mac config changed 0x00000040
>>> [  170.396079] wcn36xx: wcn36xx_config channel switch=60
>>> [  170.396083] wcn36xx: hal init scan mode 2
>>> [  170.399139] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  170.399144] wcn36xx: hal start scan channel 60
>>> [  170.404547] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  170.516260] wcn36xx: mac config changed 0x00000040
>>> [  170.516268] wcn36xx: wcn36xx_config channel switch=40
>>> [  170.516272] wcn36xx: hal finish scan mode 2
>>> [  170.525323] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  170.528989] wcn36xx: indication arrived
>>> [  170.731306] wcn36xx: indication arrived
>>> [  170.832258] wcn36xx: mac config changed 0x00000040
>>> [  170.832266] wcn36xx: wcn36xx_config channel switch=64
>>> [  170.832270] wcn36xx: hal init scan mode 2
>>> [  170.835453] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  170.835457] wcn36xx: hal start scan channel 64
>>> [  170.840746] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  170.952490] wcn36xx: mac config changed 0x00000040
>>> [  170.952497] wcn36xx: wcn36xx_config channel switch=40
>>> [  170.952501] wcn36xx: hal finish scan mode 2
>>> [  170.961563] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  170.964663] wcn36xx: indication arrived
>>> [  171.167256] wcn36xx: indication arrived
>>> [  171.268465] wcn36xx: mac config changed 0x00000040
>>> [  171.268474] wcn36xx: wcn36xx_config channel switch=100
>>> [  171.268478] wcn36xx: hal init scan mode 2
>>> [  171.271622] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  171.271626] wcn36xx: hal start scan channel 100
>>> [  171.277068] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  171.388309] wcn36xx: mac config changed 0x00000040
>>> [  171.388316] wcn36xx: wcn36xx_config channel switch=40
>>> [  171.388320] wcn36xx: hal finish scan mode 2
>>> [  171.397462] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  171.400449] wcn36xx: indication arrived
>>> [  171.603380] wcn36xx: indication arrived
>>> [  171.704307] wcn36xx: mac config changed 0x00000040
>>> [  171.704315] wcn36xx: wcn36xx_config channel switch=104
>>> [  171.704318] wcn36xx: hal init scan mode 2
>>> [  171.707472] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  171.707476] wcn36xx: hal start scan channel 104
>>> [  171.712907] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  171.824322] wcn36xx: mac config changed 0x00000040
>>> [  171.824330] wcn36xx: wcn36xx_config channel switch=40
>>> [  171.824334] wcn36xx: hal finish scan mode 2
>>> [  171.833404] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  171.836577] wcn36xx: indication arrived
>>> [  172.039628] wcn36xx: indication arrived
>>> [  172.140321] wcn36xx: mac config changed 0x00000040
>>> [  172.140329] wcn36xx: wcn36xx_config channel switch=108
>>> [  172.140333] wcn36xx: hal init scan mode 2
>>> [  172.143442] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  172.143447] wcn36xx: hal start scan channel 108
>>> [  172.149071] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  172.260211] wcn36xx: mac config changed 0x00000040
>>> [  172.260219] wcn36xx: wcn36xx_config channel switch=40
>>> [  172.260222] wcn36xx: hal finish scan mode 2
>>> [  172.269482] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  172.272333] wcn36xx: indication arrived
>>> [  172.475588] wcn36xx: indication arrived
>>> [  172.576210] wcn36xx: mac config changed 0x00000040
>>> [  172.576217] wcn36xx: wcn36xx_config channel switch=112
>>> [  172.576221] wcn36xx: hal init scan mode 2
>>> [  172.579357] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  172.579362] wcn36xx: hal start scan channel 112
>>> [  172.584763] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  172.696318] wcn36xx: mac config changed 0x00000040
>>> [  172.696325] wcn36xx: wcn36xx_config channel switch=40
>>> [  172.696329] wcn36xx: hal finish scan mode 2
>>> [  172.705421] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  172.708542] wcn36xx: indication arrived
>>> [  172.911501] wcn36xx: indication arrived
>>> [  173.012248] wcn36xx: mac config changed 0x00000040
>>> [  173.012255] wcn36xx: wcn36xx_config channel switch=116
>>> [  173.012259] wcn36xx: hal init scan mode 2
>>> [  173.015521] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  173.015532] wcn36xx: hal start scan channel 116
>>> [  173.020870] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  173.132338] wcn36xx: mac config changed 0x00000040
>>> [  173.132346] wcn36xx: wcn36xx_config channel switch=40
>>> [  173.132350] wcn36xx: hal finish scan mode 2
>>> [  173.141388] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  173.144426] wcn36xx: indication arrived
>>> [  173.347588] wcn36xx: indication arrived
>>> [  173.448338] wcn36xx: mac config changed 0x00000040
>>> [  173.448347] wcn36xx: wcn36xx_config channel switch=120
>>> [  173.448350] wcn36xx: hal init scan mode 2
>>> [  173.451499] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  173.451503] wcn36xx: hal start scan channel 120
>>> [  173.456889] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  173.568336] wcn36xx: mac config changed 0x00000040
>>> [  173.568344] wcn36xx: wcn36xx_config channel switch=40
>>> [  173.568348] wcn36xx: hal finish scan mode 2
>>> [  173.577465] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  173.580602] wcn36xx: indication arrived
>>> [  173.783414] wcn36xx: indication arrived
>>> [  173.884494] wcn36xx: mac config changed 0x00000040
>>> [  173.884504] wcn36xx: wcn36xx_config channel switch=124
>>> [  173.884508] wcn36xx: hal init scan mode 2
>>> [  173.887627] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  173.887633] wcn36xx: hal start scan channel 124
>>> [  173.892978] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  174.004293] wcn36xx: mac config changed 0x00000040
>>> [  174.004303] wcn36xx: wcn36xx_config channel switch=40
>>> [  174.004308] wcn36xx: hal finish scan mode 2
>>> [  174.013188] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  174.017060] wcn36xx: indication arrived
>>> [  174.219812] wcn36xx: indication arrived
>>> [  174.320551] wcn36xx: mac config changed 0x00000040
>>> [  174.320559] wcn36xx: wcn36xx_config channel switch=128
>>> [  174.320563] wcn36xx: hal init scan mode 2
>>> [  174.324192] wcn36xx: SMD command (req 4, rsp 5) completed in 4ms
>>> [  174.324197] wcn36xx: hal start scan channel 128
>>> [  174.329545] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
>>> [  174.440367] wcn36xx: mac config changed 0x00000040
>>> [  174.440374] wcn36xx: wcn36xx_config channel switch=40
>>> [  174.440378] wcn36xx: hal finish scan mode 2
>>> [  174.449705] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  174.452983] wcn36xx: indication arrived
>>> [  174.655452] wcn36xx: indication arrived
>>> [  174.756428] wcn36xx: mac config changed 0x00000040
>>> [  174.756438] wcn36xx: wcn36xx_config channel switch=132
>>> [  174.756443] wcn36xx: hal init scan mode 2
>>> [  174.759554] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  174.759560] wcn36xx: hal start scan channel 132
>>> [  174.764959] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  174.876237] wcn36xx: mac config changed 0x00000040
>>> [  174.876245] wcn36xx: wcn36xx_config channel switch=40
>>> [  174.876250] wcn36xx: hal finish scan mode 2
>>> [  174.885310] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  174.888341] wcn36xx: indication arrived
>>> [  175.091324] wcn36xx: indication arrived
>>> [  175.192423] wcn36xx: mac config changed 0x00000040
>>> [  175.192430] wcn36xx: wcn36xx_config channel switch=140
>>> [  175.192433] wcn36xx: hal init scan mode 2
>>> [  175.195530] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  175.195534] wcn36xx: hal start scan channel 140
>>> [  175.200805] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  175.312321] wcn36xx: mac config changed 0x00000040
>>> [  175.312329] wcn36xx: wcn36xx_config channel switch=40
>>> [  175.312333] wcn36xx: hal finish scan mode 2
>>> [  175.321295] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  175.324800] wcn36xx: indication arrived
>>> [  175.527611] wcn36xx: indication arrived
>>> [  175.628313] wcn36xx: mac config changed 0x00000040
>>> [  175.628320] wcn36xx: wcn36xx_config channel switch=149
>>> [  175.628324] wcn36xx: hal init scan mode 2
>>> [  175.631414] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  175.631419] wcn36xx: hal start scan channel 149
>>> [  175.636846] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  175.748358] wcn36xx: mac config changed 0x00000040
>>> [  175.748367] wcn36xx: wcn36xx_config channel switch=40
>>> [  175.748371] wcn36xx: hal finish scan mode 2
>>> [  175.758146] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  175.761536] wcn36xx: indication arrived
>>> [  175.963887] wcn36xx: indication arrived
>>> [  176.064314] wcn36xx: mac config changed 0x00000040
>>> [  176.064322] wcn36xx: wcn36xx_config channel switch=153
>>> [  176.064326] wcn36xx: hal init scan mode 2
>>> [  176.067659] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  176.067663] wcn36xx: hal start scan channel 153
>>> [  176.072911] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  176.184091] wcn36xx: mac config changed 0x00000040
>>> [  176.184099] wcn36xx: wcn36xx_config channel switch=40
>>> [  176.184104] wcn36xx: hal finish scan mode 2
>>> [  176.193195] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  176.196177] wcn36xx: indication arrived
>>> [  176.399382] wcn36xx: indication arrived
>>> [  176.500288] wcn36xx: mac config changed 0x00000040
>>> [  176.500295] wcn36xx: wcn36xx_config channel switch=157
>>> [  176.500299] wcn36xx: hal init scan mode 2
>>> [  176.503417] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  176.503421] wcn36xx: hal start scan channel 157
>>> [  176.508762] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  176.620389] wcn36xx: mac config changed 0x00000040
>>> [  176.620396] wcn36xx: wcn36xx_config channel switch=40
>>> [  176.620400] wcn36xx: hal finish scan mode 2
>>> [  176.629516] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  176.632609] wcn36xx: indication arrived
>>> [  176.835319] wcn36xx: indication arrived
>>> [  176.936427] wcn36xx: mac config changed 0x00000040
>>> [  176.936435] wcn36xx: wcn36xx_config channel switch=161
>>> [  176.936440] wcn36xx: hal init scan mode 2
>>> [  176.939590] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  176.939595] wcn36xx: hal start scan channel 161
>>> [  176.945005] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  177.056380] wcn36xx: mac config changed 0x00000040
>>> [  177.056388] wcn36xx: wcn36xx_config channel switch=40
>>> [  177.056392] wcn36xx: hal finish scan mode 2
>>> [  177.065466] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
>>> [  177.068489] wcn36xx: indication arrived
>>> [  177.271739] wcn36xx: indication arrived
>>> [  177.372381] wcn36xx: mac config changed 0x00000040
>>> [  177.372389] wcn36xx: wcn36xx_config channel switch=165
>>> [  177.372393] wcn36xx: hal init scan mode 2
>>> [  177.375538] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
>>> [  177.375543] wcn36xx: hal start scan channel 165
>>> [  177.380982] wcn36xx: SMD command (req 6, rsp 7) completed in 8ms
>>> [  177.492402] wcn36xx: mac config changed 0x00000040
>>> [  177.492409] wcn36xx: wcn36xx_config channel switch=40
>>> [  177.492413] wcn36xx: hal finish scan mode 2
>>>
>>> Basically it takes 15 seconds to complete.
>>>
>>> Interleaved scan seems very slow and is IMO unusable on Android
>>
>>
>> The software scan is driven by mac80211 which interleaves channels 
>> scanning
>> with the regular data operations. In worst case, it scans during 111ms 
>> on the
>> channel and switches back to the operating channel for 200ms.
>> So, with 35 channels to scan that would take about 11 seconds to 
>> complete...
>> So yes, it's quite slow...
> 
> Yes looks a scheduling thing in mac80211.
> 
>> However, one remaining
>> thing to try would be to send an update-channel-list command to the
>> firmware before each offload scan (cf UPDATE_CHANNEL_LIST_REQ
>> in the downstream driver). That's not something I've tried yet.
> 
> I've tried
> 
> 1. Setting the operating frequency to a 5ghz band before the scan
> 2. Updating the channel list with 2g/5g channels via 
> UPDATE_CHANNEL_LIST_REQ
> 3. Updating the channel list with 5g only with UPDATE_CHANNEL_LIST_REQ
> 4. Doing 5g channels only in the channel list of 
> WCN36XX_HAL_START_SCAN_OFFLOAD_REQ
> 
> I don't think the channel list matters, if I recall rightly I've also 
> tried leaving out the channel list in WCN36XX_HAL_START_SCAN_OFFLOAD_REQ 
> and get back the same set of channels in the result
> 
> I guess we should take this patch anyway, since it makes wcn36xx and 
> mac80211 agree on ownership of the antenna...
> 
> ---
> bod

Ah.

If we implement ops->flush() we can slash that idle time down significantly

static void ieee80211_scan_state_resume(struct ieee80211_local *local,
                                         unsigned long *next_delay)
{

         if (local->ops->flush) {
                 ieee80211_flush_queues(local, NULL, false);
                 *next_delay = 0;
         } else
                 *next_delay = HZ / 10;
}

Trivial hack example:

+void wcn36xx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+                  u32 queues, bool drop)
+{
+}
+
  static const struct ieee80211_ops wcn36xx_ops = {
         .start                  = wcn36xx_start,
         .stop                   = wcn36xx_stop,
@@ -1187,7 +1192,7 @@ static const struct ieee80211_ops wcn36xx_ops = {
         .sta_add                = wcn36xx_sta_add,
         .sta_remove             = wcn36xx_sta_remove,
         .ampdu_action           = wcn36xx_ampdu_action,
-
+       .flush                  = wcn36xx_flush,
         CFG80211_TESTMODE_CMD(wcn36xx_tm_cmd)
  };

That ~ 20 seconds is cut to just 4 ! Which to be fair seems to be the 
kind of time it took to do the old version of the software scan.

[  869.625922] wcn36xx: mac config changed 0x00000040
[  869.625930] wcn36xx: wcn36xx_config channel switch=1
[  869.625938] wcn36xx: hal init scan mode 2
[  869.628080] wcn36xx: SMD command (req 4, rsp 5) completed in 4ms
[  869.628103] wcn36xx: hal start scan channel 1
[  869.633985] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  869.694216] wcn36xx: mac config changed 0x00000040
[  869.694233] wcn36xx: wcn36xx_config channel switch=2
[  869.694240] wcn36xx: hal init scan mode 2
[  869.695465] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  869.695472] wcn36xx: hal start scan channel 2
[  869.700504] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  869.762229] wcn36xx: mac config changed 0x00000040
[  869.762247] wcn36xx: wcn36xx_config channel switch=3
[  869.762252] wcn36xx: hal init scan mode 2
[  869.763425] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  869.763431] wcn36xx: hal start scan channel 3
[  869.768356] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  869.830220] wcn36xx: mac config changed 0x00000040
[  869.830237] wcn36xx: wcn36xx_config channel switch=4
[  869.830242] wcn36xx: hal init scan mode 2
[  869.831435] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  869.831441] wcn36xx: hal start scan channel 4
[  869.836358] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  869.898218] wcn36xx: mac config changed 0x00000040
[  869.898232] wcn36xx: wcn36xx_config channel switch=5
[  869.898237] wcn36xx: hal init scan mode 2
[  869.899401] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  869.899406] wcn36xx: hal start scan channel 5
[  869.904244] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  869.966234] wcn36xx: mac config changed 0x00000040
[  869.966248] wcn36xx: wcn36xx_config channel switch=6
[  869.966256] wcn36xx: hal init scan mode 2
[  869.967417] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  869.967423] wcn36xx: hal start scan channel 6
[  869.972551] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  870.034227] wcn36xx: mac config changed 0x00000040
[  870.034242] wcn36xx: wcn36xx_config channel switch=7
[  870.034248] wcn36xx: hal init scan mode 2
[  870.035426] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  870.035431] wcn36xx: hal start scan channel 7
[  870.040348] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  870.102225] wcn36xx: mac config changed 0x00000040
[  870.102240] wcn36xx: wcn36xx_config channel switch=8
[  870.102246] wcn36xx: hal init scan mode 2
[  870.103425] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  870.103430] wcn36xx: hal start scan channel 8
[  870.108288] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  870.170241] wcn36xx: mac config changed 0x00000040
[  870.170253] wcn36xx: wcn36xx_config channel switch=9
[  870.170258] wcn36xx: hal init scan mode 2
[  870.171801] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  870.171806] wcn36xx: hal start scan channel 9
[  870.176850] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  870.238228] wcn36xx: mac config changed 0x00000040
[  870.238245] wcn36xx: wcn36xx_config channel switch=10
[  870.238252] wcn36xx: hal init scan mode 2
[  870.239430] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  870.239435] wcn36xx: hal start scan channel 10
[  870.244371] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  870.306231] wcn36xx: mac config changed 0x00000040
[  870.306244] wcn36xx: wcn36xx_config channel switch=11
[  870.306250] wcn36xx: hal init scan mode 2
[  870.307409] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  870.307414] wcn36xx: hal start scan channel 11
[  870.312317] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  870.374252] wcn36xx: mac config changed 0x00000040
[  870.374265] wcn36xx: wcn36xx_config channel switch=12
[  870.374270] wcn36xx: hal init scan mode 2
[  870.375476] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  870.375481] wcn36xx: hal start scan channel 12
[  870.380445] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  870.490250] wcn36xx: mac config changed 0x00000040
[  870.490265] wcn36xx: wcn36xx_config channel switch=13
[  870.490271] wcn36xx: hal init scan mode 2
[  870.491464] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  870.491470] wcn36xx: hal start scan channel 13
[  870.496469] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  870.606269] wcn36xx: mac config changed 0x00000040
[  870.606280] wcn36xx: wcn36xx_config channel switch=14
[  870.606286] wcn36xx: hal init scan mode 2
[  870.607451] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  870.607457] wcn36xx: hal start scan channel 14
[  870.612376] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  870.722256] wcn36xx: mac config changed 0x00000040
[  870.722273] wcn36xx: wcn36xx_config channel switch=36
[  870.722278] wcn36xx: hal init scan mode 2
[  870.723462] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  870.723468] wcn36xx: hal start scan channel 36
[  870.729088] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  870.838293] wcn36xx: mac config changed 0x00000040
[  870.838320] wcn36xx: wcn36xx_config channel switch=40
[  870.838328] wcn36xx: hal init scan mode 2
[  870.839584] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  870.839593] wcn36xx: hal start scan channel 40
[  870.844505] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  870.954291] wcn36xx: mac config changed 0x00000040
[  870.954313] wcn36xx: wcn36xx_config channel switch=44
[  870.954321] wcn36xx: hal init scan mode 2
[  870.955544] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  870.955552] wcn36xx: hal start scan channel 44
[  870.960510] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  871.070288] wcn36xx: mac config changed 0x00000040
[  871.070312] wcn36xx: wcn36xx_config channel switch=48
[  871.070321] wcn36xx: hal init scan mode 2
[  871.071546] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  871.071553] wcn36xx: hal start scan channel 48
[  871.076610] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  871.186286] wcn36xx: mac config changed 0x00000040
[  871.186299] wcn36xx: wcn36xx_config channel switch=52
[  871.186306] wcn36xx: hal init scan mode 2
[  871.187547] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  871.187553] wcn36xx: hal start scan channel 52
[  871.192430] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  871.302301] wcn36xx: mac config changed 0x00000040
[  871.302316] wcn36xx: wcn36xx_config channel switch=56
[  871.302322] wcn36xx: hal init scan mode 2
[  871.303526] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  871.303532] wcn36xx: hal start scan channel 56
[  871.308372] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  871.418292] wcn36xx: mac config changed 0x00000040
[  871.418303] wcn36xx: wcn36xx_config channel switch=60
[  871.418308] wcn36xx: hal init scan mode 2
[  871.419511] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  871.419517] wcn36xx: hal start scan channel 60
[  871.424368] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  871.534320] wcn36xx: mac config changed 0x00000040
[  871.534335] wcn36xx: wcn36xx_config channel switch=64
[  871.534341] wcn36xx: hal init scan mode 2
[  871.535526] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  871.535532] wcn36xx: hal start scan channel 64
[  871.540434] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  871.650286] wcn36xx: mac config changed 0x00000040
[  871.650299] wcn36xx: wcn36xx_config channel switch=100
[  871.650306] wcn36xx: hal init scan mode 2
[  871.651480] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  871.651486] wcn36xx: hal start scan channel 100
[  871.656365] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  871.766292] wcn36xx: mac config changed 0x00000040
[  871.766305] wcn36xx: wcn36xx_config channel switch=104
[  871.766311] wcn36xx: hal init scan mode 2
[  871.767516] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  871.767522] wcn36xx: hal start scan channel 104
[  871.772388] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  871.882301] wcn36xx: mac config changed 0x00000040
[  871.882313] wcn36xx: wcn36xx_config channel switch=108
[  871.882319] wcn36xx: hal init scan mode 2
[  871.883488] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  871.883493] wcn36xx: hal start scan channel 108
[  871.888315] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  871.998313] wcn36xx: mac config changed 0x00000040
[  871.998326] wcn36xx: wcn36xx_config channel switch=112
[  871.998335] wcn36xx: hal init scan mode 2
[  871.999509] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  871.999514] wcn36xx: hal start scan channel 112
[  872.004329] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  872.114319] wcn36xx: mac config changed 0x00000040
[  872.114334] wcn36xx: wcn36xx_config channel switch=116
[  872.114340] wcn36xx: hal init scan mode 2
[  872.115511] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  872.115516] wcn36xx: hal start scan channel 116
[  872.120361] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  872.230319] wcn36xx: mac config changed 0x00000040
[  872.230330] wcn36xx: wcn36xx_config channel switch=120
[  872.230337] wcn36xx: hal init scan mode 2
[  872.231539] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  872.231545] wcn36xx: hal start scan channel 120
[  872.236431] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  872.346316] wcn36xx: mac config changed 0x00000040
[  872.346330] wcn36xx: wcn36xx_config channel switch=124
[  872.346336] wcn36xx: hal init scan mode 2
[  872.347521] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  872.347526] wcn36xx: hal start scan channel 124
[  872.352380] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  872.462328] wcn36xx: mac config changed 0x00000040
[  872.462343] wcn36xx: wcn36xx_config channel switch=128
[  872.462349] wcn36xx: hal init scan mode 2
[  872.463527] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  872.463534] wcn36xx: hal start scan channel 128
[  872.468355] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  872.578340] wcn36xx: mac config changed 0x00000040
[  872.578349] wcn36xx: wcn36xx_config channel switch=132
[  872.578354] wcn36xx: hal init scan mode 2
[  872.579558] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  872.579565] wcn36xx: hal start scan channel 132
[  872.584405] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  872.694321] wcn36xx: mac config changed 0x00000040
[  872.694337] wcn36xx: wcn36xx_config channel switch=140
[  872.694343] wcn36xx: hal init scan mode 2
[  872.695500] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  872.695506] wcn36xx: hal start scan channel 140
[  872.700290] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  872.810339] wcn36xx: mac config changed 0x00000040
[  872.810351] wcn36xx: wcn36xx_config channel switch=149
[  872.810357] wcn36xx: hal init scan mode 2
[  872.811528] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  872.811535] wcn36xx: hal start scan channel 149
[  872.816424] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  872.926347] wcn36xx: mac config changed 0x00000040
[  872.926359] wcn36xx: wcn36xx_config channel switch=153
[  872.926366] wcn36xx: hal init scan mode 2
[  872.927525] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  872.927531] wcn36xx: hal start scan channel 153
[  872.932361] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  873.042347] wcn36xx: mac config changed 0x00000040
[  873.042359] wcn36xx: wcn36xx_config channel switch=157
[  873.042366] wcn36xx: hal init scan mode 2
[  873.043531] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  873.043536] wcn36xx: hal start scan channel 157
[  873.048367] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  873.158352] wcn36xx: mac config changed 0x00000040
[  873.158366] wcn36xx: wcn36xx_config channel switch=161
[  873.158373] wcn36xx: hal init scan mode 2
[  873.159550] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  873.159557] wcn36xx: hal start scan channel 161
[  873.164385] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  873.274356] wcn36xx: mac config changed 0x00000040
[  873.274368] wcn36xx: wcn36xx_config channel switch=165
[  873.274374] wcn36xx: hal init scan mode 2
[  873.275673] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  873.275679] wcn36xx: hal start scan channel 165
[  873.280543] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  873.390365] wcn36xx: mac config changed 0x00000040
[  873.390376] wcn36xx: wcn36xx_config channel switch=36
[  873.390382] wcn36xx: hal init scan mode 2
[  873.391571] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms
[  873.391582] wcn36xx: hal start scan channel 36
[  873.395275] wlan0: authenticate with e0:63:da:cc:a4:bd
[  873.396502] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms
[  873.396522] wcn36xx: mac prepare multicast list
[  873.396539] wcn36xx: mac configure filter
[  873.396551] wcn36xx: hal finish scan mode 2
[  873.405870] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms
[  873.405953] wcn36xx: mac config changed 0x00000100
[  873.406063] wcn36xx: mac config changed 0x00000100
[  873.406070] wcn36xx: mac config changed 0x00000040
[  873.406075] wcn36xx: wcn36xx_config channel switch=36

Not only that but I get the full scan-result list as expected...

So yeah I think this patch is good as-is.
We should add ops->flush() - I guess I'll send something out for comment 
on that in the next 12-18 hours.

---
bod
Loic Poulain Aug. 20, 2020, 11:27 a.m. UTC | #7
HI Bryan,

On Thu, 20 Aug 2020 at 01:54, Bryan O'Donoghue
<bryan.odonoghue@linaro.org> wrote:
>

> On 19/08/2020 11:52, Bryan O'Donoghue wrote:

> > On 19/08/2020 09:15, Loic Poulain wrote:

> >> Hi Bryan,

> >>

> >> On Tue, 18 Aug 2020 at 20:00, Bryan O'Donoghue

> >> <pure.logic@nexus-software.ie> wrote:

> >>>

> >>> On 18/08/2020 14:34, Loic Poulain wrote:

> >>>> On Tue, 18 Aug 2020 at 08:15, Kalle Valo <kvalo@codeaurora.org> wrote:

> >>>>>

> >>>>> Loic Poulain <loic.poulain@linaro.org> writes:

> >>>>>

> >>>>>> For software-driven scan, rely on mac80211 software scan instead

> >>>>>> of internal driver implementation. The internal implementation

> >>>>>> cause connection trouble since it keep the antenna busy during

> >>>>>> the entire scan duration, moreover it's only a passive scanning

> >>>>>> (no probe request). Therefore, let mac80211 manages sw scan.

> >>>>>>

> >>>>>> Note: we fallback to software scan if firmware does not report

> >>>>>> scan offload support or if we need to scan the 5Ghz band (currently

> >>>>>> not supported by the offload scan...).

> >>>>>>

> >>>>>> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

> >>>>>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

> >>>>>

> >>>>> What changed since v2? Please always include a changelog so that I

> >>>>> don't

> >>>>> need to guess what you have changed in the patch. No need to resend, a

> >>>>> reply is enough.

> >>>>

> >>>> Yes sorry, this patch has been rebased on ath master and squashed with

> >>>> Bryan's fix:

> >>>>        wcn36xx: Set sw-scan chan to 0 when not associated

> >>>> No additional changes have been made on top of the initial patches.

> >>>>

> >>>> Regards,

> >>>> Loic

> >>>>

> >>>

> >>> This is excruciatingly slow on Android.

> >>>

> >>> Android I'm finding unlike Debian where this stuff was tested, merrily

> >>> issues scan requests every 30 seconds.

> >>>

> >>> For me this ends up looking like this

> >>>

> >>> [  162.296995] wcn36xx: mac config changed 0x00000040

> >>> [  162.297001] wcn36xx: wcn36xx_config channel switch=1

> >>> [  162.297005] wcn36xx: hal init scan mode 2

> >>> [  177.492402] wcn36xx: mac config changed 0x00000040

> >>> [  177.492409] wcn36xx: wcn36xx_config channel switch=40

> >>> [  177.492413] wcn36xx: hal finish scan mode 2

> >>>

> >>> Basically it takes 15 seconds to complete.

> >>>

> >>> Interleaved scan seems very slow and is IMO unusable on Android

> >>

> >>

> >> The software scan is driven by mac80211 which interleaves channels

> >> scanning

> >> with the regular data operations. In worst case, it scans during 111ms

> >> on the

> >> channel and switches back to the operating channel for 200ms.

> >> So, with 35 channels to scan that would take about 11 seconds to

> >> complete...

> >> So yes, it's quite slow...

> >

> > Yes looks a scheduling thing in mac80211.

> >

> >> However, one remaining

> >> thing to try would be to send an update-channel-list command to the

> >> firmware before each offload scan (cf UPDATE_CHANNEL_LIST_REQ

> >> in the downstream driver). That's not something I've tried yet.

> >

> > I've tried

> >

> > 1. Setting the operating frequency to a 5ghz band before the scan

> > 2. Updating the channel list with 2g/5g channels via

> > UPDATE_CHANNEL_LIST_REQ

> > 3. Updating the channel list with 5g only with UPDATE_CHANNEL_LIST_REQ

> > 4. Doing 5g channels only in the channel list of

> > WCN36XX_HAL_START_SCAN_OFFLOAD_REQ

> >

> > I don't think the channel list matters, if I recall rightly I've also

> > tried leaving out the channel list in WCN36XX_HAL_START_SCAN_OFFLOAD_REQ

> > and get back the same set of channels in the result

> >

> > I guess we should take this patch anyway, since it makes wcn36xx and

> > mac80211 agree on ownership of the antenna...

> >

> > ---

> > bod

>

> Ah.

>

> If we implement ops->flush() we can slash that idle time down significantly

>

> static void ieee80211_scan_state_resume(struct ieee80211_local *local,

>                                          unsigned long *next_delay)

> {

>

>          if (local->ops->flush) {

>                  ieee80211_flush_queues(local, NULL, false);

>                  *next_delay = 0;

>          } else

>                  *next_delay = HZ / 10;

> }

>

> Trivial hack example:

>

> +void wcn36xx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,

> +                  u32 queues, bool drop)

> +{

> +}

> +

>   static const struct ieee80211_ops wcn36xx_ops = {

>          .start                  = wcn36xx_start,

>          .stop                   = wcn36xx_stop,

> @@ -1187,7 +1192,7 @@ static const struct ieee80211_ops wcn36xx_ops = {

>          .sta_add                = wcn36xx_sta_add,

>          .sta_remove             = wcn36xx_sta_remove,

>          .ampdu_action           = wcn36xx_ampdu_action,

> -

> +       .flush                  = wcn36xx_flush,

>          CFG80211_TESTMODE_CMD(wcn36xx_tm_cmd)

>   };


Interestingly, we could indeed get rid of this extra 100ms.
Maybe a way to implement this would be to wait for the TX
ring to be empty in dxe.

> That ~ 20 seconds is cut to just 4 ! Which to be fair seems to be the

> kind of time it took to do the old version of the software scan.


Sure but In the below case, it seems scan occurs while you're not
connected to an AP, which prevents interleaving of operating channel.
The same scan while connected should be longer.

> [  869.625922] wcn36xx: mac config changed 0x00000040

> [  869.625930] wcn36xx: wcn36xx_config channel switch=1

> [  869.625938] wcn36xx: hal init scan mode 2

> [  869.628080] wcn36xx: SMD command (req 4, rsp 5) completed in 4ms

> [  869.628103] wcn36xx: hal start scan channel 1

> [  869.633985] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  869.694216] wcn36xx: mac config changed 0x00000040

> [  869.694233] wcn36xx: wcn36xx_config channel switch=2

> [  869.694240] wcn36xx: hal init scan mode 2

> [  869.695465] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  869.695472] wcn36xx: hal start scan channel 2

> [  869.700504] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  869.762229] wcn36xx: mac config changed 0x00000040

> [  869.762247] wcn36xx: wcn36xx_config channel switch=3

> [  869.762252] wcn36xx: hal init scan mode 2

> [  869.763425] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  869.763431] wcn36xx: hal start scan channel 3

> [  869.768356] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  869.830220] wcn36xx: mac config changed 0x00000040

> [  869.830237] wcn36xx: wcn36xx_config channel switch=4

> [  869.830242] wcn36xx: hal init scan mode 2

> [  869.831435] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  869.831441] wcn36xx: hal start scan channel 4

> [  869.836358] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  869.898218] wcn36xx: mac config changed 0x00000040

> [  869.898232] wcn36xx: wcn36xx_config channel switch=5

> [  869.898237] wcn36xx: hal init scan mode 2

> [  869.899401] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  869.899406] wcn36xx: hal start scan channel 5

> [  869.904244] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  869.966234] wcn36xx: mac config changed 0x00000040

> [  869.966248] wcn36xx: wcn36xx_config channel switch=6

> [  869.966256] wcn36xx: hal init scan mode 2

> [  869.967417] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  869.967423] wcn36xx: hal start scan channel 6

> [  869.972551] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  870.034227] wcn36xx: mac config changed 0x00000040

> [  870.034242] wcn36xx: wcn36xx_config channel switch=7

> [  870.034248] wcn36xx: hal init scan mode 2

> [  870.035426] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  870.035431] wcn36xx: hal start scan channel 7

> [  870.040348] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  870.102225] wcn36xx: mac config changed 0x00000040

> [  870.102240] wcn36xx: wcn36xx_config channel switch=8

> [  870.102246] wcn36xx: hal init scan mode 2

> [  870.103425] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  870.103430] wcn36xx: hal start scan channel 8

> [  870.108288] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  870.170241] wcn36xx: mac config changed 0x00000040

> [  870.170253] wcn36xx: wcn36xx_config channel switch=9

> [  870.170258] wcn36xx: hal init scan mode 2

> [  870.171801] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  870.171806] wcn36xx: hal start scan channel 9

> [  870.176850] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  870.238228] wcn36xx: mac config changed 0x00000040

> [  870.238245] wcn36xx: wcn36xx_config channel switch=10

> [  870.238252] wcn36xx: hal init scan mode 2

> [  870.239430] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  870.239435] wcn36xx: hal start scan channel 10

> [  870.244371] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  870.306231] wcn36xx: mac config changed 0x00000040

> [  870.306244] wcn36xx: wcn36xx_config channel switch=11

> [  870.306250] wcn36xx: hal init scan mode 2

> [  870.307409] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  870.307414] wcn36xx: hal start scan channel 11

> [  870.312317] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  870.374252] wcn36xx: mac config changed 0x00000040

> [  870.374265] wcn36xx: wcn36xx_config channel switch=12

> [  870.374270] wcn36xx: hal init scan mode 2

> [  870.375476] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  870.375481] wcn36xx: hal start scan channel 12

> [  870.380445] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  870.490250] wcn36xx: mac config changed 0x00000040

> [  870.490265] wcn36xx: wcn36xx_config channel switch=13

> [  870.490271] wcn36xx: hal init scan mode 2

> [  870.491464] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  870.491470] wcn36xx: hal start scan channel 13

> [  870.496469] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  870.606269] wcn36xx: mac config changed 0x00000040

> [  870.606280] wcn36xx: wcn36xx_config channel switch=14

> [  870.606286] wcn36xx: hal init scan mode 2

> [  870.607451] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  870.607457] wcn36xx: hal start scan channel 14

> [  870.612376] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  870.722256] wcn36xx: mac config changed 0x00000040

> [  870.722273] wcn36xx: wcn36xx_config channel switch=36

> [  870.722278] wcn36xx: hal init scan mode 2

> [  870.723462] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  870.723468] wcn36xx: hal start scan channel 36

> [  870.729088] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  870.838293] wcn36xx: mac config changed 0x00000040

> [  870.838320] wcn36xx: wcn36xx_config channel switch=40

> [  870.838328] wcn36xx: hal init scan mode 2

> [  870.839584] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  870.839593] wcn36xx: hal start scan channel 40

> [  870.844505] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  870.954291] wcn36xx: mac config changed 0x00000040

> [  870.954313] wcn36xx: wcn36xx_config channel switch=44

> [  870.954321] wcn36xx: hal init scan mode 2

> [  870.955544] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  870.955552] wcn36xx: hal start scan channel 44

> [  870.960510] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  871.070288] wcn36xx: mac config changed 0x00000040

> [  871.070312] wcn36xx: wcn36xx_config channel switch=48

> [  871.070321] wcn36xx: hal init scan mode 2

> [  871.071546] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  871.071553] wcn36xx: hal start scan channel 48

> [  871.076610] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  871.186286] wcn36xx: mac config changed 0x00000040

> [  871.186299] wcn36xx: wcn36xx_config channel switch=52

> [  871.186306] wcn36xx: hal init scan mode 2

> [  871.187547] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  871.187553] wcn36xx: hal start scan channel 52

> [  871.192430] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  871.302301] wcn36xx: mac config changed 0x00000040

> [  871.302316] wcn36xx: wcn36xx_config channel switch=56

> [  871.302322] wcn36xx: hal init scan mode 2

> [  871.303526] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  871.303532] wcn36xx: hal start scan channel 56

> [  871.308372] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  871.418292] wcn36xx: mac config changed 0x00000040

> [  871.418303] wcn36xx: wcn36xx_config channel switch=60

> [  871.418308] wcn36xx: hal init scan mode 2

> [  871.419511] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  871.419517] wcn36xx: hal start scan channel 60

> [  871.424368] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  871.534320] wcn36xx: mac config changed 0x00000040

> [  871.534335] wcn36xx: wcn36xx_config channel switch=64

> [  871.534341] wcn36xx: hal init scan mode 2

> [  871.535526] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  871.535532] wcn36xx: hal start scan channel 64

> [  871.540434] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  871.650286] wcn36xx: mac config changed 0x00000040

> [  871.650299] wcn36xx: wcn36xx_config channel switch=100

> [  871.650306] wcn36xx: hal init scan mode 2

> [  871.651480] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  871.651486] wcn36xx: hal start scan channel 100

> [  871.656365] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  871.766292] wcn36xx: mac config changed 0x00000040

> [  871.766305] wcn36xx: wcn36xx_config channel switch=104

> [  871.766311] wcn36xx: hal init scan mode 2

> [  871.767516] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  871.767522] wcn36xx: hal start scan channel 104

> [  871.772388] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  871.882301] wcn36xx: mac config changed 0x00000040

> [  871.882313] wcn36xx: wcn36xx_config channel switch=108

> [  871.882319] wcn36xx: hal init scan mode 2

> [  871.883488] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  871.883493] wcn36xx: hal start scan channel 108

> [  871.888315] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  871.998313] wcn36xx: mac config changed 0x00000040

> [  871.998326] wcn36xx: wcn36xx_config channel switch=112

> [  871.998335] wcn36xx: hal init scan mode 2

> [  871.999509] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  871.999514] wcn36xx: hal start scan channel 112

> [  872.004329] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  872.114319] wcn36xx: mac config changed 0x00000040

> [  872.114334] wcn36xx: wcn36xx_config channel switch=116

> [  872.114340] wcn36xx: hal init scan mode 2

> [  872.115511] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  872.115516] wcn36xx: hal start scan channel 116

> [  872.120361] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  872.230319] wcn36xx: mac config changed 0x00000040

> [  872.230330] wcn36xx: wcn36xx_config channel switch=120

> [  872.230337] wcn36xx: hal init scan mode 2

> [  872.231539] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  872.231545] wcn36xx: hal start scan channel 120

> [  872.236431] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  872.346316] wcn36xx: mac config changed 0x00000040

> [  872.346330] wcn36xx: wcn36xx_config channel switch=124

> [  872.346336] wcn36xx: hal init scan mode 2

> [  872.347521] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  872.347526] wcn36xx: hal start scan channel 124

> [  872.352380] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  872.462328] wcn36xx: mac config changed 0x00000040

> [  872.462343] wcn36xx: wcn36xx_config channel switch=128

> [  872.462349] wcn36xx: hal init scan mode 2

> [  872.463527] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  872.463534] wcn36xx: hal start scan channel 128

> [  872.468355] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  872.578340] wcn36xx: mac config changed 0x00000040

> [  872.578349] wcn36xx: wcn36xx_config channel switch=132

> [  872.578354] wcn36xx: hal init scan mode 2

> [  872.579558] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  872.579565] wcn36xx: hal start scan channel 132

> [  872.584405] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  872.694321] wcn36xx: mac config changed 0x00000040

> [  872.694337] wcn36xx: wcn36xx_config channel switch=140

> [  872.694343] wcn36xx: hal init scan mode 2

> [  872.695500] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  872.695506] wcn36xx: hal start scan channel 140

> [  872.700290] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  872.810339] wcn36xx: mac config changed 0x00000040

> [  872.810351] wcn36xx: wcn36xx_config channel switch=149

> [  872.810357] wcn36xx: hal init scan mode 2

> [  872.811528] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  872.811535] wcn36xx: hal start scan channel 149

> [  872.816424] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  872.926347] wcn36xx: mac config changed 0x00000040

> [  872.926359] wcn36xx: wcn36xx_config channel switch=153

> [  872.926366] wcn36xx: hal init scan mode 2

> [  872.927525] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  872.927531] wcn36xx: hal start scan channel 153

> [  872.932361] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  873.042347] wcn36xx: mac config changed 0x00000040

> [  873.042359] wcn36xx: wcn36xx_config channel switch=157

> [  873.042366] wcn36xx: hal init scan mode 2

> [  873.043531] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  873.043536] wcn36xx: hal start scan channel 157

> [  873.048367] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  873.158352] wcn36xx: mac config changed 0x00000040

> [  873.158366] wcn36xx: wcn36xx_config channel switch=161

> [  873.158373] wcn36xx: hal init scan mode 2

> [  873.159550] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  873.159557] wcn36xx: hal start scan channel 161

> [  873.164385] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  873.274356] wcn36xx: mac config changed 0x00000040

> [  873.274368] wcn36xx: wcn36xx_config channel switch=165

> [  873.274374] wcn36xx: hal init scan mode 2

> [  873.275673] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  873.275679] wcn36xx: hal start scan channel 165

> [  873.280543] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  873.390365] wcn36xx: mac config changed 0x00000040

> [  873.390376] wcn36xx: wcn36xx_config channel switch=36

> [  873.390382] wcn36xx: hal init scan mode 2

> [  873.391571] wcn36xx: SMD command (req 4, rsp 5) completed in 0ms

> [  873.391582] wcn36xx: hal start scan channel 36

> [  873.395275] wlan0: authenticate with e0:63:da:cc:a4:bd

> [  873.396502] wcn36xx: SMD command (req 6, rsp 7) completed in 4ms

> [  873.396522] wcn36xx: mac prepare multicast list

> [  873.396539] wcn36xx: mac configure filter

> [  873.396551] wcn36xx: hal finish scan mode 2

> [  873.405870] wcn36xx: SMD command (req 10, rsp 11) completed in 8ms

> [  873.405953] wcn36xx: mac config changed 0x00000100

> [  873.406063] wcn36xx: mac config changed 0x00000100

> [  873.406070] wcn36xx: mac config changed 0x00000040

> [  873.406075] wcn36xx: wcn36xx_config channel switch=36

>

> Not only that but I get the full scan-result list as expected...

>

> So yeah I think this patch is good as-is.

> We should add ops->flush() - I guess I'll send something out for comment

> on that in the next 12-18 hours.

>

> ---

> bod


_______________________________________________
wcn36xx mailing list
wcn36xx@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/wcn36xx
Bryan O'Donoghue Aug. 20, 2020, 12:14 p.m. UTC | #8
On 20/08/2020 12:27, Loic Poulain wrote:
> HI Bryan,

> 

> On Thu, 20 Aug 2020 at 01:54, Bryan O'Donoghue

> <bryan.odonoghue@linaro.org> wrote:

>>

>> On 19/08/2020 11:52, Bryan O'Donoghue wrote:

>>> On 19/08/2020 09:15, Loic Poulain wrote:

>>>> Hi Bryan,

>>>>

>>>> On Tue, 18 Aug 2020 at 20:00, Bryan O'Donoghue

>>>> <pure.logic@nexus-software.ie> wrote:

>>>>>

>>>>> On 18/08/2020 14:34, Loic Poulain wrote:

>>>>>> On Tue, 18 Aug 2020 at 08:15, Kalle Valo <kvalo@codeaurora.org> wrote:

>>>>>>>

>>>>>>> Loic Poulain <loic.poulain@linaro.org> writes:

>>>>>>>

>>>>>>>> For software-driven scan, rely on mac80211 software scan instead

>>>>>>>> of internal driver implementation. The internal implementation

>>>>>>>> cause connection trouble since it keep the antenna busy during

>>>>>>>> the entire scan duration, moreover it's only a passive scanning

>>>>>>>> (no probe request). Therefore, let mac80211 manages sw scan.

>>>>>>>>

>>>>>>>> Note: we fallback to software scan if firmware does not report

>>>>>>>> scan offload support or if we need to scan the 5Ghz band (currently

>>>>>>>> not supported by the offload scan...).

>>>>>>>>

>>>>>>>> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

>>>>>>>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

>>>>>>>

>>>>>>> What changed since v2? Please always include a changelog so that I

>>>>>>> don't

>>>>>>> need to guess what you have changed in the patch. No need to resend, a

>>>>>>> reply is enough.

>>>>>>

>>>>>> Yes sorry, this patch has been rebased on ath master and squashed with

>>>>>> Bryan's fix:

>>>>>>         wcn36xx: Set sw-scan chan to 0 when not associated

>>>>>> No additional changes have been made on top of the initial patches.

>>>>>>

>>>>>> Regards,

>>>>>> Loic

>>>>>>

>>>>>

>>>>> This is excruciatingly slow on Android.

>>>>>

>>>>> Android I'm finding unlike Debian where this stuff was tested, merrily

>>>>> issues scan requests every 30 seconds.

>>>>>

>>>>> For me this ends up looking like this

>>>>>

>>>>> [  162.296995] wcn36xx: mac config changed 0x00000040

>>>>> [  162.297001] wcn36xx: wcn36xx_config channel switch=1

>>>>> [  162.297005] wcn36xx: hal init scan mode 2

>>>>> [  177.492402] wcn36xx: mac config changed 0x00000040

>>>>> [  177.492409] wcn36xx: wcn36xx_config channel switch=40

>>>>> [  177.492413] wcn36xx: hal finish scan mode 2

>>>>>

>>>>> Basically it takes 15 seconds to complete.

>>>>>

>>>>> Interleaved scan seems very slow and is IMO unusable on Android

>>>>

>>>>

>>>> The software scan is driven by mac80211 which interleaves channels

>>>> scanning

>>>> with the regular data operations. In worst case, it scans during 111ms

>>>> on the

>>>> channel and switches back to the operating channel for 200ms.

>>>> So, with 35 channels to scan that would take about 11 seconds to

>>>> complete...

>>>> So yes, it's quite slow...

>>>

>>> Yes looks a scheduling thing in mac80211.

>>>

>>>> However, one remaining

>>>> thing to try would be to send an update-channel-list command to the

>>>> firmware before each offload scan (cf UPDATE_CHANNEL_LIST_REQ

>>>> in the downstream driver). That's not something I've tried yet.

>>>

>>> I've tried

>>>

>>> 1. Setting the operating frequency to a 5ghz band before the scan

>>> 2. Updating the channel list with 2g/5g channels via

>>> UPDATE_CHANNEL_LIST_REQ

>>> 3. Updating the channel list with 5g only with UPDATE_CHANNEL_LIST_REQ

>>> 4. Doing 5g channels only in the channel list of

>>> WCN36XX_HAL_START_SCAN_OFFLOAD_REQ

>>>

>>> I don't think the channel list matters, if I recall rightly I've also

>>> tried leaving out the channel list in WCN36XX_HAL_START_SCAN_OFFLOAD_REQ

>>> and get back the same set of channels in the result

>>>

>>> I guess we should take this patch anyway, since it makes wcn36xx and

>>> mac80211 agree on ownership of the antenna...

>>>

>>> ---

>>> bod

>>

>> Ah.

>>

>> If we implement ops->flush() we can slash that idle time down significantly

>>

>> static void ieee80211_scan_state_resume(struct ieee80211_local *local,

>>                                           unsigned long *next_delay)

>> {

>>

>>           if (local->ops->flush) {

>>                   ieee80211_flush_queues(local, NULL, false);

>>                   *next_delay = 0;

>>           } else

>>                   *next_delay = HZ / 10;

>> }

>>

>> Trivial hack example:

>>

>> +void wcn36xx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,

>> +                  u32 queues, bool drop)

>> +{

>> +}

>> +

>>    static const struct ieee80211_ops wcn36xx_ops = {

>>           .start                  = wcn36xx_start,

>>           .stop                   = wcn36xx_stop,

>> @@ -1187,7 +1192,7 @@ static const struct ieee80211_ops wcn36xx_ops = {

>>           .sta_add                = wcn36xx_sta_add,

>>           .sta_remove             = wcn36xx_sta_remove,

>>           .ampdu_action           = wcn36xx_ampdu_action,

>> -

>> +       .flush                  = wcn36xx_flush,

>>           CFG80211_TESTMODE_CMD(wcn36xx_tm_cmd)

>>    };

> 

> Interestingly, we could indeed get rid of this extra 100ms.

> Maybe a way to implement this would be to wait for the TX

> ring to be empty in dxe.

> 

>> That ~ 20 seconds is cut to just 4 ! Which to be fair seems to be the

>> kind of time it took to do the old version of the software scan.

> 

> Sure but In the below case, it seems scan occurs while you're not

> connected to an AP, which prevents interleaving of operating channel.

> The same scan while connected should be longer.


You're right, don't get excited about a fix you 'find' at 1 am.

Still having a hard time getting this one running on Android, even 
dropping the scan interval to 60 seconds.

ops->flush() helps a bit but not enough

In terms of keeping the antenna busy during the current scan - is that a 
problem if we skip over the active channel when connected to an AP ?

__ieee80211_scan_completed() seems to re-schedule work which was delayed 
while hardware scan was ongoing, so, the TX path should be OK with the 
current scan.

The issue then I guess is on the RX path. During a scan we could tune to 
the current operational channel, the AP could send data but, we would 
drop it, because we are scanning.

One solution might be, if we were to skip scanning the operational 
channel when connected to an STA, then this problem would not happen.

Because the only time we would be tuned to the operational channel would 
be when we are also in a state to receive any data the AP might send.

We should still get a notification from the firmware on 
disconnect/dis-assocation.


_______________________________________________
wcn36xx mailing list
wcn36xx@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/wcn36xx
Bryan O'Donoghue Aug. 20, 2020, 12:17 p.m. UTC | #9
On 20/08/2020 13:14, Bryan O'Donoghue wrote:
> On 20/08/2020 12:27, Loic Poulain wrote:

>> HI Bryan,

>>

>> On Thu, 20 Aug 2020 at 01:54, Bryan O'Donoghue

>> <bryan.odonoghue@linaro.org> wrote:

>>>

>>> On 19/08/2020 11:52, Bryan O'Donoghue wrote:

>>>> On 19/08/2020 09:15, Loic Poulain wrote:

>>>>> Hi Bryan,

>>>>>

>>>>> On Tue, 18 Aug 2020 at 20:00, Bryan O'Donoghue

>>>>> <pure.logic@nexus-software.ie> wrote:

>>>>>>

>>>>>> On 18/08/2020 14:34, Loic Poulain wrote:

>>>>>>> On Tue, 18 Aug 2020 at 08:15, Kalle Valo <kvalo@codeaurora.org> 

>>>>>>> wrote:

>>>>>>>>

>>>>>>>> Loic Poulain <loic.poulain@linaro.org> writes:

>>>>>>>>

>>>>>>>>> For software-driven scan, rely on mac80211 software scan instead

>>>>>>>>> of internal driver implementation. The internal implementation

>>>>>>>>> cause connection trouble since it keep the antenna busy during

>>>>>>>>> the entire scan duration, moreover it's only a passive scanning

>>>>>>>>> (no probe request). Therefore, let mac80211 manages sw scan.

>>>>>>>>>

>>>>>>>>> Note: we fallback to software scan if firmware does not report

>>>>>>>>> scan offload support or if we need to scan the 5Ghz band 

>>>>>>>>> (currently

>>>>>>>>> not supported by the offload scan...).

>>>>>>>>>

>>>>>>>>> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

>>>>>>>>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

>>>>>>>>

>>>>>>>> What changed since v2? Please always include a changelog so that I

>>>>>>>> don't

>>>>>>>> need to guess what you have changed in the patch. No need to 

>>>>>>>> resend, a

>>>>>>>> reply is enough.

>>>>>>>

>>>>>>> Yes sorry, this patch has been rebased on ath master and squashed 

>>>>>>> with

>>>>>>> Bryan's fix:

>>>>>>>         wcn36xx: Set sw-scan chan to 0 when not associated

>>>>>>> No additional changes have been made on top of the initial patches.

>>>>>>>

>>>>>>> Regards,

>>>>>>> Loic

>>>>>>>

>>>>>>

>>>>>> This is excruciatingly slow on Android.

>>>>>>

>>>>>> Android I'm finding unlike Debian where this stuff was tested, 

>>>>>> merrily

>>>>>> issues scan requests every 30 seconds.

>>>>>>

>>>>>> For me this ends up looking like this

>>>>>>

>>>>>> [  162.296995] wcn36xx: mac config changed 0x00000040

>>>>>> [  162.297001] wcn36xx: wcn36xx_config channel switch=1

>>>>>> [  162.297005] wcn36xx: hal init scan mode 2

>>>>>> [  177.492402] wcn36xx: mac config changed 0x00000040

>>>>>> [  177.492409] wcn36xx: wcn36xx_config channel switch=40

>>>>>> [  177.492413] wcn36xx: hal finish scan mode 2

>>>>>>

>>>>>> Basically it takes 15 seconds to complete.

>>>>>>

>>>>>> Interleaved scan seems very slow and is IMO unusable on Android

>>>>>

>>>>>

>>>>> The software scan is driven by mac80211 which interleaves channels

>>>>> scanning

>>>>> with the regular data operations. In worst case, it scans during 111ms

>>>>> on the

>>>>> channel and switches back to the operating channel for 200ms.

>>>>> So, with 35 channels to scan that would take about 11 seconds to

>>>>> complete...

>>>>> So yes, it's quite slow...

>>>>

>>>> Yes looks a scheduling thing in mac80211.

>>>>

>>>>> However, one remaining

>>>>> thing to try would be to send an update-channel-list command to the

>>>>> firmware before each offload scan (cf UPDATE_CHANNEL_LIST_REQ

>>>>> in the downstream driver). That's not something I've tried yet.

>>>>

>>>> I've tried

>>>>

>>>> 1. Setting the operating frequency to a 5ghz band before the scan

>>>> 2. Updating the channel list with 2g/5g channels via

>>>> UPDATE_CHANNEL_LIST_REQ

>>>> 3. Updating the channel list with 5g only with UPDATE_CHANNEL_LIST_REQ

>>>> 4. Doing 5g channels only in the channel list of

>>>> WCN36XX_HAL_START_SCAN_OFFLOAD_REQ

>>>>

>>>> I don't think the channel list matters, if I recall rightly I've also

>>>> tried leaving out the channel list in 

>>>> WCN36XX_HAL_START_SCAN_OFFLOAD_REQ

>>>> and get back the same set of channels in the result

>>>>

>>>> I guess we should take this patch anyway, since it makes wcn36xx and

>>>> mac80211 agree on ownership of the antenna...

>>>>

>>>> ---

>>>> bod

>>>

>>> Ah.

>>>

>>> If we implement ops->flush() we can slash that idle time down 

>>> significantly

>>>

>>> static void ieee80211_scan_state_resume(struct ieee80211_local *local,

>>>                                           unsigned long *next_delay)

>>> {

>>>

>>>           if (local->ops->flush) {

>>>                   ieee80211_flush_queues(local, NULL, false);

>>>                   *next_delay = 0;

>>>           } else

>>>                   *next_delay = HZ / 10;

>>> }

>>>

>>> Trivial hack example:

>>>

>>> +void wcn36xx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,

>>> +                  u32 queues, bool drop)

>>> +{

>>> +}

>>> +

>>>    static const struct ieee80211_ops wcn36xx_ops = {

>>>           .start                  = wcn36xx_start,

>>>           .stop                   = wcn36xx_stop,

>>> @@ -1187,7 +1192,7 @@ static const struct ieee80211_ops wcn36xx_ops = {

>>>           .sta_add                = wcn36xx_sta_add,

>>>           .sta_remove             = wcn36xx_sta_remove,

>>>           .ampdu_action           = wcn36xx_ampdu_action,

>>> -

>>> +       .flush                  = wcn36xx_flush,

>>>           CFG80211_TESTMODE_CMD(wcn36xx_tm_cmd)

>>>    };

>>

>> Interestingly, we could indeed get rid of this extra 100ms.

>> Maybe a way to implement this would be to wait for the TX

>> ring to be empty in dxe.

>>

>>> That ~ 20 seconds is cut to just 4 ! Which to be fair seems to be the

>>> kind of time it took to do the old version of the software scan.

>>

>> Sure but In the below case, it seems scan occurs while you're not

>> connected to an AP, which prevents interleaving of operating channel.

>> The same scan while connected should be longer.

> 

> You're right, don't get excited about a fix you 'find' at 1 am.

> 

> Still having a hard time getting this one running on Android, even 

> dropping the scan interval to 60 seconds.

> 

> ops->flush() helps a bit but not enough

> 

> In terms of keeping the antenna busy during the current scan - is that a 

> problem if we skip over the active channel when connected to an AP ?

> 

> __ieee80211_scan_completed() seems to re-schedule work which was delayed 

> while hardware scan was ongoing, so, the TX path should be OK with the 

> current scan.

> 

> The issue then I guess is on the RX path. During a scan we could tune to 

> the current operational channel, the AP could send data but, we would 

> drop it, because we are scanning.

> 

> One solution might be, if we were to skip scanning the operational 

> channel when connected to an STA, then this problem would not happen.

> 

> Because the only time we would be tuned to the operational channel would 

> be when we are also in a state to receive any data the AP might send.

> 

> We should still get a notification from the firmware on 

> disconnect/dis-assocation.

> 


Something like this
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index 8d44e39052ec..8d8dc6fc10e8 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -28,7 +28,7 @@
 #include "wcn36xx.h"
 #include "testmode.h"
 
-unsigned int wcn36xx_dbg_mask;
+unsigned int wcn36xx_dbg_mask = WCN36XX_DBG_MAC | WCN36XX_DBG_HAL | WCN36XX_DBG_SMD;
 module_param_named(debug_mask, wcn36xx_dbg_mask, uint, 0644);
 MODULE_PARM_DESC(debug_mask, "Debugging mask");
 
@@ -621,6 +621,7 @@ static void wcn36xx_hw_scan_worker(struct work_struct *work)
 	u8 channels[WCN36XX_HAL_PNO_MAX_NETW_CHANNELS_EX];
 	struct cfg80211_scan_info scan_info = {};
 	bool aborted = false;
+	int ch;
 	int i;
 
 	wcn36xx_dbg(WCN36XX_DBG_MAC, "mac80211 scan %d channels worker\n", req->n_channels);
@@ -628,6 +629,8 @@ static void wcn36xx_hw_scan_worker(struct work_struct *work)
 	for (i = 0; i < req->n_channels; i++)
 		channels[i] = req->channels[i]->hw_value;
 
+	mutex_lock(&wcn->conf_mutex);
+	ch = WCN36XX_HW_CHANNEL(wcn);
 	wcn36xx_smd_update_scan_params(wcn, channels, req->n_channels);
 
 	wcn36xx_smd_init_scan(wcn, HAL_SYS_MODE_SCAN);
@@ -639,6 +642,11 @@ static void wcn36xx_hw_scan_worker(struct work_struct *work)
 		if (aborted)
 			break;
 
+		if (ch == req->channels[i]->hw_value) {
+			wcn36xx_dbg(WCN36XX_DBG_MAC, "Skipping scan on active channel %d\n", ch);
+			continue;
+		}
+
 		wcn->scan_freq = req->channels[i]->center_freq;
 		wcn->scan_band = req->channels[i]->band;
 
@@ -649,6 +657,7 @@ static void wcn36xx_hw_scan_worker(struct work_struct *work)
 		wcn->scan_freq = 0;
 	}
 	wcn36xx_smd_finish_scan(wcn, HAL_SYS_MODE_SCAN);
+	mutex_unlock(&wcn->conf_mutex);
 
 	scan_info.aborted = aborted;
 	ieee80211_scan_completed(wcn->hw, &scan_info);
_______________________________________________
wcn36xx mailing list
wcn36xx@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/wcn36xx
Bryan O'Donoghue Aug. 24, 2020, 1:46 a.m. UTC | #10
On 17/08/2020 17:01, Loic Poulain wrote:
> For software-driven scan, rely on mac80211 software scan instead

> of internal driver implementation. The internal implementation

> cause connection trouble since it keep the antenna busy during

> the entire scan duration, moreover it's only a passive scanning

> (no probe request). Therefore, let mac80211 manages sw scan.

> 

> Note: we fallback to software scan if firmware does not report

> scan offload support or if we need to scan the 5Ghz band (currently

> not supported by the offload scan...).

> 

> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>


OK.

TL;DR included diff fixes the performance issue.

I've poked about with the old scan, and this new scan and I've managed 
to find to find where the new scan is killing performance.

Please see below.

@@ -792,6 +792,7 @@ int wcn36xx_smd_finish_scan(struct wcn36xx *wcn,
  {
         struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
         struct wcn36xx_hal_finish_scan_req_msg msg_body;
+       u8 oper_channel;
         int ret;

         mutex_lock(&wcn->hal_mutex);
@@ -802,7 +803,9 @@ int wcn36xx_smd_finish_scan(struct wcn36xx *wcn,
                 /* Notify BSSID with null data packet */
                 msg_body.notify = 1;
                 msg_body.frame_type = 2;
-               msg_body.oper_channel = channel;
+               oper_channel = WCN36XX_HW_CHANNEL(wcn);
+               if (oper_channel != channel)
+                       msg_body.oper_channel = channel;
                 msg_body.scan_entry.bss_index[0] = vif_priv->bss_index;
                 msg_body.scan_entry.active_bss_count = 1;
         }

Happily, I'm finding with this modification on top of your patch

1. Running a continuous Android scan
    As in when you have the network scan window open
    A simultaneous "iperf -c xxx.xxx.xxx.xxx -i 1 -t 1800"
2. Performance is as expected
    I see throughput oscillate between 30 mbit and 100 mbit
    - Android runs a scan every 15 seconds
    - Software scan takes 11 seconds to complete
    - So this is expected behavior
3. During quiescent periods we have the expected throughput
4. We gain from the additional stability the rest of your patch provides

Specifically on #4 what I find with the old scan is that with some APs 
we can get a disassocation after a scan completes.

My test-case AP for that behavior is a Ubiquiti Nano HD on a 5ghz frequency.

Its funny that rewriting the operating channel in the finish_scan path 
should make a difference.

All I can guess at here is that the PHY mode doesn't get updated correctly

Loic, can you make sure you are happy with the change and V2 this patch?

You can retain my SoB.

---
bod
Loic Poulain Aug. 24, 2020, 7:51 a.m. UTC | #11
Hi Bryan,

On Mon, 24 Aug 2020 at 03:45, Bryan O'Donoghue
<bryan.odonoghue@linaro.org> wrote:
>

> On 17/08/2020 17:01, Loic Poulain wrote:

> > For software-driven scan, rely on mac80211 software scan instead

> > of internal driver implementation. The internal implementation

> > cause connection trouble since it keep the antenna busy during

> > the entire scan duration, moreover it's only a passive scanning

> > (no probe request). Therefore, let mac80211 manages sw scan.

> >

> > Note: we fallback to software scan if firmware does not report

> > scan offload support or if we need to scan the 5Ghz band (currently

> > not supported by the offload scan...).

> >

> > Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

> > Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

>

> OK.

>

> TL;DR included diff fixes the performance issue.

>

> I've poked about with the old scan, and this new scan and I've managed

> to find to find where the new scan is killing performance.

>

> Please see below.

>

> @@ -792,6 +792,7 @@ int wcn36xx_smd_finish_scan(struct wcn36xx *wcn,

>   {

>          struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);

>          struct wcn36xx_hal_finish_scan_req_msg msg_body;

> +       u8 oper_channel;

>          int ret;

>

>          mutex_lock(&wcn->hal_mutex);

> @@ -802,7 +803,9 @@ int wcn36xx_smd_finish_scan(struct wcn36xx *wcn,

>                  /* Notify BSSID with null data packet */

>                  msg_body.notify = 1;

>                  msg_body.frame_type = 2;

> -               msg_body.oper_channel = channel;

> +               oper_channel = WCN36XX_HW_CHANNEL(wcn);

> +               if (oper_channel != channel)

> +                       msg_body.oper_channel = channel;


Is this condition ever satisfied? I mean, finish_scan is normally always
called with operating-channel as channel parameter.

>                  msg_body.scan_entry.bss_index[0] = vif_priv->bss_index;

>                  msg_body.scan_entry.active_bss_count = 1;

>          }

>

> Happily, I'm finding with this modification on top of your patch

>

> 1. Running a continuous Android scan

>     As in when you have the network scan window open

>     A simultaneous "iperf -c xxx.xxx.xxx.xxx -i 1 -t 1800"

> 2. Performance is as expected

>     I see throughput oscillate between 30 mbit and 100 mbit

>     - Android runs a scan every 15 seconds


With scanning app in the foreground, right?
While connected to an AP, Android 'should' only background scan if
RSSI becomes too low (for roaming).

>     - Software scan takes 11 seconds to complete

>     - So this is expected behavior

> 3. During quiescent periods we have the expected throughput

> 4. We gain from the additional stability the rest of your patch provides

>

> Specifically on #4 what I find with the old scan is that with some APs

> we can get a disassocation after a scan completes.

>

> My test-case AP for that behavior is a Ubiquiti Nano HD on a 5ghz frequency.

>

> Its funny that rewriting the operating channel in the finish_scan path

> should make a difference.

>

> All I can guess at here is that the PHY mode doesn't get updated correctly

>

> Loic, can you make sure you are happy with the change and V2 this patch?

>

> You can retain my SoB.

>

> ---

> bod
Bryan O'Donoghue Aug. 24, 2020, 9:57 a.m. UTC | #12
On 24/08/2020 08:51, Loic Poulain wrote:
> Hi Bryan,

> 

> On Mon, 24 Aug 2020 at 03:45, Bryan O'Donoghue

> <bryan.odonoghue@linaro.org> wrote:

>>

>> On 17/08/2020 17:01, Loic Poulain wrote:

>>> For software-driven scan, rely on mac80211 software scan instead

>>> of internal driver implementation. The internal implementation

>>> cause connection trouble since it keep the antenna busy during

>>> the entire scan duration, moreover it's only a passive scanning

>>> (no probe request). Therefore, let mac80211 manages sw scan.

>>>

>>> Note: we fallback to software scan if firmware does not report

>>> scan offload support or if we need to scan the 5Ghz band (currently

>>> not supported by the offload scan...).

>>>

>>> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

>>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

>>

>> OK.

>>

>> TL;DR included diff fixes the performance issue.

>>

>> I've poked about with the old scan, and this new scan and I've managed

>> to find to find where the new scan is killing performance.

>>

>> Please see below.

>>

>> @@ -792,6 +792,7 @@ int wcn36xx_smd_finish_scan(struct wcn36xx *wcn,

>>    {

>>           struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);

>>           struct wcn36xx_hal_finish_scan_req_msg msg_body;

>> +       u8 oper_channel;

>>           int ret;

>>

>>           mutex_lock(&wcn->hal_mutex);

>> @@ -802,7 +803,9 @@ int wcn36xx_smd_finish_scan(struct wcn36xx *wcn,

>>                   /* Notify BSSID with null data packet */

>>                   msg_body.notify = 1;

>>                   msg_body.frame_type = 2;

>> -               msg_body.oper_channel = channel;

>> +               oper_channel = WCN36XX_HW_CHANNEL(wcn);

>> +               if (oper_channel != channel)

>> +                       msg_body.oper_channel = channel;

> 

> Is this condition ever satisfied? I mean, finish_scan is normally always

> called with operating-channel as channel parameter.


I had a debug statement and never saw it run, so I think no is probably 
the answer to that.

Basically though the msg_body.oper_channel needs to be left at zero. 
Whatever the firmware does with non-zero is not correct @ 80Mhz/5ghz


>> 2. Performance is as expected

>>      I see throughput oscillate between 30 mbit and 100 mbit

>>      - Android runs a scan every 15 seconds

> 

> With scanning app in the foreground, right?

> While connected to an AP, Android 'should' only background scan if

> RSSI becomes too low (for roaming).


Foreground scanning yes, I'm forcing a constant interleaving.
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index 868de9d..f389cd4 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -354,8 +354,6 @@  static void wcn36xx_stop(struct ieee80211_hw *hw)
 
 	wcn36xx_dbg(WCN36XX_DBG_MAC, "mac stop\n");
 
-	cancel_work_sync(&wcn->scan_work);
-
 	mutex_lock(&wcn->scan_lock);
 	if (wcn->scan_req) {
 		struct cfg80211_scan_info scan_info = {
@@ -378,12 +376,37 @@  static void wcn36xx_stop(struct ieee80211_hw *hw)
 	kfree(wcn->hal_buf);
 }
 
-static int wcn36xx_config(struct ieee80211_hw *hw, u32 changed)
+static void wcn36xx_change_ps(struct wcn36xx *wcn, bool enable)
+{
+	struct ieee80211_vif *vif = NULL;
+	struct wcn36xx_vif *tmp;
+
+	list_for_each_entry(tmp, &wcn->vif_list, list) {
+		vif = wcn36xx_priv_to_vif(tmp);
+		if (enable && !wcn->sw_scan) {
+			if (vif->bss_conf.ps) /* ps allowed ? */
+				wcn36xx_pmc_enter_bmps_state(wcn, vif);
+		} else {
+			wcn36xx_pmc_exit_bmps_state(wcn, vif);
+		}
+	}
+}
+
+static void wcn36xx_change_opchannel(struct wcn36xx *wcn, int ch)
 {
-	struct wcn36xx *wcn = hw->priv;
 	struct ieee80211_vif *vif = NULL;
 	struct wcn36xx_vif *tmp;
 
+	list_for_each_entry(tmp, &wcn->vif_list, list) {
+		vif = wcn36xx_priv_to_vif(tmp);
+		wcn36xx_smd_switch_channel(wcn, vif, ch);
+	}
+}
+
+static int wcn36xx_config(struct ieee80211_hw *hw, u32 changed)
+{
+	struct wcn36xx *wcn = hw->priv;
+
 	wcn36xx_dbg(WCN36XX_DBG_MAC, "mac config changed 0x%08x\n", changed);
 
 	mutex_lock(&wcn->conf_mutex);
@@ -392,24 +415,29 @@  static int wcn36xx_config(struct ieee80211_hw *hw, u32 changed)
 		int ch = WCN36XX_HW_CHANNEL(wcn);
 		wcn36xx_dbg(WCN36XX_DBG_MAC, "wcn36xx_config channel switch=%d\n",
 			    ch);
-		list_for_each_entry(tmp, &wcn->vif_list, list) {
-			vif = wcn36xx_priv_to_vif(tmp);
-			wcn36xx_smd_switch_channel(wcn, vif, ch);
-		}
-	}
 
-	if (changed & IEEE80211_CONF_CHANGE_PS) {
-		list_for_each_entry(tmp, &wcn->vif_list, list) {
-			vif = wcn36xx_priv_to_vif(tmp);
-			if (hw->conf.flags & IEEE80211_CONF_PS) {
-				if (vif->bss_conf.ps) /* ps allowed ? */
-					wcn36xx_pmc_enter_bmps_state(wcn, vif);
-			} else {
-				wcn36xx_pmc_exit_bmps_state(wcn, vif);
-			}
+		if (wcn->sw_scan_opchannel == ch) {
+			/* If channel is the initial operating channel, we may
+			 * want to receive/transmit regular data packets, then
+			 * simply stop the scan session and exit PS mode.
+			 */
+			wcn36xx_smd_finish_scan(wcn, HAL_SYS_MODE_SCAN,
+						wcn->sw_scan_vif, ch);
+		} else if (wcn->sw_scan) {
+			/* A scan is ongoing, do not change the operating
+			 * channel, but start a scan session on the channel.
+			 */
+			wcn36xx_smd_init_scan(wcn, HAL_SYS_MODE_SCAN,
+					      wcn->sw_scan_vif);
+			wcn36xx_smd_start_scan(wcn, ch);
+		} else {
+			wcn36xx_change_opchannel(wcn, ch);
 		}
 	}
 
+	if (changed & IEEE80211_CONF_CHANGE_PS)
+		wcn36xx_change_ps(wcn, hw->conf.flags & IEEE80211_CONF_PS);
+
 	mutex_unlock(&wcn->conf_mutex);
 
 	return 0;
@@ -614,55 +642,26 @@  static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 	return ret;
 }
 
-static void wcn36xx_hw_scan_worker(struct work_struct *work)
+static int wcn36xx_hw_scan(struct ieee80211_hw *hw,
+			   struct ieee80211_vif *vif,
+			   struct ieee80211_scan_request *hw_req)
 {
-	struct wcn36xx *wcn = container_of(work, struct wcn36xx, scan_work);
-	struct cfg80211_scan_request *req = wcn->scan_req;
-	u8 channels[WCN36XX_HAL_PNO_MAX_NETW_CHANNELS_EX];
-	struct cfg80211_scan_info scan_info = {};
-	bool aborted = false;
+	struct wcn36xx *wcn = hw->priv;
 	int i;
 
-	wcn36xx_dbg(WCN36XX_DBG_MAC, "mac80211 scan %d channels worker\n", req->n_channels);
-
-	for (i = 0; i < req->n_channels; i++)
-		channels[i] = req->channels[i]->hw_value;
-
-	wcn36xx_smd_update_scan_params(wcn, channels, req->n_channels);
-
-	wcn36xx_smd_init_scan(wcn, HAL_SYS_MODE_SCAN);
-	for (i = 0; i < req->n_channels; i++) {
-		mutex_lock(&wcn->scan_lock);
-		aborted = wcn->scan_aborted;
-		mutex_unlock(&wcn->scan_lock);
-
-		if (aborted)
-			break;
-
-		wcn->scan_freq = req->channels[i]->center_freq;
-		wcn->scan_band = req->channels[i]->band;
-
-		wcn36xx_smd_start_scan(wcn, req->channels[i]->hw_value);
-		msleep(30);
-		wcn36xx_smd_end_scan(wcn, req->channels[i]->hw_value);
-
-		wcn->scan_freq = 0;
+	if (!get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
+		/* fallback to mac80211 software scan */
+		return 1;
 	}
-	wcn36xx_smd_finish_scan(wcn, HAL_SYS_MODE_SCAN);
-
-	scan_info.aborted = aborted;
-	ieee80211_scan_completed(wcn->hw, &scan_info);
 
-	mutex_lock(&wcn->scan_lock);
-	wcn->scan_req = NULL;
-	mutex_unlock(&wcn->scan_lock);
-}
+	/* For unknown reason, the hardware offloaded scan only works with
+	 * 2.4Ghz channels, fallback to software scan in other cases.
+	 */
+	for (i = 0; i < hw_req->req.n_channels; i++) {
+		if (hw_req->req.channels[i]->band != NL80211_BAND_2GHZ)
+			return 1;
+	}
 
-static int wcn36xx_hw_scan(struct ieee80211_hw *hw,
-			   struct ieee80211_vif *vif,
-			   struct ieee80211_scan_request *hw_req)
-{
-	struct wcn36xx *wcn = hw->priv;
 	mutex_lock(&wcn->scan_lock);
 	if (wcn->scan_req) {
 		mutex_unlock(&wcn->scan_lock);
@@ -674,12 +673,6 @@  static int wcn36xx_hw_scan(struct ieee80211_hw *hw,
 
 	mutex_unlock(&wcn->scan_lock);
 
-	if (!get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
-		/* legacy manual/sw scan */
-		schedule_work(&wcn->scan_work);
-		return 0;
-	}
-
 	return wcn36xx_smd_start_hw_scan(wcn, vif, &hw_req->req);
 }
 
@@ -696,16 +689,36 @@  static void wcn36xx_cancel_hw_scan(struct ieee80211_hw *hw,
 		/* ieee80211_scan_completed will be called on FW scan
 		 * indication */
 		wcn36xx_smd_stop_hw_scan(wcn);
-	} else {
-		struct cfg80211_scan_info scan_info = {
-			.aborted = true,
-		};
-
-		cancel_work_sync(&wcn->scan_work);
-		ieee80211_scan_completed(wcn->hw, &scan_info);
 	}
 }
 
+static void wcn36xx_sw_scan_start(struct ieee80211_hw *hw,
+				  struct ieee80211_vif *vif,
+				  const u8 *mac_addr)
+{
+	struct wcn36xx *wcn = hw->priv;
+	struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
+
+	wcn->sw_scan = true;
+	wcn->sw_scan_vif = vif;
+	if (vif_priv->sta_assoc)
+		wcn->sw_scan_opchannel = WCN36XX_HW_CHANNEL(wcn);
+	else
+		wcn->sw_scan_opchannel = 0;
+}
+
+static void wcn36xx_sw_scan_complete(struct ieee80211_hw *hw,
+				     struct ieee80211_vif *vif)
+{
+	struct wcn36xx *wcn = hw->priv;
+
+	/* ensure that any scan session is finished */
+	wcn36xx_smd_finish_scan(wcn, HAL_SYS_MODE_SCAN, wcn->sw_scan_vif,
+				wcn->sw_scan_opchannel);
+	wcn->sw_scan = false;
+	wcn->sw_scan_opchannel = 0;
+}
+
 static void wcn36xx_update_allowed_rates(struct ieee80211_sta *sta,
 					 enum nl80211_band band)
 {
@@ -1151,6 +1164,8 @@  static const struct ieee80211_ops wcn36xx_ops = {
 	.set_key		= wcn36xx_set_key,
 	.hw_scan		= wcn36xx_hw_scan,
 	.cancel_hw_scan		= wcn36xx_cancel_hw_scan,
+	.sw_scan_start		= wcn36xx_sw_scan_start,
+	.sw_scan_complete	= wcn36xx_sw_scan_complete,
 	.bss_info_changed	= wcn36xx_bss_info_changed,
 	.set_rts_threshold	= wcn36xx_set_rts_threshold,
 	.sta_add		= wcn36xx_sta_add,
@@ -1329,8 +1344,6 @@  static int wcn36xx_probe(struct platform_device *pdev)
 		goto out_wq;
 	}
 
-	INIT_WORK(&wcn->scan_work, wcn36xx_hw_scan_worker);
-
 	wcn->smd_channel = qcom_wcnss_open_channel(wcnss, "WLAN_CTRL", wcn36xx_smd_rsp_process, hw);
 	if (IS_ERR(wcn->smd_channel)) {
 		wcn36xx_err("failed to open WLAN_CTRL channel\n");
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
index 908cc6c..218f702 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -517,8 +517,10 @@  int wcn36xx_smd_stop(struct wcn36xx *wcn)
 	return ret;
 }
 
-int wcn36xx_smd_init_scan(struct wcn36xx *wcn, enum wcn36xx_hal_sys_mode mode)
+int wcn36xx_smd_init_scan(struct wcn36xx *wcn, enum wcn36xx_hal_sys_mode mode,
+			  struct ieee80211_vif *vif)
 {
+	struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
 	struct wcn36xx_hal_init_scan_req_msg msg_body;
 	int ret;
 
@@ -526,6 +528,13 @@  int wcn36xx_smd_init_scan(struct wcn36xx *wcn, enum wcn36xx_hal_sys_mode mode)
 	INIT_HAL_MSG(msg_body, WCN36XX_HAL_INIT_SCAN_REQ);
 
 	msg_body.mode = mode;
+	if (vif_priv->bss_index != WCN36XX_HAL_BSS_INVALID_IDX) {
+		/* Notify BSSID with null DATA packet */
+		msg_body.frame_type = 2;
+		msg_body.notify = 1;
+		msg_body.scan_entry.bss_index[0] = vif_priv->bss_index;
+		msg_body.scan_entry.active_bss_count = 1;
+	}
 
 	PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
 
@@ -607,8 +616,10 @@  int wcn36xx_smd_end_scan(struct wcn36xx *wcn, u8 scan_channel)
 }
 
 int wcn36xx_smd_finish_scan(struct wcn36xx *wcn,
-			    enum wcn36xx_hal_sys_mode mode)
+			    enum wcn36xx_hal_sys_mode mode,
+			    struct ieee80211_vif *vif, u8 channel)
 {
+	struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
 	struct wcn36xx_hal_finish_scan_req_msg msg_body;
 	int ret;
 
@@ -616,6 +627,14 @@  int wcn36xx_smd_finish_scan(struct wcn36xx *wcn,
 	INIT_HAL_MSG(msg_body, WCN36XX_HAL_FINISH_SCAN_REQ);
 
 	msg_body.mode = mode;
+	if (vif_priv->bss_index != WCN36XX_HAL_BSS_INVALID_IDX) {
+		/* Notify BSSID with null data packet */
+		msg_body.notify = 1;
+		msg_body.frame_type = 2;
+		msg_body.oper_channel = channel;
+		msg_body.scan_entry.bss_index[0] = vif_priv->bss_index;
+		msg_body.scan_entry.active_bss_count = 1;
+	}
 
 	PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
 
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.h b/drivers/net/wireless/ath/wcn36xx/smd.h
index 68c59df..ffe8b0c 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.h
+++ b/drivers/net/wireless/ath/wcn36xx/smd.h
@@ -59,11 +59,13 @@  void wcn36xx_smd_close(struct wcn36xx *wcn);
 int wcn36xx_smd_load_nv(struct wcn36xx *wcn);
 int wcn36xx_smd_start(struct wcn36xx *wcn);
 int wcn36xx_smd_stop(struct wcn36xx *wcn);
-int wcn36xx_smd_init_scan(struct wcn36xx *wcn, enum wcn36xx_hal_sys_mode mode);
 int wcn36xx_smd_start_scan(struct wcn36xx *wcn, u8 scan_channel);
 int wcn36xx_smd_end_scan(struct wcn36xx *wcn, u8 scan_channel);
-int wcn36xx_smd_finish_scan(struct wcn36xx *wcn,
-			    enum wcn36xx_hal_sys_mode mode);
+int wcn36xx_smd_finish_scan(struct wcn36xx *wcn, enum wcn36xx_hal_sys_mode mode,
+			    struct ieee80211_vif *vif, u8 channel);
+int wcn36xx_smd_init_scan(struct wcn36xx *wcn, enum wcn36xx_hal_sys_mode mode,
+			  struct ieee80211_vif *vif);
+
 int wcn36xx_smd_update_scan_params(struct wcn36xx *wcn, u8 *channels, size_t channel_count);
 int wcn36xx_smd_start_hw_scan(struct wcn36xx *wcn, struct ieee80211_vif *vif,
 			      struct cfg80211_scan_request *req);
diff --git a/drivers/net/wireless/ath/wcn36xx/txrx.c b/drivers/net/wireless/ath/wcn36xx/txrx.c
index f5872e7..8205056 100644
--- a/drivers/net/wireless/ath/wcn36xx/txrx.c
+++ b/drivers/net/wireless/ath/wcn36xx/txrx.c
@@ -144,15 +144,8 @@  int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb)
 	fc = __le16_to_cpu(hdr->frame_control);
 	sn = IEEE80211_SEQ_TO_SN(__le16_to_cpu(hdr->seq_ctrl));
 
-	/* When scanning associate beacons to this */
-	if (ieee80211_is_beacon(hdr->frame_control) && wcn->scan_freq) {
-		status.freq = wcn->scan_freq;
-		status.band = wcn->scan_band;
-	} else {
-		status.freq = WCN36XX_CENTER_FREQ(wcn);
-		status.band = WCN36XX_BAND(wcn);
-	}
-
+	status.freq = WCN36XX_CENTER_FREQ(wcn);
+	status.band = WCN36XX_BAND(wcn);
 	status.mactime = 10;
 	status.signal = -get_rssi0(bd);
 	status.antenna = 1;
diff --git a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
index 2d89849..3221fed 100644
--- a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
+++ b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
@@ -223,10 +223,10 @@  struct wcn36xx {
 	spinlock_t		hal_ind_lock;
 	struct list_head	hal_ind_queue;
 
-	struct work_struct	scan_work;
 	struct cfg80211_scan_request *scan_req;
-	int			scan_freq;
-	int			scan_band;
+	bool			sw_scan;
+	u8			sw_scan_opchannel;
+	struct ieee80211_vif	*sw_scan_vif;
 	struct mutex		scan_lock;
 	bool			scan_aborted;