Loading...
1/*
2 * This file is part of wl1271
3 *
4 * Copyright (C) 2009-2010 Nokia Corporation
5 *
6 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
24#ifndef __SCAN_H__
25#define __SCAN_H__
26
27#include "wlcore.h"
28
29int wlcore_scan(struct wl1271 *wl, struct ieee80211_vif *vif,
30 const u8 *ssid, size_t ssid_len,
31 struct cfg80211_scan_request *req);
32int wl1271_scan_build_probe_req(struct wl1271 *wl,
33 const u8 *ssid, size_t ssid_len,
34 const u8 *ie, size_t ie_len, u8 band);
35void wl1271_scan_stm(struct wl1271 *wl, struct wl12xx_vif *wlvif);
36void wl1271_scan_complete_work(struct work_struct *work);
37int wl1271_scan_sched_scan_config(struct wl1271 *wl,
38 struct wl12xx_vif *wlvif,
39 struct cfg80211_sched_scan_request *req,
40 struct ieee80211_scan_ies *ies);
41int wl1271_scan_sched_scan_start(struct wl1271 *wl, struct wl12xx_vif *wlvif);
42void wlcore_scan_sched_scan_results(struct wl1271 *wl);
43
44#define WL1271_SCAN_MAX_CHANNELS 24
45#define WL1271_SCAN_DEFAULT_TAG 1
46#define WL1271_SCAN_CURRENT_TX_PWR 0
47#define WL1271_SCAN_OPT_ACTIVE 0
48#define WL1271_SCAN_OPT_PASSIVE 1
49#define WL1271_SCAN_OPT_SPLIT_SCAN 2
50#define WL1271_SCAN_OPT_PRIORITY_HIGH 4
51/* scan even if we fail to enter psm */
52#define WL1271_SCAN_OPT_FORCE 8
53#define WL1271_SCAN_BAND_2_4_GHZ 0
54#define WL1271_SCAN_BAND_5_GHZ 1
55
56#define WL1271_SCAN_TIMEOUT 30000 /* msec */
57
58enum {
59 WL1271_SCAN_STATE_IDLE,
60 WL1271_SCAN_STATE_2GHZ_ACTIVE,
61 WL1271_SCAN_STATE_2GHZ_PASSIVE,
62 WL1271_SCAN_STATE_5GHZ_ACTIVE,
63 WL1271_SCAN_STATE_5GHZ_PASSIVE,
64 WL1271_SCAN_STATE_DONE
65};
66
67struct wl1271_cmd_trigger_scan_to {
68 struct wl1271_cmd_header header;
69
70 __le32 timeout;
71} __packed;
72
73#define MAX_CHANNELS_2GHZ 14
74#define MAX_CHANNELS_4GHZ 4
75
76/*
77 * This max value here is used only for the struct definition of
78 * wlcore_scan_channels. This struct is used by both 12xx
79 * and 18xx (which have different max 5ghz channels value).
80 * In order to make sure this is large enough, just use the
81 * max possible 5ghz channels.
82 */
83#define MAX_CHANNELS_5GHZ 42
84
85#define SCAN_MAX_CYCLE_INTERVALS 16
86
87/* The FW intervals can take up to 16 entries.
88 * The 1st entry isn't used (scan is immediate). The last
89 * entry should be used for the long_interval
90 */
91#define SCAN_MAX_SHORT_INTERVALS (SCAN_MAX_CYCLE_INTERVALS - 2)
92#define SCAN_MAX_BANDS 3
93
94enum {
95 SCAN_SSID_FILTER_ANY = 0,
96 SCAN_SSID_FILTER_SPECIFIC = 1,
97 SCAN_SSID_FILTER_LIST = 2,
98 SCAN_SSID_FILTER_DISABLED = 3
99};
100
101enum {
102 SCAN_BSS_TYPE_INDEPENDENT,
103 SCAN_BSS_TYPE_INFRASTRUCTURE,
104 SCAN_BSS_TYPE_ANY,
105};
106
107#define SCAN_CHANNEL_FLAGS_DFS BIT(0) /* channel is passive until an
108 activity is detected on it */
109#define SCAN_CHANNEL_FLAGS_DFS_ENABLED BIT(1)
110
111struct conn_scan_ch_params {
112 __le16 min_duration;
113 __le16 max_duration;
114 __le16 passive_duration;
115
116 u8 channel;
117 u8 tx_power_att;
118
119 /* bit 0: DFS channel; bit 1: DFS enabled */
120 u8 flags;
121
122 u8 padding[3];
123} __packed;
124
125#define SCHED_SCAN_MAX_SSIDS 16
126
127enum {
128 SCAN_SSID_TYPE_PUBLIC = 0,
129 SCAN_SSID_TYPE_HIDDEN = 1,
130};
131
132struct wl1271_ssid {
133 u8 type;
134 u8 len;
135 u8 ssid[IEEE80211_MAX_SSID_LEN];
136 /* u8 padding[2]; */
137} __packed;
138
139struct wl1271_cmd_sched_scan_ssid_list {
140 struct wl1271_cmd_header header;
141
142 u8 n_ssids;
143 struct wl1271_ssid ssids[SCHED_SCAN_MAX_SSIDS];
144 u8 role_id;
145 u8 padding[2];
146} __packed;
147
148struct wlcore_scan_channels {
149 u8 passive[SCAN_MAX_BANDS]; /* number of passive scan channels */
150 u8 active[SCAN_MAX_BANDS]; /* number of active scan channels */
151 u8 dfs; /* number of dfs channels in 5ghz */
152 u8 passive_active; /* number of passive before active channels 2.4ghz */
153
154 struct conn_scan_ch_params channels_2[MAX_CHANNELS_2GHZ];
155 struct conn_scan_ch_params channels_5[MAX_CHANNELS_5GHZ];
156 struct conn_scan_ch_params channels_4[MAX_CHANNELS_4GHZ];
157};
158
159enum {
160 SCAN_TYPE_SEARCH = 0,
161 SCAN_TYPE_PERIODIC = 1,
162 SCAN_TYPE_TRACKING = 2,
163};
164
165bool
166wlcore_set_scan_chan_params(struct wl1271 *wl,
167 struct wlcore_scan_channels *cfg,
168 struct ieee80211_channel *channels[],
169 u32 n_channels,
170 u32 n_ssids,
171 int scan_type);
172
173int
174wlcore_scan_sched_scan_ssid_list(struct wl1271 *wl,
175 struct wl12xx_vif *wlvif,
176 struct cfg80211_sched_scan_request *req);
177
178#endif /* __WL1271_SCAN_H__ */
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * This file is part of wl1271
4 *
5 * Copyright (C) 2009-2010 Nokia Corporation
6 *
7 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
8 */
9
10#ifndef __SCAN_H__
11#define __SCAN_H__
12
13#include "wlcore.h"
14
15int wlcore_scan(struct wl1271 *wl, struct ieee80211_vif *vif,
16 const u8 *ssid, size_t ssid_len,
17 struct cfg80211_scan_request *req);
18int wl1271_scan_build_probe_req(struct wl1271 *wl,
19 const u8 *ssid, size_t ssid_len,
20 const u8 *ie, size_t ie_len, u8 band);
21void wl1271_scan_stm(struct wl1271 *wl, struct wl12xx_vif *wlvif);
22void wl1271_scan_complete_work(struct work_struct *work);
23int wl1271_scan_sched_scan_config(struct wl1271 *wl,
24 struct wl12xx_vif *wlvif,
25 struct cfg80211_sched_scan_request *req,
26 struct ieee80211_scan_ies *ies);
27int wl1271_scan_sched_scan_start(struct wl1271 *wl, struct wl12xx_vif *wlvif);
28void wlcore_scan_sched_scan_results(struct wl1271 *wl);
29
30#define WL1271_SCAN_MAX_CHANNELS 24
31#define WL1271_SCAN_DEFAULT_TAG 1
32#define WL1271_SCAN_CURRENT_TX_PWR 0
33#define WL1271_SCAN_OPT_ACTIVE 0
34#define WL1271_SCAN_OPT_PASSIVE 1
35#define WL1271_SCAN_OPT_SPLIT_SCAN 2
36#define WL1271_SCAN_OPT_PRIORITY_HIGH 4
37/* scan even if we fail to enter psm */
38#define WL1271_SCAN_OPT_FORCE 8
39#define WL1271_SCAN_BAND_2_4_GHZ 0
40#define WL1271_SCAN_BAND_5_GHZ 1
41
42#define WL1271_SCAN_TIMEOUT 30000 /* msec */
43
44enum {
45 WL1271_SCAN_STATE_IDLE,
46 WL1271_SCAN_STATE_2GHZ_ACTIVE,
47 WL1271_SCAN_STATE_2GHZ_PASSIVE,
48 WL1271_SCAN_STATE_5GHZ_ACTIVE,
49 WL1271_SCAN_STATE_5GHZ_PASSIVE,
50 WL1271_SCAN_STATE_DONE
51};
52
53struct wl1271_cmd_trigger_scan_to {
54 struct wl1271_cmd_header header;
55
56 __le32 timeout;
57} __packed;
58
59#define MAX_CHANNELS_2GHZ 14
60#define MAX_CHANNELS_4GHZ 4
61
62/*
63 * This max value here is used only for the struct definition of
64 * wlcore_scan_channels. This struct is used by both 12xx
65 * and 18xx (which have different max 5ghz channels value).
66 * In order to make sure this is large enough, just use the
67 * max possible 5ghz channels.
68 */
69#define MAX_CHANNELS_5GHZ 42
70
71#define SCAN_MAX_CYCLE_INTERVALS 16
72
73/* The FW intervals can take up to 16 entries.
74 * The 1st entry isn't used (scan is immediate). The last
75 * entry should be used for the long_interval
76 */
77#define SCAN_MAX_SHORT_INTERVALS (SCAN_MAX_CYCLE_INTERVALS - 2)
78#define SCAN_MAX_BANDS 3
79
80enum {
81 SCAN_SSID_FILTER_ANY = 0,
82 SCAN_SSID_FILTER_SPECIFIC = 1,
83 SCAN_SSID_FILTER_LIST = 2,
84 SCAN_SSID_FILTER_DISABLED = 3
85};
86
87enum {
88 SCAN_BSS_TYPE_INDEPENDENT,
89 SCAN_BSS_TYPE_INFRASTRUCTURE,
90 SCAN_BSS_TYPE_ANY,
91};
92
93#define SCAN_CHANNEL_FLAGS_DFS BIT(0) /* channel is passive until an
94 activity is detected on it */
95#define SCAN_CHANNEL_FLAGS_DFS_ENABLED BIT(1)
96
97struct conn_scan_ch_params {
98 __le16 min_duration;
99 __le16 max_duration;
100 __le16 passive_duration;
101
102 u8 channel;
103 u8 tx_power_att;
104
105 /* bit 0: DFS channel; bit 1: DFS enabled */
106 u8 flags;
107
108 u8 padding[3];
109} __packed;
110
111#define SCHED_SCAN_MAX_SSIDS 16
112
113enum {
114 SCAN_SSID_TYPE_PUBLIC = 0,
115 SCAN_SSID_TYPE_HIDDEN = 1,
116};
117
118struct wl1271_ssid {
119 u8 type;
120 u8 len;
121 u8 ssid[IEEE80211_MAX_SSID_LEN];
122 /* u8 padding[2]; */
123} __packed;
124
125struct wl1271_cmd_sched_scan_ssid_list {
126 struct wl1271_cmd_header header;
127
128 u8 n_ssids;
129 struct wl1271_ssid ssids[SCHED_SCAN_MAX_SSIDS];
130 u8 role_id;
131 u8 padding[2];
132} __packed;
133
134struct wlcore_scan_channels {
135 u8 passive[SCAN_MAX_BANDS]; /* number of passive scan channels */
136 u8 active[SCAN_MAX_BANDS]; /* number of active scan channels */
137 u8 dfs; /* number of dfs channels in 5ghz */
138 u8 passive_active; /* number of passive before active channels 2.4ghz */
139
140 struct conn_scan_ch_params channels_2[MAX_CHANNELS_2GHZ];
141 struct conn_scan_ch_params channels_5[MAX_CHANNELS_5GHZ];
142 struct conn_scan_ch_params channels_4[MAX_CHANNELS_4GHZ];
143};
144
145enum {
146 SCAN_TYPE_SEARCH = 0,
147 SCAN_TYPE_PERIODIC = 1,
148 SCAN_TYPE_TRACKING = 2,
149};
150
151bool
152wlcore_set_scan_chan_params(struct wl1271 *wl,
153 struct wlcore_scan_channels *cfg,
154 struct ieee80211_channel *channels[],
155 u32 n_channels,
156 u32 n_ssids,
157 int scan_type);
158
159int
160wlcore_scan_sched_scan_ssid_list(struct wl1271 *wl,
161 struct wl12xx_vif *wlvif,
162 struct cfg80211_sched_scan_request *req);
163
164#endif /* __WL1271_SCAN_H__ */