Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 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 | |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 24 | #ifndef __SCAN_H__ |
| 25 | #define __SCAN_H__ |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 26 | |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 27 | #include "wl12xx.h" |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 28 | |
| 29 | int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len, |
Luciano Coelho | 08688d6 | 2010-07-08 17:50:07 +0300 | [diff] [blame] | 30 | struct cfg80211_scan_request *req); |
Eliad Peller | 2aa0159 | 2011-06-27 13:06:44 +0300 | [diff] [blame] | 31 | int wl1271_scan_stop(struct wl1271 *wl); |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 32 | int 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); |
Luciano Coelho | 08688d6 | 2010-07-08 17:50:07 +0300 | [diff] [blame] | 35 | void wl1271_scan_stm(struct wl1271 *wl); |
Juuso Oikarinen | c454f1d | 2010-08-24 06:28:03 +0300 | [diff] [blame] | 36 | void wl1271_scan_complete_work(struct work_struct *work); |
Luciano Coelho | 95feadc | 2011-05-10 14:38:59 +0300 | [diff] [blame] | 37 | int wl1271_scan_sched_scan_config(struct wl1271 *wl, |
| 38 | struct cfg80211_sched_scan_request *req, |
| 39 | struct ieee80211_sched_scan_ies *ies); |
| 40 | int wl1271_scan_sched_scan_start(struct wl1271 *wl); |
| 41 | void wl1271_scan_sched_scan_stop(struct wl1271 *wl); |
| 42 | void wl1271_scan_sched_scan_results(struct wl1271 *wl); |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 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 |
Eliad Peller | a4e02f3 | 2011-08-14 13:17:10 +0300 | [diff] [blame] | 49 | #define WL1271_SCAN_OPT_TRIGGERED_SCAN 2 |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 50 | #define WL1271_SCAN_OPT_PRIORITY_HIGH 4 |
Eliad Peller | a4e02f3 | 2011-08-14 13:17:10 +0300 | [diff] [blame] | 51 | /* scan even if we fail to enter psm */ |
| 52 | #define WL1271_SCAN_OPT_FORCE 8 |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 53 | #define WL1271_SCAN_BAND_2_4_GHZ 0 |
| 54 | #define WL1271_SCAN_BAND_5_GHZ 1 |
Luciano Coelho | 08688d6 | 2010-07-08 17:50:07 +0300 | [diff] [blame] | 55 | |
Juuso Oikarinen | 78abd32 | 2010-09-21 06:23:32 +0200 | [diff] [blame] | 56 | #define WL1271_SCAN_TIMEOUT 10000 /* msec */ |
| 57 | |
Luciano Coelho | 08688d6 | 2010-07-08 17:50:07 +0300 | [diff] [blame] | 58 | enum { |
| 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 | }; |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 66 | |
| 67 | struct basic_scan_params { |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 68 | /* Scan option flags (WL1271_SCAN_OPT_*) */ |
| 69 | __le16 scan_options; |
Eliad Peller | a4e02f3 | 2011-08-14 13:17:10 +0300 | [diff] [blame] | 70 | u8 role_id; |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 71 | /* Number of scan channels in the list (maximum 30) */ |
Luciano Coelho | 08688d6 | 2010-07-08 17:50:07 +0300 | [diff] [blame] | 72 | u8 n_ch; |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 73 | /* This field indicates the number of probe requests to send |
| 74 | per channel for an active scan */ |
Luciano Coelho | 08688d6 | 2010-07-08 17:50:07 +0300 | [diff] [blame] | 75 | u8 n_probe_reqs; |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 76 | u8 tid_trigger; |
| 77 | u8 ssid_len; |
Eliad Peller | a4e02f3 | 2011-08-14 13:17:10 +0300 | [diff] [blame] | 78 | u8 use_ssid_list; |
| 79 | |
| 80 | /* Rate bit field for sending the probes */ |
| 81 | __le32 tx_rate; |
| 82 | |
Johannes Berg | 3b40c04 | 2011-07-13 10:39:16 +0200 | [diff] [blame] | 83 | u8 ssid[IEEE80211_MAX_SSID_LEN]; |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 84 | /* Band to scan */ |
| 85 | u8 band; |
Eliad Peller | a4e02f3 | 2011-08-14 13:17:10 +0300 | [diff] [blame] | 86 | |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 87 | u8 scan_tag; |
Eliad Peller | a4e02f3 | 2011-08-14 13:17:10 +0300 | [diff] [blame] | 88 | u8 padding2[2]; |
Luciano Coelho | 72e93e9 | 2010-07-09 14:10:58 +0300 | [diff] [blame] | 89 | } __packed; |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 90 | |
| 91 | struct basic_scan_channel_params { |
| 92 | /* Duration in TU to wait for frames on a channel for active scan */ |
| 93 | __le32 min_duration; |
| 94 | __le32 max_duration; |
| 95 | __le32 bssid_lsb; |
| 96 | __le16 bssid_msb; |
| 97 | u8 early_termination; |
| 98 | u8 tx_power_att; |
| 99 | u8 channel; |
| 100 | /* FW internal use only! */ |
| 101 | u8 dfs_candidate; |
| 102 | u8 activity_detected; |
| 103 | u8 pad; |
Luciano Coelho | 72e93e9 | 2010-07-09 14:10:58 +0300 | [diff] [blame] | 104 | } __packed; |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 105 | |
| 106 | struct wl1271_cmd_scan { |
| 107 | struct wl1271_cmd_header header; |
| 108 | |
| 109 | struct basic_scan_params params; |
| 110 | struct basic_scan_channel_params channels[WL1271_SCAN_MAX_CHANNELS]; |
Eliad Peller | a4e02f3 | 2011-08-14 13:17:10 +0300 | [diff] [blame] | 111 | |
| 112 | /* src mac address */ |
| 113 | u8 addr[ETH_ALEN]; |
| 114 | u8 padding[2]; |
Luciano Coelho | 72e93e9 | 2010-07-09 14:10:58 +0300 | [diff] [blame] | 115 | } __packed; |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 116 | |
| 117 | struct wl1271_cmd_trigger_scan_to { |
| 118 | struct wl1271_cmd_header header; |
| 119 | |
| 120 | __le32 timeout; |
Luciano Coelho | 72e93e9 | 2010-07-09 14:10:58 +0300 | [diff] [blame] | 121 | } __packed; |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 122 | |
Luciano Coelho | d2c2bb9 | 2011-05-31 16:38:56 +0300 | [diff] [blame] | 123 | #define MAX_CHANNELS_2GHZ 14 |
| 124 | #define MAX_CHANNELS_5GHZ 23 |
| 125 | #define MAX_CHANNELS_4GHZ 4 |
| 126 | |
Luciano Coelho | 95feadc | 2011-05-10 14:38:59 +0300 | [diff] [blame] | 127 | #define SCAN_MAX_CYCLE_INTERVALS 16 |
| 128 | #define SCAN_MAX_BANDS 3 |
| 129 | |
| 130 | enum { |
Luciano Coelho | 95feadc | 2011-05-10 14:38:59 +0300 | [diff] [blame] | 131 | SCAN_SSID_FILTER_ANY = 0, |
| 132 | SCAN_SSID_FILTER_SPECIFIC = 1, |
| 133 | SCAN_SSID_FILTER_LIST = 2, |
| 134 | SCAN_SSID_FILTER_DISABLED = 3 |
| 135 | }; |
| 136 | |
| 137 | enum { |
| 138 | SCAN_BSS_TYPE_INDEPENDENT, |
| 139 | SCAN_BSS_TYPE_INFRASTRUCTURE, |
| 140 | SCAN_BSS_TYPE_ANY, |
| 141 | }; |
| 142 | |
Luciano Coelho | 2497a24 | 2011-05-27 15:34:46 +0300 | [diff] [blame] | 143 | #define SCAN_CHANNEL_FLAGS_DFS BIT(0) |
| 144 | #define SCAN_CHANNEL_FLAGS_DFS_ENABLED BIT(1) |
| 145 | |
Luciano Coelho | 95feadc | 2011-05-10 14:38:59 +0300 | [diff] [blame] | 146 | struct conn_scan_ch_params { |
| 147 | __le16 min_duration; |
| 148 | __le16 max_duration; |
| 149 | __le16 passive_duration; |
| 150 | |
| 151 | u8 channel; |
| 152 | u8 tx_power_att; |
| 153 | |
| 154 | /* bit 0: DFS channel; bit 1: DFS enabled */ |
| 155 | u8 flags; |
| 156 | |
| 157 | u8 padding[3]; |
| 158 | } __packed; |
| 159 | |
| 160 | struct wl1271_cmd_sched_scan_config { |
| 161 | struct wl1271_cmd_header header; |
| 162 | |
| 163 | __le32 intervals[SCAN_MAX_CYCLE_INTERVALS]; |
| 164 | |
| 165 | s8 rssi_threshold; /* for filtering (in dBm) */ |
| 166 | s8 snr_threshold; /* for filtering (in dB) */ |
| 167 | |
| 168 | u8 cycles; /* maximum number of scan cycles */ |
| 169 | u8 report_after; /* report when this number of results are received */ |
| 170 | u8 terminate; /* stop scanning after reporting */ |
| 171 | |
| 172 | u8 tag; |
| 173 | u8 bss_type; /* for filtering */ |
| 174 | u8 filter_type; |
| 175 | |
| 176 | u8 ssid_len; /* For SCAN_SSID_FILTER_SPECIFIC */ |
Johannes Berg | 3b40c04 | 2011-07-13 10:39:16 +0200 | [diff] [blame] | 177 | u8 ssid[IEEE80211_MAX_SSID_LEN]; |
Luciano Coelho | 95feadc | 2011-05-10 14:38:59 +0300 | [diff] [blame] | 178 | |
| 179 | u8 n_probe_reqs; /* Number of probes requests per channel */ |
| 180 | |
| 181 | u8 passive[SCAN_MAX_BANDS]; |
| 182 | u8 active[SCAN_MAX_BANDS]; |
| 183 | |
| 184 | u8 dfs; |
| 185 | |
| 186 | u8 padding[3]; |
| 187 | |
Luciano Coelho | d2c2bb9 | 2011-05-31 16:38:56 +0300 | [diff] [blame] | 188 | struct conn_scan_ch_params channels_2[MAX_CHANNELS_2GHZ]; |
| 189 | struct conn_scan_ch_params channels_5[MAX_CHANNELS_5GHZ]; |
| 190 | struct conn_scan_ch_params channels_4[MAX_CHANNELS_4GHZ]; |
Luciano Coelho | 95feadc | 2011-05-10 14:38:59 +0300 | [diff] [blame] | 191 | } __packed; |
| 192 | |
| 193 | |
Eliad Peller | a4e02f3 | 2011-08-14 13:17:10 +0300 | [diff] [blame] | 194 | #define SCHED_SCAN_MAX_SSIDS 16 |
Luciano Coelho | 95feadc | 2011-05-10 14:38:59 +0300 | [diff] [blame] | 195 | |
| 196 | enum { |
| 197 | SCAN_SSID_TYPE_PUBLIC = 0, |
| 198 | SCAN_SSID_TYPE_HIDDEN = 1, |
| 199 | }; |
| 200 | |
| 201 | struct wl1271_ssid { |
| 202 | u8 type; |
| 203 | u8 len; |
Johannes Berg | 3b40c04 | 2011-07-13 10:39:16 +0200 | [diff] [blame] | 204 | u8 ssid[IEEE80211_MAX_SSID_LEN]; |
Luciano Coelho | 95feadc | 2011-05-10 14:38:59 +0300 | [diff] [blame] | 205 | /* u8 padding[2]; */ |
| 206 | } __packed; |
| 207 | |
| 208 | struct wl1271_cmd_sched_scan_ssid_list { |
| 209 | struct wl1271_cmd_header header; |
| 210 | |
| 211 | u8 n_ssids; |
| 212 | struct wl1271_ssid ssids[SCHED_SCAN_MAX_SSIDS]; |
| 213 | u8 padding[3]; |
| 214 | } __packed; |
| 215 | |
| 216 | struct wl1271_cmd_sched_scan_start { |
| 217 | struct wl1271_cmd_header header; |
| 218 | |
| 219 | u8 tag; |
| 220 | u8 padding[3]; |
| 221 | } __packed; |
| 222 | |
| 223 | struct wl1271_cmd_sched_scan_stop { |
| 224 | struct wl1271_cmd_header header; |
| 225 | |
| 226 | u8 tag; |
| 227 | u8 padding[3]; |
| 228 | } __packed; |
| 229 | |
| 230 | |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 231 | #endif /* __WL1271_SCAN_H__ */ |