aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi')
-rw-r--r--drivers/net/wireless/iwlwifi/Makefile2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-1000.c7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-debugfs.c500
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-debugfs.h60
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c74
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c15
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c84
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c110
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c834
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-debugfs.h56
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-lib.c416
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c67
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tx.c58
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-ucode.c36
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c65
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-calib.c12
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c57
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h24
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-csr.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debug.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c764
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h15
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.h40
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-prph.h80
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c538
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c13
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c93
31 files changed, 2436 insertions, 1603 deletions
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index a684a72eb6e9..7c7235385513 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_IWLAGN) += iwlagn.o
12iwlagn-objs := iwl-agn.o iwl-agn-rs.o iwl-agn-led.o iwl-agn-ict.o 12iwlagn-objs := iwl-agn.o iwl-agn-rs.o iwl-agn-led.o iwl-agn-ict.o
13iwlagn-objs += iwl-agn-ucode.o iwl-agn-hcmd.o iwl-agn-tx.o 13iwlagn-objs += iwl-agn-ucode.o iwl-agn-hcmd.o iwl-agn-tx.o
14iwlagn-objs += iwl-agn-lib.o 14iwlagn-objs += iwl-agn-lib.o
15iwlagn-$(CONFIG_IWLWIFI_DEBUGFS) += iwl-agn-debugfs.o
15 16
16iwlagn-$(CONFIG_IWL4965) += iwl-4965.o 17iwlagn-$(CONFIG_IWL4965) += iwl-4965.o
17iwlagn-$(CONFIG_IWL5000) += iwl-5000.o 18iwlagn-$(CONFIG_IWL5000) += iwl-5000.o
@@ -21,5 +22,6 @@ iwlagn-$(CONFIG_IWL5000) += iwl-1000.o
21# 3945 22# 3945
22obj-$(CONFIG_IWL3945) += iwl3945.o 23obj-$(CONFIG_IWL3945) += iwl3945.o
23iwl3945-objs := iwl3945-base.o iwl-3945.o iwl-3945-rs.o iwl-3945-led.o 24iwl3945-objs := iwl3945-base.o iwl-3945.o iwl-3945-rs.o iwl-3945-led.o
25iwl3945-$(CONFIG_IWLWIFI_DEBUGFS) += iwl-3945-debugfs.o
24 26
25ccflags-y += -D__CHECK_ENDIAN__ 27ccflags-y += -D__CHECK_ENDIAN__
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index 9a0191a5ea35..fb59af2d41c6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -46,6 +46,7 @@
46#include "iwl-helpers.h" 46#include "iwl-helpers.h"
47#include "iwl-agn-hw.h" 47#include "iwl-agn-hw.h"
48#include "iwl-agn-led.h" 48#include "iwl-agn-led.h"
49#include "iwl-agn-debugfs.h"
49 50
50/* Highest firmware API version supported */ 51/* Highest firmware API version supported */
51#define IWL1000_UCODE_API_MAX 3 52#define IWL1000_UCODE_API_MAX 3
@@ -212,6 +213,11 @@ static struct iwl_lib_ops iwl1000_lib = {
212 .set_ct_kill = iwl1000_set_ct_threshold, 213 .set_ct_kill = iwl1000_set_ct_threshold,
213 }, 214 },
214 .add_bcast_station = iwl_add_bcast_station, 215 .add_bcast_station = iwl_add_bcast_station,
216 .debugfs_ops = {
217 .rx_stats_read = iwl_ucode_rx_stats_read,
218 .tx_stats_read = iwl_ucode_tx_stats_read,
219 .general_stats_read = iwl_ucode_general_stats_read,
220 },
215 .recover_from_tx_stall = iwl_bg_monitor_recover, 221 .recover_from_tx_stall = iwl_bg_monitor_recover,
216 .check_plcp_health = iwl_good_plcp_health, 222 .check_plcp_health = iwl_good_plcp_health,
217 .check_ack_health = iwl_good_ack_health, 223 .check_ack_health = iwl_good_ack_health,
@@ -276,7 +282,6 @@ struct iwl_cfg iwl1000_bg_cfg = {
276 .use_bsm = false, 282 .use_bsm = false,
277 .max_ll_items = OTP_MAX_LL_ITEMS_1000, 283 .max_ll_items = OTP_MAX_LL_ITEMS_1000,
278 .shadow_ram_support = false, 284 .shadow_ram_support = false,
279 .ht_greenfield_support = true,
280 .led_compensation = 51, 285 .led_compensation = 51,
281 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS, 286 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
282 .support_ct_kill_exit = true, 287 .support_ct_kill_exit = true,
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-3945-debugfs.c
new file mode 100644
index 000000000000..6a9c64a50e36
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-debugfs.c
@@ -0,0 +1,500 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
29#include "iwl-3945-debugfs.h"
30
31ssize_t iwl3945_ucode_rx_stats_read(struct file *file,
32 char __user *user_buf,
33 size_t count, loff_t *ppos)
34{
35 struct iwl_priv *priv = file->private_data;
36 int pos = 0;
37 char *buf;
38 int bufsz = sizeof(struct iwl39_statistics_rx_phy) * 40 +
39 sizeof(struct iwl39_statistics_rx_non_phy) * 40 + 400;
40 ssize_t ret;
41 struct iwl39_statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
42 struct iwl39_statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
43 struct iwl39_statistics_rx_non_phy *general, *accum_general;
44 struct iwl39_statistics_rx_non_phy *delta_general, *max_general;
45
46 if (!iwl_is_alive(priv))
47 return -EAGAIN;
48
49 buf = kzalloc(bufsz, GFP_KERNEL);
50 if (!buf) {
51 IWL_ERR(priv, "Can not allocate Buffer\n");
52 return -ENOMEM;
53 }
54
55 /*
56 * The statistic information display here is based on
57 * the last statistics notification from uCode
58 * might not reflect the current uCode activity
59 */
60 ofdm = &priv->_3945.statistics.rx.ofdm;
61 cck = &priv->_3945.statistics.rx.cck;
62 general = &priv->_3945.statistics.rx.general;
63 accum_ofdm = &priv->_3945.accum_statistics.rx.ofdm;
64 accum_cck = &priv->_3945.accum_statistics.rx.cck;
65 accum_general = &priv->_3945.accum_statistics.rx.general;
66 delta_ofdm = &priv->_3945.delta_statistics.rx.ofdm;
67 delta_cck = &priv->_3945.delta_statistics.rx.cck;
68 delta_general = &priv->_3945.delta_statistics.rx.general;
69 max_ofdm = &priv->_3945.max_delta.rx.ofdm;
70 max_cck = &priv->_3945.max_delta.rx.cck;
71 max_general = &priv->_3945.max_delta.rx.general;
72
73 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
74 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
75 "acumulative delta max\n",
76 "Statistics_Rx - OFDM:");
77 pos += scnprintf(buf + pos, bufsz - pos,
78 " %-30s %10u %10u %10u %10u\n",
79 "ina_cnt:", le32_to_cpu(ofdm->ina_cnt),
80 accum_ofdm->ina_cnt,
81 delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
82 pos += scnprintf(buf + pos, bufsz - pos,
83 " %-30s %10u %10u %10u %10u\n",
84 "fina_cnt:",
85 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
86 delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
87 pos += scnprintf(buf + pos, bufsz - pos,
88 " %-30s %10u %10u %10u %10u\n", "plcp_err:",
89 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
90 delta_ofdm->plcp_err, max_ofdm->plcp_err);
91 pos += scnprintf(buf + pos, bufsz - pos,
92 " %-30s %10u %10u %10u %10u\n", "crc32_err:",
93 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
94 delta_ofdm->crc32_err, max_ofdm->crc32_err);
95 pos += scnprintf(buf + pos, bufsz - pos,
96 " %-30s %10u %10u %10u %10u\n", "overrun_err:",
97 le32_to_cpu(ofdm->overrun_err),
98 accum_ofdm->overrun_err, delta_ofdm->overrun_err,
99 max_ofdm->overrun_err);
100 pos += scnprintf(buf + pos, bufsz - pos,
101 " %-30s %10u %10u %10u %10u\n",
102 "early_overrun_err:",
103 le32_to_cpu(ofdm->early_overrun_err),
104 accum_ofdm->early_overrun_err,
105 delta_ofdm->early_overrun_err,
106 max_ofdm->early_overrun_err);
107 pos += scnprintf(buf + pos, bufsz - pos,
108 " %-30s %10u %10u %10u %10u\n",
109 "crc32_good:", le32_to_cpu(ofdm->crc32_good),
110 accum_ofdm->crc32_good, delta_ofdm->crc32_good,
111 max_ofdm->crc32_good);
112 pos += scnprintf(buf + pos, bufsz - pos,
113 " %-30s %10u %10u %10u %10u\n", "false_alarm_cnt:",
114 le32_to_cpu(ofdm->false_alarm_cnt),
115 accum_ofdm->false_alarm_cnt,
116 delta_ofdm->false_alarm_cnt,
117 max_ofdm->false_alarm_cnt);
118 pos += scnprintf(buf + pos, bufsz - pos,
119 " %-30s %10u %10u %10u %10u\n",
120 "fina_sync_err_cnt:",
121 le32_to_cpu(ofdm->fina_sync_err_cnt),
122 accum_ofdm->fina_sync_err_cnt,
123 delta_ofdm->fina_sync_err_cnt,
124 max_ofdm->fina_sync_err_cnt);
125 pos += scnprintf(buf + pos, bufsz - pos,
126 " %-30s %10u %10u %10u %10u\n",
127 "sfd_timeout:",
128 le32_to_cpu(ofdm->sfd_timeout),
129 accum_ofdm->sfd_timeout,
130 delta_ofdm->sfd_timeout,
131 max_ofdm->sfd_timeout);
132 pos += scnprintf(buf + pos, bufsz - pos,
133 " %-30s %10u %10u %10u %10u\n",
134 "fina_timeout:",
135 le32_to_cpu(ofdm->fina_timeout),
136 accum_ofdm->fina_timeout,
137 delta_ofdm->fina_timeout,
138 max_ofdm->fina_timeout);
139 pos += scnprintf(buf + pos, bufsz - pos,
140 " %-30s %10u %10u %10u %10u\n",
141 "unresponded_rts:",
142 le32_to_cpu(ofdm->unresponded_rts),
143 accum_ofdm->unresponded_rts,
144 delta_ofdm->unresponded_rts,
145 max_ofdm->unresponded_rts);
146 pos += scnprintf(buf + pos, bufsz - pos,
147 " %-30s %10u %10u %10u %10u\n",
148 "rxe_frame_lmt_ovrun:",
149 le32_to_cpu(ofdm->rxe_frame_limit_overrun),
150 accum_ofdm->rxe_frame_limit_overrun,
151 delta_ofdm->rxe_frame_limit_overrun,
152 max_ofdm->rxe_frame_limit_overrun);
153 pos += scnprintf(buf + pos, bufsz - pos,
154 " %-30s %10u %10u %10u %10u\n",
155 "sent_ack_cnt:",
156 le32_to_cpu(ofdm->sent_ack_cnt),
157 accum_ofdm->sent_ack_cnt,
158 delta_ofdm->sent_ack_cnt,
159 max_ofdm->sent_ack_cnt);
160 pos += scnprintf(buf + pos, bufsz - pos,
161 " %-30s %10u %10u %10u %10u\n",
162 "sent_cts_cnt:",
163 le32_to_cpu(ofdm->sent_cts_cnt),
164 accum_ofdm->sent_cts_cnt,
165 delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt);
166
167 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
168 "acumulative delta max\n",
169 "Statistics_Rx - CCK:");
170 pos += scnprintf(buf + pos, bufsz - pos,
171 " %-30s %10u %10u %10u %10u\n",
172 "ina_cnt:",
173 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
174 delta_cck->ina_cnt, max_cck->ina_cnt);
175 pos += scnprintf(buf + pos, bufsz - pos,
176 " %-30s %10u %10u %10u %10u\n",
177 "fina_cnt:",
178 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
179 delta_cck->fina_cnt, max_cck->fina_cnt);
180 pos += scnprintf(buf + pos, bufsz - pos,
181 " %-30s %10u %10u %10u %10u\n",
182 "plcp_err:",
183 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
184 delta_cck->plcp_err, max_cck->plcp_err);
185 pos += scnprintf(buf + pos, bufsz - pos,
186 " %-30s %10u %10u %10u %10u\n",
187 "crc32_err:",
188 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
189 delta_cck->crc32_err, max_cck->crc32_err);
190 pos += scnprintf(buf + pos, bufsz - pos,
191 " %-30s %10u %10u %10u %10u\n",
192 "overrun_err:",
193 le32_to_cpu(cck->overrun_err),
194 accum_cck->overrun_err,
195 delta_cck->overrun_err, max_cck->overrun_err);
196 pos += scnprintf(buf + pos, bufsz - pos,
197 " %-30s %10u %10u %10u %10u\n",
198 "early_overrun_err:",
199 le32_to_cpu(cck->early_overrun_err),
200 accum_cck->early_overrun_err,
201 delta_cck->early_overrun_err,
202 max_cck->early_overrun_err);
203 pos += scnprintf(buf + pos, bufsz - pos,
204 " %-30s %10u %10u %10u %10u\n",
205 "crc32_good:",
206 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
207 delta_cck->crc32_good,
208 max_cck->crc32_good);
209 pos += scnprintf(buf + pos, bufsz - pos,
210 " %-30s %10u %10u %10u %10u\n",
211 "false_alarm_cnt:",
212 le32_to_cpu(cck->false_alarm_cnt),
213 accum_cck->false_alarm_cnt,
214 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
215 pos += scnprintf(buf + pos, bufsz - pos,
216 " %-30s %10u %10u %10u %10u\n",
217 "fina_sync_err_cnt:",
218 le32_to_cpu(cck->fina_sync_err_cnt),
219 accum_cck->fina_sync_err_cnt,
220 delta_cck->fina_sync_err_cnt,
221 max_cck->fina_sync_err_cnt);
222 pos += scnprintf(buf + pos, bufsz - pos,
223 " %-30s %10u %10u %10u %10u\n",
224 "sfd_timeout:",
225 le32_to_cpu(cck->sfd_timeout),
226 accum_cck->sfd_timeout,
227 delta_cck->sfd_timeout, max_cck->sfd_timeout);
228 pos += scnprintf(buf + pos, bufsz - pos,
229 " %-30s %10u %10u %10u %10u\n",
230 "fina_timeout:",
231 le32_to_cpu(cck->fina_timeout),
232 accum_cck->fina_timeout,
233 delta_cck->fina_timeout, max_cck->fina_timeout);
234 pos += scnprintf(buf + pos, bufsz - pos,
235 " %-30s %10u %10u %10u %10u\n",
236 "unresponded_rts:",
237 le32_to_cpu(cck->unresponded_rts),
238 accum_cck->unresponded_rts,
239 delta_cck->unresponded_rts,
240 max_cck->unresponded_rts);
241 pos += scnprintf(buf + pos, bufsz - pos,
242 " %-30s %10u %10u %10u %10u\n",
243 "rxe_frame_lmt_ovrun:",
244 le32_to_cpu(cck->rxe_frame_limit_overrun),
245 accum_cck->rxe_frame_limit_overrun,
246 delta_cck->rxe_frame_limit_overrun,
247 max_cck->rxe_frame_limit_overrun);
248 pos += scnprintf(buf + pos, bufsz - pos,
249 " %-30s %10u %10u %10u %10u\n",
250 "sent_ack_cnt:",
251 le32_to_cpu(cck->sent_ack_cnt),
252 accum_cck->sent_ack_cnt,
253 delta_cck->sent_ack_cnt,
254 max_cck->sent_ack_cnt);
255 pos += scnprintf(buf + pos, bufsz - pos,
256 " %-30s %10u %10u %10u %10u\n",
257 "sent_cts_cnt:",
258 le32_to_cpu(cck->sent_cts_cnt),
259 accum_cck->sent_cts_cnt,
260 delta_cck->sent_cts_cnt,
261 max_cck->sent_cts_cnt);
262
263 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
264 "acumulative delta max\n",
265 "Statistics_Rx - GENERAL:");
266 pos += scnprintf(buf + pos, bufsz - pos,
267 " %-30s %10u %10u %10u %10u\n",
268 "bogus_cts:",
269 le32_to_cpu(general->bogus_cts),
270 accum_general->bogus_cts,
271 delta_general->bogus_cts, max_general->bogus_cts);
272 pos += scnprintf(buf + pos, bufsz - pos,
273 " %-30s %10u %10u %10u %10u\n",
274 "bogus_ack:",
275 le32_to_cpu(general->bogus_ack),
276 accum_general->bogus_ack,
277 delta_general->bogus_ack, max_general->bogus_ack);
278 pos += scnprintf(buf + pos, bufsz - pos,
279 " %-30s %10u %10u %10u %10u\n",
280 "non_bssid_frames:",
281 le32_to_cpu(general->non_bssid_frames),
282 accum_general->non_bssid_frames,
283 delta_general->non_bssid_frames,
284 max_general->non_bssid_frames);
285 pos += scnprintf(buf + pos, bufsz - pos,
286 " %-30s %10u %10u %10u %10u\n",
287 "filtered_frames:",
288 le32_to_cpu(general->filtered_frames),
289 accum_general->filtered_frames,
290 delta_general->filtered_frames,
291 max_general->filtered_frames);
292 pos += scnprintf(buf + pos, bufsz - pos,
293 " %-30s %10u %10u %10u %10u\n",
294 "non_channel_beacons:",
295 le32_to_cpu(general->non_channel_beacons),
296 accum_general->non_channel_beacons,
297 delta_general->non_channel_beacons,
298 max_general->non_channel_beacons);
299
300 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
301 kfree(buf);
302 return ret;
303}
304
305ssize_t iwl3945_ucode_tx_stats_read(struct file *file,
306 char __user *user_buf,
307 size_t count, loff_t *ppos)
308{
309 struct iwl_priv *priv = file->private_data;
310 int pos = 0;
311 char *buf;
312 int bufsz = (sizeof(struct iwl39_statistics_tx) * 48) + 250;
313 ssize_t ret;
314 struct iwl39_statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
315
316 if (!iwl_is_alive(priv))
317 return -EAGAIN;
318
319 buf = kzalloc(bufsz, GFP_KERNEL);
320 if (!buf) {
321 IWL_ERR(priv, "Can not allocate Buffer\n");
322 return -ENOMEM;
323 }
324
325 /*
326 * The statistic information display here is based on
327 * the last statistics notification from uCode
328 * might not reflect the current uCode activity
329 */
330 tx = &priv->_3945.statistics.tx;
331 accum_tx = &priv->_3945.accum_statistics.tx;
332 delta_tx = &priv->_3945.delta_statistics.tx;
333 max_tx = &priv->_3945.max_delta.tx;
334 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
335 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
336 "acumulative delta max\n",
337 "Statistics_Tx:");
338 pos += scnprintf(buf + pos, bufsz - pos,
339 " %-30s %10u %10u %10u %10u\n",
340 "preamble:",
341 le32_to_cpu(tx->preamble_cnt),
342 accum_tx->preamble_cnt,
343 delta_tx->preamble_cnt, max_tx->preamble_cnt);
344 pos += scnprintf(buf + pos, bufsz - pos,
345 " %-30s %10u %10u %10u %10u\n",
346 "rx_detected_cnt:",
347 le32_to_cpu(tx->rx_detected_cnt),
348 accum_tx->rx_detected_cnt,
349 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
350 pos += scnprintf(buf + pos, bufsz - pos,
351 " %-30s %10u %10u %10u %10u\n",
352 "bt_prio_defer_cnt:",
353 le32_to_cpu(tx->bt_prio_defer_cnt),
354 accum_tx->bt_prio_defer_cnt,
355 delta_tx->bt_prio_defer_cnt,
356 max_tx->bt_prio_defer_cnt);
357 pos += scnprintf(buf + pos, bufsz - pos,
358 " %-30s %10u %10u %10u %10u\n",
359 "bt_prio_kill_cnt:",
360 le32_to_cpu(tx->bt_prio_kill_cnt),
361 accum_tx->bt_prio_kill_cnt,
362 delta_tx->bt_prio_kill_cnt,
363 max_tx->bt_prio_kill_cnt);
364 pos += scnprintf(buf + pos, bufsz - pos,
365 " %-30s %10u %10u %10u %10u\n",
366 "few_bytes_cnt:",
367 le32_to_cpu(tx->few_bytes_cnt),
368 accum_tx->few_bytes_cnt,
369 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
370 pos += scnprintf(buf + pos, bufsz - pos,
371 " %-30s %10u %10u %10u %10u\n",
372 "cts_timeout:",
373 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
374 delta_tx->cts_timeout, max_tx->cts_timeout);
375 pos += scnprintf(buf + pos, bufsz - pos,
376 " %-30s %10u %10u %10u %10u\n",
377 "ack_timeout:",
378 le32_to_cpu(tx->ack_timeout),
379 accum_tx->ack_timeout,
380 delta_tx->ack_timeout, max_tx->ack_timeout);
381 pos += scnprintf(buf + pos, bufsz - pos,
382 " %-30s %10u %10u %10u %10u\n",
383 "expected_ack_cnt:",
384 le32_to_cpu(tx->expected_ack_cnt),
385 accum_tx->expected_ack_cnt,
386 delta_tx->expected_ack_cnt,
387 max_tx->expected_ack_cnt);
388 pos += scnprintf(buf + pos, bufsz - pos,
389 " %-30s %10u %10u %10u %10u\n",
390 "actual_ack_cnt:",
391 le32_to_cpu(tx->actual_ack_cnt),
392 accum_tx->actual_ack_cnt,
393 delta_tx->actual_ack_cnt,
394 max_tx->actual_ack_cnt);
395
396 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
397 kfree(buf);
398 return ret;
399}
400
401ssize_t iwl3945_ucode_general_stats_read(struct file *file,
402 char __user *user_buf,
403 size_t count, loff_t *ppos)
404{
405 struct iwl_priv *priv = file->private_data;
406 int pos = 0;
407 char *buf;
408 int bufsz = sizeof(struct iwl39_statistics_general) * 10 + 300;
409 ssize_t ret;
410 struct iwl39_statistics_general *general, *accum_general;
411 struct iwl39_statistics_general *delta_general, *max_general;
412 struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
413 struct iwl39_statistics_div *div, *accum_div, *delta_div, *max_div;
414
415 if (!iwl_is_alive(priv))
416 return -EAGAIN;
417
418 buf = kzalloc(bufsz, GFP_KERNEL);
419 if (!buf) {
420 IWL_ERR(priv, "Can not allocate Buffer\n");
421 return -ENOMEM;
422 }
423
424 /*
425 * The statistic information display here is based on
426 * the last statistics notification from uCode
427 * might not reflect the current uCode activity
428 */
429 general = &priv->_3945.statistics.general;
430 dbg = &priv->_3945.statistics.general.dbg;
431 div = &priv->_3945.statistics.general.div;
432 accum_general = &priv->_3945.accum_statistics.general;
433 delta_general = &priv->_3945.delta_statistics.general;
434 max_general = &priv->_3945.max_delta.general;
435 accum_dbg = &priv->_3945.accum_statistics.general.dbg;
436 delta_dbg = &priv->_3945.delta_statistics.general.dbg;
437 max_dbg = &priv->_3945.max_delta.general.dbg;
438 accum_div = &priv->_3945.accum_statistics.general.div;
439 delta_div = &priv->_3945.delta_statistics.general.div;
440 max_div = &priv->_3945.max_delta.general.div;
441 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
442 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
443 "acumulative delta max\n",
444 "Statistics_General:");
445 pos += scnprintf(buf + pos, bufsz - pos,
446 " %-30s %10u %10u %10u %10u\n",
447 "burst_check:",
448 le32_to_cpu(dbg->burst_check),
449 accum_dbg->burst_check,
450 delta_dbg->burst_check, max_dbg->burst_check);
451 pos += scnprintf(buf + pos, bufsz - pos,
452 " %-30s %10u %10u %10u %10u\n",
453 "burst_count:",
454 le32_to_cpu(dbg->burst_count),
455 accum_dbg->burst_count,
456 delta_dbg->burst_count, max_dbg->burst_count);
457 pos += scnprintf(buf + pos, bufsz - pos,
458 " %-30s %10u %10u %10u %10u\n",
459 "sleep_time:",
460 le32_to_cpu(general->sleep_time),
461 accum_general->sleep_time,
462 delta_general->sleep_time, max_general->sleep_time);
463 pos += scnprintf(buf + pos, bufsz - pos,
464 " %-30s %10u %10u %10u %10u\n",
465 "slots_out:",
466 le32_to_cpu(general->slots_out),
467 accum_general->slots_out,
468 delta_general->slots_out, max_general->slots_out);
469 pos += scnprintf(buf + pos, bufsz - pos,
470 " %-30s %10u %10u %10u %10u\n",
471 "slots_idle:",
472 le32_to_cpu(general->slots_idle),
473 accum_general->slots_idle,
474 delta_general->slots_idle, max_general->slots_idle);
475 pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n",
476 le32_to_cpu(general->ttl_timestamp));
477 pos += scnprintf(buf + pos, bufsz - pos,
478 " %-30s %10u %10u %10u %10u\n",
479 "tx_on_a:",
480 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
481 delta_div->tx_on_a, max_div->tx_on_a);
482 pos += scnprintf(buf + pos, bufsz - pos,
483 " %-30s %10u %10u %10u %10u\n",
484 "tx_on_b:",
485 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
486 delta_div->tx_on_b, max_div->tx_on_b);
487 pos += scnprintf(buf + pos, bufsz - pos,
488 " %-30s %10u %10u %10u %10u\n",
489 "exec_time:",
490 le32_to_cpu(div->exec_time), accum_div->exec_time,
491 delta_div->exec_time, max_div->exec_time);
492 pos += scnprintf(buf + pos, bufsz - pos,
493 " %-30s %10u %10u %10u %10u\n",
494 "probe_time:",
495 le32_to_cpu(div->probe_time), accum_div->probe_time,
496 delta_div->probe_time, max_div->probe_time);
497 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
498 kfree(buf);
499 return ret;
500}
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-debugfs.h b/drivers/net/wireless/iwlwifi/iwl-3945-debugfs.h
new file mode 100644
index 000000000000..70809c53c215
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-debugfs.h
@@ -0,0 +1,60 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
29#include "iwl-dev.h"
30#include "iwl-core.h"
31#include "iwl-debug.h"
32
33#ifdef CONFIG_IWLWIFI_DEBUGFS
34ssize_t iwl3945_ucode_rx_stats_read(struct file *file, char __user *user_buf,
35 size_t count, loff_t *ppos);
36ssize_t iwl3945_ucode_tx_stats_read(struct file *file, char __user *user_buf,
37 size_t count, loff_t *ppos);
38ssize_t iwl3945_ucode_general_stats_read(struct file *file,
39 char __user *user_buf, size_t count,
40 loff_t *ppos);
41#else
42static ssize_t iwl3945_ucode_rx_stats_read(struct file *file,
43 char __user *user_buf, size_t count,
44 loff_t *ppos)
45{
46 return 0;
47}
48static ssize_t iwl3945_ucode_tx_stats_read(struct file *file,
49 char __user *user_buf, size_t count,
50 loff_t *ppos)
51{
52 return 0;
53}
54static ssize_t iwl3945_ucode_general_stats_read(struct file *file,
55 char __user *user_buf,
56 size_t count, loff_t *ppos)
57{
58 return 0;
59}
60#endif
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index bde3b4cbab9d..17197a78d894 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -50,6 +50,7 @@
50#include "iwl-helpers.h" 50#include "iwl-helpers.h"
51#include "iwl-led.h" 51#include "iwl-led.h"
52#include "iwl-3945-led.h" 52#include "iwl-3945-led.h"
53#include "iwl-3945-debugfs.h"
53 54
54#define IWL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ 55#define IWL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \
55 [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \ 56 [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \
@@ -293,7 +294,7 @@ static void iwl3945_tx_queue_reclaim(struct iwl_priv *priv,
293 * iwl3945_rx_reply_tx - Handle Tx response 294 * iwl3945_rx_reply_tx - Handle Tx response
294 */ 295 */
295static void iwl3945_rx_reply_tx(struct iwl_priv *priv, 296static void iwl3945_rx_reply_tx(struct iwl_priv *priv,
296 struct iwl_rx_mem_buffer *rxb) 297 struct iwl_rx_mem_buffer *rxb)
297{ 298{
298 struct iwl_rx_packet *pkt = rxb_addr(rxb); 299 struct iwl_rx_packet *pkt = rxb_addr(rxb);
299 u16 sequence = le16_to_cpu(pkt->hdr.sequence); 300 u16 sequence = le16_to_cpu(pkt->hdr.sequence);
@@ -351,18 +352,81 @@ static void iwl3945_rx_reply_tx(struct iwl_priv *priv,
351 * RX handler implementations 352 * RX handler implementations
352 * 353 *
353 *****************************************************************************/ 354 *****************************************************************************/
355#ifdef CONFIG_IWLWIFI_DEBUG
356/*
357 * based on the assumption of all statistics counter are in DWORD
358 * FIXME: This function is for debugging, do not deal with
359 * the case of counters roll-over.
360 */
361static void iwl3945_accumulative_statistics(struct iwl_priv *priv,
362 __le32 *stats)
363{
364 int i;
365 __le32 *prev_stats;
366 u32 *accum_stats;
367 u32 *delta, *max_delta;
368
369 prev_stats = (__le32 *)&priv->_3945.statistics;
370 accum_stats = (u32 *)&priv->_3945.accum_statistics;
371 delta = (u32 *)&priv->_3945.delta_statistics;
372 max_delta = (u32 *)&priv->_3945.max_delta;
373
374 for (i = sizeof(__le32); i < sizeof(struct iwl3945_notif_statistics);
375 i += sizeof(__le32), stats++, prev_stats++, delta++,
376 max_delta++, accum_stats++) {
377 if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) {
378 *delta = (le32_to_cpu(*stats) -
379 le32_to_cpu(*prev_stats));
380 *accum_stats += *delta;
381 if (*delta > *max_delta)
382 *max_delta = *delta;
383 }
384 }
385
386 /* reset accumulative statistics for "no-counter" type statistics */
387 priv->_3945.accum_statistics.general.temperature =
388 priv->_3945.statistics.general.temperature;
389 priv->_3945.accum_statistics.general.ttl_timestamp =
390 priv->_3945.statistics.general.ttl_timestamp;
391}
392#endif
354 393
355void iwl3945_hw_rx_statistics(struct iwl_priv *priv, 394void iwl3945_hw_rx_statistics(struct iwl_priv *priv,
356 struct iwl_rx_mem_buffer *rxb) 395 struct iwl_rx_mem_buffer *rxb)
357{ 396{
358 struct iwl_rx_packet *pkt = rxb_addr(rxb); 397 struct iwl_rx_packet *pkt = rxb_addr(rxb);
398
359 IWL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n", 399 IWL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n",
360 (int)sizeof(struct iwl3945_notif_statistics), 400 (int)sizeof(struct iwl3945_notif_statistics),
361 le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); 401 le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK);
402#ifdef CONFIG_IWLWIFI_DEBUG
403 iwl3945_accumulative_statistics(priv, (__le32 *)&pkt->u.raw);
404#endif
362 405
363 memcpy(&priv->_3945.statistics, pkt->u.raw, sizeof(priv->_3945.statistics)); 406 memcpy(&priv->_3945.statistics, pkt->u.raw, sizeof(priv->_3945.statistics));
364} 407}
365 408
409void iwl3945_reply_statistics(struct iwl_priv *priv,
410 struct iwl_rx_mem_buffer *rxb)
411{
412 struct iwl_rx_packet *pkt = rxb_addr(rxb);
413 __le32 *flag = (__le32 *)&pkt->u.raw;
414
415 if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) {
416#ifdef CONFIG_IWLWIFI_DEBUG
417 memset(&priv->_3945.accum_statistics, 0,
418 sizeof(struct iwl3945_notif_statistics));
419 memset(&priv->_3945.delta_statistics, 0,
420 sizeof(struct iwl3945_notif_statistics));
421 memset(&priv->_3945.max_delta, 0,
422 sizeof(struct iwl3945_notif_statistics));
423#endif
424 IWL_DEBUG_RX(priv, "Statistics have been cleared\n");
425 }
426 iwl3945_hw_rx_statistics(priv, rxb);
427}
428
429
366/****************************************************************************** 430/******************************************************************************
367 * 431 *
368 * Misc. internal state and helper functions 432 * Misc. internal state and helper functions
@@ -2688,6 +2752,7 @@ IWL3945_UCODE_GET(boot_size);
2688static struct iwl_hcmd_ops iwl3945_hcmd = { 2752static struct iwl_hcmd_ops iwl3945_hcmd = {
2689 .rxon_assoc = iwl3945_send_rxon_assoc, 2753 .rxon_assoc = iwl3945_send_rxon_assoc,
2690 .commit_rxon = iwl3945_commit_rxon, 2754 .commit_rxon = iwl3945_commit_rxon,
2755 .send_bt_config = iwl_send_bt_config,
2691}; 2756};
2692 2757
2693static struct iwl_ucode_ops iwl3945_ucode = { 2758static struct iwl_ucode_ops iwl3945_ucode = {
@@ -2735,12 +2800,19 @@ static struct iwl_lib_ops iwl3945_lib = {
2735 .isr = iwl_isr_legacy, 2800 .isr = iwl_isr_legacy,
2736 .config_ap = iwl3945_config_ap, 2801 .config_ap = iwl3945_config_ap,
2737 .add_bcast_station = iwl3945_add_bcast_station, 2802 .add_bcast_station = iwl3945_add_bcast_station,
2803
2804 .debugfs_ops = {
2805 .rx_stats_read = iwl3945_ucode_rx_stats_read,
2806 .tx_stats_read = iwl3945_ucode_tx_stats_read,
2807 .general_stats_read = iwl3945_ucode_general_stats_read,
2808 },
2738}; 2809};
2739 2810
2740static struct iwl_hcmd_utils_ops iwl3945_hcmd_utils = { 2811static struct iwl_hcmd_utils_ops iwl3945_hcmd_utils = {
2741 .get_hcmd_size = iwl3945_get_hcmd_size, 2812 .get_hcmd_size = iwl3945_get_hcmd_size,
2742 .build_addsta_hcmd = iwl3945_build_addsta_hcmd, 2813 .build_addsta_hcmd = iwl3945_build_addsta_hcmd,
2743 .rts_tx_cmd_flag = iwlcore_rts_tx_cmd_flag, 2814 .rts_tx_cmd_flag = iwlcore_rts_tx_cmd_flag,
2815 .request_scan = iwl3945_request_scan,
2744}; 2816};
2745 2817
2746static const struct iwl_ops iwl3945_ops = { 2818static const struct iwl_ops iwl3945_ops = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index b89219573b91..643adb644bb8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -264,6 +264,8 @@ extern int iwl3945_hw_reg_send_txpower(struct iwl_priv *priv);
264extern int iwl3945_hw_reg_set_txpower(struct iwl_priv *priv, s8 power); 264extern int iwl3945_hw_reg_set_txpower(struct iwl_priv *priv, s8 power);
265extern void iwl3945_hw_rx_statistics(struct iwl_priv *priv, 265extern void iwl3945_hw_rx_statistics(struct iwl_priv *priv,
266 struct iwl_rx_mem_buffer *rxb); 266 struct iwl_rx_mem_buffer *rxb);
267void iwl3945_reply_statistics(struct iwl_priv *priv,
268 struct iwl_rx_mem_buffer *rxb);
267extern void iwl3945_disable_events(struct iwl_priv *priv); 269extern void iwl3945_disable_events(struct iwl_priv *priv);
268extern int iwl4965_get_temperature(const struct iwl_priv *priv); 270extern int iwl4965_get_temperature(const struct iwl_priv *priv);
269extern void iwl3945_post_associate(struct iwl_priv *priv); 271extern void iwl3945_post_associate(struct iwl_priv *priv);
@@ -294,6 +296,9 @@ extern const struct iwl_channel_info *iwl3945_get_channel_info(
294 296
295extern int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate); 297extern int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate);
296 298
299/* scanning */
300void iwl3945_request_scan(struct iwl_priv *priv);
301
297/* Requires full declaration of iwl_priv before including */ 302/* Requires full declaration of iwl_priv before including */
298#include "iwl-io.h" 303#include "iwl-io.h"
299 304
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 2e3cda75f3ad..136c29067489 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -47,6 +47,7 @@
47#include "iwl-sta.h" 47#include "iwl-sta.h"
48#include "iwl-agn-led.h" 48#include "iwl-agn-led.h"
49#include "iwl-agn.h" 49#include "iwl-agn.h"
50#include "iwl-agn-debugfs.h"
50 51
51static int iwl4965_send_tx_power(struct iwl_priv *priv); 52static int iwl4965_send_tx_power(struct iwl_priv *priv);
52static int iwl4965_hw_get_temperature(struct iwl_priv *priv); 53static int iwl4965_hw_get_temperature(struct iwl_priv *priv);
@@ -2143,6 +2144,7 @@ static struct iwl_hcmd_ops iwl4965_hcmd = {
2143 .rxon_assoc = iwl4965_send_rxon_assoc, 2144 .rxon_assoc = iwl4965_send_rxon_assoc,
2144 .commit_rxon = iwl_commit_rxon, 2145 .commit_rxon = iwl_commit_rxon,
2145 .set_rxon_chain = iwl_set_rxon_chain, 2146 .set_rxon_chain = iwl_set_rxon_chain,
2147 .send_bt_config = iwl_send_bt_config,
2146}; 2148};
2147 2149
2148static struct iwl_ucode_ops iwl4965_ucode = { 2150static struct iwl_ucode_ops iwl4965_ucode = {
@@ -2162,6 +2164,7 @@ static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = {
2162 .gain_computation = iwl4965_gain_computation, 2164 .gain_computation = iwl4965_gain_computation,
2163 .rts_tx_cmd_flag = iwlcore_rts_tx_cmd_flag, 2165 .rts_tx_cmd_flag = iwlcore_rts_tx_cmd_flag,
2164 .calc_rssi = iwl4965_calc_rssi, 2166 .calc_rssi = iwl4965_calc_rssi,
2167 .request_scan = iwlagn_request_scan,
2165}; 2168};
2166 2169
2167static struct iwl_lib_ops iwl4965_lib = { 2170static struct iwl_lib_ops iwl4965_lib = {
@@ -2216,6 +2219,11 @@ static struct iwl_lib_ops iwl4965_lib = {
2216 .set_ct_kill = iwl4965_set_ct_threshold, 2219 .set_ct_kill = iwl4965_set_ct_threshold,
2217 }, 2220 },
2218 .add_bcast_station = iwl_add_bcast_station, 2221 .add_bcast_station = iwl_add_bcast_station,
2222 .debugfs_ops = {
2223 .rx_stats_read = iwl_ucode_rx_stats_read,
2224 .tx_stats_read = iwl_ucode_tx_stats_read,
2225 .general_stats_read = iwl_ucode_general_stats_read,
2226 },
2219 .check_plcp_health = iwl_good_plcp_health, 2227 .check_plcp_health = iwl_good_plcp_health,
2220}; 2228};
2221 2229
@@ -2253,8 +2261,13 @@ struct iwl_cfg iwl4965_agn_cfg = {
2253 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 2261 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
2254 .monitor_recover_period = IWL_MONITORING_PERIOD, 2262 .monitor_recover_period = IWL_MONITORING_PERIOD,
2255 .temperature_kelvin = true, 2263 .temperature_kelvin = true,
2256 .off_channel_workaround = true,
2257 .max_event_log_size = 512, 2264 .max_event_log_size = 512,
2265
2266 /*
2267 * Force use of chains B and C for scan RX on 5 GHz band
2268 * because the device has off-channel reception on chain A.
2269 */
2270 .scan_antennas[IEEE80211_BAND_5GHZ] = ANT_BC,
2258}; 2271};
2259 2272
2260/* Module firmware */ 2273/* Module firmware */
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index e967cfcac224..115d3ea1142f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -48,6 +48,7 @@
48#include "iwl-agn-led.h" 48#include "iwl-agn-led.h"
49#include "iwl-agn-hw.h" 49#include "iwl-agn-hw.h"
50#include "iwl-5000-hw.h" 50#include "iwl-5000-hw.h"
51#include "iwl-agn-debugfs.h"
51 52
52/* Highest firmware API version supported */ 53/* Highest firmware API version supported */
53#define IWL5000_UCODE_API_MAX 2 54#define IWL5000_UCODE_API_MAX 2
@@ -199,26 +200,57 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
199 200
200 /* Set initial sensitivity parameters */ 201 /* Set initial sensitivity parameters */
201 /* Set initial calibration set */ 202 /* Set initial calibration set */
202 switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) { 203 priv->hw_params.sens = &iwl5000_sensitivity;
203 case CSR_HW_REV_TYPE_5150: 204 priv->hw_params.calib_init_cfg =
204 priv->hw_params.sens = &iwl5150_sensitivity; 205 BIT(IWL_CALIB_XTAL) |
205 priv->hw_params.calib_init_cfg = 206 BIT(IWL_CALIB_LO) |
206 BIT(IWL_CALIB_DC) | 207 BIT(IWL_CALIB_TX_IQ) |
207 BIT(IWL_CALIB_LO) | 208 BIT(IWL_CALIB_TX_IQ_PERD) |
208 BIT(IWL_CALIB_TX_IQ) | 209 BIT(IWL_CALIB_BASE_BAND);
209 BIT(IWL_CALIB_BASE_BAND); 210
210 211 return 0;
211 break; 212}
212 default: 213
213 priv->hw_params.sens = &iwl5000_sensitivity; 214static int iwl5150_hw_set_hw_params(struct iwl_priv *priv)
214 priv->hw_params.calib_init_cfg = 215{
215 BIT(IWL_CALIB_XTAL) | 216 if (priv->cfg->mod_params->num_of_queues >= IWL_MIN_NUM_QUEUES &&
216 BIT(IWL_CALIB_LO) | 217 priv->cfg->mod_params->num_of_queues <= IWLAGN_NUM_QUEUES)
217 BIT(IWL_CALIB_TX_IQ) | 218 priv->cfg->num_of_queues =
218 BIT(IWL_CALIB_TX_IQ_PERD) | 219 priv->cfg->mod_params->num_of_queues;
219 BIT(IWL_CALIB_BASE_BAND); 220
220 break; 221 priv->hw_params.max_txq_num = priv->cfg->num_of_queues;
221 } 222 priv->hw_params.dma_chnl_num = FH50_TCSR_CHNL_NUM;
223 priv->hw_params.scd_bc_tbls_size =
224 priv->cfg->num_of_queues *
225 sizeof(struct iwlagn_scd_bc_tbl);
226 priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
227 priv->hw_params.max_stations = IWL5000_STATION_COUNT;
228 priv->hw_params.bcast_sta_id = IWL5000_BROADCAST_ID;
229
230 priv->hw_params.max_data_size = IWLAGN_RTC_DATA_SIZE;
231 priv->hw_params.max_inst_size = IWLAGN_RTC_INST_SIZE;
232
233 priv->hw_params.max_bsm_size = 0;
234 priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
235 BIT(IEEE80211_BAND_5GHZ);
236 priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR;
237
238 priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
239 priv->hw_params.rx_chains_num = num_of_ant(priv->cfg->valid_rx_ant);
240 priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
241 priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
242
243 if (priv->cfg->ops->lib->temp_ops.set_ct_kill)
244 priv->cfg->ops->lib->temp_ops.set_ct_kill(priv);
245
246 /* Set initial sensitivity parameters */
247 /* Set initial calibration set */
248 priv->hw_params.sens = &iwl5150_sensitivity;
249 priv->hw_params.calib_init_cfg =
250 BIT(IWL_CALIB_DC) |
251 BIT(IWL_CALIB_LO) |
252 BIT(IWL_CALIB_TX_IQ) |
253 BIT(IWL_CALIB_BASE_BAND);
222 254
223 return 0; 255 return 0;
224} 256}
@@ -320,13 +352,18 @@ static struct iwl_lib_ops iwl5000_lib = {
320 .set_ct_kill = iwl5000_set_ct_threshold, 352 .set_ct_kill = iwl5000_set_ct_threshold,
321 }, 353 },
322 .add_bcast_station = iwl_add_bcast_station, 354 .add_bcast_station = iwl_add_bcast_station,
355 .debugfs_ops = {
356 .rx_stats_read = iwl_ucode_rx_stats_read,
357 .tx_stats_read = iwl_ucode_tx_stats_read,
358 .general_stats_read = iwl_ucode_general_stats_read,
359 },
323 .recover_from_tx_stall = iwl_bg_monitor_recover, 360 .recover_from_tx_stall = iwl_bg_monitor_recover,
324 .check_plcp_health = iwl_good_plcp_health, 361 .check_plcp_health = iwl_good_plcp_health,
325 .check_ack_health = iwl_good_ack_health, 362 .check_ack_health = iwl_good_ack_health,
326}; 363};
327 364
328static struct iwl_lib_ops iwl5150_lib = { 365static struct iwl_lib_ops iwl5150_lib = {
329 .set_hw_params = iwl5000_hw_set_hw_params, 366 .set_hw_params = iwl5150_hw_set_hw_params,
330 .txq_update_byte_cnt_tbl = iwlagn_txq_update_byte_cnt_tbl, 367 .txq_update_byte_cnt_tbl = iwlagn_txq_update_byte_cnt_tbl,
331 .txq_inval_byte_cnt_tbl = iwlagn_txq_inval_byte_cnt_tbl, 368 .txq_inval_byte_cnt_tbl = iwlagn_txq_inval_byte_cnt_tbl,
332 .txq_set_sched = iwlagn_txq_set_sched, 369 .txq_set_sched = iwlagn_txq_set_sched,
@@ -377,6 +414,11 @@ static struct iwl_lib_ops iwl5150_lib = {
377 .set_ct_kill = iwl5150_set_ct_threshold, 414 .set_ct_kill = iwl5150_set_ct_threshold,
378 }, 415 },
379 .add_bcast_station = iwl_add_bcast_station, 416 .add_bcast_station = iwl_add_bcast_station,
417 .debugfs_ops = {
418 .rx_stats_read = iwl_ucode_rx_stats_read,
419 .tx_stats_read = iwl_ucode_tx_stats_read,
420 .general_stats_read = iwl_ucode_general_stats_read,
421 },
380 .recover_from_tx_stall = iwl_bg_monitor_recover, 422 .recover_from_tx_stall = iwl_bg_monitor_recover,
381 .check_plcp_health = iwl_good_plcp_health, 423 .check_plcp_health = iwl_good_plcp_health,
382 .check_ack_health = iwl_good_ack_health, 424 .check_ack_health = iwl_good_ack_health,
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index dd03384432f4..7acef703253a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -47,17 +47,19 @@
47#include "iwl-agn-hw.h" 47#include "iwl-agn-hw.h"
48#include "iwl-6000-hw.h" 48#include "iwl-6000-hw.h"
49#include "iwl-agn-led.h" 49#include "iwl-agn-led.h"
50#include "iwl-agn-debugfs.h"
50 51
51/* Highest firmware API version supported */ 52/* Highest firmware API version supported */
52#define IWL6000_UCODE_API_MAX 4 53#define IWL6000_UCODE_API_MAX 4
53#define IWL6050_UCODE_API_MAX 4 54#define IWL6050_UCODE_API_MAX 4
55#define IWL6000G2_UCODE_API_MAX 4
54 56
55/* Lowest firmware API version supported */ 57/* Lowest firmware API version supported */
56#define IWL6000_UCODE_API_MIN 4 58#define IWL6000_UCODE_API_MIN 4
57#define IWL6050_UCODE_API_MIN 4 59#define IWL6050_UCODE_API_MIN 4
60#define IWL6000G2_UCODE_API_MIN 4
58 61
59#define IWL6000_FW_PRE "iwlwifi-6000-" 62#define IWL6000_FW_PRE "iwlwifi-6000-"
60#define IWL6000_G2_FW_PRE "iwlwifi-6005-"
61#define _IWL6000_MODULE_FIRMWARE(api) IWL6000_FW_PRE #api ".ucode" 63#define _IWL6000_MODULE_FIRMWARE(api) IWL6000_FW_PRE #api ".ucode"
62#define IWL6000_MODULE_FIRMWARE(api) _IWL6000_MODULE_FIRMWARE(api) 64#define IWL6000_MODULE_FIRMWARE(api) _IWL6000_MODULE_FIRMWARE(api)
63 65
@@ -65,6 +67,10 @@
65#define _IWL6050_MODULE_FIRMWARE(api) IWL6050_FW_PRE #api ".ucode" 67#define _IWL6050_MODULE_FIRMWARE(api) IWL6050_FW_PRE #api ".ucode"
66#define IWL6050_MODULE_FIRMWARE(api) _IWL6050_MODULE_FIRMWARE(api) 68#define IWL6050_MODULE_FIRMWARE(api) _IWL6050_MODULE_FIRMWARE(api)
67 69
70#define IWL6000G2_FW_PRE "iwlwifi-6005-"
71#define _IWL6000G2_MODULE_FIRMWARE(api) IWL6000G2_FW_PRE #api ".ucode"
72#define IWL6000G2_MODULE_FIRMWARE(api) _IWL6000G2_MODULE_FIRMWARE(api)
73
68static void iwl6000_set_ct_threshold(struct iwl_priv *priv) 74static void iwl6000_set_ct_threshold(struct iwl_priv *priv)
69{ 75{
70 /* want Celsius */ 76 /* want Celsius */
@@ -170,24 +176,56 @@ static int iwl6000_hw_set_hw_params(struct iwl_priv *priv)
170 /* Set initial sensitivity parameters */ 176 /* Set initial sensitivity parameters */
171 /* Set initial calibration set */ 177 /* Set initial calibration set */
172 priv->hw_params.sens = &iwl6000_sensitivity; 178 priv->hw_params.sens = &iwl6000_sensitivity;
173 switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) { 179 priv->hw_params.calib_init_cfg =
174 case CSR_HW_REV_TYPE_6x50: 180 BIT(IWL_CALIB_XTAL) |
175 priv->hw_params.calib_init_cfg = 181 BIT(IWL_CALIB_LO) |
176 BIT(IWL_CALIB_XTAL) | 182 BIT(IWL_CALIB_TX_IQ) |
177 BIT(IWL_CALIB_DC) | 183 BIT(IWL_CALIB_BASE_BAND);
178 BIT(IWL_CALIB_LO) | 184
179 BIT(IWL_CALIB_TX_IQ) | 185 return 0;
180 BIT(IWL_CALIB_BASE_BAND); 186}
181 187
182 break; 188static int iwl6050_hw_set_hw_params(struct iwl_priv *priv)
183 default: 189{
184 priv->hw_params.calib_init_cfg = 190 if (priv->cfg->mod_params->num_of_queues >= IWL_MIN_NUM_QUEUES &&
185 BIT(IWL_CALIB_XTAL) | 191 priv->cfg->mod_params->num_of_queues <= IWLAGN_NUM_QUEUES)
186 BIT(IWL_CALIB_LO) | 192 priv->cfg->num_of_queues =
187 BIT(IWL_CALIB_TX_IQ) | 193 priv->cfg->mod_params->num_of_queues;
188 BIT(IWL_CALIB_BASE_BAND); 194
189 break; 195 priv->hw_params.max_txq_num = priv->cfg->num_of_queues;
190 } 196 priv->hw_params.dma_chnl_num = FH50_TCSR_CHNL_NUM;
197 priv->hw_params.scd_bc_tbls_size =
198 priv->cfg->num_of_queues *
199 sizeof(struct iwlagn_scd_bc_tbl);
200 priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
201 priv->hw_params.max_stations = IWL5000_STATION_COUNT;
202 priv->hw_params.bcast_sta_id = IWL5000_BROADCAST_ID;
203
204 priv->hw_params.max_data_size = IWL60_RTC_DATA_SIZE;
205 priv->hw_params.max_inst_size = IWL60_RTC_INST_SIZE;
206
207 priv->hw_params.max_bsm_size = 0;
208 priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
209 BIT(IEEE80211_BAND_5GHZ);
210 priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR;
211
212 priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
213 priv->hw_params.rx_chains_num = num_of_ant(priv->cfg->valid_rx_ant);
214 priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
215 priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
216
217 if (priv->cfg->ops->lib->temp_ops.set_ct_kill)
218 priv->cfg->ops->lib->temp_ops.set_ct_kill(priv);
219
220 /* Set initial sensitivity parameters */
221 /* Set initial calibration set */
222 priv->hw_params.sens = &iwl6000_sensitivity;
223 priv->hw_params.calib_init_cfg =
224 BIT(IWL_CALIB_XTAL) |
225 BIT(IWL_CALIB_DC) |
226 BIT(IWL_CALIB_LO) |
227 BIT(IWL_CALIB_TX_IQ) |
228 BIT(IWL_CALIB_BASE_BAND);
191 229
192 return 0; 230 return 0;
193} 231}
@@ -261,7 +299,7 @@ static struct iwl_lib_ops iwl6000_lib = {
261 EEPROM_REG_BAND_3_CHANNELS, 299 EEPROM_REG_BAND_3_CHANNELS,
262 EEPROM_REG_BAND_4_CHANNELS, 300 EEPROM_REG_BAND_4_CHANNELS,
263 EEPROM_REG_BAND_5_CHANNELS, 301 EEPROM_REG_BAND_5_CHANNELS,
264 EEPROM_REG_BAND_24_HT40_CHANNELS, 302 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
265 EEPROM_REG_BAND_52_HT40_CHANNELS 303 EEPROM_REG_BAND_52_HT40_CHANNELS
266 }, 304 },
267 .verify_signature = iwlcore_eeprom_verify_signature, 305 .verify_signature = iwlcore_eeprom_verify_signature,
@@ -279,6 +317,11 @@ static struct iwl_lib_ops iwl6000_lib = {
279 .set_ct_kill = iwl6000_set_ct_threshold, 317 .set_ct_kill = iwl6000_set_ct_threshold,
280 }, 318 },
281 .add_bcast_station = iwl_add_bcast_station, 319 .add_bcast_station = iwl_add_bcast_station,
320 .debugfs_ops = {
321 .rx_stats_read = iwl_ucode_rx_stats_read,
322 .tx_stats_read = iwl_ucode_tx_stats_read,
323 .general_stats_read = iwl_ucode_general_stats_read,
324 },
282 .recover_from_tx_stall = iwl_bg_monitor_recover, 325 .recover_from_tx_stall = iwl_bg_monitor_recover,
283 .check_plcp_health = iwl_good_plcp_health, 326 .check_plcp_health = iwl_good_plcp_health,
284 .check_ack_health = iwl_good_ack_health, 327 .check_ack_health = iwl_good_ack_health,
@@ -293,7 +336,7 @@ static const struct iwl_ops iwl6000_ops = {
293}; 336};
294 337
295static struct iwl_lib_ops iwl6050_lib = { 338static struct iwl_lib_ops iwl6050_lib = {
296 .set_hw_params = iwl6000_hw_set_hw_params, 339 .set_hw_params = iwl6050_hw_set_hw_params,
297 .txq_update_byte_cnt_tbl = iwlagn_txq_update_byte_cnt_tbl, 340 .txq_update_byte_cnt_tbl = iwlagn_txq_update_byte_cnt_tbl,
298 .txq_inval_byte_cnt_tbl = iwlagn_txq_inval_byte_cnt_tbl, 341 .txq_inval_byte_cnt_tbl = iwlagn_txq_inval_byte_cnt_tbl,
299 .txq_set_sched = iwlagn_txq_set_sched, 342 .txq_set_sched = iwlagn_txq_set_sched,
@@ -328,7 +371,7 @@ static struct iwl_lib_ops iwl6050_lib = {
328 EEPROM_REG_BAND_3_CHANNELS, 371 EEPROM_REG_BAND_3_CHANNELS,
329 EEPROM_REG_BAND_4_CHANNELS, 372 EEPROM_REG_BAND_4_CHANNELS,
330 EEPROM_REG_BAND_5_CHANNELS, 373 EEPROM_REG_BAND_5_CHANNELS,
331 EEPROM_REG_BAND_24_HT40_CHANNELS, 374 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
332 EEPROM_REG_BAND_52_HT40_CHANNELS 375 EEPROM_REG_BAND_52_HT40_CHANNELS
333 }, 376 },
334 .verify_signature = iwlcore_eeprom_verify_signature, 377 .verify_signature = iwlcore_eeprom_verify_signature,
@@ -347,6 +390,11 @@ static struct iwl_lib_ops iwl6050_lib = {
347 .set_calib_version = iwl6050_set_calib_version, 390 .set_calib_version = iwl6050_set_calib_version,
348 }, 391 },
349 .add_bcast_station = iwl_add_bcast_station, 392 .add_bcast_station = iwl_add_bcast_station,
393 .debugfs_ops = {
394 .rx_stats_read = iwl_ucode_rx_stats_read,
395 .tx_stats_read = iwl_ucode_tx_stats_read,
396 .general_stats_read = iwl_ucode_general_stats_read,
397 },
350 .recover_from_tx_stall = iwl_bg_monitor_recover, 398 .recover_from_tx_stall = iwl_bg_monitor_recover,
351 .check_plcp_health = iwl_good_plcp_health, 399 .check_plcp_health = iwl_good_plcp_health,
352 .check_ack_health = iwl_good_ack_health, 400 .check_ack_health = iwl_good_ack_health,
@@ -363,16 +411,16 @@ static const struct iwl_ops iwl6050_ops = {
363/* 411/*
364 * "i": Internal configuration, use internal Power Amplifier 412 * "i": Internal configuration, use internal Power Amplifier
365 */ 413 */
366struct iwl_cfg iwl6000i_g2_2agn_cfg = { 414struct iwl_cfg iwl6000g2_2agn_cfg = {
367 .name = "6000 Series 2x2 AGN Gen2", 415 .name = "6000 Series 2x2 AGN Gen2",
368 .fw_name_pre = IWL6000_G2_FW_PRE, 416 .fw_name_pre = IWL6000G2_FW_PRE,
369 .ucode_api_max = IWL6000_UCODE_API_MAX, 417 .ucode_api_max = IWL6000G2_UCODE_API_MAX,
370 .ucode_api_min = IWL6000_UCODE_API_MIN, 418 .ucode_api_min = IWL6000G2_UCODE_API_MIN,
371 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, 419 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
372 .ops = &iwl6000_ops, 420 .ops = &iwl6000_ops,
373 .eeprom_size = OTP_LOW_IMAGE_SIZE, 421 .eeprom_size = OTP_LOW_IMAGE_SIZE,
374 .eeprom_ver = EEPROM_6000_EEPROM_VERSION, 422 .eeprom_ver = EEPROM_6000G2_EEPROM_VERSION,
375 .eeprom_calib_ver = EEPROM_6000_TX_POWER_VERSION, 423 .eeprom_calib_ver = EEPROM_6000G2_TX_POWER_VERSION,
376 .num_of_queues = IWLAGN_NUM_QUEUES, 424 .num_of_queues = IWLAGN_NUM_QUEUES,
377 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES, 425 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
378 .mod_params = &iwlagn_mod_params, 426 .mod_params = &iwlagn_mod_params,
@@ -381,7 +429,7 @@ struct iwl_cfg iwl6000i_g2_2agn_cfg = {
381 .pll_cfg_val = 0, 429 .pll_cfg_val = 0,
382 .set_l0s = true, 430 .set_l0s = true,
383 .use_bsm = false, 431 .use_bsm = false,
384 .pa_type = IWL_PA_INTERNAL, 432 .pa_type = IWL_PA_SYSTEM,
385 .max_ll_items = OTP_MAX_LL_ITEMS_6x00, 433 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
386 .shadow_ram_support = true, 434 .shadow_ram_support = true,
387 .ht_greenfield_support = true, 435 .ht_greenfield_support = true,
@@ -452,7 +500,6 @@ struct iwl_cfg iwl6000i_2abg_cfg = {
452 .pa_type = IWL_PA_INTERNAL, 500 .pa_type = IWL_PA_INTERNAL,
453 .max_ll_items = OTP_MAX_LL_ITEMS_6x00, 501 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
454 .shadow_ram_support = true, 502 .shadow_ram_support = true,
455 .ht_greenfield_support = true,
456 .led_compensation = 51, 503 .led_compensation = 51,
457 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS, 504 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
458 .supports_idle = true, 505 .supports_idle = true,
@@ -485,7 +532,6 @@ struct iwl_cfg iwl6000i_2bg_cfg = {
485 .pa_type = IWL_PA_INTERNAL, 532 .pa_type = IWL_PA_INTERNAL,
486 .max_ll_items = OTP_MAX_LL_ITEMS_6x00, 533 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
487 .shadow_ram_support = true, 534 .shadow_ram_support = true,
488 .ht_greenfield_support = true,
489 .led_compensation = 51, 535 .led_compensation = 51,
490 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS, 536 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
491 .supports_idle = true, 537 .supports_idle = true,
@@ -552,7 +598,6 @@ struct iwl_cfg iwl6050_2abg_cfg = {
552 .pa_type = IWL_PA_SYSTEM, 598 .pa_type = IWL_PA_SYSTEM,
553 .max_ll_items = OTP_MAX_LL_ITEMS_6x50, 599 .max_ll_items = OTP_MAX_LL_ITEMS_6x50,
554 .shadow_ram_support = true, 600 .shadow_ram_support = true,
555 .ht_greenfield_support = true,
556 .led_compensation = 51, 601 .led_compensation = 51,
557 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS, 602 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
558 .supports_idle = true, 603 .supports_idle = true,
@@ -600,3 +645,4 @@ struct iwl_cfg iwl6000_3agn_cfg = {
600 645
601MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX)); 646MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX));
602MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_MAX)); 647MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_MAX));
648MODULE_FIRMWARE(IWL6000G2_MODULE_FIRMWARE(IWL6000G2_UCODE_API_MAX));
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c
new file mode 100644
index 000000000000..f249b706bf17
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c
@@ -0,0 +1,834 @@
1/******************************************************************************
2*
3* GPL LICENSE SUMMARY
4*
5* Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
6*
7* This program is free software; you can redistribute it and/or modify
8* it under the terms of version 2 of the GNU General Public License as
9* published by the Free Software Foundation.
10*
11* This program is distributed in the hope that it will be useful, but
12* WITHOUT ANY WARRANTY; without even the implied warranty of
13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14* General Public License for more details.
15*
16* You should have received a copy of the GNU General Public License
17* along with this program; if not, write to the Free Software
18* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19* USA
20*
21* The full GNU General Public License is included in this distribution
22* in the file called LICENSE.GPL.
23*
24* Contact Information:
25* Intel Linux Wireless <ilw@linux.intel.com>
26* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27*****************************************************************************/
28
29#include "iwl-agn-debugfs.h"
30
31ssize_t iwl_ucode_rx_stats_read(struct file *file, char __user *user_buf,
32 size_t count, loff_t *ppos)
33 {
34 struct iwl_priv *priv = file->private_data;
35 int pos = 0;
36 char *buf;
37 int bufsz = sizeof(struct statistics_rx_phy) * 40 +
38 sizeof(struct statistics_rx_non_phy) * 40 +
39 sizeof(struct statistics_rx_ht_phy) * 40 + 400;
40 ssize_t ret;
41 struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
42 struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
43 struct statistics_rx_non_phy *general, *accum_general;
44 struct statistics_rx_non_phy *delta_general, *max_general;
45 struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
46
47 if (!iwl_is_alive(priv))
48 return -EAGAIN;
49
50 buf = kzalloc(bufsz, GFP_KERNEL);
51 if (!buf) {
52 IWL_ERR(priv, "Can not allocate Buffer\n");
53 return -ENOMEM;
54 }
55
56 /*
57 * the statistic information display here is based on
58 * the last statistics notification from uCode
59 * might not reflect the current uCode activity
60 */
61 ofdm = &priv->statistics.rx.ofdm;
62 cck = &priv->statistics.rx.cck;
63 general = &priv->statistics.rx.general;
64 ht = &priv->statistics.rx.ofdm_ht;
65 accum_ofdm = &priv->accum_statistics.rx.ofdm;
66 accum_cck = &priv->accum_statistics.rx.cck;
67 accum_general = &priv->accum_statistics.rx.general;
68 accum_ht = &priv->accum_statistics.rx.ofdm_ht;
69 delta_ofdm = &priv->delta_statistics.rx.ofdm;
70 delta_cck = &priv->delta_statistics.rx.cck;
71 delta_general = &priv->delta_statistics.rx.general;
72 delta_ht = &priv->delta_statistics.rx.ofdm_ht;
73 max_ofdm = &priv->max_delta.rx.ofdm;
74 max_cck = &priv->max_delta.rx.cck;
75 max_general = &priv->max_delta.rx.general;
76 max_ht = &priv->max_delta.rx.ofdm_ht;
77
78 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
79 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
80 "acumulative delta max\n",
81 "Statistics_Rx - OFDM:");
82 pos += scnprintf(buf + pos, bufsz - pos,
83 " %-30s %10u %10u %10u %10u\n",
84 "ina_cnt:", le32_to_cpu(ofdm->ina_cnt),
85 accum_ofdm->ina_cnt,
86 delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
87 pos += scnprintf(buf + pos, bufsz - pos,
88 " %-30s %10u %10u %10u %10u\n",
89 "fina_cnt:",
90 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
91 delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
92 pos += scnprintf(buf + pos, bufsz - pos,
93 " %-30s %10u %10u %10u %10u\n",
94 "plcp_err:",
95 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
96 delta_ofdm->plcp_err, max_ofdm->plcp_err);
97 pos += scnprintf(buf + pos, bufsz - pos,
98 " %-30s %10u %10u %10u %10u\n", "crc32_err:",
99 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
100 delta_ofdm->crc32_err, max_ofdm->crc32_err);
101 pos += scnprintf(buf + pos, bufsz - pos,
102 " %-30s %10u %10u %10u %10u\n", "overrun_err:",
103 le32_to_cpu(ofdm->overrun_err),
104 accum_ofdm->overrun_err, delta_ofdm->overrun_err,
105 max_ofdm->overrun_err);
106 pos += scnprintf(buf + pos, bufsz - pos,
107 " %-30s %10u %10u %10u %10u\n",
108 "early_overrun_err:",
109 le32_to_cpu(ofdm->early_overrun_err),
110 accum_ofdm->early_overrun_err,
111 delta_ofdm->early_overrun_err,
112 max_ofdm->early_overrun_err);
113 pos += scnprintf(buf + pos, bufsz - pos,
114 " %-30s %10u %10u %10u %10u\n",
115 "crc32_good:", le32_to_cpu(ofdm->crc32_good),
116 accum_ofdm->crc32_good, delta_ofdm->crc32_good,
117 max_ofdm->crc32_good);
118 pos += scnprintf(buf + pos, bufsz - pos,
119 " %-30s %10u %10u %10u %10u\n", "false_alarm_cnt:",
120 le32_to_cpu(ofdm->false_alarm_cnt),
121 accum_ofdm->false_alarm_cnt,
122 delta_ofdm->false_alarm_cnt,
123 max_ofdm->false_alarm_cnt);
124 pos += scnprintf(buf + pos, bufsz - pos,
125 " %-30s %10u %10u %10u %10u\n",
126 "fina_sync_err_cnt:",
127 le32_to_cpu(ofdm->fina_sync_err_cnt),
128 accum_ofdm->fina_sync_err_cnt,
129 delta_ofdm->fina_sync_err_cnt,
130 max_ofdm->fina_sync_err_cnt);
131 pos += scnprintf(buf + pos, bufsz - pos,
132 " %-30s %10u %10u %10u %10u\n", "sfd_timeout:",
133 le32_to_cpu(ofdm->sfd_timeout),
134 accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout,
135 max_ofdm->sfd_timeout);
136 pos += scnprintf(buf + pos, bufsz - pos,
137 " %-30s %10u %10u %10u %10u\n", "fina_timeout:",
138 le32_to_cpu(ofdm->fina_timeout),
139 accum_ofdm->fina_timeout, delta_ofdm->fina_timeout,
140 max_ofdm->fina_timeout);
141 pos += scnprintf(buf + pos, bufsz - pos,
142 " %-30s %10u %10u %10u %10u\n",
143 "unresponded_rts:",
144 le32_to_cpu(ofdm->unresponded_rts),
145 accum_ofdm->unresponded_rts,
146 delta_ofdm->unresponded_rts,
147 max_ofdm->unresponded_rts);
148 pos += scnprintf(buf + pos, bufsz - pos,
149 " %-30s %10u %10u %10u %10u\n",
150 "rxe_frame_lmt_ovrun:",
151 le32_to_cpu(ofdm->rxe_frame_limit_overrun),
152 accum_ofdm->rxe_frame_limit_overrun,
153 delta_ofdm->rxe_frame_limit_overrun,
154 max_ofdm->rxe_frame_limit_overrun);
155 pos += scnprintf(buf + pos, bufsz - pos,
156 " %-30s %10u %10u %10u %10u\n", "sent_ack_cnt:",
157 le32_to_cpu(ofdm->sent_ack_cnt),
158 accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt,
159 max_ofdm->sent_ack_cnt);
160 pos += scnprintf(buf + pos, bufsz - pos,
161 " %-30s %10u %10u %10u %10u\n", "sent_cts_cnt:",
162 le32_to_cpu(ofdm->sent_cts_cnt),
163 accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt,
164 max_ofdm->sent_cts_cnt);
165 pos += scnprintf(buf + pos, bufsz - pos,
166 " %-30s %10u %10u %10u %10u\n",
167 "sent_ba_rsp_cnt:",
168 le32_to_cpu(ofdm->sent_ba_rsp_cnt),
169 accum_ofdm->sent_ba_rsp_cnt,
170 delta_ofdm->sent_ba_rsp_cnt,
171 max_ofdm->sent_ba_rsp_cnt);
172 pos += scnprintf(buf + pos, bufsz - pos,
173 " %-30s %10u %10u %10u %10u\n", "dsp_self_kill:",
174 le32_to_cpu(ofdm->dsp_self_kill),
175 accum_ofdm->dsp_self_kill,
176 delta_ofdm->dsp_self_kill,
177 max_ofdm->dsp_self_kill);
178 pos += scnprintf(buf + pos, bufsz - pos,
179 " %-30s %10u %10u %10u %10u\n",
180 "mh_format_err:",
181 le32_to_cpu(ofdm->mh_format_err),
182 accum_ofdm->mh_format_err,
183 delta_ofdm->mh_format_err,
184 max_ofdm->mh_format_err);
185 pos += scnprintf(buf + pos, bufsz - pos,
186 " %-30s %10u %10u %10u %10u\n",
187 "re_acq_main_rssi_sum:",
188 le32_to_cpu(ofdm->re_acq_main_rssi_sum),
189 accum_ofdm->re_acq_main_rssi_sum,
190 delta_ofdm->re_acq_main_rssi_sum,
191 max_ofdm->re_acq_main_rssi_sum);
192
193 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
194 "acumulative delta max\n",
195 "Statistics_Rx - CCK:");
196 pos += scnprintf(buf + pos, bufsz - pos,
197 " %-30s %10u %10u %10u %10u\n",
198 "ina_cnt:",
199 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
200 delta_cck->ina_cnt, max_cck->ina_cnt);
201 pos += scnprintf(buf + pos, bufsz - pos,
202 " %-30s %10u %10u %10u %10u\n",
203 "fina_cnt:",
204 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
205 delta_cck->fina_cnt, max_cck->fina_cnt);
206 pos += scnprintf(buf + pos, bufsz - pos,
207 " %-30s %10u %10u %10u %10u\n",
208 "plcp_err:",
209 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
210 delta_cck->plcp_err, max_cck->plcp_err);
211 pos += scnprintf(buf + pos, bufsz - pos,
212 " %-30s %10u %10u %10u %10u\n",
213 "crc32_err:",
214 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
215 delta_cck->crc32_err, max_cck->crc32_err);
216 pos += scnprintf(buf + pos, bufsz - pos,
217 " %-30s %10u %10u %10u %10u\n",
218 "overrun_err:",
219 le32_to_cpu(cck->overrun_err),
220 accum_cck->overrun_err, delta_cck->overrun_err,
221 max_cck->overrun_err);
222 pos += scnprintf(buf + pos, bufsz - pos,
223 " %-30s %10u %10u %10u %10u\n",
224 "early_overrun_err:",
225 le32_to_cpu(cck->early_overrun_err),
226 accum_cck->early_overrun_err,
227 delta_cck->early_overrun_err,
228 max_cck->early_overrun_err);
229 pos += scnprintf(buf + pos, bufsz - pos,
230 " %-30s %10u %10u %10u %10u\n",
231 "crc32_good:",
232 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
233 delta_cck->crc32_good, max_cck->crc32_good);
234 pos += scnprintf(buf + pos, bufsz - pos,
235 " %-30s %10u %10u %10u %10u\n",
236 "false_alarm_cnt:",
237 le32_to_cpu(cck->false_alarm_cnt),
238 accum_cck->false_alarm_cnt,
239 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
240 pos += scnprintf(buf + pos, bufsz - pos,
241 " %-30s %10u %10u %10u %10u\n",
242 "fina_sync_err_cnt:",
243 le32_to_cpu(cck->fina_sync_err_cnt),
244 accum_cck->fina_sync_err_cnt,
245 delta_cck->fina_sync_err_cnt,
246 max_cck->fina_sync_err_cnt);
247 pos += scnprintf(buf + pos, bufsz - pos,
248 " %-30s %10u %10u %10u %10u\n",
249 "sfd_timeout:",
250 le32_to_cpu(cck->sfd_timeout),
251 accum_cck->sfd_timeout, delta_cck->sfd_timeout,
252 max_cck->sfd_timeout);
253 pos += scnprintf(buf + pos, bufsz - pos,
254 " %-30s %10u %10u %10u %10u\n", "fina_timeout:",
255 le32_to_cpu(cck->fina_timeout),
256 accum_cck->fina_timeout, delta_cck->fina_timeout,
257 max_cck->fina_timeout);
258 pos += scnprintf(buf + pos, bufsz - pos,
259 " %-30s %10u %10u %10u %10u\n",
260 "unresponded_rts:",
261 le32_to_cpu(cck->unresponded_rts),
262 accum_cck->unresponded_rts, delta_cck->unresponded_rts,
263 max_cck->unresponded_rts);
264 pos += scnprintf(buf + pos, bufsz - pos,
265 " %-30s %10u %10u %10u %10u\n",
266 "rxe_frame_lmt_ovrun:",
267 le32_to_cpu(cck->rxe_frame_limit_overrun),
268 accum_cck->rxe_frame_limit_overrun,
269 delta_cck->rxe_frame_limit_overrun,
270 max_cck->rxe_frame_limit_overrun);
271 pos += scnprintf(buf + pos, bufsz - pos,
272 " %-30s %10u %10u %10u %10u\n", "sent_ack_cnt:",
273 le32_to_cpu(cck->sent_ack_cnt),
274 accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt,
275 max_cck->sent_ack_cnt);
276 pos += scnprintf(buf + pos, bufsz - pos,
277 " %-30s %10u %10u %10u %10u\n", "sent_cts_cnt:",
278 le32_to_cpu(cck->sent_cts_cnt),
279 accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt,
280 max_cck->sent_cts_cnt);
281 pos += scnprintf(buf + pos, bufsz - pos,
282 " %-30s %10u %10u %10u %10u\n", "sent_ba_rsp_cnt:",
283 le32_to_cpu(cck->sent_ba_rsp_cnt),
284 accum_cck->sent_ba_rsp_cnt,
285 delta_cck->sent_ba_rsp_cnt,
286 max_cck->sent_ba_rsp_cnt);
287 pos += scnprintf(buf + pos, bufsz - pos,
288 " %-30s %10u %10u %10u %10u\n", "dsp_self_kill:",
289 le32_to_cpu(cck->dsp_self_kill),
290 accum_cck->dsp_self_kill, delta_cck->dsp_self_kill,
291 max_cck->dsp_self_kill);
292 pos += scnprintf(buf + pos, bufsz - pos,
293 " %-30s %10u %10u %10u %10u\n", "mh_format_err:",
294 le32_to_cpu(cck->mh_format_err),
295 accum_cck->mh_format_err, delta_cck->mh_format_err,
296 max_cck->mh_format_err);
297 pos += scnprintf(buf + pos, bufsz - pos,
298 " %-30s %10u %10u %10u %10u\n",
299 "re_acq_main_rssi_sum:",
300 le32_to_cpu(cck->re_acq_main_rssi_sum),
301 accum_cck->re_acq_main_rssi_sum,
302 delta_cck->re_acq_main_rssi_sum,
303 max_cck->re_acq_main_rssi_sum);
304
305 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
306 "acumulative delta max\n",
307 "Statistics_Rx - GENERAL:");
308 pos += scnprintf(buf + pos, bufsz - pos,
309 " %-30s %10u %10u %10u %10u\n", "bogus_cts:",
310 le32_to_cpu(general->bogus_cts),
311 accum_general->bogus_cts, delta_general->bogus_cts,
312 max_general->bogus_cts);
313 pos += scnprintf(buf + pos, bufsz - pos,
314 " %-30s %10u %10u %10u %10u\n", "bogus_ack:",
315 le32_to_cpu(general->bogus_ack),
316 accum_general->bogus_ack, delta_general->bogus_ack,
317 max_general->bogus_ack);
318 pos += scnprintf(buf + pos, bufsz - pos,
319 " %-30s %10u %10u %10u %10u\n",
320 "non_bssid_frames:",
321 le32_to_cpu(general->non_bssid_frames),
322 accum_general->non_bssid_frames,
323 delta_general->non_bssid_frames,
324 max_general->non_bssid_frames);
325 pos += scnprintf(buf + pos, bufsz - pos,
326 " %-30s %10u %10u %10u %10u\n",
327 "filtered_frames:",
328 le32_to_cpu(general->filtered_frames),
329 accum_general->filtered_frames,
330 delta_general->filtered_frames,
331 max_general->filtered_frames);
332 pos += scnprintf(buf + pos, bufsz - pos,
333 " %-30s %10u %10u %10u %10u\n",
334 "non_channel_beacons:",
335 le32_to_cpu(general->non_channel_beacons),
336 accum_general->non_channel_beacons,
337 delta_general->non_channel_beacons,
338 max_general->non_channel_beacons);
339 pos += scnprintf(buf + pos, bufsz - pos,
340 " %-30s %10u %10u %10u %10u\n",
341 "channel_beacons:",
342 le32_to_cpu(general->channel_beacons),
343 accum_general->channel_beacons,
344 delta_general->channel_beacons,
345 max_general->channel_beacons);
346 pos += scnprintf(buf + pos, bufsz - pos,
347 " %-30s %10u %10u %10u %10u\n",
348 "num_missed_bcon:",
349 le32_to_cpu(general->num_missed_bcon),
350 accum_general->num_missed_bcon,
351 delta_general->num_missed_bcon,
352 max_general->num_missed_bcon);
353 pos += scnprintf(buf + pos, bufsz - pos,
354 " %-30s %10u %10u %10u %10u\n",
355 "adc_rx_saturation_time:",
356 le32_to_cpu(general->adc_rx_saturation_time),
357 accum_general->adc_rx_saturation_time,
358 delta_general->adc_rx_saturation_time,
359 max_general->adc_rx_saturation_time);
360 pos += scnprintf(buf + pos, bufsz - pos,
361 " %-30s %10u %10u %10u %10u\n",
362 "ina_detect_search_tm:",
363 le32_to_cpu(general->ina_detection_search_time),
364 accum_general->ina_detection_search_time,
365 delta_general->ina_detection_search_time,
366 max_general->ina_detection_search_time);
367 pos += scnprintf(buf + pos, bufsz - pos,
368 " %-30s %10u %10u %10u %10u\n",
369 "beacon_silence_rssi_a:",
370 le32_to_cpu(general->beacon_silence_rssi_a),
371 accum_general->beacon_silence_rssi_a,
372 delta_general->beacon_silence_rssi_a,
373 max_general->beacon_silence_rssi_a);
374 pos += scnprintf(buf + pos, bufsz - pos,
375 " %-30s %10u %10u %10u %10u\n",
376 "beacon_silence_rssi_b:",
377 le32_to_cpu(general->beacon_silence_rssi_b),
378 accum_general->beacon_silence_rssi_b,
379 delta_general->beacon_silence_rssi_b,
380 max_general->beacon_silence_rssi_b);
381 pos += scnprintf(buf + pos, bufsz - pos,
382 " %-30s %10u %10u %10u %10u\n",
383 "beacon_silence_rssi_c:",
384 le32_to_cpu(general->beacon_silence_rssi_c),
385 accum_general->beacon_silence_rssi_c,
386 delta_general->beacon_silence_rssi_c,
387 max_general->beacon_silence_rssi_c);
388 pos += scnprintf(buf + pos, bufsz - pos,
389 " %-30s %10u %10u %10u %10u\n",
390 "interference_data_flag:",
391 le32_to_cpu(general->interference_data_flag),
392 accum_general->interference_data_flag,
393 delta_general->interference_data_flag,
394 max_general->interference_data_flag);
395 pos += scnprintf(buf + pos, bufsz - pos,
396 " %-30s %10u %10u %10u %10u\n",
397 "channel_load:",
398 le32_to_cpu(general->channel_load),
399 accum_general->channel_load,
400 delta_general->channel_load,
401 max_general->channel_load);
402 pos += scnprintf(buf + pos, bufsz - pos,
403 " %-30s %10u %10u %10u %10u\n",
404 "dsp_false_alarms:",
405 le32_to_cpu(general->dsp_false_alarms),
406 accum_general->dsp_false_alarms,
407 delta_general->dsp_false_alarms,
408 max_general->dsp_false_alarms);
409 pos += scnprintf(buf + pos, bufsz - pos,
410 " %-30s %10u %10u %10u %10u\n",
411 "beacon_rssi_a:",
412 le32_to_cpu(general->beacon_rssi_a),
413 accum_general->beacon_rssi_a,
414 delta_general->beacon_rssi_a,
415 max_general->beacon_rssi_a);
416 pos += scnprintf(buf + pos, bufsz - pos,
417 " %-30s %10u %10u %10u %10u\n",
418 "beacon_rssi_b:",
419 le32_to_cpu(general->beacon_rssi_b),
420 accum_general->beacon_rssi_b,
421 delta_general->beacon_rssi_b,
422 max_general->beacon_rssi_b);
423 pos += scnprintf(buf + pos, bufsz - pos,
424 " %-30s %10u %10u %10u %10u\n",
425 "beacon_rssi_c:",
426 le32_to_cpu(general->beacon_rssi_c),
427 accum_general->beacon_rssi_c,
428 delta_general->beacon_rssi_c,
429 max_general->beacon_rssi_c);
430 pos += scnprintf(buf + pos, bufsz - pos,
431 " %-30s %10u %10u %10u %10u\n",
432 "beacon_energy_a:",
433 le32_to_cpu(general->beacon_energy_a),
434 accum_general->beacon_energy_a,
435 delta_general->beacon_energy_a,
436 max_general->beacon_energy_a);
437 pos += scnprintf(buf + pos, bufsz - pos,
438 " %-30s %10u %10u %10u %10u\n",
439 "beacon_energy_b:",
440 le32_to_cpu(general->beacon_energy_b),
441 accum_general->beacon_energy_b,
442 delta_general->beacon_energy_b,
443 max_general->beacon_energy_b);
444 pos += scnprintf(buf + pos, bufsz - pos,
445 " %-30s %10u %10u %10u %10u\n",
446 "beacon_energy_c:",
447 le32_to_cpu(general->beacon_energy_c),
448 accum_general->beacon_energy_c,
449 delta_general->beacon_energy_c,
450 max_general->beacon_energy_c);
451
452 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Rx - OFDM_HT:\n");
453 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
454 "acumulative delta max\n",
455 "Statistics_Rx - OFDM_HT:");
456 pos += scnprintf(buf + pos, bufsz - pos,
457 " %-30s %10u %10u %10u %10u\n",
458 "plcp_err:",
459 le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
460 delta_ht->plcp_err, max_ht->plcp_err);
461 pos += scnprintf(buf + pos, bufsz - pos,
462 " %-30s %10u %10u %10u %10u\n",
463 "overrun_err:",
464 le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
465 delta_ht->overrun_err, max_ht->overrun_err);
466 pos += scnprintf(buf + pos, bufsz - pos,
467 " %-30s %10u %10u %10u %10u\n",
468 "early_overrun_err:",
469 le32_to_cpu(ht->early_overrun_err),
470 accum_ht->early_overrun_err,
471 delta_ht->early_overrun_err,
472 max_ht->early_overrun_err);
473 pos += scnprintf(buf + pos, bufsz - pos,
474 " %-30s %10u %10u %10u %10u\n",
475 "crc32_good:",
476 le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
477 delta_ht->crc32_good, max_ht->crc32_good);
478 pos += scnprintf(buf + pos, bufsz - pos,
479 " %-30s %10u %10u %10u %10u\n",
480 "crc32_err:",
481 le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
482 delta_ht->crc32_err, max_ht->crc32_err);
483 pos += scnprintf(buf + pos, bufsz - pos,
484 " %-30s %10u %10u %10u %10u\n",
485 "mh_format_err:",
486 le32_to_cpu(ht->mh_format_err),
487 accum_ht->mh_format_err,
488 delta_ht->mh_format_err, max_ht->mh_format_err);
489 pos += scnprintf(buf + pos, bufsz - pos,
490 " %-30s %10u %10u %10u %10u\n",
491 "agg_crc32_good:",
492 le32_to_cpu(ht->agg_crc32_good),
493 accum_ht->agg_crc32_good,
494 delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
495 pos += scnprintf(buf + pos, bufsz - pos,
496 " %-30s %10u %10u %10u %10u\n",
497 "agg_mpdu_cnt:",
498 le32_to_cpu(ht->agg_mpdu_cnt),
499 accum_ht->agg_mpdu_cnt,
500 delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
501 pos += scnprintf(buf + pos, bufsz - pos,
502 " %-30s %10u %10u %10u %10u\n",
503 "agg_cnt:",
504 le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
505 delta_ht->agg_cnt, max_ht->agg_cnt);
506 pos += scnprintf(buf + pos, bufsz - pos,
507 " %-30s %10u %10u %10u %10u\n",
508 "unsupport_mcs:",
509 le32_to_cpu(ht->unsupport_mcs),
510 accum_ht->unsupport_mcs,
511 delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
512
513 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
514 kfree(buf);
515 return ret;
516}
517
518ssize_t iwl_ucode_tx_stats_read(struct file *file,
519 char __user *user_buf,
520 size_t count, loff_t *ppos)
521{
522 struct iwl_priv *priv = file->private_data;
523 int pos = 0;
524 char *buf;
525 int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
526 ssize_t ret;
527 struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
528
529 if (!iwl_is_alive(priv))
530 return -EAGAIN;
531
532 buf = kzalloc(bufsz, GFP_KERNEL);
533 if (!buf) {
534 IWL_ERR(priv, "Can not allocate Buffer\n");
535 return -ENOMEM;
536 }
537
538 /* the statistic information display here is based on
539 * the last statistics notification from uCode
540 * might not reflect the current uCode activity
541 */
542 tx = &priv->statistics.tx;
543 accum_tx = &priv->accum_statistics.tx;
544 delta_tx = &priv->delta_statistics.tx;
545 max_tx = &priv->max_delta.tx;
546 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
547 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
548 "acumulative delta max\n",
549 "Statistics_Tx:");
550 pos += scnprintf(buf + pos, bufsz - pos,
551 " %-30s %10u %10u %10u %10u\n",
552 "preamble:",
553 le32_to_cpu(tx->preamble_cnt),
554 accum_tx->preamble_cnt,
555 delta_tx->preamble_cnt, max_tx->preamble_cnt);
556 pos += scnprintf(buf + pos, bufsz - pos,
557 " %-30s %10u %10u %10u %10u\n",
558 "rx_detected_cnt:",
559 le32_to_cpu(tx->rx_detected_cnt),
560 accum_tx->rx_detected_cnt,
561 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
562 pos += scnprintf(buf + pos, bufsz - pos,
563 " %-30s %10u %10u %10u %10u\n",
564 "bt_prio_defer_cnt:",
565 le32_to_cpu(tx->bt_prio_defer_cnt),
566 accum_tx->bt_prio_defer_cnt,
567 delta_tx->bt_prio_defer_cnt,
568 max_tx->bt_prio_defer_cnt);
569 pos += scnprintf(buf + pos, bufsz - pos,
570 " %-30s %10u %10u %10u %10u\n",
571 "bt_prio_kill_cnt:",
572 le32_to_cpu(tx->bt_prio_kill_cnt),
573 accum_tx->bt_prio_kill_cnt,
574 delta_tx->bt_prio_kill_cnt,
575 max_tx->bt_prio_kill_cnt);
576 pos += scnprintf(buf + pos, bufsz - pos,
577 " %-30s %10u %10u %10u %10u\n",
578 "few_bytes_cnt:",
579 le32_to_cpu(tx->few_bytes_cnt),
580 accum_tx->few_bytes_cnt,
581 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
582 pos += scnprintf(buf + pos, bufsz - pos,
583 " %-30s %10u %10u %10u %10u\n",
584 "cts_timeout:",
585 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
586 delta_tx->cts_timeout, max_tx->cts_timeout);
587 pos += scnprintf(buf + pos, bufsz - pos,
588 " %-30s %10u %10u %10u %10u\n",
589 "ack_timeout:",
590 le32_to_cpu(tx->ack_timeout),
591 accum_tx->ack_timeout,
592 delta_tx->ack_timeout, max_tx->ack_timeout);
593 pos += scnprintf(buf + pos, bufsz - pos,
594 " %-30s %10u %10u %10u %10u\n",
595 "expected_ack_cnt:",
596 le32_to_cpu(tx->expected_ack_cnt),
597 accum_tx->expected_ack_cnt,
598 delta_tx->expected_ack_cnt,
599 max_tx->expected_ack_cnt);
600 pos += scnprintf(buf + pos, bufsz - pos,
601 " %-30s %10u %10u %10u %10u\n",
602 "actual_ack_cnt:",
603 le32_to_cpu(tx->actual_ack_cnt),
604 accum_tx->actual_ack_cnt,
605 delta_tx->actual_ack_cnt,
606 max_tx->actual_ack_cnt);
607 pos += scnprintf(buf + pos, bufsz - pos,
608 " %-30s %10u %10u %10u %10u\n",
609 "dump_msdu_cnt:",
610 le32_to_cpu(tx->dump_msdu_cnt),
611 accum_tx->dump_msdu_cnt,
612 delta_tx->dump_msdu_cnt,
613 max_tx->dump_msdu_cnt);
614 pos += scnprintf(buf + pos, bufsz - pos,
615 " %-30s %10u %10u %10u %10u\n",
616 "abort_nxt_frame_mismatch:",
617 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
618 accum_tx->burst_abort_next_frame_mismatch_cnt,
619 delta_tx->burst_abort_next_frame_mismatch_cnt,
620 max_tx->burst_abort_next_frame_mismatch_cnt);
621 pos += scnprintf(buf + pos, bufsz - pos,
622 " %-30s %10u %10u %10u %10u\n",
623 "abort_missing_nxt_frame:",
624 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
625 accum_tx->burst_abort_missing_next_frame_cnt,
626 delta_tx->burst_abort_missing_next_frame_cnt,
627 max_tx->burst_abort_missing_next_frame_cnt);
628 pos += scnprintf(buf + pos, bufsz - pos,
629 " %-30s %10u %10u %10u %10u\n",
630 "cts_timeout_collision:",
631 le32_to_cpu(tx->cts_timeout_collision),
632 accum_tx->cts_timeout_collision,
633 delta_tx->cts_timeout_collision,
634 max_tx->cts_timeout_collision);
635 pos += scnprintf(buf + pos, bufsz - pos,
636 " %-30s %10u %10u %10u %10u\n",
637 "ack_ba_timeout_collision:",
638 le32_to_cpu(tx->ack_or_ba_timeout_collision),
639 accum_tx->ack_or_ba_timeout_collision,
640 delta_tx->ack_or_ba_timeout_collision,
641 max_tx->ack_or_ba_timeout_collision);
642 pos += scnprintf(buf + pos, bufsz - pos,
643 " %-30s %10u %10u %10u %10u\n",
644 "agg ba_timeout:",
645 le32_to_cpu(tx->agg.ba_timeout),
646 accum_tx->agg.ba_timeout,
647 delta_tx->agg.ba_timeout,
648 max_tx->agg.ba_timeout);
649 pos += scnprintf(buf + pos, bufsz - pos,
650 " %-30s %10u %10u %10u %10u\n",
651 "agg ba_resched_frames:",
652 le32_to_cpu(tx->agg.ba_reschedule_frames),
653 accum_tx->agg.ba_reschedule_frames,
654 delta_tx->agg.ba_reschedule_frames,
655 max_tx->agg.ba_reschedule_frames);
656 pos += scnprintf(buf + pos, bufsz - pos,
657 " %-30s %10u %10u %10u %10u\n",
658 "agg scd_query_agg_frame:",
659 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
660 accum_tx->agg.scd_query_agg_frame_cnt,
661 delta_tx->agg.scd_query_agg_frame_cnt,
662 max_tx->agg.scd_query_agg_frame_cnt);
663 pos += scnprintf(buf + pos, bufsz - pos,
664 " %-30s %10u %10u %10u %10u\n",
665 "agg scd_query_no_agg:",
666 le32_to_cpu(tx->agg.scd_query_no_agg),
667 accum_tx->agg.scd_query_no_agg,
668 delta_tx->agg.scd_query_no_agg,
669 max_tx->agg.scd_query_no_agg);
670 pos += scnprintf(buf + pos, bufsz - pos,
671 " %-30s %10u %10u %10u %10u\n",
672 "agg scd_query_agg:",
673 le32_to_cpu(tx->agg.scd_query_agg),
674 accum_tx->agg.scd_query_agg,
675 delta_tx->agg.scd_query_agg,
676 max_tx->agg.scd_query_agg);
677 pos += scnprintf(buf + pos, bufsz - pos,
678 " %-30s %10u %10u %10u %10u\n",
679 "agg scd_query_mismatch:",
680 le32_to_cpu(tx->agg.scd_query_mismatch),
681 accum_tx->agg.scd_query_mismatch,
682 delta_tx->agg.scd_query_mismatch,
683 max_tx->agg.scd_query_mismatch);
684 pos += scnprintf(buf + pos, bufsz - pos,
685 " %-30s %10u %10u %10u %10u\n",
686 "agg frame_not_ready:",
687 le32_to_cpu(tx->agg.frame_not_ready),
688 accum_tx->agg.frame_not_ready,
689 delta_tx->agg.frame_not_ready,
690 max_tx->agg.frame_not_ready);
691 pos += scnprintf(buf + pos, bufsz - pos,
692 " %-30s %10u %10u %10u %10u\n",
693 "agg underrun:",
694 le32_to_cpu(tx->agg.underrun),
695 accum_tx->agg.underrun,
696 delta_tx->agg.underrun, max_tx->agg.underrun);
697 pos += scnprintf(buf + pos, bufsz - pos,
698 " %-30s %10u %10u %10u %10u\n",
699 "agg bt_prio_kill:",
700 le32_to_cpu(tx->agg.bt_prio_kill),
701 accum_tx->agg.bt_prio_kill,
702 delta_tx->agg.bt_prio_kill,
703 max_tx->agg.bt_prio_kill);
704 pos += scnprintf(buf + pos, bufsz - pos,
705 " %-30s %10u %10u %10u %10u\n",
706 "agg rx_ba_rsp_cnt:",
707 le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
708 accum_tx->agg.rx_ba_rsp_cnt,
709 delta_tx->agg.rx_ba_rsp_cnt,
710 max_tx->agg.rx_ba_rsp_cnt);
711
712 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
713 kfree(buf);
714 return ret;
715}
716
717ssize_t iwl_ucode_general_stats_read(struct file *file, char __user *user_buf,
718 size_t count, loff_t *ppos)
719{
720 struct iwl_priv *priv = file->private_data;
721 int pos = 0;
722 char *buf;
723 int bufsz = sizeof(struct statistics_general) * 10 + 300;
724 ssize_t ret;
725 struct statistics_general *general, *accum_general;
726 struct statistics_general *delta_general, *max_general;
727 struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
728 struct statistics_div *div, *accum_div, *delta_div, *max_div;
729
730 if (!iwl_is_alive(priv))
731 return -EAGAIN;
732
733 buf = kzalloc(bufsz, GFP_KERNEL);
734 if (!buf) {
735 IWL_ERR(priv, "Can not allocate Buffer\n");
736 return -ENOMEM;
737 }
738
739 /* the statistic information display here is based on
740 * the last statistics notification from uCode
741 * might not reflect the current uCode activity
742 */
743 general = &priv->statistics.general;
744 dbg = &priv->statistics.general.dbg;
745 div = &priv->statistics.general.div;
746 accum_general = &priv->accum_statistics.general;
747 delta_general = &priv->delta_statistics.general;
748 max_general = &priv->max_delta.general;
749 accum_dbg = &priv->accum_statistics.general.dbg;
750 delta_dbg = &priv->delta_statistics.general.dbg;
751 max_dbg = &priv->max_delta.general.dbg;
752 accum_div = &priv->accum_statistics.general.div;
753 delta_div = &priv->delta_statistics.general.div;
754 max_div = &priv->max_delta.general.div;
755 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
756 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
757 "acumulative delta max\n",
758 "Statistics_General:");
759 pos += scnprintf(buf + pos, bufsz - pos, " %-30s %10u\n",
760 "temperature:",
761 le32_to_cpu(general->temperature));
762 pos += scnprintf(buf + pos, bufsz - pos, " %-30s %10u\n",
763 "temperature_m:",
764 le32_to_cpu(general->temperature_m));
765 pos += scnprintf(buf + pos, bufsz - pos,
766 " %-30s %10u %10u %10u %10u\n",
767 "burst_check:",
768 le32_to_cpu(dbg->burst_check),
769 accum_dbg->burst_check,
770 delta_dbg->burst_check, max_dbg->burst_check);
771 pos += scnprintf(buf + pos, bufsz - pos,
772 " %-30s %10u %10u %10u %10u\n",
773 "burst_count:",
774 le32_to_cpu(dbg->burst_count),
775 accum_dbg->burst_count,
776 delta_dbg->burst_count, max_dbg->burst_count);
777 pos += scnprintf(buf + pos, bufsz - pos,
778 " %-30s %10u %10u %10u %10u\n",
779 "sleep_time:",
780 le32_to_cpu(general->sleep_time),
781 accum_general->sleep_time,
782 delta_general->sleep_time, max_general->sleep_time);
783 pos += scnprintf(buf + pos, bufsz - pos,
784 " %-30s %10u %10u %10u %10u\n",
785 "slots_out:",
786 le32_to_cpu(general->slots_out),
787 accum_general->slots_out,
788 delta_general->slots_out, max_general->slots_out);
789 pos += scnprintf(buf + pos, bufsz - pos,
790 " %-30s %10u %10u %10u %10u\n",
791 "slots_idle:",
792 le32_to_cpu(general->slots_idle),
793 accum_general->slots_idle,
794 delta_general->slots_idle, max_general->slots_idle);
795 pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n",
796 le32_to_cpu(general->ttl_timestamp));
797 pos += scnprintf(buf + pos, bufsz - pos,
798 " %-30s %10u %10u %10u %10u\n",
799 "tx_on_a:",
800 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
801 delta_div->tx_on_a, max_div->tx_on_a);
802 pos += scnprintf(buf + pos, bufsz - pos,
803 " %-30s %10u %10u %10u %10u\n",
804 "tx_on_b:",
805 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
806 delta_div->tx_on_b, max_div->tx_on_b);
807 pos += scnprintf(buf + pos, bufsz - pos,
808 " %-30s %10u %10u %10u %10u\n",
809 "exec_time:",
810 le32_to_cpu(div->exec_time), accum_div->exec_time,
811 delta_div->exec_time, max_div->exec_time);
812 pos += scnprintf(buf + pos, bufsz - pos,
813 " %-30s %10u %10u %10u %10u\n",
814 "probe_time:",
815 le32_to_cpu(div->probe_time), accum_div->probe_time,
816 delta_div->probe_time, max_div->probe_time);
817 pos += scnprintf(buf + pos, bufsz - pos,
818 " %-30s %10u %10u %10u %10u\n",
819 "rx_enable_counter:",
820 le32_to_cpu(general->rx_enable_counter),
821 accum_general->rx_enable_counter,
822 delta_general->rx_enable_counter,
823 max_general->rx_enable_counter);
824 pos += scnprintf(buf + pos, bufsz - pos,
825 " %-30s %10u %10u %10u %10u\n",
826 "num_of_sos_states:",
827 le32_to_cpu(general->num_of_sos_states),
828 accum_general->num_of_sos_states,
829 delta_general->num_of_sos_states,
830 max_general->num_of_sos_states);
831 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
832 kfree(buf);
833 return ret;
834}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.h b/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.h
new file mode 100644
index 000000000000..59b1f25f0d85
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.h
@@ -0,0 +1,56 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
29#include "iwl-dev.h"
30#include "iwl-core.h"
31#include "iwl-debug.h"
32
33#ifdef CONFIG_IWLWIFI_DEBUGFS
34ssize_t iwl_ucode_rx_stats_read(struct file *file, char __user *user_buf,
35 size_t count, loff_t *ppos);
36ssize_t iwl_ucode_tx_stats_read(struct file *file, char __user *user_buf,
37 size_t count, loff_t *ppos);
38ssize_t iwl_ucode_general_stats_read(struct file *file, char __user *user_buf,
39 size_t count, loff_t *ppos);
40#else
41static ssize_t iwl_ucode_rx_stats_read(struct file *file, char __user *user_buf,
42 size_t count, loff_t *ppos)
43{
44 return 0;
45}
46static ssize_t iwl_ucode_tx_stats_read(struct file *file, char __user *user_buf,
47 size_t count, loff_t *ppos)
48{
49 return 0;
50}
51static ssize_t iwl_ucode_general_stats_read(struct file *file, char __user *user_buf,
52 size_t count, loff_t *ppos)
53{
54 return 0;
55}
56#endif
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
index 28bc8f8ba981..44ef5d93befc 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
@@ -262,6 +262,7 @@ struct iwl_hcmd_ops iwlagn_hcmd = {
262 .commit_rxon = iwl_commit_rxon, 262 .commit_rxon = iwl_commit_rxon,
263 .set_rxon_chain = iwl_set_rxon_chain, 263 .set_rxon_chain = iwl_set_rxon_chain,
264 .set_tx_ant = iwlagn_send_tx_ant_config, 264 .set_tx_ant = iwlagn_send_tx_ant_config,
265 .send_bt_config = iwl_send_bt_config,
265}; 266};
266 267
267struct iwl_hcmd_utils_ops iwlagn_hcmd_utils = { 268struct iwl_hcmd_utils_ops iwlagn_hcmd_utils = {
@@ -271,4 +272,5 @@ struct iwl_hcmd_utils_ops iwlagn_hcmd_utils = {
271 .chain_noise_reset = iwlagn_chain_noise_reset, 272 .chain_noise_reset = iwlagn_chain_noise_reset,
272 .rts_tx_cmd_flag = iwlagn_rts_tx_cmd_flag, 273 .rts_tx_cmd_flag = iwlagn_rts_tx_cmd_flag,
273 .calc_rssi = iwlagn_calc_rssi, 274 .calc_rssi = iwlagn_calc_rssi,
275 .request_scan = iwlagn_request_scan,
274}; 276};
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index c465c8590833..a27347425968 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -331,7 +331,7 @@ u16 iwlagn_eeprom_calib_version(struct iwl_priv *priv)
331 } *hdr; 331 } *hdr;
332 332
333 hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv, 333 hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv,
334 EEPROM_5000_CALIB_ALL); 334 EEPROM_CALIB_ALL);
335 return hdr->version; 335 return hdr->version;
336 336
337} 337}
@@ -348,22 +348,22 @@ static u32 eeprom_indirect_address(const struct iwl_priv *priv, u32 address)
348 348
349 switch (address & INDIRECT_TYPE_MSK) { 349 switch (address & INDIRECT_TYPE_MSK) {
350 case INDIRECT_HOST: 350 case INDIRECT_HOST:
351 offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_HOST); 351 offset = iwl_eeprom_query16(priv, EEPROM_LINK_HOST);
352 break; 352 break;
353 case INDIRECT_GENERAL: 353 case INDIRECT_GENERAL:
354 offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_GENERAL); 354 offset = iwl_eeprom_query16(priv, EEPROM_LINK_GENERAL);
355 break; 355 break;
356 case INDIRECT_REGULATORY: 356 case INDIRECT_REGULATORY:
357 offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_REGULATORY); 357 offset = iwl_eeprom_query16(priv, EEPROM_LINK_REGULATORY);
358 break; 358 break;
359 case INDIRECT_CALIBRATION: 359 case INDIRECT_CALIBRATION:
360 offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_CALIBRATION); 360 offset = iwl_eeprom_query16(priv, EEPROM_LINK_CALIBRATION);
361 break; 361 break;
362 case INDIRECT_PROCESS_ADJST: 362 case INDIRECT_PROCESS_ADJST:
363 offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_PROCESS_ADJST); 363 offset = iwl_eeprom_query16(priv, EEPROM_LINK_PROCESS_ADJST);
364 break; 364 break;
365 case INDIRECT_OTHERS: 365 case INDIRECT_OTHERS:
366 offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_OTHERS); 366 offset = iwl_eeprom_query16(priv, EEPROM_LINK_OTHERS);
367 break; 367 break;
368 default: 368 default:
369 IWL_ERR(priv, "illegal indirect type: 0x%X\n", 369 IWL_ERR(priv, "illegal indirect type: 0x%X\n",
@@ -1111,3 +1111,405 @@ void iwlagn_rx_reply_rx_phy(struct iwl_priv *priv,
1111 memcpy(&priv->_agn.last_phy_res, pkt->u.raw, 1111 memcpy(&priv->_agn.last_phy_res, pkt->u.raw,
1112 sizeof(struct iwl_rx_phy_res)); 1112 sizeof(struct iwl_rx_phy_res));
1113} 1113}
1114
1115static int iwl_get_single_channel_for_scan(struct iwl_priv *priv,
1116 enum ieee80211_band band,
1117 struct iwl_scan_channel *scan_ch)
1118{
1119 const struct ieee80211_supported_band *sband;
1120 const struct iwl_channel_info *ch_info;
1121 u16 passive_dwell = 0;
1122 u16 active_dwell = 0;
1123 int i, added = 0;
1124 u16 channel = 0;
1125
1126 sband = iwl_get_hw_mode(priv, band);
1127 if (!sband) {
1128 IWL_ERR(priv, "invalid band\n");
1129 return added;
1130 }
1131
1132 active_dwell = iwl_get_active_dwell_time(priv, band, 0);
1133 passive_dwell = iwl_get_passive_dwell_time(priv, band);
1134
1135 if (passive_dwell <= active_dwell)
1136 passive_dwell = active_dwell + 1;
1137
1138 /* only scan single channel, good enough to reset the RF */
1139 /* pick the first valid not in-use channel */
1140 if (band == IEEE80211_BAND_5GHZ) {
1141 for (i = 14; i < priv->channel_count; i++) {
1142 if (priv->channel_info[i].channel !=
1143 le16_to_cpu(priv->staging_rxon.channel)) {
1144 channel = priv->channel_info[i].channel;
1145 ch_info = iwl_get_channel_info(priv,
1146 band, channel);
1147 if (is_channel_valid(ch_info))
1148 break;
1149 }
1150 }
1151 } else {
1152 for (i = 0; i < 14; i++) {
1153 if (priv->channel_info[i].channel !=
1154 le16_to_cpu(priv->staging_rxon.channel)) {
1155 channel =
1156 priv->channel_info[i].channel;
1157 ch_info = iwl_get_channel_info(priv,
1158 band, channel);
1159 if (is_channel_valid(ch_info))
1160 break;
1161 }
1162 }
1163 }
1164 if (channel) {
1165 scan_ch->channel = cpu_to_le16(channel);
1166 scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
1167 scan_ch->active_dwell = cpu_to_le16(active_dwell);
1168 scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
1169 /* Set txpower levels to defaults */
1170 scan_ch->dsp_atten = 110;
1171 if (band == IEEE80211_BAND_5GHZ)
1172 scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3;
1173 else
1174 scan_ch->tx_gain = ((1 << 5) | (5 << 3));
1175 added++;
1176 } else
1177 IWL_ERR(priv, "no valid channel found\n");
1178 return added;
1179}
1180
1181static int iwl_get_channels_for_scan(struct iwl_priv *priv,
1182 enum ieee80211_band band,
1183 u8 is_active, u8 n_probes,
1184 struct iwl_scan_channel *scan_ch)
1185{
1186 struct ieee80211_channel *chan;
1187 const struct ieee80211_supported_band *sband;
1188 const struct iwl_channel_info *ch_info;
1189 u16 passive_dwell = 0;
1190 u16 active_dwell = 0;
1191 int added, i;
1192 u16 channel;
1193
1194 sband = iwl_get_hw_mode(priv, band);
1195 if (!sband)
1196 return 0;
1197
1198 active_dwell = iwl_get_active_dwell_time(priv, band, n_probes);
1199 passive_dwell = iwl_get_passive_dwell_time(priv, band);
1200
1201 if (passive_dwell <= active_dwell)
1202 passive_dwell = active_dwell + 1;
1203
1204 for (i = 0, added = 0; i < priv->scan_request->n_channels; i++) {
1205 chan = priv->scan_request->channels[i];
1206
1207 if (chan->band != band)
1208 continue;
1209
1210 channel = ieee80211_frequency_to_channel(chan->center_freq);
1211 scan_ch->channel = cpu_to_le16(channel);
1212
1213 ch_info = iwl_get_channel_info(priv, band, channel);
1214 if (!is_channel_valid(ch_info)) {
1215 IWL_DEBUG_SCAN(priv, "Channel %d is INVALID for this band.\n",
1216 channel);
1217 continue;
1218 }
1219
1220 if (!is_active || is_channel_passive(ch_info) ||
1221 (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN))
1222 scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
1223 else
1224 scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE;
1225
1226 if (n_probes)
1227 scan_ch->type |= IWL_SCAN_PROBE_MASK(n_probes);
1228
1229 scan_ch->active_dwell = cpu_to_le16(active_dwell);
1230 scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
1231
1232 /* Set txpower levels to defaults */
1233 scan_ch->dsp_atten = 110;
1234
1235 /* NOTE: if we were doing 6Mb OFDM for scans we'd use
1236 * power level:
1237 * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3;
1238 */
1239 if (band == IEEE80211_BAND_5GHZ)
1240 scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3;
1241 else
1242 scan_ch->tx_gain = ((1 << 5) | (5 << 3));
1243
1244 IWL_DEBUG_SCAN(priv, "Scanning ch=%d prob=0x%X [%s %d]\n",
1245 channel, le32_to_cpu(scan_ch->type),
1246 (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ?
1247 "ACTIVE" : "PASSIVE",
1248 (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ?
1249 active_dwell : passive_dwell);
1250
1251 scan_ch++;
1252 added++;
1253 }
1254
1255 IWL_DEBUG_SCAN(priv, "total channels to scan %d\n", added);
1256 return added;
1257}
1258
1259void iwlagn_request_scan(struct iwl_priv *priv)
1260{
1261 struct iwl_host_cmd cmd = {
1262 .id = REPLY_SCAN_CMD,
1263 .len = sizeof(struct iwl_scan_cmd),
1264 .flags = CMD_SIZE_HUGE,
1265 };
1266 struct iwl_scan_cmd *scan;
1267 struct ieee80211_conf *conf = NULL;
1268 u32 rate_flags = 0;
1269 u16 cmd_len;
1270 u16 rx_chain = 0;
1271 enum ieee80211_band band;
1272 u8 n_probes = 0;
1273 u8 rx_ant = priv->hw_params.valid_rx_ant;
1274 u8 rate;
1275 bool is_active = false;
1276 int chan_mod;
1277 u8 active_chains;
1278
1279 conf = ieee80211_get_hw_conf(priv->hw);
1280
1281 cancel_delayed_work(&priv->scan_check);
1282
1283 if (!iwl_is_ready(priv)) {
1284 IWL_WARN(priv, "request scan called when driver not ready.\n");
1285 goto done;
1286 }
1287
1288 /* Make sure the scan wasn't canceled before this queued work
1289 * was given the chance to run... */
1290 if (!test_bit(STATUS_SCANNING, &priv->status))
1291 goto done;
1292
1293 /* This should never be called or scheduled if there is currently
1294 * a scan active in the hardware. */
1295 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
1296 IWL_DEBUG_INFO(priv, "Multiple concurrent scan requests in parallel. "
1297 "Ignoring second request.\n");
1298 goto done;
1299 }
1300
1301 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
1302 IWL_DEBUG_SCAN(priv, "Aborting scan due to device shutdown\n");
1303 goto done;
1304 }
1305
1306 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
1307 IWL_DEBUG_HC(priv, "Scan request while abort pending. Queuing.\n");
1308 goto done;
1309 }
1310
1311 if (iwl_is_rfkill(priv)) {
1312 IWL_DEBUG_HC(priv, "Aborting scan due to RF Kill activation\n");
1313 goto done;
1314 }
1315
1316 if (!test_bit(STATUS_READY, &priv->status)) {
1317 IWL_DEBUG_HC(priv, "Scan request while uninitialized. Queuing.\n");
1318 goto done;
1319 }
1320
1321 if (!priv->scan_cmd) {
1322 priv->scan_cmd = kmalloc(sizeof(struct iwl_scan_cmd) +
1323 IWL_MAX_SCAN_SIZE, GFP_KERNEL);
1324 if (!priv->scan_cmd) {
1325 IWL_DEBUG_SCAN(priv,
1326 "fail to allocate memory for scan\n");
1327 goto done;
1328 }
1329 }
1330 scan = priv->scan_cmd;
1331 memset(scan, 0, sizeof(struct iwl_scan_cmd) + IWL_MAX_SCAN_SIZE);
1332
1333 scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH;
1334 scan->quiet_time = IWL_ACTIVE_QUIET_TIME;
1335
1336 if (iwl_is_associated(priv)) {
1337 u16 interval = 0;
1338 u32 extra;
1339 u32 suspend_time = 100;
1340 u32 scan_suspend_time = 100;
1341 unsigned long flags;
1342
1343 IWL_DEBUG_INFO(priv, "Scanning while associated...\n");
1344 spin_lock_irqsave(&priv->lock, flags);
1345 interval = priv->beacon_int;
1346 spin_unlock_irqrestore(&priv->lock, flags);
1347
1348 scan->suspend_time = 0;
1349 scan->max_out_time = cpu_to_le32(200 * 1024);
1350 if (!interval)
1351 interval = suspend_time;
1352
1353 extra = (suspend_time / interval) << 22;
1354 scan_suspend_time = (extra |
1355 ((suspend_time % interval) * 1024));
1356 scan->suspend_time = cpu_to_le32(scan_suspend_time);
1357 IWL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n",
1358 scan_suspend_time, interval);
1359 }
1360
1361 if (priv->is_internal_short_scan) {
1362 IWL_DEBUG_SCAN(priv, "Start internal passive scan.\n");
1363 } else if (priv->scan_request->n_ssids) {
1364 int i, p = 0;
1365 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n");
1366 for (i = 0; i < priv->scan_request->n_ssids; i++) {
1367 /* always does wildcard anyway */
1368 if (!priv->scan_request->ssids[i].ssid_len)
1369 continue;
1370 scan->direct_scan[p].id = WLAN_EID_SSID;
1371 scan->direct_scan[p].len =
1372 priv->scan_request->ssids[i].ssid_len;
1373 memcpy(scan->direct_scan[p].ssid,
1374 priv->scan_request->ssids[i].ssid,
1375 priv->scan_request->ssids[i].ssid_len);
1376 n_probes++;
1377 p++;
1378 }
1379 is_active = true;
1380 } else
1381 IWL_DEBUG_SCAN(priv, "Start passive scan.\n");
1382
1383 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK;
1384 scan->tx_cmd.sta_id = priv->hw_params.bcast_sta_id;
1385 scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
1386
1387 switch (priv->scan_band) {
1388 case IEEE80211_BAND_2GHZ:
1389 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK;
1390 chan_mod = le32_to_cpu(priv->active_rxon.flags & RXON_FLG_CHANNEL_MODE_MSK)
1391 >> RXON_FLG_CHANNEL_MODE_POS;
1392 if (chan_mod == CHANNEL_MODE_PURE_40) {
1393 rate = IWL_RATE_6M_PLCP;
1394 } else {
1395 rate = IWL_RATE_1M_PLCP;
1396 rate_flags = RATE_MCS_CCK_MSK;
1397 }
1398 scan->good_CRC_th = IWL_GOOD_CRC_TH_DISABLED;
1399 break;
1400 case IEEE80211_BAND_5GHZ:
1401 rate = IWL_RATE_6M_PLCP;
1402 /*
1403 * If active scanning is requested but a certain channel is
1404 * marked passive, we can do active scanning if we detect
1405 * transmissions.
1406 *
1407 * There is an issue with some firmware versions that triggers
1408 * a sysassert on a "good CRC threshold" of zero (== disabled),
1409 * on a radar channel even though this means that we should NOT
1410 * send probes.
1411 *
1412 * The "good CRC threshold" is the number of frames that we
1413 * need to receive during our dwell time on a channel before
1414 * sending out probes -- setting this to a huge value will
1415 * mean we never reach it, but at the same time work around
1416 * the aforementioned issue. Thus use IWL_GOOD_CRC_TH_NEVER
1417 * here instead of IWL_GOOD_CRC_TH_DISABLED.
1418 */
1419 scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH_DEFAULT :
1420 IWL_GOOD_CRC_TH_NEVER;
1421 break;
1422 default:
1423 IWL_WARN(priv, "Invalid scan band count\n");
1424 goto done;
1425 }
1426
1427 band = priv->scan_band;
1428
1429 if (priv->cfg->scan_antennas[band])
1430 rx_ant = priv->cfg->scan_antennas[band];
1431
1432 priv->scan_tx_ant[band] =
1433 iwl_toggle_tx_ant(priv, priv->scan_tx_ant[band]);
1434 rate_flags |= iwl_ant_idx_to_flags(priv->scan_tx_ant[band]);
1435 scan->tx_cmd.rate_n_flags = iwl_hw_set_rate_n_flags(rate, rate_flags);
1436
1437 /* In power save mode use one chain, otherwise use all chains */
1438 if (test_bit(STATUS_POWER_PMI, &priv->status)) {
1439 /* rx_ant has been set to all valid chains previously */
1440 active_chains = rx_ant &
1441 ((u8)(priv->chain_noise_data.active_chains));
1442 if (!active_chains)
1443 active_chains = rx_ant;
1444
1445 IWL_DEBUG_SCAN(priv, "chain_noise_data.active_chains: %u\n",
1446 priv->chain_noise_data.active_chains);
1447
1448 rx_ant = first_antenna(active_chains);
1449 }
1450 /* MIMO is not used here, but value is required */
1451 rx_chain |= priv->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS;
1452 rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS;
1453 rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS;
1454 rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS;
1455 scan->rx_chain = cpu_to_le16(rx_chain);
1456 if (!priv->is_internal_short_scan) {
1457 cmd_len = iwl_fill_probe_req(priv,
1458 (struct ieee80211_mgmt *)scan->data,
1459 priv->scan_request->ie,
1460 priv->scan_request->ie_len,
1461 IWL_MAX_SCAN_SIZE - sizeof(*scan));
1462 } else {
1463 cmd_len = iwl_fill_probe_req(priv,
1464 (struct ieee80211_mgmt *)scan->data,
1465 NULL, 0,
1466 IWL_MAX_SCAN_SIZE - sizeof(*scan));
1467
1468 }
1469 scan->tx_cmd.len = cpu_to_le16(cmd_len);
1470
1471 scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK |
1472 RXON_FILTER_BCON_AWARE_MSK);
1473
1474 if (priv->is_internal_short_scan) {
1475 scan->channel_count =
1476 iwl_get_single_channel_for_scan(priv, band,
1477 (void *)&scan->data[le16_to_cpu(
1478 scan->tx_cmd.len)]);
1479 } else {
1480 scan->channel_count =
1481 iwl_get_channels_for_scan(priv, band,
1482 is_active, n_probes,
1483 (void *)&scan->data[le16_to_cpu(
1484 scan->tx_cmd.len)]);
1485 }
1486 if (scan->channel_count == 0) {
1487 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count);
1488 goto done;
1489 }
1490
1491 cmd.len += le16_to_cpu(scan->tx_cmd.len) +
1492 scan->channel_count * sizeof(struct iwl_scan_channel);
1493 cmd.data = scan;
1494 scan->len = cpu_to_le16(cmd.len);
1495
1496 set_bit(STATUS_SCAN_HW, &priv->status);
1497 if (iwl_send_cmd_sync(priv, &cmd))
1498 goto done;
1499
1500 queue_delayed_work(priv->workqueue, &priv->scan_check,
1501 IWL_SCAN_CHECK_WATCHDOG);
1502
1503 return;
1504
1505 done:
1506 /* Cannot perform scan. Make sure we clear scanning
1507 * bits from status so next scan request can be performed.
1508 * If we don't clear scanning status bit here all next scan
1509 * will fail
1510 */
1511 clear_bit(STATUS_SCAN_HW, &priv->status);
1512 clear_bit(STATUS_SCANNING, &priv->status);
1513 /* inform mac80211 scan aborted */
1514 queue_work(priv->workqueue, &priv->scan_completed);
1515}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index f7d85a2173c8..bfcac5608d87 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -295,11 +295,11 @@ static u32 rs_tl_get_load(struct iwl_lq_sta *lq_data, u8 tid)
295 return tl->total; 295 return tl->total;
296} 296}
297 297
298static void rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv, 298static int rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv,
299 struct iwl_lq_sta *lq_data, u8 tid, 299 struct iwl_lq_sta *lq_data, u8 tid,
300 struct ieee80211_sta *sta) 300 struct ieee80211_sta *sta)
301{ 301{
302 int ret; 302 int ret = -EAGAIN;
303 303
304 if (rs_tl_get_load(lq_data, tid) > IWL_AGG_LOAD_THRESHOLD) { 304 if (rs_tl_get_load(lq_data, tid) > IWL_AGG_LOAD_THRESHOLD) {
305 IWL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n", 305 IWL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n",
@@ -313,29 +313,29 @@ static void rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv,
313 */ 313 */
314 IWL_DEBUG_HT(priv, "Fail start Tx agg on tid: %d\n", 314 IWL_DEBUG_HT(priv, "Fail start Tx agg on tid: %d\n",
315 tid); 315 tid);
316 ret = ieee80211_stop_tx_ba_session(sta, tid, 316 ieee80211_stop_tx_ba_session(sta, tid,
317 WLAN_BACK_INITIATOR); 317 WLAN_BACK_INITIATOR);
318 } 318 }
319 } 319 } else
320 IWL_ERR(priv, "Fail finding valid aggregation tid: %d\n", tid);
321 return ret;
320} 322}
321 323
322static void rs_tl_turn_on_agg(struct iwl_priv *priv, u8 tid, 324static void rs_tl_turn_on_agg(struct iwl_priv *priv, u8 tid,
323 struct iwl_lq_sta *lq_data, 325 struct iwl_lq_sta *lq_data,
324 struct ieee80211_sta *sta) 326 struct ieee80211_sta *sta)
325{ 327{
326 if ((tid < TID_MAX_LOAD_COUNT)) 328 if ((tid < TID_MAX_LOAD_COUNT) &&
327 rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta); 329 !rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta)) {
328 else if (tid == IWL_AGG_ALL_TID) 330 if (priv->cfg->use_rts_for_ht) {
329 for (tid = 0; tid < TID_MAX_LOAD_COUNT; tid++) 331 /*
330 rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta); 332 * switch to RTS/CTS if it is the prefer protection
331 if (priv->cfg->use_rts_for_ht) { 333 * method for HT traffic
332 /* 334 */
333 * switch to RTS/CTS if it is the prefer protection method 335 IWL_DEBUG_HT(priv, "use RTS/CTS protection for HT\n");
334 * for HT traffic 336 priv->staging_rxon.flags &= ~RXON_FLG_SELF_CTS_EN;
335 */ 337 iwlcore_commit_rxon(priv);
336 IWL_DEBUG_HT(priv, "use RTS/CTS protection for HT\n"); 338 }
337 priv->staging_rxon.flags &= ~RXON_FLG_SELF_CTS_EN;
338 iwlcore_commit_rxon(priv);
339 } 339 }
340} 340}
341 341
@@ -868,14 +868,14 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
868 rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, 868 rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type,
869 &rs_index); 869 &rs_index);
870 rs_collect_tx_data(curr_tbl, rs_index, 870 rs_collect_tx_data(curr_tbl, rs_index,
871 info->status.ampdu_ack_len, 871 info->status.ampdu_len,
872 info->status.ampdu_ack_map); 872 info->status.ampdu_ack_len);
873 873
874 /* Update success/fail counts if not searching for new mode */ 874 /* Update success/fail counts if not searching for new mode */
875 if (lq_sta->stay_in_tbl) { 875 if (lq_sta->stay_in_tbl) {
876 lq_sta->total_success += info->status.ampdu_ack_map; 876 lq_sta->total_success += info->status.ampdu_ack_len;
877 lq_sta->total_failed += (info->status.ampdu_ack_len - 877 lq_sta->total_failed += (info->status.ampdu_len -
878 info->status.ampdu_ack_map); 878 info->status.ampdu_ack_len);
879 } 879 }
880 } else { 880 } else {
881 /* 881 /*
@@ -2078,10 +2078,12 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
2078 } 2078 }
2079 /* Else we have enough samples; calculate estimate of 2079 /* Else we have enough samples; calculate estimate of
2080 * actual average throughput */ 2080 * actual average throughput */
2081 2081 if (window->average_tpt != ((window->success_ratio *
2082 /* Sanity-check TPT calculations */ 2082 tbl->expected_tpt[index] + 64) / 128)) {
2083 BUG_ON(window->average_tpt != ((window->success_ratio * 2083 IWL_ERR(priv, "expected_tpt should have been calculated by now\n");
2084 tbl->expected_tpt[index] + 64) / 128)); 2084 window->average_tpt = ((window->success_ratio *
2085 tbl->expected_tpt[index] + 64) / 128);
2086 }
2085 2087
2086 /* If we are searching for better modulation mode, check success. */ 2088 /* If we are searching for better modulation mode, check success. */
2087 if (lq_sta->search_better_tbl && 2089 if (lq_sta->search_better_tbl &&
@@ -2558,8 +2560,17 @@ void iwl_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 sta_i
2558 lq_sta->active_mimo3_rate); 2560 lq_sta->active_mimo3_rate);
2559 2561
2560 /* These values will be overridden later */ 2562 /* These values will be overridden later */
2561 lq_sta->lq.general_params.single_stream_ant_msk = ANT_A; 2563 lq_sta->lq.general_params.single_stream_ant_msk =
2562 lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB; 2564 first_antenna(priv->hw_params.valid_tx_ant);
2565 lq_sta->lq.general_params.dual_stream_ant_msk =
2566 priv->hw_params.valid_tx_ant &
2567 ~first_antenna(priv->hw_params.valid_tx_ant);
2568 if (!lq_sta->lq.general_params.dual_stream_ant_msk) {
2569 lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB;
2570 } else if (num_of_ant(priv->hw_params.valid_tx_ant) == 2) {
2571 lq_sta->lq.general_params.dual_stream_ant_msk =
2572 priv->hw_params.valid_tx_ant;
2573 }
2563 2574
2564 /* as default allow aggregation for all tids */ 2575 /* as default allow aggregation for all tids */
2565 lq_sta->tx_agg_tid_en = IWL_AGG_ALL_TID; 2576 lq_sta->tx_agg_tid_en = IWL_AGG_ALL_TID;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
index 3077eac58880..c2a5c85542bf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
@@ -83,6 +83,15 @@ static inline int get_fifo_from_ac(u8 ac)
83 return ac_to_fifo[ac]; 83 return ac_to_fifo[ac];
84} 84}
85 85
86static inline int get_ac_from_tid(u16 tid)
87{
88 if (likely(tid < ARRAY_SIZE(tid_to_ac)))
89 return tid_to_ac[tid];
90
91 /* no support for TIDs 8-15 yet */
92 return -EINVAL;
93}
94
86static inline int get_fifo_from_tid(u16 tid) 95static inline int get_fifo_from_tid(u16 tid)
87{ 96{
88 if (likely(tid < ARRAY_SIZE(tid_to_ac))) 97 if (likely(tid < ARRAY_SIZE(tid_to_ac)))
@@ -167,7 +176,7 @@ static int iwlagn_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid,
167 scd_q2ratid = ra_tid & IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; 176 scd_q2ratid = ra_tid & IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK;
168 177
169 tbl_dw_addr = priv->scd_base_addr + 178 tbl_dw_addr = priv->scd_base_addr +
170 IWL50_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); 179 IWLAGN_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id);
171 180
172 tbl_dw = iwl_read_targ_mem(priv, tbl_dw_addr); 181 tbl_dw = iwl_read_targ_mem(priv, tbl_dw_addr);
173 182
@@ -186,9 +195,9 @@ static void iwlagn_tx_queue_stop_scheduler(struct iwl_priv *priv, u16 txq_id)
186 /* Simply stop the queue, but don't change any configuration; 195 /* Simply stop the queue, but don't change any configuration;
187 * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ 196 * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */
188 iwl_write_prph(priv, 197 iwl_write_prph(priv,
189 IWL50_SCD_QUEUE_STATUS_BITS(txq_id), 198 IWLAGN_SCD_QUEUE_STATUS_BITS(txq_id),
190 (0 << IWL50_SCD_QUEUE_STTS_REG_POS_ACTIVE)| 199 (0 << IWLAGN_SCD_QUEUE_STTS_REG_POS_ACTIVE)|
191 (1 << IWL50_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); 200 (1 << IWLAGN_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN));
192} 201}
193 202
194void iwlagn_set_wr_ptrs(struct iwl_priv *priv, 203void iwlagn_set_wr_ptrs(struct iwl_priv *priv,
@@ -196,7 +205,7 @@ void iwlagn_set_wr_ptrs(struct iwl_priv *priv,
196{ 205{
197 iwl_write_direct32(priv, HBUS_TARG_WRPTR, 206 iwl_write_direct32(priv, HBUS_TARG_WRPTR,
198 (index & 0xff) | (txq_id << 8)); 207 (index & 0xff) | (txq_id << 8));
199 iwl_write_prph(priv, IWL50_SCD_QUEUE_RDPTR(txq_id), index); 208 iwl_write_prph(priv, IWLAGN_SCD_QUEUE_RDPTR(txq_id), index);
200} 209}
201 210
202void iwlagn_tx_queue_set_status(struct iwl_priv *priv, 211void iwlagn_tx_queue_set_status(struct iwl_priv *priv,
@@ -206,11 +215,11 @@ void iwlagn_tx_queue_set_status(struct iwl_priv *priv,
206 int txq_id = txq->q.id; 215 int txq_id = txq->q.id;
207 int active = test_bit(txq_id, &priv->txq_ctx_active_msk) ? 1 : 0; 216 int active = test_bit(txq_id, &priv->txq_ctx_active_msk) ? 1 : 0;
208 217
209 iwl_write_prph(priv, IWL50_SCD_QUEUE_STATUS_BITS(txq_id), 218 iwl_write_prph(priv, IWLAGN_SCD_QUEUE_STATUS_BITS(txq_id),
210 (active << IWL50_SCD_QUEUE_STTS_REG_POS_ACTIVE) | 219 (active << IWLAGN_SCD_QUEUE_STTS_REG_POS_ACTIVE) |
211 (tx_fifo_id << IWL50_SCD_QUEUE_STTS_REG_POS_TXF) | 220 (tx_fifo_id << IWLAGN_SCD_QUEUE_STTS_REG_POS_TXF) |
212 (1 << IWL50_SCD_QUEUE_STTS_REG_POS_WSL) | 221 (1 << IWLAGN_SCD_QUEUE_STTS_REG_POS_WSL) |
213 IWL50_SCD_QUEUE_STTS_REG_MSK); 222 IWLAGN_SCD_QUEUE_STTS_REG_MSK);
214 223
215 txq->sched_retry = scd_retry; 224 txq->sched_retry = scd_retry;
216 225
@@ -250,10 +259,10 @@ int iwlagn_txq_agg_enable(struct iwl_priv *priv, int txq_id,
250 iwlagn_tx_queue_set_q2ratid(priv, ra_tid, txq_id); 259 iwlagn_tx_queue_set_q2ratid(priv, ra_tid, txq_id);
251 260
252 /* Set this queue as a chain-building queue */ 261 /* Set this queue as a chain-building queue */
253 iwl_set_bits_prph(priv, IWL50_SCD_QUEUECHAIN_SEL, (1<<txq_id)); 262 iwl_set_bits_prph(priv, IWLAGN_SCD_QUEUECHAIN_SEL, (1<<txq_id));
254 263
255 /* enable aggregations for the queue */ 264 /* enable aggregations for the queue */
256 iwl_set_bits_prph(priv, IWL50_SCD_AGGR_SEL, (1<<txq_id)); 265 iwl_set_bits_prph(priv, IWLAGN_SCD_AGGR_SEL, (1<<txq_id));
257 266
258 /* Place first TFD at index corresponding to start sequence number. 267 /* Place first TFD at index corresponding to start sequence number.
259 * Assumes that ssn_idx is valid (!= 0xFFF) */ 268 * Assumes that ssn_idx is valid (!= 0xFFF) */
@@ -263,16 +272,16 @@ int iwlagn_txq_agg_enable(struct iwl_priv *priv, int txq_id,
263 272
264 /* Set up Tx window size and frame limit for this queue */ 273 /* Set up Tx window size and frame limit for this queue */
265 iwl_write_targ_mem(priv, priv->scd_base_addr + 274 iwl_write_targ_mem(priv, priv->scd_base_addr +
266 IWL50_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + 275 IWLAGN_SCD_CONTEXT_QUEUE_OFFSET(txq_id) +
267 sizeof(u32), 276 sizeof(u32),
268 ((SCD_WIN_SIZE << 277 ((SCD_WIN_SIZE <<
269 IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) & 278 IWLAGN_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) &
270 IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) | 279 IWLAGN_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) |
271 ((SCD_FRAME_LIMIT << 280 ((SCD_FRAME_LIMIT <<
272 IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & 281 IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
273 IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK)); 282 IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK));
274 283
275 iwl_set_bits_prph(priv, IWL50_SCD_INTERRUPT_MASK, (1 << txq_id)); 284 iwl_set_bits_prph(priv, IWLAGN_SCD_INTERRUPT_MASK, (1 << txq_id));
276 285
277 /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */ 286 /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */
278 iwlagn_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1); 287 iwlagn_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1);
@@ -298,14 +307,14 @@ int iwlagn_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
298 307
299 iwlagn_tx_queue_stop_scheduler(priv, txq_id); 308 iwlagn_tx_queue_stop_scheduler(priv, txq_id);
300 309
301 iwl_clear_bits_prph(priv, IWL50_SCD_AGGR_SEL, (1 << txq_id)); 310 iwl_clear_bits_prph(priv, IWLAGN_SCD_AGGR_SEL, (1 << txq_id));
302 311
303 priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); 312 priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
304 priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); 313 priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
305 /* supposes that ssn_idx is valid (!= 0xFFF) */ 314 /* supposes that ssn_idx is valid (!= 0xFFF) */
306 iwlagn_set_wr_ptrs(priv, txq_id, ssn_idx); 315 iwlagn_set_wr_ptrs(priv, txq_id, ssn_idx);
307 316
308 iwl_clear_bits_prph(priv, IWL50_SCD_INTERRUPT_MASK, (1 << txq_id)); 317 iwl_clear_bits_prph(priv, IWLAGN_SCD_INTERRUPT_MASK, (1 << txq_id));
309 iwl_txq_ctx_deactivate(priv, txq_id); 318 iwl_txq_ctx_deactivate(priv, txq_id);
310 iwlagn_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0); 319 iwlagn_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0);
311 320
@@ -318,7 +327,7 @@ int iwlagn_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
318 */ 327 */
319void iwlagn_txq_set_sched(struct iwl_priv *priv, u32 mask) 328void iwlagn_txq_set_sched(struct iwl_priv *priv, u32 mask)
320{ 329{
321 iwl_write_prph(priv, IWL50_SCD_TXFACT, mask); 330 iwl_write_prph(priv, IWLAGN_SCD_TXFACT, mask);
322} 331}
323 332
324static inline int get_queue_from_ac(u16 ac) 333static inline int get_queue_from_ac(u16 ac)
@@ -991,7 +1000,7 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn)
991 tid_data = &priv->stations[sta_id].tid[tid]; 1000 tid_data = &priv->stations[sta_id].tid[tid];
992 *ssn = SEQ_TO_SN(tid_data->seq_number); 1001 *ssn = SEQ_TO_SN(tid_data->seq_number);
993 tid_data->agg.txq_id = txq_id; 1002 tid_data->agg.txq_id = txq_id;
994 priv->txq[txq_id].swq_id = iwl_virtual_agg_queue_num(tx_fifo, txq_id); 1003 priv->txq[txq_id].swq_id = iwl_virtual_agg_queue_num(get_ac_from_tid(tid), txq_id);
995 spin_unlock_irqrestore(&priv->sta_lock, flags); 1004 spin_unlock_irqrestore(&priv->sta_lock, flags);
996 1005
997 ret = priv->cfg->ops->lib->txq_agg_enable(priv, txq_id, tx_fifo, 1006 ret = priv->cfg->ops->lib->txq_agg_enable(priv, txq_id, tx_fifo,
@@ -1224,8 +1233,9 @@ static int iwlagn_tx_status_reply_compressed_ba(struct iwl_priv *priv,
1224 memset(&info->status, 0, sizeof(info->status)); 1233 memset(&info->status, 0, sizeof(info->status));
1225 info->flags |= IEEE80211_TX_STAT_ACK; 1234 info->flags |= IEEE80211_TX_STAT_ACK;
1226 info->flags |= IEEE80211_TX_STAT_AMPDU; 1235 info->flags |= IEEE80211_TX_STAT_AMPDU;
1227 info->status.ampdu_ack_map = successes; 1236 info->status.ampdu_ack_len = successes;
1228 info->status.ampdu_ack_len = agg->frame_count; 1237 info->status.ampdu_ack_map = bitmap;
1238 info->status.ampdu_len = agg->frame_count;
1229 iwlagn_hwrate_to_tx_control(priv, agg->rate_n_flags, info); 1239 iwlagn_hwrate_to_tx_control(priv, agg->rate_n_flags, info);
1230 1240
1231 IWL_DEBUG_TX_REPLY(priv, "Bitmap %llx\n", (unsigned long long)bitmap); 1241 IWL_DEBUG_TX_REPLY(priv, "Bitmap %llx\n", (unsigned long long)bitmap);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
index 52ae157968b2..ae476c234a7c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
@@ -207,7 +207,7 @@ static int iwlagn_set_Xtal_calib(struct iwl_priv *priv)
207{ 207{
208 struct iwl_calib_xtal_freq_cmd cmd; 208 struct iwl_calib_xtal_freq_cmd cmd;
209 __le16 *xtal_calib = 209 __le16 *xtal_calib =
210 (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_XTAL); 210 (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_XTAL);
211 211
212 cmd.hdr.op_code = IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD; 212 cmd.hdr.op_code = IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD;
213 cmd.hdr.first_group = 0; 213 cmd.hdr.first_group = 0;
@@ -329,19 +329,19 @@ int iwlagn_alive_notify(struct iwl_priv *priv)
329 329
330 spin_lock_irqsave(&priv->lock, flags); 330 spin_lock_irqsave(&priv->lock, flags);
331 331
332 priv->scd_base_addr = iwl_read_prph(priv, IWL50_SCD_SRAM_BASE_ADDR); 332 priv->scd_base_addr = iwl_read_prph(priv, IWLAGN_SCD_SRAM_BASE_ADDR);
333 a = priv->scd_base_addr + IWL50_SCD_CONTEXT_DATA_OFFSET; 333 a = priv->scd_base_addr + IWLAGN_SCD_CONTEXT_DATA_OFFSET;
334 for (; a < priv->scd_base_addr + IWL50_SCD_TX_STTS_BITMAP_OFFSET; 334 for (; a < priv->scd_base_addr + IWLAGN_SCD_TX_STTS_BITMAP_OFFSET;
335 a += 4) 335 a += 4)
336 iwl_write_targ_mem(priv, a, 0); 336 iwl_write_targ_mem(priv, a, 0);
337 for (; a < priv->scd_base_addr + IWL50_SCD_TRANSLATE_TBL_OFFSET; 337 for (; a < priv->scd_base_addr + IWLAGN_SCD_TRANSLATE_TBL_OFFSET;
338 a += 4) 338 a += 4)
339 iwl_write_targ_mem(priv, a, 0); 339 iwl_write_targ_mem(priv, a, 0);
340 for (; a < priv->scd_base_addr + 340 for (; a < priv->scd_base_addr +
341 IWL50_SCD_TRANSLATE_TBL_OFFSET_QUEUE(priv->hw_params.max_txq_num); a += 4) 341 IWLAGN_SCD_TRANSLATE_TBL_OFFSET_QUEUE(priv->hw_params.max_txq_num); a += 4)
342 iwl_write_targ_mem(priv, a, 0); 342 iwl_write_targ_mem(priv, a, 0);
343 343
344 iwl_write_prph(priv, IWL50_SCD_DRAM_BASE_ADDR, 344 iwl_write_prph(priv, IWLAGN_SCD_DRAM_BASE_ADDR,
345 priv->scd_bc_tbls.dma >> 10); 345 priv->scd_bc_tbls.dma >> 10);
346 346
347 /* Enable DMA channel */ 347 /* Enable DMA channel */
@@ -355,28 +355,28 @@ int iwlagn_alive_notify(struct iwl_priv *priv)
355 iwl_write_direct32(priv, FH_TX_CHICKEN_BITS_REG, 355 iwl_write_direct32(priv, FH_TX_CHICKEN_BITS_REG,
356 reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); 356 reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN);
357 357
358 iwl_write_prph(priv, IWL50_SCD_QUEUECHAIN_SEL, 358 iwl_write_prph(priv, IWLAGN_SCD_QUEUECHAIN_SEL,
359 IWL50_SCD_QUEUECHAIN_SEL_ALL(priv->hw_params.max_txq_num)); 359 IWLAGN_SCD_QUEUECHAIN_SEL_ALL(priv->hw_params.max_txq_num));
360 iwl_write_prph(priv, IWL50_SCD_AGGR_SEL, 0); 360 iwl_write_prph(priv, IWLAGN_SCD_AGGR_SEL, 0);
361 361
362 /* initiate the queues */ 362 /* initiate the queues */
363 for (i = 0; i < priv->hw_params.max_txq_num; i++) { 363 for (i = 0; i < priv->hw_params.max_txq_num; i++) {
364 iwl_write_prph(priv, IWL50_SCD_QUEUE_RDPTR(i), 0); 364 iwl_write_prph(priv, IWLAGN_SCD_QUEUE_RDPTR(i), 0);
365 iwl_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8)); 365 iwl_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8));
366 iwl_write_targ_mem(priv, priv->scd_base_addr + 366 iwl_write_targ_mem(priv, priv->scd_base_addr +
367 IWL50_SCD_CONTEXT_QUEUE_OFFSET(i), 0); 367 IWLAGN_SCD_CONTEXT_QUEUE_OFFSET(i), 0);
368 iwl_write_targ_mem(priv, priv->scd_base_addr + 368 iwl_write_targ_mem(priv, priv->scd_base_addr +
369 IWL50_SCD_CONTEXT_QUEUE_OFFSET(i) + 369 IWLAGN_SCD_CONTEXT_QUEUE_OFFSET(i) +
370 sizeof(u32), 370 sizeof(u32),
371 ((SCD_WIN_SIZE << 371 ((SCD_WIN_SIZE <<
372 IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) & 372 IWLAGN_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) &
373 IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) | 373 IWLAGN_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) |
374 ((SCD_FRAME_LIMIT << 374 ((SCD_FRAME_LIMIT <<
375 IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & 375 IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
376 IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK)); 376 IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK));
377 } 377 }
378 378
379 iwl_write_prph(priv, IWL50_SCD_INTERRUPT_MASK, 379 iwl_write_prph(priv, IWLAGN_SCD_INTERRUPT_MASK,
380 IWL_MASK(0, priv->hw_params.max_txq_num)); 380 IWL_MASK(0, priv->hw_params.max_txq_num));
381 381
382 /* Activate all Tx DMA/FIFO channels */ 382 /* Activate all Tx DMA/FIFO channels */
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 0b497d4bc659..a672d3379cfd 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -2174,7 +2174,7 @@ static void iwl_alive_start(struct iwl_priv *priv)
2174 } 2174 }
2175 2175
2176 /* Configure Bluetooth device coexistence support */ 2176 /* Configure Bluetooth device coexistence support */
2177 iwl_send_bt_config(priv); 2177 priv->cfg->ops->hcmd->send_bt_config(priv);
2178 2178
2179 iwl_reset_run_time_calib(priv); 2179 iwl_reset_run_time_calib(priv);
2180 2180
@@ -2654,7 +2654,6 @@ static int iwl_mac_setup_register(struct iwl_priv *priv)
2654 2654
2655 /* Tell mac80211 our characteristics */ 2655 /* Tell mac80211 our characteristics */
2656 hw->flags = IEEE80211_HW_SIGNAL_DBM | 2656 hw->flags = IEEE80211_HW_SIGNAL_DBM |
2657 IEEE80211_HW_NOISE_DBM |
2658 IEEE80211_HW_AMPDU_AGGREGATION | 2657 IEEE80211_HW_AMPDU_AGGREGATION |
2659 IEEE80211_HW_SPECTRUM_MGMT; 2658 IEEE80211_HW_SPECTRUM_MGMT;
2660 2659
@@ -3002,18 +3001,6 @@ static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
3002 return 0; 3001 return 0;
3003} 3002}
3004 3003
3005static int iwl_mac_get_stats(struct ieee80211_hw *hw,
3006 struct ieee80211_low_level_stats *stats)
3007{
3008 struct iwl_priv *priv = hw->priv;
3009
3010 priv = hw->priv;
3011 IWL_DEBUG_MAC80211(priv, "enter\n");
3012 IWL_DEBUG_MAC80211(priv, "leave\n");
3013
3014 return 0;
3015}
3016
3017static void iwl_mac_sta_notify(struct ieee80211_hw *hw, 3004static void iwl_mac_sta_notify(struct ieee80211_hw *hw,
3018 struct ieee80211_vif *vif, 3005 struct ieee80211_vif *vif,
3019 enum sta_notify_cmd cmd, 3006 enum sta_notify_cmd cmd,
@@ -3178,44 +3165,6 @@ static ssize_t store_tx_power(struct device *d,
3178 3165
3179static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power); 3166static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power);
3180 3167
3181static ssize_t show_statistics(struct device *d,
3182 struct device_attribute *attr, char *buf)
3183{
3184 struct iwl_priv *priv = dev_get_drvdata(d);
3185 u32 size = sizeof(struct iwl_notif_statistics);
3186 u32 len = 0, ofs = 0;
3187 u8 *data = (u8 *)&priv->statistics;
3188 int rc = 0;
3189
3190 if (!iwl_is_alive(priv))
3191 return -EAGAIN;
3192
3193 mutex_lock(&priv->mutex);
3194 rc = iwl_send_statistics_request(priv, CMD_SYNC, false);
3195 mutex_unlock(&priv->mutex);
3196
3197 if (rc) {
3198 len = sprintf(buf,
3199 "Error sending statistics request: 0x%08X\n", rc);
3200 return len;
3201 }
3202
3203 while (size && (PAGE_SIZE - len)) {
3204 hex_dump_to_buffer(data + ofs, size, 16, 1, buf + len,
3205 PAGE_SIZE - len, 1);
3206 len = strlen(buf);
3207 if (PAGE_SIZE - len)
3208 buf[len++] = '\n';
3209
3210 ofs += 16;
3211 size -= min(size, 16U);
3212 }
3213
3214 return len;
3215}
3216
3217static DEVICE_ATTR(statistics, S_IRUGO, show_statistics, NULL);
3218
3219static ssize_t show_rts_ht_protection(struct device *d, 3168static ssize_t show_rts_ht_protection(struct device *d,
3220 struct device_attribute *attr, char *buf) 3169 struct device_attribute *attr, char *buf)
3221{ 3170{
@@ -3305,6 +3254,7 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv)
3305 3254
3306 cancel_delayed_work_sync(&priv->init_alive_start); 3255 cancel_delayed_work_sync(&priv->init_alive_start);
3307 cancel_delayed_work(&priv->scan_check); 3256 cancel_delayed_work(&priv->scan_check);
3257 cancel_work_sync(&priv->start_internal_scan);
3308 cancel_delayed_work(&priv->alive_start); 3258 cancel_delayed_work(&priv->alive_start);
3309 cancel_work_sync(&priv->beacon_update); 3259 cancel_work_sync(&priv->beacon_update);
3310 del_timer_sync(&priv->statistics_periodic); 3260 del_timer_sync(&priv->statistics_periodic);
@@ -3400,11 +3350,10 @@ static void iwl_uninit_drv(struct iwl_priv *priv)
3400 iwl_calib_free_results(priv); 3350 iwl_calib_free_results(priv);
3401 iwlcore_free_geos(priv); 3351 iwlcore_free_geos(priv);
3402 iwl_free_channel_map(priv); 3352 iwl_free_channel_map(priv);
3403 kfree(priv->scan); 3353 kfree(priv->scan_cmd);
3404} 3354}
3405 3355
3406static struct attribute *iwl_sysfs_entries[] = { 3356static struct attribute *iwl_sysfs_entries[] = {
3407 &dev_attr_statistics.attr,
3408 &dev_attr_temperature.attr, 3357 &dev_attr_temperature.attr,
3409 &dev_attr_tx_power.attr, 3358 &dev_attr_tx_power.attr,
3410 &dev_attr_rts_ht_protection.attr, 3359 &dev_attr_rts_ht_protection.attr,
@@ -3429,7 +3378,6 @@ static struct ieee80211_ops iwl_hw_ops = {
3429 .configure_filter = iwl_configure_filter, 3378 .configure_filter = iwl_configure_filter,
3430 .set_key = iwl_mac_set_key, 3379 .set_key = iwl_mac_set_key,
3431 .update_tkip_key = iwl_mac_update_tkip_key, 3380 .update_tkip_key = iwl_mac_update_tkip_key,
3432 .get_stats = iwl_mac_get_stats,
3433 .conf_tx = iwl_mac_conf_tx, 3381 .conf_tx = iwl_mac_conf_tx,
3434 .reset_tsf = iwl_mac_reset_tsf, 3382 .reset_tsf = iwl_mac_reset_tsf,
3435 .bss_info_changed = iwl_bss_info_changed, 3383 .bss_info_changed = iwl_bss_info_changed,
@@ -3835,7 +3783,12 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = {
3835 {IWL_PCI_DEVICE(0x4238, 0x1111, iwl6000_3agn_cfg)}, 3783 {IWL_PCI_DEVICE(0x4238, 0x1111, iwl6000_3agn_cfg)},
3836 {IWL_PCI_DEVICE(0x4239, 0x1311, iwl6000i_2agn_cfg)}, 3784 {IWL_PCI_DEVICE(0x4239, 0x1311, iwl6000i_2agn_cfg)},
3837 {IWL_PCI_DEVICE(0x4239, 0x1316, iwl6000i_2abg_cfg)}, 3785 {IWL_PCI_DEVICE(0x4239, 0x1316, iwl6000i_2abg_cfg)},
3838 {IWL_PCI_DEVICE(0x0082, 0x1201, iwl6000i_g2_2agn_cfg)}, 3786
3787/* 6x00 Series Gen2 */
3788 {IWL_PCI_DEVICE(0x0082, 0x1201, iwl6000g2_2agn_cfg)},
3789 {IWL_PCI_DEVICE(0x0082, 0x1301, iwl6000g2_2agn_cfg)},
3790 {IWL_PCI_DEVICE(0x0082, 0x1321, iwl6000g2_2agn_cfg)},
3791 {IWL_PCI_DEVICE(0x0085, 0x1311, iwl6000g2_2agn_cfg)},
3839 3792
3840/* 6x50 WiFi/WiMax Series */ 3793/* 6x50 WiFi/WiMax Series */
3841 {IWL_PCI_DEVICE(0x0087, 0x1301, iwl6050_2agn_cfg)}, 3794 {IWL_PCI_DEVICE(0x0087, 0x1301, iwl6050_2agn_cfg)},
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index 5d3142287e14..cfee9994383e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -171,4 +171,7 @@ static inline bool iwl_is_tx_success(u32 status)
171 (status == TX_STATUS_DIRECT_DONE); 171 (status == TX_STATUS_DIRECT_DONE);
172} 172}
173 173
174/* scan */
175void iwlagn_request_scan(struct iwl_priv *priv);
176
174#endif /* __iwl_agn_h__ */ 177#endif /* __iwl_agn_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-calib.c b/drivers/net/wireless/iwlwifi/iwl-calib.c
index 0471c3f8713e..f1fd00b1a65d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-calib.c
@@ -808,6 +808,18 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv,
808 } 808 }
809 } 809 }
810 810
811 /*
812 * The above algorithm sometimes fails when the ucode
813 * reports 0 for all chains. It's not clear why that
814 * happens to start with, but it is then causing trouble
815 * because this can make us enable more chains than the
816 * hardware really has.
817 *
818 * To be safe, simply mask out any chains that we know
819 * are not on the device.
820 */
821 active_chains &= priv->hw_params.valid_rx_ant;
822
811 num_tx_chains = 0; 823 num_tx_chains = 0;
812 for (i = 0; i < NUM_RX_CHAINS; i++) { 824 for (i = 0; i < NUM_RX_CHAINS; i++) {
813 /* loops on all the bits of 825 /* loops on all the bits of
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index d830086ca195..0086019b7a15 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -1443,7 +1443,7 @@ struct iwl4965_rx_mpdu_res_start {
1443 1443
1444/* 1: Ignore Bluetooth priority for this frame. 1444/* 1: Ignore Bluetooth priority for this frame.
1445 * 0: Delay Tx until Bluetooth device is done (normal usage). */ 1445 * 0: Delay Tx until Bluetooth device is done (normal usage). */
1446#define TX_CMD_FLG_BT_DIS_MSK cpu_to_le32(1 << 12) 1446#define TX_CMD_FLG_IGNORE_BT cpu_to_le32(1 << 12)
1447 1447
1448/* 1: uCode overrides sequence control field in MAC header. 1448/* 1: uCode overrides sequence control field in MAC header.
1449 * 0: Driver provides sequence control field in MAC header. 1449 * 0: Driver provides sequence control field in MAC header.
@@ -2663,7 +2663,9 @@ struct iwl_ssid_ie {
2663#define PROBE_OPTION_MAX_3945 4 2663#define PROBE_OPTION_MAX_3945 4
2664#define PROBE_OPTION_MAX 20 2664#define PROBE_OPTION_MAX 20
2665#define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF) 2665#define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF)
2666#define IWL_GOOD_CRC_TH cpu_to_le16(1) 2666#define IWL_GOOD_CRC_TH_DISABLED 0
2667#define IWL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1)
2668#define IWL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff)
2667#define IWL_MAX_SCAN_SIZE 1024 2669#define IWL_MAX_SCAN_SIZE 1024
2668#define IWL_MAX_CMD_SIZE 4096 2670#define IWL_MAX_CMD_SIZE 4096
2669#define IWL_MAX_PROBE_REQUEST 200 2671#define IWL_MAX_PROBE_REQUEST 200
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 2a89747d3473..4cdf4d3a9ddb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -829,19 +829,6 @@ static u8 iwl_count_chain_bitmap(u32 chain_bitmap)
829} 829}
830 830
831/** 831/**
832 * iwl_is_monitor_mode - Determine if interface in monitor mode
833 *
834 * priv->iw_mode is set in add_interface, but add_interface is
835 * never called for monitor mode. The only way mac80211 informs us about
836 * monitor mode is through configuring filters (call to configure_filter).
837 */
838bool iwl_is_monitor_mode(struct iwl_priv *priv)
839{
840 return !!(priv->staging_rxon.filter_flags & RXON_FILTER_PROMISC_MSK);
841}
842EXPORT_SYMBOL(iwl_is_monitor_mode);
843
844/**
845 * iwl_set_rxon_chain - Set up Rx chain usage in "staging" RXON image 832 * iwl_set_rxon_chain - Set up Rx chain usage in "staging" RXON image
846 * 833 *
847 * Selects how many and which Rx receivers/antennas/chains to use. 834 * Selects how many and which Rx receivers/antennas/chains to use.
@@ -884,19 +871,6 @@ void iwl_set_rxon_chain(struct iwl_priv *priv)
884 rx_chain |= active_rx_cnt << RXON_RX_CHAIN_MIMO_CNT_POS; 871 rx_chain |= active_rx_cnt << RXON_RX_CHAIN_MIMO_CNT_POS;
885 rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS; 872 rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS;
886 873
887 /* copied from 'iwl_bg_request_scan()' */
888 /* Force use of chains B and C (0x6) for Rx
889 * Avoid A (0x1) for the device has off-channel reception on A-band.
890 * MIMO is not used here, but value is required */
891 if (iwl_is_monitor_mode(priv) &&
892 !(priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) &&
893 priv->cfg->off_channel_workaround) {
894 rx_chain = ANT_ABC << RXON_RX_CHAIN_VALID_POS;
895 rx_chain |= ANT_BC << RXON_RX_CHAIN_FORCE_SEL_POS;
896 rx_chain |= ANT_ABC << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS;
897 rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS;
898 }
899
900 priv->staging_rxon.rx_chain = cpu_to_le16(rx_chain); 874 priv->staging_rxon.rx_chain = cpu_to_le16(rx_chain);
901 875
902 if (!is_single && (active_rx_cnt >= IWL_NUM_RX_CHAINS_SINGLE) && is_cam) 876 if (!is_single && (active_rx_cnt >= IWL_NUM_RX_CHAINS_SINGLE) && is_cam)
@@ -1480,7 +1454,7 @@ irqreturn_t iwl_isr_legacy(int irq, void *data)
1480} 1454}
1481EXPORT_SYMBOL(iwl_isr_legacy); 1455EXPORT_SYMBOL(iwl_isr_legacy);
1482 1456
1483int iwl_send_bt_config(struct iwl_priv *priv) 1457void iwl_send_bt_config(struct iwl_priv *priv)
1484{ 1458{
1485 struct iwl_bt_cmd bt_cmd = { 1459 struct iwl_bt_cmd bt_cmd = {
1486 .lead_time = BT_LEAD_TIME_DEF, 1460 .lead_time = BT_LEAD_TIME_DEF,
@@ -1497,8 +1471,9 @@ int iwl_send_bt_config(struct iwl_priv *priv)
1497 IWL_DEBUG_INFO(priv, "BT coex %s\n", 1471 IWL_DEBUG_INFO(priv, "BT coex %s\n",
1498 (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); 1472 (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active");
1499 1473
1500 return iwl_send_cmd_pdu(priv, REPLY_BT_CONFIG, 1474 if (iwl_send_cmd_pdu(priv, REPLY_BT_CONFIG,
1501 sizeof(struct iwl_bt_cmd), &bt_cmd); 1475 sizeof(struct iwl_bt_cmd), &bt_cmd))
1476 IWL_ERR(priv, "failed to send BT Coex Config\n");
1502} 1477}
1503EXPORT_SYMBOL(iwl_send_bt_config); 1478EXPORT_SYMBOL(iwl_send_bt_config);
1504 1479
@@ -1868,7 +1843,6 @@ static inline void iwl_set_no_assoc(struct iwl_priv *priv)
1868 iwlcore_commit_rxon(priv); 1843 iwlcore_commit_rxon(priv);
1869} 1844}
1870 1845
1871#define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6)
1872void iwl_bss_info_changed(struct ieee80211_hw *hw, 1846void iwl_bss_info_changed(struct ieee80211_hw *hw,
1873 struct ieee80211_vif *vif, 1847 struct ieee80211_vif *vif,
1874 struct ieee80211_bss_conf *bss_conf, 1848 struct ieee80211_bss_conf *bss_conf,
@@ -1989,14 +1963,6 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
1989 1963
1990 iwl_led_associate(priv); 1964 iwl_led_associate(priv);
1991 1965
1992 /*
1993 * We have just associated, don't start scan too early
1994 * leave time for EAPOL exchange to complete.
1995 *
1996 * XXX: do this in mac80211
1997 */
1998 priv->next_scan_jiffies = jiffies +
1999 IWL_DELAY_NEXT_SCAN_AFTER_ASSOC;
2000 if (!iwl_is_rfkill(priv)) 1966 if (!iwl_is_rfkill(priv))
2001 priv->cfg->ops->lib->post_associate(priv); 1967 priv->cfg->ops->lib->post_associate(priv);
2002 } else 1968 } else
@@ -2151,10 +2117,6 @@ EXPORT_SYMBOL(iwl_mac_remove_interface);
2151 2117
2152/** 2118/**
2153 * iwl_mac_config - mac80211 config callback 2119 * iwl_mac_config - mac80211 config callback
2154 *
2155 * We ignore conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME since it seems to
2156 * be set inappropriately and the driver currently sets the hardware up to
2157 * use it whenever needed.
2158 */ 2120 */
2159int iwl_mac_config(struct ieee80211_hw *hw, u32 changed) 2121int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
2160{ 2122{
@@ -2383,11 +2345,11 @@ EXPORT_SYMBOL(iwl_free_txq_mem);
2383 2345
2384int iwl_send_wimax_coex(struct iwl_priv *priv) 2346int iwl_send_wimax_coex(struct iwl_priv *priv)
2385{ 2347{
2386 struct iwl_wimax_coex_cmd uninitialized_var(coex_cmd); 2348 struct iwl_wimax_coex_cmd coex_cmd;
2387 2349
2388 if (priv->cfg->support_wimax_coexist) { 2350 if (priv->cfg->support_wimax_coexist) {
2389 /* UnMask wake up src at associated sleep */ 2351 /* UnMask wake up src at associated sleep */
2390 coex_cmd.flags |= COEX_FLAGS_ASSOC_WA_UNMASK_MSK; 2352 coex_cmd.flags = COEX_FLAGS_ASSOC_WA_UNMASK_MSK;
2391 2353
2392 /* UnMask wake up src at unassociated sleep */ 2354 /* UnMask wake up src at unassociated sleep */
2393 coex_cmd.flags |= COEX_FLAGS_UNASSOC_WA_UNMASK_MSK; 2355 coex_cmd.flags |= COEX_FLAGS_UNASSOC_WA_UNMASK_MSK;
@@ -2802,7 +2764,6 @@ static void iwl_force_rf_reset(struct iwl_priv *priv)
2802 */ 2764 */
2803 IWL_DEBUG_INFO(priv, "perform radio reset.\n"); 2765 IWL_DEBUG_INFO(priv, "perform radio reset.\n");
2804 iwl_internal_short_hw_scan(priv); 2766 iwl_internal_short_hw_scan(priv);
2805 return;
2806} 2767}
2807 2768
2808 2769
@@ -2970,6 +2931,12 @@ int iwl_pci_resume(struct pci_dev *pdev)
2970 struct iwl_priv *priv = pci_get_drvdata(pdev); 2931 struct iwl_priv *priv = pci_get_drvdata(pdev);
2971 int ret; 2932 int ret;
2972 2933
2934 /*
2935 * We disable the RETRY_TIMEOUT register (0x41) to keep
2936 * PCI Tx retries from interfering with C3 CPU state.
2937 */
2938 pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00);
2939
2973 pci_set_power_state(pdev, PCI_D0); 2940 pci_set_power_state(pdev, PCI_D0);
2974 ret = pci_enable_device(pdev); 2941 ret = pci_enable_device(pdev);
2975 if (ret) 2942 if (ret)
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index d89755f5031a..727360944859 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -90,6 +90,7 @@ struct iwl_hcmd_ops {
90 int (*commit_rxon)(struct iwl_priv *priv); 90 int (*commit_rxon)(struct iwl_priv *priv);
91 void (*set_rxon_chain)(struct iwl_priv *priv); 91 void (*set_rxon_chain)(struct iwl_priv *priv);
92 int (*set_tx_ant)(struct iwl_priv *priv, u8 valid_tx_ant); 92 int (*set_tx_ant)(struct iwl_priv *priv, u8 valid_tx_ant);
93 void (*send_bt_config)(struct iwl_priv *priv);
93}; 94};
94 95
95struct iwl_hcmd_utils_ops { 96struct iwl_hcmd_utils_ops {
@@ -105,6 +106,7 @@ struct iwl_hcmd_utils_ops {
105 __le32 *tx_flags); 106 __le32 *tx_flags);
106 int (*calc_rssi)(struct iwl_priv *priv, 107 int (*calc_rssi)(struct iwl_priv *priv,
107 struct iwl_rx_phy_res *rx_resp); 108 struct iwl_rx_phy_res *rx_resp);
109 void (*request_scan)(struct iwl_priv *priv);
108}; 110};
109 111
110struct iwl_apm_ops { 112struct iwl_apm_ops {
@@ -114,6 +116,15 @@ struct iwl_apm_ops {
114 int (*set_pwr_src)(struct iwl_priv *priv, enum iwl_pwr_src src); 116 int (*set_pwr_src)(struct iwl_priv *priv, enum iwl_pwr_src src);
115}; 117};
116 118
119struct iwl_debugfs_ops {
120 ssize_t (*rx_stats_read)(struct file *file, char __user *user_buf,
121 size_t count, loff_t *ppos);
122 ssize_t (*tx_stats_read)(struct file *file, char __user *user_buf,
123 size_t count, loff_t *ppos);
124 ssize_t (*general_stats_read)(struct file *file, char __user *user_buf,
125 size_t count, loff_t *ppos);
126};
127
117struct iwl_temp_ops { 128struct iwl_temp_ops {
118 void (*temperature)(struct iwl_priv *priv); 129 void (*temperature)(struct iwl_priv *priv);
119 void (*set_ct_kill)(struct iwl_priv *priv); 130 void (*set_ct_kill)(struct iwl_priv *priv);
@@ -199,6 +210,7 @@ struct iwl_lib_ops {
199 /* check for ack health */ 210 /* check for ack health */
200 bool (*check_ack_health)(struct iwl_priv *priv, 211 bool (*check_ack_health)(struct iwl_priv *priv,
201 struct iwl_rx_packet *pkt); 212 struct iwl_rx_packet *pkt);
213 struct iwl_debugfs_ops debugfs_ops;
202}; 214};
203 215
204struct iwl_led_ops { 216struct iwl_led_ops {
@@ -306,8 +318,8 @@ struct iwl_cfg {
306 /* timer period for monitor the driver queues */ 318 /* timer period for monitor the driver queues */
307 u32 monitor_recover_period; 319 u32 monitor_recover_period;
308 bool temperature_kelvin; 320 bool temperature_kelvin;
309 bool off_channel_workaround;
310 u32 max_event_log_size; 321 u32 max_event_log_size;
322 u8 scan_antennas[IEEE80211_NUM_BANDS];
311}; 323};
312 324
313/*************************** 325/***************************
@@ -339,7 +351,6 @@ void iwl_configure_filter(struct ieee80211_hw *hw,
339 unsigned int changed_flags, 351 unsigned int changed_flags,
340 unsigned int *total_flags, u64 multicast); 352 unsigned int *total_flags, u64 multicast);
341int iwl_set_hw_params(struct iwl_priv *priv); 353int iwl_set_hw_params(struct iwl_priv *priv);
342bool iwl_is_monitor_mode(struct iwl_priv *priv);
343void iwl_post_associate(struct iwl_priv *priv); 354void iwl_post_associate(struct iwl_priv *priv);
344void iwl_bss_info_changed(struct ieee80211_hw *hw, 355void iwl_bss_info_changed(struct ieee80211_hw *hw,
345 struct ieee80211_vif *vif, 356 struct ieee80211_vif *vif,
@@ -501,8 +512,10 @@ static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags)
501void iwl_init_scan_params(struct iwl_priv *priv); 512void iwl_init_scan_params(struct iwl_priv *priv);
502int iwl_scan_cancel(struct iwl_priv *priv); 513int iwl_scan_cancel(struct iwl_priv *priv);
503int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); 514int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms);
504int iwl_mac_hw_scan(struct ieee80211_hw *hw, struct cfg80211_scan_request *req); 515int iwl_mac_hw_scan(struct ieee80211_hw *hw,
505int iwl_internal_short_hw_scan(struct iwl_priv *priv); 516 struct ieee80211_vif *vif,
517 struct cfg80211_scan_request *req);
518void iwl_internal_short_hw_scan(struct iwl_priv *priv);
506int iwl_force_reset(struct iwl_priv *priv, int mode); 519int iwl_force_reset(struct iwl_priv *priv, int mode);
507u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, 520u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
508 const u8 *ie, int ie_len, int left); 521 const u8 *ie, int ie_len, int left);
@@ -526,6 +539,7 @@ void iwl_setup_scan_deferred_work(struct iwl_priv *priv);
526#define IWL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */ 539#define IWL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */
527#define IWL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */ 540#define IWL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */
528 541
542#define IWL_SCAN_CHECK_WATCHDOG (HZ * 7)
529 543
530/******************************************************************************* 544/*******************************************************************************
531 * Calibrations - implemented in iwl-calib.c 545 * Calibrations - implemented in iwl-calib.c
@@ -665,7 +679,7 @@ static inline int iwl_is_ready_rf(struct iwl_priv *priv)
665} 679}
666 680
667extern void iwl_rf_kill_ct_config(struct iwl_priv *priv); 681extern void iwl_rf_kill_ct_config(struct iwl_priv *priv);
668extern int iwl_send_bt_config(struct iwl_priv *priv); 682extern void iwl_send_bt_config(struct iwl_priv *priv);
669extern int iwl_send_statistics_request(struct iwl_priv *priv, 683extern int iwl_send_statistics_request(struct iwl_priv *priv,
670 u8 flags, bool clear); 684 u8 flags, bool clear);
671extern int iwl_verify_ucode(struct iwl_priv *priv); 685extern int iwl_verify_ucode(struct iwl_priv *priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h
index 808b7146bead..254c35ae8b38 100644
--- a/drivers/net/wireless/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/iwlwifi/iwl-csr.h
@@ -298,6 +298,7 @@
298#define CSR_HW_REV_TYPE_1000 (0x0000060) 298#define CSR_HW_REV_TYPE_1000 (0x0000060)
299#define CSR_HW_REV_TYPE_6x00 (0x0000070) 299#define CSR_HW_REV_TYPE_6x00 (0x0000070)
300#define CSR_HW_REV_TYPE_6x50 (0x0000080) 300#define CSR_HW_REV_TYPE_6x50 (0x0000080)
301#define CSR_HW_REV_TYPE_6x00g2 (0x00000B0)
301#define CSR_HW_REV_TYPE_NONE (0x00000F0) 302#define CSR_HW_REV_TYPE_NONE (0x00000F0)
302 303
303/* EEPROM REG */ 304/* EEPROM REG */
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index 1c7b53d511c7..5c2bcef5df0c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -78,6 +78,8 @@ static inline void iwl_print_hex_dump(struct iwl_priv *priv, int level,
78#ifdef CONFIG_IWLWIFI_DEBUGFS 78#ifdef CONFIG_IWLWIFI_DEBUGFS
79int iwl_dbgfs_register(struct iwl_priv *priv, const char *name); 79int iwl_dbgfs_register(struct iwl_priv *priv, const char *name);
80void iwl_dbgfs_unregister(struct iwl_priv *priv); 80void iwl_dbgfs_unregister(struct iwl_priv *priv);
81extern int iwl_dbgfs_statistics_flag(struct iwl_priv *priv, char *buf,
82 int bufsz);
81#else 83#else
82static inline int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) 84static inline int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
83{ 85{
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 607a91f3eb6b..4aabb542fcbe 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -106,6 +106,26 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
106 .open = iwl_dbgfs_open_file_generic, \ 106 .open = iwl_dbgfs_open_file_generic, \
107}; 107};
108 108
109int iwl_dbgfs_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
110{
111 int p = 0;
112
113 p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n",
114 le32_to_cpu(priv->statistics.flag));
115 if (le32_to_cpu(priv->statistics.flag) & UCODE_STATISTICS_CLEAR_MSK)
116 p += scnprintf(buf + p, bufsz - p,
117 "\tStatistics have been cleared\n");
118 p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
119 (le32_to_cpu(priv->statistics.flag) &
120 UCODE_STATISTICS_FREQUENCY_MSK)
121 ? "2.4 GHz" : "5.2 GHz");
122 p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
123 (le32_to_cpu(priv->statistics.flag) &
124 UCODE_STATISTICS_NARROW_BAND_MSK)
125 ? "enabled" : "disabled");
126 return p;
127}
128EXPORT_SYMBOL(iwl_dbgfs_statistics_flag);
109 129
110static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file, 130static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file,
111 char __user *user_buf, 131 char __user *user_buf,
@@ -1034,474 +1054,13 @@ static ssize_t iwl_dbgfs_rx_queue_read(struct file *file,
1034 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 1054 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1035} 1055}
1036 1056
1037static int iwl_dbgfs_statistics_flag(struct iwl_priv *priv, char *buf,
1038 int bufsz)
1039{
1040 int p = 0;
1041
1042 p += scnprintf(buf + p, bufsz - p,
1043 "Statistics Flag(0x%X):\n",
1044 le32_to_cpu(priv->statistics.flag));
1045 if (le32_to_cpu(priv->statistics.flag) & UCODE_STATISTICS_CLEAR_MSK)
1046 p += scnprintf(buf + p, bufsz - p,
1047 "\tStatistics have been cleared\n");
1048 p += scnprintf(buf + p, bufsz - p,
1049 "\tOperational Frequency: %s\n",
1050 (le32_to_cpu(priv->statistics.flag) &
1051 UCODE_STATISTICS_FREQUENCY_MSK)
1052 ? "2.4 GHz" : "5.2 GHz");
1053 p += scnprintf(buf + p, bufsz - p,
1054 "\tTGj Narrow Band: %s\n",
1055 (le32_to_cpu(priv->statistics.flag) &
1056 UCODE_STATISTICS_NARROW_BAND_MSK)
1057 ? "enabled" : "disabled");
1058 return p;
1059}
1060
1061static const char ucode_stats_header[] =
1062 "%-32s current acumulative delta max\n";
1063static const char ucode_stats_short_format[] =
1064 " %-30s %10u\n";
1065static const char ucode_stats_format[] =
1066 " %-30s %10u %10u %10u %10u\n";
1067
1068static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file, 1057static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
1069 char __user *user_buf, 1058 char __user *user_buf,
1070 size_t count, loff_t *ppos) 1059 size_t count, loff_t *ppos)
1071{ 1060{
1072 struct iwl_priv *priv = file->private_data; 1061 struct iwl_priv *priv = file->private_data;
1073 int pos = 0; 1062 return priv->cfg->ops->lib->debugfs_ops.rx_stats_read(file,
1074 char *buf; 1063 user_buf, count, ppos);
1075 int bufsz = sizeof(struct statistics_rx_phy) * 40 +
1076 sizeof(struct statistics_rx_non_phy) * 40 +
1077 sizeof(struct statistics_rx_ht_phy) * 40 + 400;
1078 ssize_t ret;
1079 struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
1080 struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
1081 struct statistics_rx_non_phy *general, *accum_general;
1082 struct statistics_rx_non_phy *delta_general, *max_general;
1083 struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
1084
1085 if (!iwl_is_alive(priv))
1086 return -EAGAIN;
1087
1088 buf = kzalloc(bufsz, GFP_KERNEL);
1089 if (!buf) {
1090 IWL_ERR(priv, "Can not allocate Buffer\n");
1091 return -ENOMEM;
1092 }
1093
1094 /* the statistic information display here is based on
1095 * the last statistics notification from uCode
1096 * might not reflect the current uCode activity
1097 */
1098 ofdm = &priv->statistics.rx.ofdm;
1099 cck = &priv->statistics.rx.cck;
1100 general = &priv->statistics.rx.general;
1101 ht = &priv->statistics.rx.ofdm_ht;
1102 accum_ofdm = &priv->accum_statistics.rx.ofdm;
1103 accum_cck = &priv->accum_statistics.rx.cck;
1104 accum_general = &priv->accum_statistics.rx.general;
1105 accum_ht = &priv->accum_statistics.rx.ofdm_ht;
1106 delta_ofdm = &priv->delta_statistics.rx.ofdm;
1107 delta_cck = &priv->delta_statistics.rx.cck;
1108 delta_general = &priv->delta_statistics.rx.general;
1109 delta_ht = &priv->delta_statistics.rx.ofdm_ht;
1110 max_ofdm = &priv->max_delta.rx.ofdm;
1111 max_cck = &priv->max_delta.rx.cck;
1112 max_general = &priv->max_delta.rx.general;
1113 max_ht = &priv->max_delta.rx.ofdm_ht;
1114
1115 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
1116 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1117 "Statistics_Rx - OFDM:");
1118 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1119 "ina_cnt:", le32_to_cpu(ofdm->ina_cnt),
1120 accum_ofdm->ina_cnt,
1121 delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
1122 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1123 "fina_cnt:",
1124 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
1125 delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
1126 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1127 "plcp_err:",
1128 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
1129 delta_ofdm->plcp_err, max_ofdm->plcp_err);
1130 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1131 "crc32_err:",
1132 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
1133 delta_ofdm->crc32_err, max_ofdm->crc32_err);
1134 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1135 "overrun_err:",
1136 le32_to_cpu(ofdm->overrun_err),
1137 accum_ofdm->overrun_err,
1138 delta_ofdm->overrun_err, max_ofdm->overrun_err);
1139 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1140 "early_overrun_err:",
1141 le32_to_cpu(ofdm->early_overrun_err),
1142 accum_ofdm->early_overrun_err,
1143 delta_ofdm->early_overrun_err,
1144 max_ofdm->early_overrun_err);
1145 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1146 "crc32_good:",
1147 le32_to_cpu(ofdm->crc32_good),
1148 accum_ofdm->crc32_good,
1149 delta_ofdm->crc32_good, max_ofdm->crc32_good);
1150 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1151 "false_alarm_cnt:",
1152 le32_to_cpu(ofdm->false_alarm_cnt),
1153 accum_ofdm->false_alarm_cnt,
1154 delta_ofdm->false_alarm_cnt,
1155 max_ofdm->false_alarm_cnt);
1156 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1157 "fina_sync_err_cnt:",
1158 le32_to_cpu(ofdm->fina_sync_err_cnt),
1159 accum_ofdm->fina_sync_err_cnt,
1160 delta_ofdm->fina_sync_err_cnt,
1161 max_ofdm->fina_sync_err_cnt);
1162 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1163 "sfd_timeout:",
1164 le32_to_cpu(ofdm->sfd_timeout),
1165 accum_ofdm->sfd_timeout,
1166 delta_ofdm->sfd_timeout,
1167 max_ofdm->sfd_timeout);
1168 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1169 "fina_timeout:",
1170 le32_to_cpu(ofdm->fina_timeout),
1171 accum_ofdm->fina_timeout,
1172 delta_ofdm->fina_timeout,
1173 max_ofdm->fina_timeout);
1174 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1175 "unresponded_rts:",
1176 le32_to_cpu(ofdm->unresponded_rts),
1177 accum_ofdm->unresponded_rts,
1178 delta_ofdm->unresponded_rts,
1179 max_ofdm->unresponded_rts);
1180 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1181 "rxe_frame_lmt_ovrun:",
1182 le32_to_cpu(ofdm->rxe_frame_limit_overrun),
1183 accum_ofdm->rxe_frame_limit_overrun,
1184 delta_ofdm->rxe_frame_limit_overrun,
1185 max_ofdm->rxe_frame_limit_overrun);
1186 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1187 "sent_ack_cnt:",
1188 le32_to_cpu(ofdm->sent_ack_cnt),
1189 accum_ofdm->sent_ack_cnt,
1190 delta_ofdm->sent_ack_cnt,
1191 max_ofdm->sent_ack_cnt);
1192 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1193 "sent_cts_cnt:",
1194 le32_to_cpu(ofdm->sent_cts_cnt),
1195 accum_ofdm->sent_cts_cnt,
1196 delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt);
1197 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1198 "sent_ba_rsp_cnt:",
1199 le32_to_cpu(ofdm->sent_ba_rsp_cnt),
1200 accum_ofdm->sent_ba_rsp_cnt,
1201 delta_ofdm->sent_ba_rsp_cnt,
1202 max_ofdm->sent_ba_rsp_cnt);
1203 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1204 "dsp_self_kill:",
1205 le32_to_cpu(ofdm->dsp_self_kill),
1206 accum_ofdm->dsp_self_kill,
1207 delta_ofdm->dsp_self_kill,
1208 max_ofdm->dsp_self_kill);
1209 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1210 "mh_format_err:",
1211 le32_to_cpu(ofdm->mh_format_err),
1212 accum_ofdm->mh_format_err,
1213 delta_ofdm->mh_format_err,
1214 max_ofdm->mh_format_err);
1215 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1216 "re_acq_main_rssi_sum:",
1217 le32_to_cpu(ofdm->re_acq_main_rssi_sum),
1218 accum_ofdm->re_acq_main_rssi_sum,
1219 delta_ofdm->re_acq_main_rssi_sum,
1220 max_ofdm->re_acq_main_rssi_sum);
1221
1222 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1223 "Statistics_Rx - CCK:");
1224 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1225 "ina_cnt:",
1226 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
1227 delta_cck->ina_cnt, max_cck->ina_cnt);
1228 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1229 "fina_cnt:",
1230 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
1231 delta_cck->fina_cnt, max_cck->fina_cnt);
1232 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1233 "plcp_err:",
1234 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
1235 delta_cck->plcp_err, max_cck->plcp_err);
1236 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1237 "crc32_err:",
1238 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
1239 delta_cck->crc32_err, max_cck->crc32_err);
1240 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1241 "overrun_err:",
1242 le32_to_cpu(cck->overrun_err),
1243 accum_cck->overrun_err,
1244 delta_cck->overrun_err, max_cck->overrun_err);
1245 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1246 "early_overrun_err:",
1247 le32_to_cpu(cck->early_overrun_err),
1248 accum_cck->early_overrun_err,
1249 delta_cck->early_overrun_err,
1250 max_cck->early_overrun_err);
1251 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1252 "crc32_good:",
1253 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
1254 delta_cck->crc32_good,
1255 max_cck->crc32_good);
1256 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1257 "false_alarm_cnt:",
1258 le32_to_cpu(cck->false_alarm_cnt),
1259 accum_cck->false_alarm_cnt,
1260 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
1261 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1262 "fina_sync_err_cnt:",
1263 le32_to_cpu(cck->fina_sync_err_cnt),
1264 accum_cck->fina_sync_err_cnt,
1265 delta_cck->fina_sync_err_cnt,
1266 max_cck->fina_sync_err_cnt);
1267 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1268 "sfd_timeout:",
1269 le32_to_cpu(cck->sfd_timeout),
1270 accum_cck->sfd_timeout,
1271 delta_cck->sfd_timeout, max_cck->sfd_timeout);
1272 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1273 "fina_timeout:",
1274 le32_to_cpu(cck->fina_timeout),
1275 accum_cck->fina_timeout,
1276 delta_cck->fina_timeout, max_cck->fina_timeout);
1277 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1278 "unresponded_rts:",
1279 le32_to_cpu(cck->unresponded_rts),
1280 accum_cck->unresponded_rts,
1281 delta_cck->unresponded_rts,
1282 max_cck->unresponded_rts);
1283 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1284 "rxe_frame_lmt_ovrun:",
1285 le32_to_cpu(cck->rxe_frame_limit_overrun),
1286 accum_cck->rxe_frame_limit_overrun,
1287 delta_cck->rxe_frame_limit_overrun,
1288 max_cck->rxe_frame_limit_overrun);
1289 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1290 "sent_ack_cnt:",
1291 le32_to_cpu(cck->sent_ack_cnt),
1292 accum_cck->sent_ack_cnt,
1293 delta_cck->sent_ack_cnt,
1294 max_cck->sent_ack_cnt);
1295 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1296 "sent_cts_cnt:",
1297 le32_to_cpu(cck->sent_cts_cnt),
1298 accum_cck->sent_cts_cnt,
1299 delta_cck->sent_cts_cnt,
1300 max_cck->sent_cts_cnt);
1301 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1302 "sent_ba_rsp_cnt:",
1303 le32_to_cpu(cck->sent_ba_rsp_cnt),
1304 accum_cck->sent_ba_rsp_cnt,
1305 delta_cck->sent_ba_rsp_cnt,
1306 max_cck->sent_ba_rsp_cnt);
1307 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1308 "dsp_self_kill:",
1309 le32_to_cpu(cck->dsp_self_kill),
1310 accum_cck->dsp_self_kill,
1311 delta_cck->dsp_self_kill,
1312 max_cck->dsp_self_kill);
1313 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1314 "mh_format_err:",
1315 le32_to_cpu(cck->mh_format_err),
1316 accum_cck->mh_format_err,
1317 delta_cck->mh_format_err, max_cck->mh_format_err);
1318 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1319 "re_acq_main_rssi_sum:",
1320 le32_to_cpu(cck->re_acq_main_rssi_sum),
1321 accum_cck->re_acq_main_rssi_sum,
1322 delta_cck->re_acq_main_rssi_sum,
1323 max_cck->re_acq_main_rssi_sum);
1324
1325 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1326 "Statistics_Rx - GENERAL:");
1327 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1328 "bogus_cts:",
1329 le32_to_cpu(general->bogus_cts),
1330 accum_general->bogus_cts,
1331 delta_general->bogus_cts, max_general->bogus_cts);
1332 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1333 "bogus_ack:",
1334 le32_to_cpu(general->bogus_ack),
1335 accum_general->bogus_ack,
1336 delta_general->bogus_ack, max_general->bogus_ack);
1337 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1338 "non_bssid_frames:",
1339 le32_to_cpu(general->non_bssid_frames),
1340 accum_general->non_bssid_frames,
1341 delta_general->non_bssid_frames,
1342 max_general->non_bssid_frames);
1343 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1344 "filtered_frames:",
1345 le32_to_cpu(general->filtered_frames),
1346 accum_general->filtered_frames,
1347 delta_general->filtered_frames,
1348 max_general->filtered_frames);
1349 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1350 "non_channel_beacons:",
1351 le32_to_cpu(general->non_channel_beacons),
1352 accum_general->non_channel_beacons,
1353 delta_general->non_channel_beacons,
1354 max_general->non_channel_beacons);
1355 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1356 "channel_beacons:",
1357 le32_to_cpu(general->channel_beacons),
1358 accum_general->channel_beacons,
1359 delta_general->channel_beacons,
1360 max_general->channel_beacons);
1361 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1362 "num_missed_bcon:",
1363 le32_to_cpu(general->num_missed_bcon),
1364 accum_general->num_missed_bcon,
1365 delta_general->num_missed_bcon,
1366 max_general->num_missed_bcon);
1367 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1368 "adc_rx_saturation_time:",
1369 le32_to_cpu(general->adc_rx_saturation_time),
1370 accum_general->adc_rx_saturation_time,
1371 delta_general->adc_rx_saturation_time,
1372 max_general->adc_rx_saturation_time);
1373 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1374 "ina_detect_search_tm:",
1375 le32_to_cpu(general->ina_detection_search_time),
1376 accum_general->ina_detection_search_time,
1377 delta_general->ina_detection_search_time,
1378 max_general->ina_detection_search_time);
1379 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1380 "beacon_silence_rssi_a:",
1381 le32_to_cpu(general->beacon_silence_rssi_a),
1382 accum_general->beacon_silence_rssi_a,
1383 delta_general->beacon_silence_rssi_a,
1384 max_general->beacon_silence_rssi_a);
1385 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1386 "beacon_silence_rssi_b:",
1387 le32_to_cpu(general->beacon_silence_rssi_b),
1388 accum_general->beacon_silence_rssi_b,
1389 delta_general->beacon_silence_rssi_b,
1390 max_general->beacon_silence_rssi_b);
1391 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1392 "beacon_silence_rssi_c:",
1393 le32_to_cpu(general->beacon_silence_rssi_c),
1394 accum_general->beacon_silence_rssi_c,
1395 delta_general->beacon_silence_rssi_c,
1396 max_general->beacon_silence_rssi_c);
1397 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1398 "interference_data_flag:",
1399 le32_to_cpu(general->interference_data_flag),
1400 accum_general->interference_data_flag,
1401 delta_general->interference_data_flag,
1402 max_general->interference_data_flag);
1403 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1404 "channel_load:",
1405 le32_to_cpu(general->channel_load),
1406 accum_general->channel_load,
1407 delta_general->channel_load,
1408 max_general->channel_load);
1409 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1410 "dsp_false_alarms:",
1411 le32_to_cpu(general->dsp_false_alarms),
1412 accum_general->dsp_false_alarms,
1413 delta_general->dsp_false_alarms,
1414 max_general->dsp_false_alarms);
1415 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1416 "beacon_rssi_a:",
1417 le32_to_cpu(general->beacon_rssi_a),
1418 accum_general->beacon_rssi_a,
1419 delta_general->beacon_rssi_a,
1420 max_general->beacon_rssi_a);
1421 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1422 "beacon_rssi_b:",
1423 le32_to_cpu(general->beacon_rssi_b),
1424 accum_general->beacon_rssi_b,
1425 delta_general->beacon_rssi_b,
1426 max_general->beacon_rssi_b);
1427 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1428 "beacon_rssi_c:",
1429 le32_to_cpu(general->beacon_rssi_c),
1430 accum_general->beacon_rssi_c,
1431 delta_general->beacon_rssi_c,
1432 max_general->beacon_rssi_c);
1433 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1434 "beacon_energy_a:",
1435 le32_to_cpu(general->beacon_energy_a),
1436 accum_general->beacon_energy_a,
1437 delta_general->beacon_energy_a,
1438 max_general->beacon_energy_a);
1439 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1440 "beacon_energy_b:",
1441 le32_to_cpu(general->beacon_energy_b),
1442 accum_general->beacon_energy_b,
1443 delta_general->beacon_energy_b,
1444 max_general->beacon_energy_b);
1445 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1446 "beacon_energy_c:",
1447 le32_to_cpu(general->beacon_energy_c),
1448 accum_general->beacon_energy_c,
1449 delta_general->beacon_energy_c,
1450 max_general->beacon_energy_c);
1451
1452 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Rx - OFDM_HT:\n");
1453 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1454 "Statistics_Rx - OFDM_HT:");
1455 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1456 "plcp_err:",
1457 le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
1458 delta_ht->plcp_err, max_ht->plcp_err);
1459 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1460 "overrun_err:",
1461 le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
1462 delta_ht->overrun_err, max_ht->overrun_err);
1463 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1464 "early_overrun_err:",
1465 le32_to_cpu(ht->early_overrun_err),
1466 accum_ht->early_overrun_err,
1467 delta_ht->early_overrun_err,
1468 max_ht->early_overrun_err);
1469 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1470 "crc32_good:",
1471 le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
1472 delta_ht->crc32_good, max_ht->crc32_good);
1473 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1474 "crc32_err:",
1475 le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
1476 delta_ht->crc32_err, max_ht->crc32_err);
1477 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1478 "mh_format_err:",
1479 le32_to_cpu(ht->mh_format_err),
1480 accum_ht->mh_format_err,
1481 delta_ht->mh_format_err, max_ht->mh_format_err);
1482 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1483 "agg_crc32_good:",
1484 le32_to_cpu(ht->agg_crc32_good),
1485 accum_ht->agg_crc32_good,
1486 delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
1487 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1488 "agg_mpdu_cnt:",
1489 le32_to_cpu(ht->agg_mpdu_cnt),
1490 accum_ht->agg_mpdu_cnt,
1491 delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
1492 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1493 "agg_cnt:",
1494 le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
1495 delta_ht->agg_cnt, max_ht->agg_cnt);
1496 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1497 "unsupport_mcs:",
1498 le32_to_cpu(ht->unsupport_mcs),
1499 accum_ht->unsupport_mcs,
1500 delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
1501
1502 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1503 kfree(buf);
1504 return ret;
1505} 1064}
1506 1065
1507static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file, 1066static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
@@ -1509,173 +1068,8 @@ static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
1509 size_t count, loff_t *ppos) 1068 size_t count, loff_t *ppos)
1510{ 1069{
1511 struct iwl_priv *priv = file->private_data; 1070 struct iwl_priv *priv = file->private_data;
1512 int pos = 0; 1071 return priv->cfg->ops->lib->debugfs_ops.tx_stats_read(file,
1513 char *buf; 1072 user_buf, count, ppos);
1514 int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
1515 ssize_t ret;
1516 struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
1517
1518 if (!iwl_is_alive(priv))
1519 return -EAGAIN;
1520
1521 buf = kzalloc(bufsz, GFP_KERNEL);
1522 if (!buf) {
1523 IWL_ERR(priv, "Can not allocate Buffer\n");
1524 return -ENOMEM;
1525 }
1526
1527 /* the statistic information display here is based on
1528 * the last statistics notification from uCode
1529 * might not reflect the current uCode activity
1530 */
1531 tx = &priv->statistics.tx;
1532 accum_tx = &priv->accum_statistics.tx;
1533 delta_tx = &priv->delta_statistics.tx;
1534 max_tx = &priv->max_delta.tx;
1535 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
1536 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1537 "Statistics_Tx:");
1538 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1539 "preamble:",
1540 le32_to_cpu(tx->preamble_cnt),
1541 accum_tx->preamble_cnt,
1542 delta_tx->preamble_cnt, max_tx->preamble_cnt);
1543 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1544 "rx_detected_cnt:",
1545 le32_to_cpu(tx->rx_detected_cnt),
1546 accum_tx->rx_detected_cnt,
1547 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
1548 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1549 "bt_prio_defer_cnt:",
1550 le32_to_cpu(tx->bt_prio_defer_cnt),
1551 accum_tx->bt_prio_defer_cnt,
1552 delta_tx->bt_prio_defer_cnt,
1553 max_tx->bt_prio_defer_cnt);
1554 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1555 "bt_prio_kill_cnt:",
1556 le32_to_cpu(tx->bt_prio_kill_cnt),
1557 accum_tx->bt_prio_kill_cnt,
1558 delta_tx->bt_prio_kill_cnt,
1559 max_tx->bt_prio_kill_cnt);
1560 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1561 "few_bytes_cnt:",
1562 le32_to_cpu(tx->few_bytes_cnt),
1563 accum_tx->few_bytes_cnt,
1564 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
1565 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1566 "cts_timeout:",
1567 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
1568 delta_tx->cts_timeout, max_tx->cts_timeout);
1569 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1570 "ack_timeout:",
1571 le32_to_cpu(tx->ack_timeout),
1572 accum_tx->ack_timeout,
1573 delta_tx->ack_timeout, max_tx->ack_timeout);
1574 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1575 "expected_ack_cnt:",
1576 le32_to_cpu(tx->expected_ack_cnt),
1577 accum_tx->expected_ack_cnt,
1578 delta_tx->expected_ack_cnt,
1579 max_tx->expected_ack_cnt);
1580 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1581 "actual_ack_cnt:",
1582 le32_to_cpu(tx->actual_ack_cnt),
1583 accum_tx->actual_ack_cnt,
1584 delta_tx->actual_ack_cnt,
1585 max_tx->actual_ack_cnt);
1586 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1587 "dump_msdu_cnt:",
1588 le32_to_cpu(tx->dump_msdu_cnt),
1589 accum_tx->dump_msdu_cnt,
1590 delta_tx->dump_msdu_cnt,
1591 max_tx->dump_msdu_cnt);
1592 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1593 "abort_nxt_frame_mismatch:",
1594 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
1595 accum_tx->burst_abort_next_frame_mismatch_cnt,
1596 delta_tx->burst_abort_next_frame_mismatch_cnt,
1597 max_tx->burst_abort_next_frame_mismatch_cnt);
1598 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1599 "abort_missing_nxt_frame:",
1600 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
1601 accum_tx->burst_abort_missing_next_frame_cnt,
1602 delta_tx->burst_abort_missing_next_frame_cnt,
1603 max_tx->burst_abort_missing_next_frame_cnt);
1604 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1605 "cts_timeout_collision:",
1606 le32_to_cpu(tx->cts_timeout_collision),
1607 accum_tx->cts_timeout_collision,
1608 delta_tx->cts_timeout_collision,
1609 max_tx->cts_timeout_collision);
1610 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1611 "ack_ba_timeout_collision:",
1612 le32_to_cpu(tx->ack_or_ba_timeout_collision),
1613 accum_tx->ack_or_ba_timeout_collision,
1614 delta_tx->ack_or_ba_timeout_collision,
1615 max_tx->ack_or_ba_timeout_collision);
1616 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1617 "agg ba_timeout:",
1618 le32_to_cpu(tx->agg.ba_timeout),
1619 accum_tx->agg.ba_timeout,
1620 delta_tx->agg.ba_timeout,
1621 max_tx->agg.ba_timeout);
1622 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1623 "agg ba_resched_frames:",
1624 le32_to_cpu(tx->agg.ba_reschedule_frames),
1625 accum_tx->agg.ba_reschedule_frames,
1626 delta_tx->agg.ba_reschedule_frames,
1627 max_tx->agg.ba_reschedule_frames);
1628 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1629 "agg scd_query_agg_frame:",
1630 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
1631 accum_tx->agg.scd_query_agg_frame_cnt,
1632 delta_tx->agg.scd_query_agg_frame_cnt,
1633 max_tx->agg.scd_query_agg_frame_cnt);
1634 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1635 "agg scd_query_no_agg:",
1636 le32_to_cpu(tx->agg.scd_query_no_agg),
1637 accum_tx->agg.scd_query_no_agg,
1638 delta_tx->agg.scd_query_no_agg,
1639 max_tx->agg.scd_query_no_agg);
1640 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1641 "agg scd_query_agg:",
1642 le32_to_cpu(tx->agg.scd_query_agg),
1643 accum_tx->agg.scd_query_agg,
1644 delta_tx->agg.scd_query_agg,
1645 max_tx->agg.scd_query_agg);
1646 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1647 "agg scd_query_mismatch:",
1648 le32_to_cpu(tx->agg.scd_query_mismatch),
1649 accum_tx->agg.scd_query_mismatch,
1650 delta_tx->agg.scd_query_mismatch,
1651 max_tx->agg.scd_query_mismatch);
1652 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1653 "agg frame_not_ready:",
1654 le32_to_cpu(tx->agg.frame_not_ready),
1655 accum_tx->agg.frame_not_ready,
1656 delta_tx->agg.frame_not_ready,
1657 max_tx->agg.frame_not_ready);
1658 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1659 "agg underrun:",
1660 le32_to_cpu(tx->agg.underrun),
1661 accum_tx->agg.underrun,
1662 delta_tx->agg.underrun, max_tx->agg.underrun);
1663 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1664 "agg bt_prio_kill:",
1665 le32_to_cpu(tx->agg.bt_prio_kill),
1666 accum_tx->agg.bt_prio_kill,
1667 delta_tx->agg.bt_prio_kill,
1668 max_tx->agg.bt_prio_kill);
1669 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1670 "agg rx_ba_rsp_cnt:",
1671 le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
1672 accum_tx->agg.rx_ba_rsp_cnt,
1673 delta_tx->agg.rx_ba_rsp_cnt,
1674 max_tx->agg.rx_ba_rsp_cnt);
1675
1676 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1677 kfree(buf);
1678 return ret;
1679} 1073}
1680 1074
1681static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file, 1075static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
@@ -1683,107 +1077,8 @@ static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
1683 size_t count, loff_t *ppos) 1077 size_t count, loff_t *ppos)
1684{ 1078{
1685 struct iwl_priv *priv = file->private_data; 1079 struct iwl_priv *priv = file->private_data;
1686 int pos = 0; 1080 return priv->cfg->ops->lib->debugfs_ops.general_stats_read(file,
1687 char *buf; 1081 user_buf, count, ppos);
1688 int bufsz = sizeof(struct statistics_general) * 10 + 300;
1689 ssize_t ret;
1690 struct statistics_general *general, *accum_general;
1691 struct statistics_general *delta_general, *max_general;
1692 struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
1693 struct statistics_div *div, *accum_div, *delta_div, *max_div;
1694
1695 if (!iwl_is_alive(priv))
1696 return -EAGAIN;
1697
1698 buf = kzalloc(bufsz, GFP_KERNEL);
1699 if (!buf) {
1700 IWL_ERR(priv, "Can not allocate Buffer\n");
1701 return -ENOMEM;
1702 }
1703
1704 /* the statistic information display here is based on
1705 * the last statistics notification from uCode
1706 * might not reflect the current uCode activity
1707 */
1708 general = &priv->statistics.general;
1709 dbg = &priv->statistics.general.dbg;
1710 div = &priv->statistics.general.div;
1711 accum_general = &priv->accum_statistics.general;
1712 delta_general = &priv->delta_statistics.general;
1713 max_general = &priv->max_delta.general;
1714 accum_dbg = &priv->accum_statistics.general.dbg;
1715 delta_dbg = &priv->delta_statistics.general.dbg;
1716 max_dbg = &priv->max_delta.general.dbg;
1717 accum_div = &priv->accum_statistics.general.div;
1718 delta_div = &priv->delta_statistics.general.div;
1719 max_div = &priv->max_delta.general.div;
1720 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
1721 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1722 "Statistics_General:");
1723 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_short_format,
1724 "temperature:",
1725 le32_to_cpu(general->temperature));
1726 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_short_format,
1727 "temperature_m:",
1728 le32_to_cpu(general->temperature_m));
1729 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1730 "burst_check:",
1731 le32_to_cpu(dbg->burst_check),
1732 accum_dbg->burst_check,
1733 delta_dbg->burst_check, max_dbg->burst_check);
1734 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1735 "burst_count:",
1736 le32_to_cpu(dbg->burst_count),
1737 accum_dbg->burst_count,
1738 delta_dbg->burst_count, max_dbg->burst_count);
1739 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1740 "sleep_time:",
1741 le32_to_cpu(general->sleep_time),
1742 accum_general->sleep_time,
1743 delta_general->sleep_time, max_general->sleep_time);
1744 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1745 "slots_out:",
1746 le32_to_cpu(general->slots_out),
1747 accum_general->slots_out,
1748 delta_general->slots_out, max_general->slots_out);
1749 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1750 "slots_idle:",
1751 le32_to_cpu(general->slots_idle),
1752 accum_general->slots_idle,
1753 delta_general->slots_idle, max_general->slots_idle);
1754 pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n",
1755 le32_to_cpu(general->ttl_timestamp));
1756 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1757 "tx_on_a:",
1758 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
1759 delta_div->tx_on_a, max_div->tx_on_a);
1760 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1761 "tx_on_b:",
1762 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
1763 delta_div->tx_on_b, max_div->tx_on_b);
1764 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1765 "exec_time:",
1766 le32_to_cpu(div->exec_time), accum_div->exec_time,
1767 delta_div->exec_time, max_div->exec_time);
1768 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1769 "probe_time:",
1770 le32_to_cpu(div->probe_time), accum_div->probe_time,
1771 delta_div->probe_time, max_div->probe_time);
1772 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1773 "rx_enable_counter:",
1774 le32_to_cpu(general->rx_enable_counter),
1775 accum_general->rx_enable_counter,
1776 delta_general->rx_enable_counter,
1777 max_general->rx_enable_counter);
1778 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1779 "num_of_sos_states:",
1780 le32_to_cpu(general->num_of_sos_states),
1781 accum_general->num_of_sos_states,
1782 delta_general->num_of_sos_states,
1783 max_general->num_of_sos_states);
1784 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1785 kfree(buf);
1786 return ret;
1787} 1082}
1788 1083
1789static ssize_t iwl_dbgfs_sensitivity_read(struct file *file, 1084static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
@@ -2341,10 +1636,11 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
2341 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); 1636 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
2342 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR); 1637 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
2343 DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); 1638 DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR);
1639 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
1640 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
1641 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
1642
2344 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) { 1643 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) {
2345 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
2346 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
2347 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
2348 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); 1644 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
2349 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); 1645 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
2350 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR); 1646 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 9466e909f553..58c69a5798d4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -58,7 +58,7 @@ extern struct iwl_cfg iwl5100_abg_cfg;
58extern struct iwl_cfg iwl5150_agn_cfg; 58extern struct iwl_cfg iwl5150_agn_cfg;
59extern struct iwl_cfg iwl5150_abg_cfg; 59extern struct iwl_cfg iwl5150_abg_cfg;
60extern struct iwl_cfg iwl6000i_2agn_cfg; 60extern struct iwl_cfg iwl6000i_2agn_cfg;
61extern struct iwl_cfg iwl6000i_g2_2agn_cfg; 61extern struct iwl_cfg iwl6000g2_2agn_cfg;
62extern struct iwl_cfg iwl6000i_2abg_cfg; 62extern struct iwl_cfg iwl6000i_2abg_cfg;
63extern struct iwl_cfg iwl6000i_2bg_cfg; 63extern struct iwl_cfg iwl6000i_2bg_cfg;
64extern struct iwl_cfg iwl6000_3agn_cfg; 64extern struct iwl_cfg iwl6000_3agn_cfg;
@@ -1049,12 +1049,10 @@ struct iwl_priv {
1049 struct iwl_calib_result calib_results[IWL_CALIB_MAX]; 1049 struct iwl_calib_result calib_results[IWL_CALIB_MAX];
1050 1050
1051 /* Scan related variables */ 1051 /* Scan related variables */
1052 unsigned long next_scan_jiffies;
1053 unsigned long scan_start; 1052 unsigned long scan_start;
1054 unsigned long scan_pass_start;
1055 unsigned long scan_start_tsf; 1053 unsigned long scan_start_tsf;
1056 void *scan; 1054 void *scan_cmd;
1057 int scan_bands; 1055 enum ieee80211_band scan_band;
1058 struct cfg80211_scan_request *scan_request; 1056 struct cfg80211_scan_request *scan_request;
1059 bool is_internal_short_scan; 1057 bool is_internal_short_scan;
1060 u8 scan_tx_ant[IEEE80211_NUM_BANDS]; 1058 u8 scan_tx_ant[IEEE80211_NUM_BANDS];
@@ -1204,6 +1202,11 @@ struct iwl_priv {
1204 struct delayed_work rfkill_poll; 1202 struct delayed_work rfkill_poll;
1205 1203
1206 struct iwl3945_notif_statistics statistics; 1204 struct iwl3945_notif_statistics statistics;
1205#ifdef CONFIG_IWLWIFI_DEBUG
1206 struct iwl3945_notif_statistics accum_statistics;
1207 struct iwl3945_notif_statistics delta_statistics;
1208 struct iwl3945_notif_statistics max_delta;
1209#endif
1207 1210
1208 u32 sta_supp_rates; 1211 u32 sta_supp_rates;
1209 int last_rx_rssi; /* From Rx packet statistics */ 1212 int last_rx_rssi; /* From Rx packet statistics */
@@ -1259,11 +1262,11 @@ struct iwl_priv {
1259 struct work_struct scan_completed; 1262 struct work_struct scan_completed;
1260 struct work_struct rx_replenish; 1263 struct work_struct rx_replenish;
1261 struct work_struct abort_scan; 1264 struct work_struct abort_scan;
1262 struct work_struct request_scan;
1263 struct work_struct beacon_update; 1265 struct work_struct beacon_update;
1264 struct work_struct tt_work; 1266 struct work_struct tt_work;
1265 struct work_struct ct_enter; 1267 struct work_struct ct_enter;
1266 struct work_struct ct_exit; 1268 struct work_struct ct_exit;
1269 struct work_struct start_internal_scan;
1267 1270
1268 struct tasklet_struct irq_tasklet; 1271 struct tasklet_struct irq_tasklet;
1269 1272
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
index cb6d50b78140..95aa202c85e3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
@@ -172,22 +172,22 @@ struct iwl_eeprom_enhanced_txpwr {
172#define EEPROM_5000_TX_POWER_VERSION (4) 172#define EEPROM_5000_TX_POWER_VERSION (4)
173#define EEPROM_5000_EEPROM_VERSION (0x11A) 173#define EEPROM_5000_EEPROM_VERSION (0x11A)
174 174
175/*5000 calibrations */ 175/* 5000 and up calibration */
176#define EEPROM_5000_CALIB_ALL (INDIRECT_ADDRESS | INDIRECT_CALIBRATION) 176#define EEPROM_CALIB_ALL (INDIRECT_ADDRESS | INDIRECT_CALIBRATION)
177#define EEPROM_5000_XTAL ((2*0x128) | EEPROM_5000_CALIB_ALL) 177#define EEPROM_XTAL ((2*0x128) | EEPROM_CALIB_ALL)
178#define EEPROM_5000_TEMPERATURE ((2*0x12A) | EEPROM_5000_CALIB_ALL) 178
179 179/* 5000 temperature */
180/* 5000 links */ 180#define EEPROM_5000_TEMPERATURE ((2*0x12A) | EEPROM_CALIB_ALL)
181#define EEPROM_5000_LINK_HOST (2*0x64) 181
182#define EEPROM_5000_LINK_GENERAL (2*0x65) 182/* agn links */
183#define EEPROM_5000_LINK_REGULATORY (2*0x66) 183#define EEPROM_LINK_HOST (2*0x64)
184#define EEPROM_5000_LINK_CALIBRATION (2*0x67) 184#define EEPROM_LINK_GENERAL (2*0x65)
185#define EEPROM_5000_LINK_PROCESS_ADJST (2*0x68) 185#define EEPROM_LINK_REGULATORY (2*0x66)
186#define EEPROM_5000_LINK_OTHERS (2*0x69) 186#define EEPROM_LINK_CALIBRATION (2*0x67)
187 187#define EEPROM_LINK_PROCESS_ADJST (2*0x68)
188/* 5000 regulatory - indirect access */ 188#define EEPROM_LINK_OTHERS (2*0x69)
189#define EEPROM_5000_REG_SKU_ID ((0x02)\ 189
190 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 4 bytes */ 190/* agn regulatory - indirect access */
191#define EEPROM_REG_BAND_1_CHANNELS ((0x08)\ 191#define EEPROM_REG_BAND_1_CHANNELS ((0x08)\
192 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 28 bytes */ 192 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 28 bytes */
193#define EEPROM_REG_BAND_2_CHANNELS ((0x26)\ 193#define EEPROM_REG_BAND_2_CHANNELS ((0x26)\
@@ -203,6 +203,10 @@ struct iwl_eeprom_enhanced_txpwr {
203#define EEPROM_REG_BAND_52_HT40_CHANNELS ((0x92)\ 203#define EEPROM_REG_BAND_52_HT40_CHANNELS ((0x92)\
204 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 22 bytes */ 204 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 22 bytes */
205 205
206/* 6000 regulatory - indirect access */
207#define EEPROM_6000_REG_BAND_24_HT40_CHANNELS ((0x80)\
208 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 14 bytes */
209
206/* 6000 and up regulatory tx power - indirect access */ 210/* 6000 and up regulatory tx power - indirect access */
207/* max. elements per section */ 211/* max. elements per section */
208#define EEPROM_MAX_TXPOWER_SECTION_ELEMENTS (8) 212#define EEPROM_MAX_TXPOWER_SECTION_ELEMENTS (8)
@@ -272,6 +276,10 @@ struct iwl_eeprom_enhanced_txpwr {
272#define EEPROM_6050_TX_POWER_VERSION (4) 276#define EEPROM_6050_TX_POWER_VERSION (4)
273#define EEPROM_6050_EEPROM_VERSION (0x532) 277#define EEPROM_6050_EEPROM_VERSION (0x532)
274 278
279/* 6x00g2 Specific */
280#define EEPROM_6000G2_TX_POWER_VERSION (6)
281#define EEPROM_6000G2_EEPROM_VERSION (0x709)
282
275/* OTP */ 283/* OTP */
276/* lower blocks contain EEPROM image and calibration data */ 284/* lower blocks contain EEPROM image and calibration data */
277#define OTP_LOW_IMAGE_SIZE (2 * 512 * sizeof(u16)) /* 2 KB */ 285#define OTP_LOW_IMAGE_SIZE (2 * 512 * sizeof(u16)) /* 2 KB */
diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h
index 5944de7a98a2..b1f101caf19d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-prph.h
+++ b/drivers/net/wireless/iwlwifi/iwl-prph.h
@@ -529,48 +529,48 @@
529#define IWL_SCD_TXFIFO_POS_RA (4) 529#define IWL_SCD_TXFIFO_POS_RA (4)
530#define IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF) 530#define IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF)
531 531
532/* 5000 SCD */ 532/* agn SCD */
533#define IWL50_SCD_QUEUE_STTS_REG_POS_TXF (0) 533#define IWLAGN_SCD_QUEUE_STTS_REG_POS_TXF (0)
534#define IWL50_SCD_QUEUE_STTS_REG_POS_ACTIVE (3) 534#define IWLAGN_SCD_QUEUE_STTS_REG_POS_ACTIVE (3)
535#define IWL50_SCD_QUEUE_STTS_REG_POS_WSL (4) 535#define IWLAGN_SCD_QUEUE_STTS_REG_POS_WSL (4)
536#define IWL50_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (19) 536#define IWLAGN_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (19)
537#define IWL50_SCD_QUEUE_STTS_REG_MSK (0x00FF0000) 537#define IWLAGN_SCD_QUEUE_STTS_REG_MSK (0x00FF0000)
538 538
539#define IWL50_SCD_QUEUE_CTX_REG1_CREDIT_POS (8) 539#define IWLAGN_SCD_QUEUE_CTX_REG1_CREDIT_POS (8)
540#define IWL50_SCD_QUEUE_CTX_REG1_CREDIT_MSK (0x00FFFF00) 540#define IWLAGN_SCD_QUEUE_CTX_REG1_CREDIT_MSK (0x00FFFF00)
541#define IWL50_SCD_QUEUE_CTX_REG1_SUPER_CREDIT_POS (24) 541#define IWLAGN_SCD_QUEUE_CTX_REG1_SUPER_CREDIT_POS (24)
542#define IWL50_SCD_QUEUE_CTX_REG1_SUPER_CREDIT_MSK (0xFF000000) 542#define IWLAGN_SCD_QUEUE_CTX_REG1_SUPER_CREDIT_MSK (0xFF000000)
543#define IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS (0) 543#define IWLAGN_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS (0)
544#define IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK (0x0000007F) 544#define IWLAGN_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK (0x0000007F)
545#define IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16) 545#define IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16)
546#define IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000) 546#define IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000)
547 547
548#define IWL50_SCD_CONTEXT_DATA_OFFSET (0x600) 548#define IWLAGN_SCD_CONTEXT_DATA_OFFSET (0x600)
549#define IWL50_SCD_TX_STTS_BITMAP_OFFSET (0x7B1) 549#define IWLAGN_SCD_TX_STTS_BITMAP_OFFSET (0x7B1)
550#define IWL50_SCD_TRANSLATE_TBL_OFFSET (0x7E0) 550#define IWLAGN_SCD_TRANSLATE_TBL_OFFSET (0x7E0)
551 551
552#define IWL50_SCD_CONTEXT_QUEUE_OFFSET(x)\ 552#define IWLAGN_SCD_CONTEXT_QUEUE_OFFSET(x)\
553 (IWL50_SCD_CONTEXT_DATA_OFFSET + ((x) * 8)) 553 (IWLAGN_SCD_CONTEXT_DATA_OFFSET + ((x) * 8))
554 554
555#define IWL50_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ 555#define IWLAGN_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \
556 ((IWL50_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffc) 556 ((IWLAGN_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffc)
557 557
558#define IWL50_SCD_QUEUECHAIN_SEL_ALL(x) (((1<<(x)) - 1) &\ 558#define IWLAGN_SCD_QUEUECHAIN_SEL_ALL(x) (((1<<(x)) - 1) &\
559 (~(1<<IWL_CMD_QUEUE_NUM))) 559 (~(1<<IWL_CMD_QUEUE_NUM)))
560 560
561#define IWL50_SCD_BASE (PRPH_BASE + 0xa02c00) 561#define IWLAGN_SCD_BASE (PRPH_BASE + 0xa02c00)
562 562
563#define IWL50_SCD_SRAM_BASE_ADDR (IWL50_SCD_BASE + 0x0) 563#define IWLAGN_SCD_SRAM_BASE_ADDR (IWLAGN_SCD_BASE + 0x0)
564#define IWL50_SCD_DRAM_BASE_ADDR (IWL50_SCD_BASE + 0x8) 564#define IWLAGN_SCD_DRAM_BASE_ADDR (IWLAGN_SCD_BASE + 0x8)
565#define IWL50_SCD_AIT (IWL50_SCD_BASE + 0x0c) 565#define IWLAGN_SCD_AIT (IWLAGN_SCD_BASE + 0x0c)
566#define IWL50_SCD_TXFACT (IWL50_SCD_BASE + 0x10) 566#define IWLAGN_SCD_TXFACT (IWLAGN_SCD_BASE + 0x10)
567#define IWL50_SCD_ACTIVE (IWL50_SCD_BASE + 0x14) 567#define IWLAGN_SCD_ACTIVE (IWLAGN_SCD_BASE + 0x14)
568#define IWL50_SCD_QUEUE_WRPTR(x) (IWL50_SCD_BASE + 0x18 + (x) * 4) 568#define IWLAGN_SCD_QUEUE_WRPTR(x) (IWLAGN_SCD_BASE + 0x18 + (x) * 4)
569#define IWL50_SCD_QUEUE_RDPTR(x) (IWL50_SCD_BASE + 0x68 + (x) * 4) 569#define IWLAGN_SCD_QUEUE_RDPTR(x) (IWLAGN_SCD_BASE + 0x68 + (x) * 4)
570#define IWL50_SCD_QUEUECHAIN_SEL (IWL50_SCD_BASE + 0xe8) 570#define IWLAGN_SCD_QUEUECHAIN_SEL (IWLAGN_SCD_BASE + 0xe8)
571#define IWL50_SCD_AGGR_SEL (IWL50_SCD_BASE + 0x248) 571#define IWLAGN_SCD_AGGR_SEL (IWLAGN_SCD_BASE + 0x248)
572#define IWL50_SCD_INTERRUPT_MASK (IWL50_SCD_BASE + 0x108) 572#define IWLAGN_SCD_INTERRUPT_MASK (IWLAGN_SCD_BASE + 0x108)
573#define IWL50_SCD_QUEUE_STATUS_BITS(x) (IWL50_SCD_BASE + 0x10c + (x) * 4) 573#define IWLAGN_SCD_QUEUE_STATUS_BITS(x) (IWLAGN_SCD_BASE + 0x10c + (x) * 4)
574 574
575/*********************** END TX SCHEDULER *************************************/ 575/*********************** END TX SCHEDULER *************************************/
576 576
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index ae981932ce61..d12fd5553846 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -69,9 +69,8 @@ int iwl_scan_cancel(struct iwl_priv *priv)
69 } 69 }
70 70
71 if (test_bit(STATUS_SCANNING, &priv->status)) { 71 if (test_bit(STATUS_SCANNING, &priv->status)) {
72 if (!test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 72 if (!test_and_set_bit(STATUS_SCAN_ABORTING, &priv->status)) {
73 IWL_DEBUG_SCAN(priv, "Queuing scan abort.\n"); 73 IWL_DEBUG_SCAN(priv, "Queuing scan abort.\n");
74 set_bit(STATUS_SCAN_ABORTING, &priv->status);
75 queue_work(priv->workqueue, &priv->abort_scan); 74 queue_work(priv->workqueue, &priv->abort_scan);
76 75
77 } else 76 } else
@@ -201,9 +200,6 @@ static void iwl_rx_scan_results_notif(struct iwl_priv *priv,
201 le32_to_cpu(notif->statistics[0]), 200 le32_to_cpu(notif->statistics[0]),
202 le32_to_cpu(notif->tsf_low) - priv->scan_start_tsf); 201 le32_to_cpu(notif->tsf_low) - priv->scan_start_tsf);
203#endif 202#endif
204
205 if (!priv->is_internal_short_scan)
206 priv->next_scan_jiffies = 0;
207} 203}
208 204
209/* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ 205/* Service SCAN_COMPLETE_NOTIFICATION (0x84) */
@@ -223,49 +219,24 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
223 /* The HW is no longer scanning */ 219 /* The HW is no longer scanning */
224 clear_bit(STATUS_SCAN_HW, &priv->status); 220 clear_bit(STATUS_SCAN_HW, &priv->status);
225 221
226 IWL_DEBUG_INFO(priv, "Scan pass on %sGHz took %dms\n", 222 IWL_DEBUG_INFO(priv, "Scan on %sGHz took %dms\n",
227 (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) ? 223 (priv->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2",
228 "2.4" : "5.2",
229 jiffies_to_msecs(elapsed_jiffies 224 jiffies_to_msecs(elapsed_jiffies
230 (priv->scan_pass_start, jiffies))); 225 (priv->scan_start, jiffies)));
231 226
232 /* Remove this scanned band from the list of pending 227 /*
233 * bands to scan, band G precedes A in order of scanning 228 * If a request to abort was given, or the scan did not succeed
234 * as seen in iwl_bg_request_scan */
235 if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ))
236 priv->scan_bands &= ~BIT(IEEE80211_BAND_2GHZ);
237 else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ))
238 priv->scan_bands &= ~BIT(IEEE80211_BAND_5GHZ);
239
240 /* If a request to abort was given, or the scan did not succeed
241 * then we reset the scan state machine and terminate, 229 * then we reset the scan state machine and terminate,
242 * re-queuing another scan if one has been requested */ 230 * re-queuing another scan if one has been requested
243 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 231 */
232 if (test_and_clear_bit(STATUS_SCAN_ABORTING, &priv->status))
244 IWL_DEBUG_INFO(priv, "Aborted scan completed.\n"); 233 IWL_DEBUG_INFO(priv, "Aborted scan completed.\n");
245 clear_bit(STATUS_SCAN_ABORTING, &priv->status);
246 } else {
247 /* If there are more bands on this scan pass reschedule */
248 if (priv->scan_bands)
249 goto reschedule;
250 }
251
252 if (!priv->is_internal_short_scan)
253 priv->next_scan_jiffies = 0;
254 234
255 IWL_DEBUG_INFO(priv, "Setting scan to off\n"); 235 IWL_DEBUG_INFO(priv, "Setting scan to off\n");
256 236
257 clear_bit(STATUS_SCANNING, &priv->status); 237 clear_bit(STATUS_SCANNING, &priv->status);
258 238
259 IWL_DEBUG_INFO(priv, "Scan took %dms\n",
260 jiffies_to_msecs(elapsed_jiffies(priv->scan_start, jiffies)));
261
262 queue_work(priv->workqueue, &priv->scan_completed); 239 queue_work(priv->workqueue, &priv->scan_completed);
263
264 return;
265
266reschedule:
267 priv->scan_pass_start = jiffies;
268 queue_work(priv->workqueue, &priv->request_scan);
269} 240}
270 241
271void iwl_setup_rx_scan_handlers(struct iwl_priv *priv) 242void iwl_setup_rx_scan_handlers(struct iwl_priv *priv)
@@ -314,150 +285,6 @@ u16 iwl_get_passive_dwell_time(struct iwl_priv *priv,
314} 285}
315EXPORT_SYMBOL(iwl_get_passive_dwell_time); 286EXPORT_SYMBOL(iwl_get_passive_dwell_time);
316 287
317static int iwl_get_single_channel_for_scan(struct iwl_priv *priv,
318 enum ieee80211_band band,
319 struct iwl_scan_channel *scan_ch)
320{
321 const struct ieee80211_supported_band *sband;
322 const struct iwl_channel_info *ch_info;
323 u16 passive_dwell = 0;
324 u16 active_dwell = 0;
325 int i, added = 0;
326 u16 channel = 0;
327
328 sband = iwl_get_hw_mode(priv, band);
329 if (!sband) {
330 IWL_ERR(priv, "invalid band\n");
331 return added;
332 }
333
334 active_dwell = iwl_get_active_dwell_time(priv, band, 0);
335 passive_dwell = iwl_get_passive_dwell_time(priv, band);
336
337 if (passive_dwell <= active_dwell)
338 passive_dwell = active_dwell + 1;
339
340 /* only scan single channel, good enough to reset the RF */
341 /* pick the first valid not in-use channel */
342 if (band == IEEE80211_BAND_5GHZ) {
343 for (i = 14; i < priv->channel_count; i++) {
344 if (priv->channel_info[i].channel !=
345 le16_to_cpu(priv->staging_rxon.channel)) {
346 channel = priv->channel_info[i].channel;
347 ch_info = iwl_get_channel_info(priv,
348 band, channel);
349 if (is_channel_valid(ch_info))
350 break;
351 }
352 }
353 } else {
354 for (i = 0; i < 14; i++) {
355 if (priv->channel_info[i].channel !=
356 le16_to_cpu(priv->staging_rxon.channel)) {
357 channel =
358 priv->channel_info[i].channel;
359 ch_info = iwl_get_channel_info(priv,
360 band, channel);
361 if (is_channel_valid(ch_info))
362 break;
363 }
364 }
365 }
366 if (channel) {
367 scan_ch->channel = cpu_to_le16(channel);
368 scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
369 scan_ch->active_dwell = cpu_to_le16(active_dwell);
370 scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
371 /* Set txpower levels to defaults */
372 scan_ch->dsp_atten = 110;
373 if (band == IEEE80211_BAND_5GHZ)
374 scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3;
375 else
376 scan_ch->tx_gain = ((1 << 5) | (5 << 3));
377 added++;
378 } else
379 IWL_ERR(priv, "no valid channel found\n");
380 return added;
381}
382
383static int iwl_get_channels_for_scan(struct iwl_priv *priv,
384 enum ieee80211_band band,
385 u8 is_active, u8 n_probes,
386 struct iwl_scan_channel *scan_ch)
387{
388 struct ieee80211_channel *chan;
389 const struct ieee80211_supported_band *sband;
390 const struct iwl_channel_info *ch_info;
391 u16 passive_dwell = 0;
392 u16 active_dwell = 0;
393 int added, i;
394 u16 channel;
395
396 sband = iwl_get_hw_mode(priv, band);
397 if (!sband)
398 return 0;
399
400 active_dwell = iwl_get_active_dwell_time(priv, band, n_probes);
401 passive_dwell = iwl_get_passive_dwell_time(priv, band);
402
403 if (passive_dwell <= active_dwell)
404 passive_dwell = active_dwell + 1;
405
406 for (i = 0, added = 0; i < priv->scan_request->n_channels; i++) {
407 chan = priv->scan_request->channels[i];
408
409 if (chan->band != band)
410 continue;
411
412 channel = ieee80211_frequency_to_channel(chan->center_freq);
413 scan_ch->channel = cpu_to_le16(channel);
414
415 ch_info = iwl_get_channel_info(priv, band, channel);
416 if (!is_channel_valid(ch_info)) {
417 IWL_DEBUG_SCAN(priv, "Channel %d is INVALID for this band.\n",
418 channel);
419 continue;
420 }
421
422 if (!is_active || is_channel_passive(ch_info) ||
423 (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN))
424 scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
425 else
426 scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE;
427
428 if (n_probes)
429 scan_ch->type |= IWL_SCAN_PROBE_MASK(n_probes);
430
431 scan_ch->active_dwell = cpu_to_le16(active_dwell);
432 scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
433
434 /* Set txpower levels to defaults */
435 scan_ch->dsp_atten = 110;
436
437 /* NOTE: if we were doing 6Mb OFDM for scans we'd use
438 * power level:
439 * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3;
440 */
441 if (band == IEEE80211_BAND_5GHZ)
442 scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3;
443 else
444 scan_ch->tx_gain = ((1 << 5) | (5 << 3));
445
446 IWL_DEBUG_SCAN(priv, "Scanning ch=%d prob=0x%X [%s %d]\n",
447 channel, le32_to_cpu(scan_ch->type),
448 (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ?
449 "ACTIVE" : "PASSIVE",
450 (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ?
451 active_dwell : passive_dwell);
452
453 scan_ch++;
454 added++;
455 }
456
457 IWL_DEBUG_SCAN(priv, "total channels to scan %d\n", added);
458 return added;
459}
460
461void iwl_init_scan_params(struct iwl_priv *priv) 288void iwl_init_scan_params(struct iwl_priv *priv)
462{ 289{
463 u8 ant_idx = fls(priv->hw_params.valid_tx_ant) - 1; 290 u8 ant_idx = fls(priv->hw_params.valid_tx_ant) - 1;
@@ -470,30 +297,34 @@ EXPORT_SYMBOL(iwl_init_scan_params);
470 297
471static int iwl_scan_initiate(struct iwl_priv *priv) 298static int iwl_scan_initiate(struct iwl_priv *priv)
472{ 299{
300 WARN_ON(!mutex_is_locked(&priv->mutex));
301
473 IWL_DEBUG_INFO(priv, "Starting scan...\n"); 302 IWL_DEBUG_INFO(priv, "Starting scan...\n");
474 set_bit(STATUS_SCANNING, &priv->status); 303 set_bit(STATUS_SCANNING, &priv->status);
475 priv->is_internal_short_scan = false; 304 priv->is_internal_short_scan = false;
476 priv->scan_start = jiffies; 305 priv->scan_start = jiffies;
477 priv->scan_pass_start = priv->scan_start;
478 306
479 queue_work(priv->workqueue, &priv->request_scan); 307 if (WARN_ON(!priv->cfg->ops->utils->request_scan))
308 return -EOPNOTSUPP;
309
310 priv->cfg->ops->utils->request_scan(priv);
480 311
481 return 0; 312 return 0;
482} 313}
483 314
484#define IWL_DELAY_NEXT_SCAN (HZ*2)
485
486int iwl_mac_hw_scan(struct ieee80211_hw *hw, 315int iwl_mac_hw_scan(struct ieee80211_hw *hw,
487 struct cfg80211_scan_request *req) 316 struct ieee80211_vif *vif,
317 struct cfg80211_scan_request *req)
488{ 318{
489 unsigned long flags;
490 struct iwl_priv *priv = hw->priv; 319 struct iwl_priv *priv = hw->priv;
491 int ret, i; 320 int ret;
492 321
493 IWL_DEBUG_MAC80211(priv, "enter\n"); 322 IWL_DEBUG_MAC80211(priv, "enter\n");
494 323
324 if (req->n_channels == 0)
325 return -EINVAL;
326
495 mutex_lock(&priv->mutex); 327 mutex_lock(&priv->mutex);
496 spin_lock_irqsave(&priv->lock, flags);
497 328
498 if (!iwl_is_ready_rf(priv)) { 329 if (!iwl_is_ready_rf(priv)) {
499 ret = -EIO; 330 ret = -EIO;
@@ -513,22 +344,8 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
513 goto out_unlock; 344 goto out_unlock;
514 } 345 }
515 346
516 /* We don't schedule scan within next_scan_jiffies period. 347 /* mac80211 will only ask for one band at a time */
517 * Avoid scanning during possible EAPOL exchange, return 348 priv->scan_band = req->channels[0]->band;
518 * success immediately.
519 */
520 if (priv->next_scan_jiffies &&
521 time_after(priv->next_scan_jiffies, jiffies)) {
522 IWL_DEBUG_SCAN(priv, "scan rejected: within next scan period\n");
523 queue_work(priv->workqueue, &priv->scan_completed);
524 ret = 0;
525 goto out_unlock;
526 }
527
528 priv->scan_bands = 0;
529 for (i = 0; i < req->n_channels; i++)
530 priv->scan_bands |= BIT(req->channels[i]->band);
531
532 priv->scan_request = req; 349 priv->scan_request = req;
533 350
534 ret = iwl_scan_initiate(priv); 351 ret = iwl_scan_initiate(priv);
@@ -536,7 +353,6 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
536 IWL_DEBUG_MAC80211(priv, "leave\n"); 353 IWL_DEBUG_MAC80211(priv, "leave\n");
537 354
538out_unlock: 355out_unlock:
539 spin_unlock_irqrestore(&priv->lock, flags);
540 mutex_unlock(&priv->mutex); 356 mutex_unlock(&priv->mutex);
541 357
542 return ret; 358 return ret;
@@ -547,42 +363,46 @@ EXPORT_SYMBOL(iwl_mac_hw_scan);
547 * internal short scan, this function should only been called while associated. 363 * internal short scan, this function should only been called while associated.
548 * It will reset and tune the radio to prevent possible RF related problem 364 * It will reset and tune the radio to prevent possible RF related problem
549 */ 365 */
550int iwl_internal_short_hw_scan(struct iwl_priv *priv) 366void iwl_internal_short_hw_scan(struct iwl_priv *priv)
551{ 367{
552 int ret = 0; 368 queue_work(priv->workqueue, &priv->start_internal_scan);
369}
370
371static void iwl_bg_start_internal_scan(struct work_struct *work)
372{
373 struct iwl_priv *priv =
374 container_of(work, struct iwl_priv, start_internal_scan);
375
376 mutex_lock(&priv->mutex);
553 377
554 if (!iwl_is_ready_rf(priv)) { 378 if (!iwl_is_ready_rf(priv)) {
555 ret = -EIO;
556 IWL_DEBUG_SCAN(priv, "not ready or exit pending\n"); 379 IWL_DEBUG_SCAN(priv, "not ready or exit pending\n");
557 goto out; 380 goto unlock;
558 } 381 }
382
559 if (test_bit(STATUS_SCANNING, &priv->status)) { 383 if (test_bit(STATUS_SCANNING, &priv->status)) {
560 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n"); 384 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
561 ret = -EAGAIN; 385 goto unlock;
562 goto out;
563 } 386 }
387
564 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 388 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
565 IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n"); 389 IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n");
566 ret = -EAGAIN; 390 goto unlock;
567 goto out;
568 } 391 }
569 392
570 priv->scan_bands = 0; 393 priv->scan_band = priv->band;
571 if (priv->band == IEEE80211_BAND_5GHZ)
572 priv->scan_bands |= BIT(IEEE80211_BAND_5GHZ);
573 else
574 priv->scan_bands |= BIT(IEEE80211_BAND_2GHZ);
575 394
576 IWL_DEBUG_SCAN(priv, "Start internal short scan...\n"); 395 IWL_DEBUG_SCAN(priv, "Start internal short scan...\n");
577 set_bit(STATUS_SCANNING, &priv->status); 396 set_bit(STATUS_SCANNING, &priv->status);
578 priv->is_internal_short_scan = true; 397 priv->is_internal_short_scan = true;
579 queue_work(priv->workqueue, &priv->request_scan);
580 398
581out: 399 if (WARN_ON(!priv->cfg->ops->utils->request_scan))
582 return ret; 400 goto unlock;
583}
584 401
585#define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) 402 priv->cfg->ops->utils->request_scan(priv);
403 unlock:
404 mutex_unlock(&priv->mutex);
405}
586 406
587void iwl_bg_scan_check(struct work_struct *data) 407void iwl_bg_scan_check(struct work_struct *data)
588{ 408{
@@ -645,275 +465,15 @@ u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
645 if (WARN_ON(left < ie_len)) 465 if (WARN_ON(left < ie_len))
646 return len; 466 return len;
647 467
648 if (ies) 468 if (ies && ie_len) {
649 memcpy(pos, ies, ie_len); 469 memcpy(pos, ies, ie_len);
650 len += ie_len; 470 len += ie_len;
651 left -= ie_len; 471 }
652 472
653 return (u16)len; 473 return (u16)len;
654} 474}
655EXPORT_SYMBOL(iwl_fill_probe_req); 475EXPORT_SYMBOL(iwl_fill_probe_req);
656 476
657static void iwl_bg_request_scan(struct work_struct *data)
658{
659 struct iwl_priv *priv =
660 container_of(data, struct iwl_priv, request_scan);
661 struct iwl_host_cmd cmd = {
662 .id = REPLY_SCAN_CMD,
663 .len = sizeof(struct iwl_scan_cmd),
664 .flags = CMD_SIZE_HUGE,
665 };
666 struct iwl_scan_cmd *scan;
667 struct ieee80211_conf *conf = NULL;
668 u32 rate_flags = 0;
669 u16 cmd_len;
670 u16 rx_chain = 0;
671 enum ieee80211_band band;
672 u8 n_probes = 0;
673 u8 rx_ant = priv->hw_params.valid_rx_ant;
674 u8 rate;
675 bool is_active = false;
676 int chan_mod;
677 u8 active_chains;
678
679 conf = ieee80211_get_hw_conf(priv->hw);
680
681 mutex_lock(&priv->mutex);
682
683 cancel_delayed_work(&priv->scan_check);
684
685 if (!iwl_is_ready(priv)) {
686 IWL_WARN(priv, "request scan called when driver not ready.\n");
687 goto done;
688 }
689
690 /* Make sure the scan wasn't canceled before this queued work
691 * was given the chance to run... */
692 if (!test_bit(STATUS_SCANNING, &priv->status))
693 goto done;
694
695 /* This should never be called or scheduled if there is currently
696 * a scan active in the hardware. */
697 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
698 IWL_DEBUG_INFO(priv, "Multiple concurrent scan requests in parallel. "
699 "Ignoring second request.\n");
700 goto done;
701 }
702
703 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
704 IWL_DEBUG_SCAN(priv, "Aborting scan due to device shutdown\n");
705 goto done;
706 }
707
708 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
709 IWL_DEBUG_HC(priv, "Scan request while abort pending. Queuing.\n");
710 goto done;
711 }
712
713 if (iwl_is_rfkill(priv)) {
714 IWL_DEBUG_HC(priv, "Aborting scan due to RF Kill activation\n");
715 goto done;
716 }
717
718 if (!test_bit(STATUS_READY, &priv->status)) {
719 IWL_DEBUG_HC(priv, "Scan request while uninitialized. Queuing.\n");
720 goto done;
721 }
722
723 if (!priv->scan_bands) {
724 IWL_DEBUG_HC(priv, "Aborting scan due to no requested bands\n");
725 goto done;
726 }
727
728 if (!priv->scan) {
729 priv->scan = kmalloc(sizeof(struct iwl_scan_cmd) +
730 IWL_MAX_SCAN_SIZE, GFP_KERNEL);
731 if (!priv->scan) {
732 IWL_DEBUG_SCAN(priv,
733 "fail to allocate memory for scan\n");
734 goto done;
735 }
736 }
737 scan = priv->scan;
738 memset(scan, 0, sizeof(struct iwl_scan_cmd) + IWL_MAX_SCAN_SIZE);
739
740 scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH;
741 scan->quiet_time = IWL_ACTIVE_QUIET_TIME;
742
743 if (iwl_is_associated(priv)) {
744 u16 interval = 0;
745 u32 extra;
746 u32 suspend_time = 100;
747 u32 scan_suspend_time = 100;
748 unsigned long flags;
749
750 IWL_DEBUG_INFO(priv, "Scanning while associated...\n");
751 spin_lock_irqsave(&priv->lock, flags);
752 interval = priv->beacon_int;
753 spin_unlock_irqrestore(&priv->lock, flags);
754
755 scan->suspend_time = 0;
756 scan->max_out_time = cpu_to_le32(200 * 1024);
757 if (!interval)
758 interval = suspend_time;
759
760 extra = (suspend_time / interval) << 22;
761 scan_suspend_time = (extra |
762 ((suspend_time % interval) * 1024));
763 scan->suspend_time = cpu_to_le32(scan_suspend_time);
764 IWL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n",
765 scan_suspend_time, interval);
766 }
767
768 if (priv->is_internal_short_scan) {
769 IWL_DEBUG_SCAN(priv, "Start internal passive scan.\n");
770 } else if (priv->scan_request->n_ssids) {
771 int i, p = 0;
772 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n");
773 for (i = 0; i < priv->scan_request->n_ssids; i++) {
774 /* always does wildcard anyway */
775 if (!priv->scan_request->ssids[i].ssid_len)
776 continue;
777 scan->direct_scan[p].id = WLAN_EID_SSID;
778 scan->direct_scan[p].len =
779 priv->scan_request->ssids[i].ssid_len;
780 memcpy(scan->direct_scan[p].ssid,
781 priv->scan_request->ssids[i].ssid,
782 priv->scan_request->ssids[i].ssid_len);
783 n_probes++;
784 p++;
785 }
786 is_active = true;
787 } else
788 IWL_DEBUG_SCAN(priv, "Start passive scan.\n");
789
790 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK;
791 scan->tx_cmd.sta_id = priv->hw_params.bcast_sta_id;
792 scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
793
794
795 if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) {
796 band = IEEE80211_BAND_2GHZ;
797 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK;
798 chan_mod = le32_to_cpu(priv->active_rxon.flags & RXON_FLG_CHANNEL_MODE_MSK)
799 >> RXON_FLG_CHANNEL_MODE_POS;
800 if (chan_mod == CHANNEL_MODE_PURE_40) {
801 rate = IWL_RATE_6M_PLCP;
802 } else {
803 rate = IWL_RATE_1M_PLCP;
804 rate_flags = RATE_MCS_CCK_MSK;
805 }
806 scan->good_CRC_th = 0;
807 } else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) {
808 band = IEEE80211_BAND_5GHZ;
809 rate = IWL_RATE_6M_PLCP;
810 /*
811 * If active scaning is requested but a certain channel
812 * is marked passive, we can do active scanning if we
813 * detect transmissions.
814 */
815 scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH : 0;
816
817 /* Force use of chains B and C (0x6) for scan Rx
818 * Avoid A (0x1) for the device has off-channel reception
819 * on A-band.
820 */
821 if (priv->cfg->off_channel_workaround)
822 rx_ant = ANT_BC;
823 } else {
824 IWL_WARN(priv, "Invalid scan band count\n");
825 goto done;
826 }
827
828 priv->scan_tx_ant[band] =
829 iwl_toggle_tx_ant(priv, priv->scan_tx_ant[band]);
830 rate_flags |= iwl_ant_idx_to_flags(priv->scan_tx_ant[band]);
831 scan->tx_cmd.rate_n_flags = iwl_hw_set_rate_n_flags(rate, rate_flags);
832
833 /* In power save mode use one chain, otherwise use all chains */
834 if (test_bit(STATUS_POWER_PMI, &priv->status)) {
835 /* rx_ant has been set to all valid chains previously */
836 active_chains = rx_ant &
837 ((u8)(priv->chain_noise_data.active_chains));
838 if (!active_chains)
839 active_chains = rx_ant;
840
841 IWL_DEBUG_SCAN(priv, "chain_noise_data.active_chains: %u\n",
842 priv->chain_noise_data.active_chains);
843
844 rx_ant = first_antenna(active_chains);
845 }
846 /* MIMO is not used here, but value is required */
847 rx_chain |= priv->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS;
848 rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS;
849 rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS;
850 rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS;
851 scan->rx_chain = cpu_to_le16(rx_chain);
852 if (!priv->is_internal_short_scan) {
853 cmd_len = iwl_fill_probe_req(priv,
854 (struct ieee80211_mgmt *)scan->data,
855 priv->scan_request->ie,
856 priv->scan_request->ie_len,
857 IWL_MAX_SCAN_SIZE - sizeof(*scan));
858 } else {
859 cmd_len = iwl_fill_probe_req(priv,
860 (struct ieee80211_mgmt *)scan->data,
861 NULL, 0,
862 IWL_MAX_SCAN_SIZE - sizeof(*scan));
863
864 }
865 scan->tx_cmd.len = cpu_to_le16(cmd_len);
866 if (iwl_is_monitor_mode(priv))
867 scan->filter_flags = RXON_FILTER_PROMISC_MSK;
868
869 scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK |
870 RXON_FILTER_BCON_AWARE_MSK);
871
872 if (priv->is_internal_short_scan) {
873 scan->channel_count =
874 iwl_get_single_channel_for_scan(priv, band,
875 (void *)&scan->data[le16_to_cpu(
876 scan->tx_cmd.len)]);
877 } else {
878 scan->channel_count =
879 iwl_get_channels_for_scan(priv, band,
880 is_active, n_probes,
881 (void *)&scan->data[le16_to_cpu(
882 scan->tx_cmd.len)]);
883 }
884 if (scan->channel_count == 0) {
885 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count);
886 goto done;
887 }
888
889 cmd.len += le16_to_cpu(scan->tx_cmd.len) +
890 scan->channel_count * sizeof(struct iwl_scan_channel);
891 cmd.data = scan;
892 scan->len = cpu_to_le16(cmd.len);
893
894 set_bit(STATUS_SCAN_HW, &priv->status);
895 if (iwl_send_cmd_sync(priv, &cmd))
896 goto done;
897
898 queue_delayed_work(priv->workqueue, &priv->scan_check,
899 IWL_SCAN_CHECK_WATCHDOG);
900
901 mutex_unlock(&priv->mutex);
902 return;
903
904 done:
905 /* Cannot perform scan. Make sure we clear scanning
906 * bits from status so next scan request can be performed.
907 * If we don't clear scanning status bit here all next scan
908 * will fail
909 */
910 clear_bit(STATUS_SCAN_HW, &priv->status);
911 clear_bit(STATUS_SCANNING, &priv->status);
912 /* inform mac80211 scan aborted */
913 queue_work(priv->workqueue, &priv->scan_completed);
914 mutex_unlock(&priv->mutex);
915}
916
917void iwl_bg_abort_scan(struct work_struct *work) 477void iwl_bg_abort_scan(struct work_struct *work)
918{ 478{
919 struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan); 479 struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan);
@@ -961,8 +521,8 @@ EXPORT_SYMBOL(iwl_bg_scan_completed);
961void iwl_setup_scan_deferred_work(struct iwl_priv *priv) 521void iwl_setup_scan_deferred_work(struct iwl_priv *priv)
962{ 522{
963 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed); 523 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed);
964 INIT_WORK(&priv->request_scan, iwl_bg_request_scan);
965 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan); 524 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan);
525 INIT_WORK(&priv->start_internal_scan, iwl_bg_start_internal_scan);
966 INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check); 526 INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check);
967} 527}
968EXPORT_SYMBOL(iwl_setup_scan_deferred_work); 528EXPORT_SYMBOL(iwl_setup_scan_deferred_work);
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index d86ecd2f9ec2..db934476b5e9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -451,7 +451,17 @@ static void iwl_sta_init_lq(struct iwl_priv *priv, const u8 *addr, bool is_ap)
451 451
452 link_cmd.general_params.single_stream_ant_msk = 452 link_cmd.general_params.single_stream_ant_msk =
453 first_antenna(priv->hw_params.valid_tx_ant); 453 first_antenna(priv->hw_params.valid_tx_ant);
454 link_cmd.general_params.dual_stream_ant_msk = 3; 454
455 link_cmd.general_params.dual_stream_ant_msk =
456 priv->hw_params.valid_tx_ant &
457 ~first_antenna(priv->hw_params.valid_tx_ant);
458 if (!link_cmd.general_params.dual_stream_ant_msk) {
459 link_cmd.general_params.dual_stream_ant_msk = ANT_AB;
460 } else if (num_of_ant(priv->hw_params.valid_tx_ant) == 2) {
461 link_cmd.general_params.dual_stream_ant_msk =
462 priv->hw_params.valid_tx_ant;
463 }
464
455 link_cmd.agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; 465 link_cmd.agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF;
456 link_cmd.agg_params.agg_time_limit = 466 link_cmd.agg_params.agg_time_limit =
457 cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); 467 cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF);
@@ -1196,7 +1206,6 @@ int iwl_send_lq_cmd(struct iwl_priv *priv,
1196 iwl_dump_lq_cmd(priv, lq); 1206 iwl_dump_lq_cmd(priv, lq);
1197 BUG_ON(init && (cmd.flags & CMD_ASYNC)); 1207 BUG_ON(init && (cmd.flags & CMD_ASYNC));
1198 1208
1199 iwl_dump_lq_cmd(priv, lq);
1200 ret = iwl_send_cmd(priv, &cmd); 1209 ret = iwl_send_cmd(priv, &cmd);
1201 if (ret || (cmd.flags & CMD_ASYNC)) 1210 if (ret || (cmd.flags & CMD_ASYNC))
1202 return ret; 1211 return ret;
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 9f362024a29c..c7e1d7d09e02 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -957,7 +957,7 @@ static void iwl3945_setup_rx_handlers(struct iwl_priv *priv)
957 * statistics request from the host as well as for the periodic 957 * statistics request from the host as well as for the periodic
958 * statistics notifications (after received beacons) from the uCode. 958 * statistics notifications (after received beacons) from the uCode.
959 */ 959 */
960 priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl3945_hw_rx_statistics; 960 priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl3945_reply_statistics;
961 priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl3945_hw_rx_statistics; 961 priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl3945_hw_rx_statistics;
962 962
963 iwl_setup_rx_scan_handlers(priv); 963 iwl_setup_rx_scan_handlers(priv);
@@ -2527,7 +2527,7 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
2527 } 2527 }
2528 2528
2529 /* Configure Bluetooth device coexistence support */ 2529 /* Configure Bluetooth device coexistence support */
2530 iwl_send_bt_config(priv); 2530 priv->cfg->ops->hcmd->send_bt_config(priv);
2531 2531
2532 /* Configure the adapter for unassociated operation */ 2532 /* Configure the adapter for unassociated operation */
2533 iwlcore_commit_rxon(priv); 2533 iwlcore_commit_rxon(priv);
@@ -2791,11 +2791,8 @@ static void iwl3945_rfkill_poll(struct work_struct *data)
2791 2791
2792} 2792}
2793 2793
2794#define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) 2794void iwl3945_request_scan(struct iwl_priv *priv)
2795static void iwl3945_bg_request_scan(struct work_struct *data)
2796{ 2795{
2797 struct iwl_priv *priv =
2798 container_of(data, struct iwl_priv, request_scan);
2799 struct iwl_host_cmd cmd = { 2796 struct iwl_host_cmd cmd = {
2800 .id = REPLY_SCAN_CMD, 2797 .id = REPLY_SCAN_CMD,
2801 .len = sizeof(struct iwl3945_scan_cmd), 2798 .len = sizeof(struct iwl3945_scan_cmd),
@@ -2809,8 +2806,6 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2809 2806
2810 conf = ieee80211_get_hw_conf(priv->hw); 2807 conf = ieee80211_get_hw_conf(priv->hw);
2811 2808
2812 mutex_lock(&priv->mutex);
2813
2814 cancel_delayed_work(&priv->scan_check); 2809 cancel_delayed_work(&priv->scan_check);
2815 2810
2816 if (!iwl_is_ready(priv)) { 2811 if (!iwl_is_ready(priv)) {
@@ -2853,20 +2848,15 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2853 goto done; 2848 goto done;
2854 } 2849 }
2855 2850
2856 if (!priv->scan_bands) { 2851 if (!priv->scan_cmd) {
2857 IWL_DEBUG_HC(priv, "Aborting scan due to no requested bands\n"); 2852 priv->scan_cmd = kmalloc(sizeof(struct iwl3945_scan_cmd) +
2858 goto done; 2853 IWL_MAX_SCAN_SIZE, GFP_KERNEL);
2859 } 2854 if (!priv->scan_cmd) {
2860
2861 if (!priv->scan) {
2862 priv->scan = kmalloc(sizeof(struct iwl3945_scan_cmd) +
2863 IWL_MAX_SCAN_SIZE, GFP_KERNEL);
2864 if (!priv->scan) {
2865 IWL_DEBUG_SCAN(priv, "Fail to allocate scan memory\n"); 2855 IWL_DEBUG_SCAN(priv, "Fail to allocate scan memory\n");
2866 goto done; 2856 goto done;
2867 } 2857 }
2868 } 2858 }
2869 scan = priv->scan; 2859 scan = priv->scan_cmd;
2870 memset(scan, 0, sizeof(struct iwl3945_scan_cmd) + IWL_MAX_SCAN_SIZE); 2860 memset(scan, 0, sizeof(struct iwl3945_scan_cmd) + IWL_MAX_SCAN_SIZE);
2871 2861
2872 scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH; 2862 scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH;
@@ -2935,22 +2925,26 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2935 2925
2936 /* flags + rate selection */ 2926 /* flags + rate selection */
2937 2927
2938 if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) { 2928 switch (priv->scan_band) {
2929 case IEEE80211_BAND_2GHZ:
2939 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; 2930 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK;
2940 scan->tx_cmd.rate = IWL_RATE_1M_PLCP; 2931 scan->tx_cmd.rate = IWL_RATE_1M_PLCP;
2941 scan->good_CRC_th = 0; 2932 scan->good_CRC_th = 0;
2942 band = IEEE80211_BAND_2GHZ; 2933 band = IEEE80211_BAND_2GHZ;
2943 } else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) { 2934 break;
2935 case IEEE80211_BAND_5GHZ:
2944 scan->tx_cmd.rate = IWL_RATE_6M_PLCP; 2936 scan->tx_cmd.rate = IWL_RATE_6M_PLCP;
2945 /* 2937 /*
2946 * If active scaning is requested but a certain channel 2938 * If active scaning is requested but a certain channel
2947 * is marked passive, we can do active scanning if we 2939 * is marked passive, we can do active scanning if we
2948 * detect transmissions. 2940 * detect transmissions.
2949 */ 2941 */
2950 scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH : 0; 2942 scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH_DEFAULT :
2943 IWL_GOOD_CRC_TH_DISABLED;
2951 band = IEEE80211_BAND_5GHZ; 2944 band = IEEE80211_BAND_5GHZ;
2952 } else { 2945 break;
2953 IWL_WARN(priv, "Invalid scan band count\n"); 2946 default:
2947 IWL_WARN(priv, "Invalid scan band\n");
2954 goto done; 2948 goto done;
2955 } 2949 }
2956 2950
@@ -2971,9 +2965,6 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2971 /* select Rx antennas */ 2965 /* select Rx antennas */
2972 scan->flags |= iwl3945_get_antenna_flags(priv); 2966 scan->flags |= iwl3945_get_antenna_flags(priv);
2973 2967
2974 if (iwl_is_monitor_mode(priv))
2975 scan->filter_flags = RXON_FILTER_PROMISC_MSK;
2976
2977 scan->channel_count = 2968 scan->channel_count =
2978 iwl3945_get_channels_for_scan(priv, band, is_active, n_probes, 2969 iwl3945_get_channels_for_scan(priv, band, is_active, n_probes,
2979 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); 2970 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
@@ -2995,7 +2986,6 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2995 queue_delayed_work(priv->workqueue, &priv->scan_check, 2986 queue_delayed_work(priv->workqueue, &priv->scan_check,
2996 IWL_SCAN_CHECK_WATCHDOG); 2987 IWL_SCAN_CHECK_WATCHDOG);
2997 2988
2998 mutex_unlock(&priv->mutex);
2999 return; 2989 return;
3000 2990
3001 done: 2991 done:
@@ -3009,7 +2999,6 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
3009 2999
3010 /* inform mac80211 scan aborted */ 3000 /* inform mac80211 scan aborted */
3011 queue_work(priv->workqueue, &priv->scan_completed); 3001 queue_work(priv->workqueue, &priv->scan_completed);
3012 mutex_unlock(&priv->mutex);
3013} 3002}
3014 3003
3015static void iwl3945_bg_restart(struct work_struct *data) 3004static void iwl3945_bg_restart(struct work_struct *data)
@@ -3051,8 +3040,6 @@ static void iwl3945_bg_rx_replenish(struct work_struct *data)
3051 mutex_unlock(&priv->mutex); 3040 mutex_unlock(&priv->mutex);
3052} 3041}
3053 3042
3054#define IWL_DELAY_NEXT_SCAN (HZ*2)
3055
3056void iwl3945_post_associate(struct iwl_priv *priv) 3043void iwl3945_post_associate(struct iwl_priv *priv)
3057{ 3044{
3058 int rc = 0; 3045 int rc = 0;
@@ -3137,9 +3124,6 @@ void iwl3945_post_associate(struct iwl_priv *priv)
3137 __func__, priv->iw_mode); 3124 __func__, priv->iw_mode);
3138 break; 3125 break;
3139 } 3126 }
3140
3141 /* we have just associated, don't start scan too early */
3142 priv->next_scan_jiffies = jiffies + IWL_DELAY_NEXT_SCAN;
3143} 3127}
3144 3128
3145/***************************************************************************** 3129/*****************************************************************************
@@ -3672,44 +3656,6 @@ static ssize_t show_channels(struct device *d,
3672 3656
3673static DEVICE_ATTR(channels, S_IRUSR, show_channels, NULL); 3657static DEVICE_ATTR(channels, S_IRUSR, show_channels, NULL);
3674 3658
3675static ssize_t show_statistics(struct device *d,
3676 struct device_attribute *attr, char *buf)
3677{
3678 struct iwl_priv *priv = dev_get_drvdata(d);
3679 u32 size = sizeof(struct iwl3945_notif_statistics);
3680 u32 len = 0, ofs = 0;
3681 u8 *data = (u8 *)&priv->_3945.statistics;
3682 int rc = 0;
3683
3684 if (!iwl_is_alive(priv))
3685 return -EAGAIN;
3686
3687 mutex_lock(&priv->mutex);
3688 rc = iwl_send_statistics_request(priv, CMD_SYNC, false);
3689 mutex_unlock(&priv->mutex);
3690
3691 if (rc) {
3692 len = sprintf(buf,
3693 "Error sending statistics request: 0x%08X\n", rc);
3694 return len;
3695 }
3696
3697 while (size && (PAGE_SIZE - len)) {
3698 hex_dump_to_buffer(data + ofs, size, 16, 1, buf + len,
3699 PAGE_SIZE - len, 1);
3700 len = strlen(buf);
3701 if (PAGE_SIZE - len)
3702 buf[len++] = '\n';
3703
3704 ofs += 16;
3705 size -= min(size, 16U);
3706 }
3707
3708 return len;
3709}
3710
3711static DEVICE_ATTR(statistics, S_IRUGO, show_statistics, NULL);
3712
3713static ssize_t show_antenna(struct device *d, 3659static ssize_t show_antenna(struct device *d,
3714 struct device_attribute *attr, char *buf) 3660 struct device_attribute *attr, char *buf)
3715{ 3661{
@@ -3793,7 +3739,6 @@ static void iwl3945_setup_deferred_work(struct iwl_priv *priv)
3793 INIT_DELAYED_WORK(&priv->alive_start, iwl3945_bg_alive_start); 3739 INIT_DELAYED_WORK(&priv->alive_start, iwl3945_bg_alive_start);
3794 INIT_DELAYED_WORK(&priv->_3945.rfkill_poll, iwl3945_rfkill_poll); 3740 INIT_DELAYED_WORK(&priv->_3945.rfkill_poll, iwl3945_rfkill_poll);
3795 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed); 3741 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed);
3796 INIT_WORK(&priv->request_scan, iwl3945_bg_request_scan);
3797 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan); 3742 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan);
3798 INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check); 3743 INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check);
3799 3744
@@ -3830,7 +3775,6 @@ static struct attribute *iwl3945_sysfs_entries[] = {
3830 &dev_attr_filter_flags.attr, 3775 &dev_attr_filter_flags.attr,
3831 &dev_attr_measurement.attr, 3776 &dev_attr_measurement.attr,
3832 &dev_attr_retry_rate.attr, 3777 &dev_attr_retry_rate.attr,
3833 &dev_attr_statistics.attr,
3834 &dev_attr_status.attr, 3778 &dev_attr_status.attr,
3835 &dev_attr_temperature.attr, 3779 &dev_attr_temperature.attr,
3836 &dev_attr_tx_power.attr, 3780 &dev_attr_tx_power.attr,
@@ -3930,7 +3874,6 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
3930 3874
3931 /* Tell mac80211 our characteristics */ 3875 /* Tell mac80211 our characteristics */
3932 hw->flags = IEEE80211_HW_SIGNAL_DBM | 3876 hw->flags = IEEE80211_HW_SIGNAL_DBM |
3933 IEEE80211_HW_NOISE_DBM |
3934 IEEE80211_HW_SPECTRUM_MGMT; 3877 IEEE80211_HW_SPECTRUM_MGMT;
3935 3878
3936 if (!priv->cfg->broken_powersave) 3879 if (!priv->cfg->broken_powersave)
@@ -4253,7 +4196,7 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
4253 4196
4254 iwl_free_channel_map(priv); 4197 iwl_free_channel_map(priv);
4255 iwlcore_free_geos(priv); 4198 iwlcore_free_geos(priv);
4256 kfree(priv->scan); 4199 kfree(priv->scan_cmd);
4257 if (priv->ibss_beacon) 4200 if (priv->ibss_beacon)
4258 dev_kfree_skb(priv->ibss_beacon); 4201 dev_kfree_skb(priv->ibss_beacon);
4259 4202