mac80211: brcmfmac: backport wowlan netdetect fixes
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 357-0009-brcmfmac-use-provided-channels-for-scheduled-scan.patch
1 From 331e789443618ca9cc3ed48ada4e670225cca036 Mon Sep 17 00:00:00 2001
2 From: Arend Van Spriel <arend.vanspriel@broadcom.com>
3 Date: Wed, 23 Nov 2016 10:25:28 +0000
4 Subject: [PATCH] brcmfmac: use provided channels for scheduled scan
5
6 User-space can provide list of channels in the schedule scan request.
7 This was ignored so all channels supported and allowed by the device
8 were used. This patch configures the device to use the channels as
9 listed in the request.
10
11 Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
12 Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
13 Reviewed-by: Franky Lin <franky.lin@broadcom.com>
14 Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
15 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
16 ---
17 .../broadcom/brcm80211/brcmfmac/fwil_types.h | 16 +++++++++++++
18 .../net/wireless/broadcom/brcm80211/brcmfmac/pno.c | 26 +++++++++++++++++++++-
19 2 files changed, 41 insertions(+), 1 deletion(-)
20
21 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
22 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
23 @@ -131,6 +131,7 @@
24 #define BRCMF_TXBF_MU_BFR_CAP BIT(1)
25
26 #define BRCMF_MAXPMKID 16 /* max # PMKID cache entries */
27 +#define BRCMF_NUMCHANNELS 64
28
29 #define BRCMF_PFN_MACADDR_CFG_VER 1
30 #define BRCMF_PFN_MAC_OUI_ONLY BIT(0)
31 @@ -719,6 +720,21 @@ struct brcmf_pno_param_le {
32 };
33
34 /**
35 + * struct brcmf_pno_config_le - PNO channel configuration.
36 + *
37 + * @reporttype: determines what is reported.
38 + * @channel_num: number of channels specified in @channel_list.
39 + * @channel_list: channels to use in PNO scan.
40 + * @flags: reserved.
41 + */
42 +struct brcmf_pno_config_le {
43 + __le32 reporttype;
44 + __le32 channel_num;
45 + __le16 channel_list[BRCMF_NUMCHANNELS];
46 + __le32 flags;
47 +};
48 +
49 +/**
50 * struct brcmf_pno_net_param_le - scan parameters per preferred network.
51 *
52 * @ssid: ssid name and its length.
53 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c
54 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c
55 @@ -18,9 +18,10 @@
56
57 #include "core.h"
58 #include "debug.h"
59 -#include "pno.h"
60 #include "fwil.h"
61 #include "fwil_types.h"
62 +#include "cfg80211.h"
63 +#include "pno.h"
64
65 #define BRCMF_PNO_VERSION 2
66 #define BRCMF_PNO_REPEAT 4
67 @@ -34,6 +35,15 @@
68 #define BRCMF_PNO_HIDDEN_BIT 2
69 #define BRCMF_PNO_SCHED_SCAN_PERIOD 30
70
71 +static int brcmf_pno_channel_config(struct brcmf_if *ifp,
72 + struct brcmf_pno_config_le *cfg)
73 +{
74 + cfg->reporttype = 0;
75 + cfg->flags = 0;
76 +
77 + return brcmf_fil_iovar_data_set(ifp, "pfn_cfg", cfg, sizeof(*cfg));
78 +}
79 +
80 static int brcmf_pno_config(struct brcmf_if *ifp, u32 scan_freq,
81 u32 mscan, u32 bestn)
82 {
83 @@ -167,7 +177,10 @@ int brcmf_pno_clean(struct brcmf_if *ifp
84 int brcmf_pno_start_sched_scan(struct brcmf_if *ifp,
85 struct cfg80211_sched_scan_request *req)
86 {
87 + struct brcmu_d11inf *d11inf;
88 + struct brcmf_pno_config_le pno_cfg;
89 struct cfg80211_ssid *ssid;
90 + u16 chan;
91 int i, ret;
92
93 /* clean up everything */
94 @@ -190,6 +203,17 @@ int brcmf_pno_start_sched_scan(struct br
95 return ret;
96 }
97
98 + /* configure channels to use */
99 + d11inf = &ifp->drvr->config->d11inf;
100 + for (i = 0; i < req->n_channels; i++) {
101 + chan = req->channels[i]->hw_value;
102 + pno_cfg.channel_list[i] = cpu_to_le16(chan);
103 + }
104 + if (req->n_channels) {
105 + pno_cfg.channel_num = cpu_to_le32(req->n_channels);
106 + brcmf_pno_channel_config(ifp, &pno_cfg);
107 + }
108 +
109 /* configure each match set */
110 for (i = 0; i < req->n_match_sets; i++) {
111 ssid = &req->match_sets[i].ssid;