aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2010-09-21 21:17:19 -0400
committerDavid S. Miller <davem@davemloft.net>2010-09-21 21:17:19 -0400
commita0741ca949692904646c310573754859cba09bf1 (patch)
treefc95067d8bfee5f6c6c747c74d1d6547d70199a3 /drivers/net/wireless/iwlwifi
parent9e2e8f14d48dbb6c31aeb739ae4fc8997b9dfe84 (diff)
parentb618f6f885579a6237e5bf4582fa6167972ddef4 (diff)
Merge branch 'for-davem' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6
Diffstat (limited to 'drivers/net/wireless/iwlwifi')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-1000.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c503
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-debugfs.h7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c18
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-lib.c314
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.h9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-ucode.c34
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c49
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h19
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c72
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c58
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h56
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c381
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c19
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c99
22 files changed, 996 insertions, 670 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index 674fb93ae17..56ef4ed0db4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -223,6 +223,7 @@ static struct iwl_lib_ops iwl1000_lib = {
223 .tx_stats_read = iwl_ucode_tx_stats_read, 223 .tx_stats_read = iwl_ucode_tx_stats_read,
224 .general_stats_read = iwl_ucode_general_stats_read, 224 .general_stats_read = iwl_ucode_general_stats_read,
225 .bt_stats_read = iwl_ucode_bt_stats_read, 225 .bt_stats_read = iwl_ucode_bt_stats_read,
226 .reply_tx_error = iwl_reply_tx_error_read,
226 }, 227 },
227 .recover_from_tx_stall = iwl_bg_monitor_recover, 228 .recover_from_tx_stall = iwl_bg_monitor_recover,
228 .check_plcp_health = iwl_good_plcp_health, 229 .check_plcp_health = iwl_good_plcp_health,
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index bb2aeebf365..98509c5e708 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -295,7 +295,7 @@ extern const struct iwl_channel_info *iwl3945_get_channel_info(
295extern int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate); 295extern int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate);
296 296
297/* scanning */ 297/* scanning */
298void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif); 298int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif);
299 299
300/* Requires full declaration of iwl_priv before including */ 300/* Requires full declaration of iwl_priv before including */
301#include "iwl-io.h" 301#include "iwl-io.h"
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 1d6a46d4db5..943a9c7bfa7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -2289,6 +2289,7 @@ static struct iwl_lib_ops iwl4965_lib = {
2289 .tx_stats_read = iwl_ucode_tx_stats_read, 2289 .tx_stats_read = iwl_ucode_tx_stats_read,
2290 .general_stats_read = iwl_ucode_general_stats_read, 2290 .general_stats_read = iwl_ucode_general_stats_read,
2291 .bt_stats_read = iwl_ucode_bt_stats_read, 2291 .bt_stats_read = iwl_ucode_bt_stats_read,
2292 .reply_tx_error = iwl_reply_tx_error_read,
2292 }, 2293 },
2293 .recover_from_tx_stall = iwl_bg_monitor_recover, 2294 .recover_from_tx_stall = iwl_bg_monitor_recover,
2294 .check_plcp_health = iwl_good_plcp_health, 2295 .check_plcp_health = iwl_good_plcp_health,
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 1dbb1246c08..21b4b23368e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -404,6 +404,7 @@ static struct iwl_lib_ops iwl5000_lib = {
404 .tx_stats_read = iwl_ucode_tx_stats_read, 404 .tx_stats_read = iwl_ucode_tx_stats_read,
405 .general_stats_read = iwl_ucode_general_stats_read, 405 .general_stats_read = iwl_ucode_general_stats_read,
406 .bt_stats_read = iwl_ucode_bt_stats_read, 406 .bt_stats_read = iwl_ucode_bt_stats_read,
407 .reply_tx_error = iwl_reply_tx_error_read,
407 }, 408 },
408 .recover_from_tx_stall = iwl_bg_monitor_recover, 409 .recover_from_tx_stall = iwl_bg_monitor_recover,
409 .check_plcp_health = iwl_good_plcp_health, 410 .check_plcp_health = iwl_good_plcp_health,
@@ -474,6 +475,8 @@ static struct iwl_lib_ops iwl5150_lib = {
474 .rx_stats_read = iwl_ucode_rx_stats_read, 475 .rx_stats_read = iwl_ucode_rx_stats_read,
475 .tx_stats_read = iwl_ucode_tx_stats_read, 476 .tx_stats_read = iwl_ucode_tx_stats_read,
476 .general_stats_read = iwl_ucode_general_stats_read, 477 .general_stats_read = iwl_ucode_general_stats_read,
478 .bt_stats_read = iwl_ucode_bt_stats_read,
479 .reply_tx_error = iwl_reply_tx_error_read,
477 }, 480 },
478 .recover_from_tx_stall = iwl_bg_monitor_recover, 481 .recover_from_tx_stall = iwl_bg_monitor_recover,
479 .check_plcp_health = iwl_good_plcp_health, 482 .check_plcp_health = iwl_good_plcp_health,
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 2fdba088bd2..9f43f2770c9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -329,6 +329,7 @@ static struct iwl_lib_ops iwl6000_lib = {
329 .tx_stats_read = iwl_ucode_tx_stats_read, 329 .tx_stats_read = iwl_ucode_tx_stats_read,
330 .general_stats_read = iwl_ucode_general_stats_read, 330 .general_stats_read = iwl_ucode_general_stats_read,
331 .bt_stats_read = iwl_ucode_bt_stats_read, 331 .bt_stats_read = iwl_ucode_bt_stats_read,
332 .reply_tx_error = iwl_reply_tx_error_read,
332 }, 333 },
333 .recover_from_tx_stall = iwl_bg_monitor_recover, 334 .recover_from_tx_stall = iwl_bg_monitor_recover,
334 .check_plcp_health = iwl_good_plcp_health, 335 .check_plcp_health = iwl_good_plcp_health,
@@ -404,6 +405,7 @@ static struct iwl_lib_ops iwl6000g2b_lib = {
404 .tx_stats_read = iwl_ucode_tx_stats_read, 405 .tx_stats_read = iwl_ucode_tx_stats_read,
405 .general_stats_read = iwl_ucode_general_stats_read, 406 .general_stats_read = iwl_ucode_general_stats_read,
406 .bt_stats_read = iwl_ucode_bt_stats_read, 407 .bt_stats_read = iwl_ucode_bt_stats_read,
408 .reply_tx_error = iwl_reply_tx_error_read,
407 }, 409 },
408 .recover_from_tx_stall = iwl_bg_monitor_recover, 410 .recover_from_tx_stall = iwl_bg_monitor_recover,
409 .check_plcp_health = iwl_good_plcp_health, 411 .check_plcp_health = iwl_good_plcp_health,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c
index d706b8afbe5..5391b462739 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c
@@ -25,9 +25,15 @@
25* Intel Linux Wireless <ilw@linux.intel.com> 25* Intel Linux Wireless <ilw@linux.intel.com>
26* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27*****************************************************************************/ 27*****************************************************************************/
28 28#include "iwl-agn.h"
29#include "iwl-agn-debugfs.h" 29#include "iwl-agn-debugfs.h"
30 30
31static const char *fmt_value = " %-30s %10u\n";
32static const char *fmt_hex = " %-30s 0x%02X\n";
33static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
34static const char *fmt_header =
35 "%-32s current cumulative delta max\n";
36
31static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz) 37static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
32{ 38{
33 int p = 0; 39 int p = 0;
@@ -121,436 +127,380 @@ ssize_t iwl_ucode_rx_stats_read(struct file *file, char __user *user_buf,
121 } 127 }
122 128
123 pos += iwl_statistics_flag(priv, buf, bufsz); 129 pos += iwl_statistics_flag(priv, buf, bufsz);
124 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
125 "acumulative delta max\n",
126 "Statistics_Rx - OFDM:");
127 pos += scnprintf(buf + pos, bufsz - pos, 130 pos += scnprintf(buf + pos, bufsz - pos,
128 " %-30s %10u %10u %10u %10u\n", 131 fmt_header, "Statistics_Rx - OFDM:");
129 "ina_cnt:", le32_to_cpu(ofdm->ina_cnt), 132 pos += scnprintf(buf + pos, bufsz - pos,
133 fmt_table, "ina_cnt:",
134 le32_to_cpu(ofdm->ina_cnt),
130 accum_ofdm->ina_cnt, 135 accum_ofdm->ina_cnt,
131 delta_ofdm->ina_cnt, max_ofdm->ina_cnt); 136 delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
132 pos += scnprintf(buf + pos, bufsz - pos, 137 pos += scnprintf(buf + pos, bufsz - pos,
133 " %-30s %10u %10u %10u %10u\n", 138 fmt_table, "fina_cnt:",
134 "fina_cnt:",
135 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, 139 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
136 delta_ofdm->fina_cnt, max_ofdm->fina_cnt); 140 delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
137 pos += scnprintf(buf + pos, bufsz - pos, 141 pos += scnprintf(buf + pos, bufsz - pos,
138 " %-30s %10u %10u %10u %10u\n", 142 fmt_table, "plcp_err:",
139 "plcp_err:",
140 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, 143 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
141 delta_ofdm->plcp_err, max_ofdm->plcp_err); 144 delta_ofdm->plcp_err, max_ofdm->plcp_err);
142 pos += scnprintf(buf + pos, bufsz - pos, 145 pos += scnprintf(buf + pos, bufsz - pos,
143 " %-30s %10u %10u %10u %10u\n", "crc32_err:", 146 fmt_table, "crc32_err:",
144 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, 147 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
145 delta_ofdm->crc32_err, max_ofdm->crc32_err); 148 delta_ofdm->crc32_err, max_ofdm->crc32_err);
146 pos += scnprintf(buf + pos, bufsz - pos, 149 pos += scnprintf(buf + pos, bufsz - pos,
147 " %-30s %10u %10u %10u %10u\n", "overrun_err:", 150 fmt_table, "overrun_err:",
148 le32_to_cpu(ofdm->overrun_err), 151 le32_to_cpu(ofdm->overrun_err),
149 accum_ofdm->overrun_err, delta_ofdm->overrun_err, 152 accum_ofdm->overrun_err, delta_ofdm->overrun_err,
150 max_ofdm->overrun_err); 153 max_ofdm->overrun_err);
151 pos += scnprintf(buf + pos, bufsz - pos, 154 pos += scnprintf(buf + pos, bufsz - pos,
152 " %-30s %10u %10u %10u %10u\n", 155 fmt_table, "early_overrun_err:",
153 "early_overrun_err:",
154 le32_to_cpu(ofdm->early_overrun_err), 156 le32_to_cpu(ofdm->early_overrun_err),
155 accum_ofdm->early_overrun_err, 157 accum_ofdm->early_overrun_err,
156 delta_ofdm->early_overrun_err, 158 delta_ofdm->early_overrun_err,
157 max_ofdm->early_overrun_err); 159 max_ofdm->early_overrun_err);
158 pos += scnprintf(buf + pos, bufsz - pos, 160 pos += scnprintf(buf + pos, bufsz - pos,
159 " %-30s %10u %10u %10u %10u\n", 161 fmt_table, "crc32_good:",
160 "crc32_good:", le32_to_cpu(ofdm->crc32_good), 162 le32_to_cpu(ofdm->crc32_good),
161 accum_ofdm->crc32_good, delta_ofdm->crc32_good, 163 accum_ofdm->crc32_good, delta_ofdm->crc32_good,
162 max_ofdm->crc32_good); 164 max_ofdm->crc32_good);
163 pos += scnprintf(buf + pos, bufsz - pos, 165 pos += scnprintf(buf + pos, bufsz - pos,
164 " %-30s %10u %10u %10u %10u\n", "false_alarm_cnt:", 166 fmt_table, "false_alarm_cnt:",
165 le32_to_cpu(ofdm->false_alarm_cnt), 167 le32_to_cpu(ofdm->false_alarm_cnt),
166 accum_ofdm->false_alarm_cnt, 168 accum_ofdm->false_alarm_cnt,
167 delta_ofdm->false_alarm_cnt, 169 delta_ofdm->false_alarm_cnt,
168 max_ofdm->false_alarm_cnt); 170 max_ofdm->false_alarm_cnt);
169 pos += scnprintf(buf + pos, bufsz - pos, 171 pos += scnprintf(buf + pos, bufsz - pos,
170 " %-30s %10u %10u %10u %10u\n", 172 fmt_table, "fina_sync_err_cnt:",
171 "fina_sync_err_cnt:",
172 le32_to_cpu(ofdm->fina_sync_err_cnt), 173 le32_to_cpu(ofdm->fina_sync_err_cnt),
173 accum_ofdm->fina_sync_err_cnt, 174 accum_ofdm->fina_sync_err_cnt,
174 delta_ofdm->fina_sync_err_cnt, 175 delta_ofdm->fina_sync_err_cnt,
175 max_ofdm->fina_sync_err_cnt); 176 max_ofdm->fina_sync_err_cnt);
176 pos += scnprintf(buf + pos, bufsz - pos, 177 pos += scnprintf(buf + pos, bufsz - pos,
177 " %-30s %10u %10u %10u %10u\n", "sfd_timeout:", 178 fmt_table, "sfd_timeout:",
178 le32_to_cpu(ofdm->sfd_timeout), 179 le32_to_cpu(ofdm->sfd_timeout),
179 accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout, 180 accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout,
180 max_ofdm->sfd_timeout); 181 max_ofdm->sfd_timeout);
181 pos += scnprintf(buf + pos, bufsz - pos, 182 pos += scnprintf(buf + pos, bufsz - pos,
182 " %-30s %10u %10u %10u %10u\n", "fina_timeout:", 183 fmt_table, "fina_timeout:",
183 le32_to_cpu(ofdm->fina_timeout), 184 le32_to_cpu(ofdm->fina_timeout),
184 accum_ofdm->fina_timeout, delta_ofdm->fina_timeout, 185 accum_ofdm->fina_timeout, delta_ofdm->fina_timeout,
185 max_ofdm->fina_timeout); 186 max_ofdm->fina_timeout);
186 pos += scnprintf(buf + pos, bufsz - pos, 187 pos += scnprintf(buf + pos, bufsz - pos,
187 " %-30s %10u %10u %10u %10u\n", 188 fmt_table, "unresponded_rts:",
188 "unresponded_rts:",
189 le32_to_cpu(ofdm->unresponded_rts), 189 le32_to_cpu(ofdm->unresponded_rts),
190 accum_ofdm->unresponded_rts, 190 accum_ofdm->unresponded_rts,
191 delta_ofdm->unresponded_rts, 191 delta_ofdm->unresponded_rts,
192 max_ofdm->unresponded_rts); 192 max_ofdm->unresponded_rts);
193 pos += scnprintf(buf + pos, bufsz - pos, 193 pos += scnprintf(buf + pos, bufsz - pos,
194 " %-30s %10u %10u %10u %10u\n", 194 fmt_table, "rxe_frame_lmt_ovrun:",
195 "rxe_frame_lmt_ovrun:",
196 le32_to_cpu(ofdm->rxe_frame_limit_overrun), 195 le32_to_cpu(ofdm->rxe_frame_limit_overrun),
197 accum_ofdm->rxe_frame_limit_overrun, 196 accum_ofdm->rxe_frame_limit_overrun,
198 delta_ofdm->rxe_frame_limit_overrun, 197 delta_ofdm->rxe_frame_limit_overrun,
199 max_ofdm->rxe_frame_limit_overrun); 198 max_ofdm->rxe_frame_limit_overrun);
200 pos += scnprintf(buf + pos, bufsz - pos, 199 pos += scnprintf(buf + pos, bufsz - pos,
201 " %-30s %10u %10u %10u %10u\n", "sent_ack_cnt:", 200 fmt_table, "sent_ack_cnt:",
202 le32_to_cpu(ofdm->sent_ack_cnt), 201 le32_to_cpu(ofdm->sent_ack_cnt),
203 accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt, 202 accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt,
204 max_ofdm->sent_ack_cnt); 203 max_ofdm->sent_ack_cnt);
205 pos += scnprintf(buf + pos, bufsz - pos, 204 pos += scnprintf(buf + pos, bufsz - pos,
206 " %-30s %10u %10u %10u %10u\n", "sent_cts_cnt:", 205 fmt_table, "sent_cts_cnt:",
207 le32_to_cpu(ofdm->sent_cts_cnt), 206 le32_to_cpu(ofdm->sent_cts_cnt),
208 accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt, 207 accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt,
209 max_ofdm->sent_cts_cnt); 208 max_ofdm->sent_cts_cnt);
210 pos += scnprintf(buf + pos, bufsz - pos, 209 pos += scnprintf(buf + pos, bufsz - pos,
211 " %-30s %10u %10u %10u %10u\n", 210 fmt_table, "sent_ba_rsp_cnt:",
212 "sent_ba_rsp_cnt:",
213 le32_to_cpu(ofdm->sent_ba_rsp_cnt), 211 le32_to_cpu(ofdm->sent_ba_rsp_cnt),
214 accum_ofdm->sent_ba_rsp_cnt, 212 accum_ofdm->sent_ba_rsp_cnt,
215 delta_ofdm->sent_ba_rsp_cnt, 213 delta_ofdm->sent_ba_rsp_cnt,
216 max_ofdm->sent_ba_rsp_cnt); 214 max_ofdm->sent_ba_rsp_cnt);
217 pos += scnprintf(buf + pos, bufsz - pos, 215 pos += scnprintf(buf + pos, bufsz - pos,
218 " %-30s %10u %10u %10u %10u\n", "dsp_self_kill:", 216 fmt_table, "dsp_self_kill:",
219 le32_to_cpu(ofdm->dsp_self_kill), 217 le32_to_cpu(ofdm->dsp_self_kill),
220 accum_ofdm->dsp_self_kill, 218 accum_ofdm->dsp_self_kill,
221 delta_ofdm->dsp_self_kill, 219 delta_ofdm->dsp_self_kill,
222 max_ofdm->dsp_self_kill); 220 max_ofdm->dsp_self_kill);
223 pos += scnprintf(buf + pos, bufsz - pos, 221 pos += scnprintf(buf + pos, bufsz - pos,
224 " %-30s %10u %10u %10u %10u\n", 222 fmt_table, "mh_format_err:",
225 "mh_format_err:",
226 le32_to_cpu(ofdm->mh_format_err), 223 le32_to_cpu(ofdm->mh_format_err),
227 accum_ofdm->mh_format_err, 224 accum_ofdm->mh_format_err,
228 delta_ofdm->mh_format_err, 225 delta_ofdm->mh_format_err,
229 max_ofdm->mh_format_err); 226 max_ofdm->mh_format_err);
230 pos += scnprintf(buf + pos, bufsz - pos, 227 pos += scnprintf(buf + pos, bufsz - pos,
231 " %-30s %10u %10u %10u %10u\n", 228 fmt_table, "re_acq_main_rssi_sum:",
232 "re_acq_main_rssi_sum:",
233 le32_to_cpu(ofdm->re_acq_main_rssi_sum), 229 le32_to_cpu(ofdm->re_acq_main_rssi_sum),
234 accum_ofdm->re_acq_main_rssi_sum, 230 accum_ofdm->re_acq_main_rssi_sum,
235 delta_ofdm->re_acq_main_rssi_sum, 231 delta_ofdm->re_acq_main_rssi_sum,
236 max_ofdm->re_acq_main_rssi_sum); 232 max_ofdm->re_acq_main_rssi_sum);
237 233
238 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
239 "acumulative delta max\n",
240 "Statistics_Rx - CCK:");
241 pos += scnprintf(buf + pos, bufsz - pos, 234 pos += scnprintf(buf + pos, bufsz - pos,
242 " %-30s %10u %10u %10u %10u\n", 235 fmt_header, "Statistics_Rx - CCK:");
243 "ina_cnt:", 236 pos += scnprintf(buf + pos, bufsz - pos,
237 fmt_table, "ina_cnt:",
244 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, 238 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
245 delta_cck->ina_cnt, max_cck->ina_cnt); 239 delta_cck->ina_cnt, max_cck->ina_cnt);
246 pos += scnprintf(buf + pos, bufsz - pos, 240 pos += scnprintf(buf + pos, bufsz - pos,
247 " %-30s %10u %10u %10u %10u\n", 241 fmt_table, "fina_cnt:",
248 "fina_cnt:",
249 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, 242 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
250 delta_cck->fina_cnt, max_cck->fina_cnt); 243 delta_cck->fina_cnt, max_cck->fina_cnt);
251 pos += scnprintf(buf + pos, bufsz - pos, 244 pos += scnprintf(buf + pos, bufsz - pos,
252 " %-30s %10u %10u %10u %10u\n", 245 fmt_table, "plcp_err:",
253 "plcp_err:",
254 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, 246 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
255 delta_cck->plcp_err, max_cck->plcp_err); 247 delta_cck->plcp_err, max_cck->plcp_err);
256 pos += scnprintf(buf + pos, bufsz - pos, 248 pos += scnprintf(buf + pos, bufsz - pos,
257 " %-30s %10u %10u %10u %10u\n", 249 fmt_table, "crc32_err:",
258 "crc32_err:",
259 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, 250 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
260 delta_cck->crc32_err, max_cck->crc32_err); 251 delta_cck->crc32_err, max_cck->crc32_err);
261 pos += scnprintf(buf + pos, bufsz - pos, 252 pos += scnprintf(buf + pos, bufsz - pos,
262 " %-30s %10u %10u %10u %10u\n", 253 fmt_table, "overrun_err:",
263 "overrun_err:",
264 le32_to_cpu(cck->overrun_err), 254 le32_to_cpu(cck->overrun_err),
265 accum_cck->overrun_err, delta_cck->overrun_err, 255 accum_cck->overrun_err, delta_cck->overrun_err,
266 max_cck->overrun_err); 256 max_cck->overrun_err);
267 pos += scnprintf(buf + pos, bufsz - pos, 257 pos += scnprintf(buf + pos, bufsz - pos,
268 " %-30s %10u %10u %10u %10u\n", 258 fmt_table, "early_overrun_err:",
269 "early_overrun_err:",
270 le32_to_cpu(cck->early_overrun_err), 259 le32_to_cpu(cck->early_overrun_err),
271 accum_cck->early_overrun_err, 260 accum_cck->early_overrun_err,
272 delta_cck->early_overrun_err, 261 delta_cck->early_overrun_err,
273 max_cck->early_overrun_err); 262 max_cck->early_overrun_err);
274 pos += scnprintf(buf + pos, bufsz - pos, 263 pos += scnprintf(buf + pos, bufsz - pos,
275 " %-30s %10u %10u %10u %10u\n", 264 fmt_table, "crc32_good:",
276 "crc32_good:",
277 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, 265 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
278 delta_cck->crc32_good, max_cck->crc32_good); 266 delta_cck->crc32_good, max_cck->crc32_good);
279 pos += scnprintf(buf + pos, bufsz - pos, 267 pos += scnprintf(buf + pos, bufsz - pos,
280 " %-30s %10u %10u %10u %10u\n", 268 fmt_table, "false_alarm_cnt:",
281 "false_alarm_cnt:",
282 le32_to_cpu(cck->false_alarm_cnt), 269 le32_to_cpu(cck->false_alarm_cnt),
283 accum_cck->false_alarm_cnt, 270 accum_cck->false_alarm_cnt,
284 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); 271 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
285 pos += scnprintf(buf + pos, bufsz - pos, 272 pos += scnprintf(buf + pos, bufsz - pos,
286 " %-30s %10u %10u %10u %10u\n", 273 fmt_table, "fina_sync_err_cnt:",
287 "fina_sync_err_cnt:",
288 le32_to_cpu(cck->fina_sync_err_cnt), 274 le32_to_cpu(cck->fina_sync_err_cnt),
289 accum_cck->fina_sync_err_cnt, 275 accum_cck->fina_sync_err_cnt,
290 delta_cck->fina_sync_err_cnt, 276 delta_cck->fina_sync_err_cnt,
291 max_cck->fina_sync_err_cnt); 277 max_cck->fina_sync_err_cnt);
292 pos += scnprintf(buf + pos, bufsz - pos, 278 pos += scnprintf(buf + pos, bufsz - pos,
293 " %-30s %10u %10u %10u %10u\n", 279 fmt_table, "sfd_timeout:",
294 "sfd_timeout:",
295 le32_to_cpu(cck->sfd_timeout), 280 le32_to_cpu(cck->sfd_timeout),
296 accum_cck->sfd_timeout, delta_cck->sfd_timeout, 281 accum_cck->sfd_timeout, delta_cck->sfd_timeout,
297 max_cck->sfd_timeout); 282 max_cck->sfd_timeout);
298 pos += scnprintf(buf + pos, bufsz - pos, 283 pos += scnprintf(buf + pos, bufsz - pos,
299 " %-30s %10u %10u %10u %10u\n", "fina_timeout:", 284 fmt_table, "fina_timeout:",
300 le32_to_cpu(cck->fina_timeout), 285 le32_to_cpu(cck->fina_timeout),
301 accum_cck->fina_timeout, delta_cck->fina_timeout, 286 accum_cck->fina_timeout, delta_cck->fina_timeout,
302 max_cck->fina_timeout); 287 max_cck->fina_timeout);
303 pos += scnprintf(buf + pos, bufsz - pos, 288 pos += scnprintf(buf + pos, bufsz - pos,
304 " %-30s %10u %10u %10u %10u\n", 289 fmt_table, "unresponded_rts:",
305 "unresponded_rts:",
306 le32_to_cpu(cck->unresponded_rts), 290 le32_to_cpu(cck->unresponded_rts),
307 accum_cck->unresponded_rts, delta_cck->unresponded_rts, 291 accum_cck->unresponded_rts, delta_cck->unresponded_rts,
308 max_cck->unresponded_rts); 292 max_cck->unresponded_rts);
309 pos += scnprintf(buf + pos, bufsz - pos, 293 pos += scnprintf(buf + pos, bufsz - pos,
310 " %-30s %10u %10u %10u %10u\n", 294 fmt_table, "rxe_frame_lmt_ovrun:",
311 "rxe_frame_lmt_ovrun:",
312 le32_to_cpu(cck->rxe_frame_limit_overrun), 295 le32_to_cpu(cck->rxe_frame_limit_overrun),
313 accum_cck->rxe_frame_limit_overrun, 296 accum_cck->rxe_frame_limit_overrun,
314 delta_cck->rxe_frame_limit_overrun, 297 delta_cck->rxe_frame_limit_overrun,
315 max_cck->rxe_frame_limit_overrun); 298 max_cck->rxe_frame_limit_overrun);
316 pos += scnprintf(buf + pos, bufsz - pos, 299 pos += scnprintf(buf + pos, bufsz - pos,
317 " %-30s %10u %10u %10u %10u\n", "sent_ack_cnt:", 300 fmt_table, "sent_ack_cnt:",
318 le32_to_cpu(cck->sent_ack_cnt), 301 le32_to_cpu(cck->sent_ack_cnt),
319 accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt, 302 accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt,
320 max_cck->sent_ack_cnt); 303 max_cck->sent_ack_cnt);
321 pos += scnprintf(buf + pos, bufsz - pos, 304 pos += scnprintf(buf + pos, bufsz - pos,
322 " %-30s %10u %10u %10u %10u\n", "sent_cts_cnt:", 305 fmt_table, "sent_cts_cnt:",
323 le32_to_cpu(cck->sent_cts_cnt), 306 le32_to_cpu(cck->sent_cts_cnt),
324 accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt, 307 accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt,
325 max_cck->sent_cts_cnt); 308 max_cck->sent_cts_cnt);
326 pos += scnprintf(buf + pos, bufsz - pos, 309 pos += scnprintf(buf + pos, bufsz - pos,
327 " %-30s %10u %10u %10u %10u\n", "sent_ba_rsp_cnt:", 310 fmt_table, "sent_ba_rsp_cnt:",
328 le32_to_cpu(cck->sent_ba_rsp_cnt), 311 le32_to_cpu(cck->sent_ba_rsp_cnt),
329 accum_cck->sent_ba_rsp_cnt, 312 accum_cck->sent_ba_rsp_cnt,
330 delta_cck->sent_ba_rsp_cnt, 313 delta_cck->sent_ba_rsp_cnt,
331 max_cck->sent_ba_rsp_cnt); 314 max_cck->sent_ba_rsp_cnt);
332 pos += scnprintf(buf + pos, bufsz - pos, 315 pos += scnprintf(buf + pos, bufsz - pos,
333 " %-30s %10u %10u %10u %10u\n", "dsp_self_kill:", 316 fmt_table, "dsp_self_kill:",
334 le32_to_cpu(cck->dsp_self_kill), 317 le32_to_cpu(cck->dsp_self_kill),
335 accum_cck->dsp_self_kill, delta_cck->dsp_self_kill, 318 accum_cck->dsp_self_kill, delta_cck->dsp_self_kill,
336 max_cck->dsp_self_kill); 319 max_cck->dsp_self_kill);
337 pos += scnprintf(buf + pos, bufsz - pos, 320 pos += scnprintf(buf + pos, bufsz - pos,
338 " %-30s %10u %10u %10u %10u\n", "mh_format_err:", 321 fmt_table, "mh_format_err:",
339 le32_to_cpu(cck->mh_format_err), 322 le32_to_cpu(cck->mh_format_err),
340 accum_cck->mh_format_err, delta_cck->mh_format_err, 323 accum_cck->mh_format_err, delta_cck->mh_format_err,
341 max_cck->mh_format_err); 324 max_cck->mh_format_err);
342 pos += scnprintf(buf + pos, bufsz - pos, 325 pos += scnprintf(buf + pos, bufsz - pos,
343 " %-30s %10u %10u %10u %10u\n", 326 fmt_table, "re_acq_main_rssi_sum:",
344 "re_acq_main_rssi_sum:",
345 le32_to_cpu(cck->re_acq_main_rssi_sum), 327 le32_to_cpu(cck->re_acq_main_rssi_sum),
346 accum_cck->re_acq_main_rssi_sum, 328 accum_cck->re_acq_main_rssi_sum,
347 delta_cck->re_acq_main_rssi_sum, 329 delta_cck->re_acq_main_rssi_sum,
348 max_cck->re_acq_main_rssi_sum); 330 max_cck->re_acq_main_rssi_sum);
349 331
350 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
351 "acumulative delta max\n",
352 "Statistics_Rx - GENERAL:");
353 pos += scnprintf(buf + pos, bufsz - pos, 332 pos += scnprintf(buf + pos, bufsz - pos,
354 " %-30s %10u %10u %10u %10u\n", "bogus_cts:", 333 fmt_header, "Statistics_Rx - GENERAL:");
334 pos += scnprintf(buf + pos, bufsz - pos,
335 fmt_table, "bogus_cts:",
355 le32_to_cpu(general->bogus_cts), 336 le32_to_cpu(general->bogus_cts),
356 accum_general->bogus_cts, delta_general->bogus_cts, 337 accum_general->bogus_cts, delta_general->bogus_cts,
357 max_general->bogus_cts); 338 max_general->bogus_cts);
358 pos += scnprintf(buf + pos, bufsz - pos, 339 pos += scnprintf(buf + pos, bufsz - pos,
359 " %-30s %10u %10u %10u %10u\n", "bogus_ack:", 340 fmt_table, "bogus_ack:",
360 le32_to_cpu(general->bogus_ack), 341 le32_to_cpu(general->bogus_ack),
361 accum_general->bogus_ack, delta_general->bogus_ack, 342 accum_general->bogus_ack, delta_general->bogus_ack,
362 max_general->bogus_ack); 343 max_general->bogus_ack);
363 pos += scnprintf(buf + pos, bufsz - pos, 344 pos += scnprintf(buf + pos, bufsz - pos,
364 " %-30s %10u %10u %10u %10u\n", 345 fmt_table, "non_bssid_frames:",
365 "non_bssid_frames:",
366 le32_to_cpu(general->non_bssid_frames), 346 le32_to_cpu(general->non_bssid_frames),
367 accum_general->non_bssid_frames, 347 accum_general->non_bssid_frames,
368 delta_general->non_bssid_frames, 348 delta_general->non_bssid_frames,
369 max_general->non_bssid_frames); 349 max_general->non_bssid_frames);
370 pos += scnprintf(buf + pos, bufsz - pos, 350 pos += scnprintf(buf + pos, bufsz - pos,
371 " %-30s %10u %10u %10u %10u\n", 351 fmt_table, "filtered_frames:",
372 "filtered_frames:",
373 le32_to_cpu(general->filtered_frames), 352 le32_to_cpu(general->filtered_frames),
374 accum_general->filtered_frames, 353 accum_general->filtered_frames,
375 delta_general->filtered_frames, 354 delta_general->filtered_frames,
376 max_general->filtered_frames); 355 max_general->filtered_frames);
377 pos += scnprintf(buf + pos, bufsz - pos, 356 pos += scnprintf(buf + pos, bufsz - pos,
378 " %-30s %10u %10u %10u %10u\n", 357 fmt_table, "non_channel_beacons:",
379 "non_channel_beacons:",
380 le32_to_cpu(general->non_channel_beacons), 358 le32_to_cpu(general->non_channel_beacons),
381 accum_general->non_channel_beacons, 359 accum_general->non_channel_beacons,
382 delta_general->non_channel_beacons, 360 delta_general->non_channel_beacons,
383 max_general->non_channel_beacons); 361 max_general->non_channel_beacons);
384 pos += scnprintf(buf + pos, bufsz - pos, 362 pos += scnprintf(buf + pos, bufsz - pos,
385 " %-30s %10u %10u %10u %10u\n", 363 fmt_table, "channel_beacons:",
386 "channel_beacons:",
387 le32_to_cpu(general->channel_beacons), 364 le32_to_cpu(general->channel_beacons),
388 accum_general->channel_beacons, 365 accum_general->channel_beacons,
389 delta_general->channel_beacons, 366 delta_general->channel_beacons,
390 max_general->channel_beacons); 367 max_general->channel_beacons);
391 pos += scnprintf(buf + pos, bufsz - pos, 368 pos += scnprintf(buf + pos, bufsz - pos,
392 " %-30s %10u %10u %10u %10u\n", 369 fmt_table, "num_missed_bcon:",
393 "num_missed_bcon:",
394 le32_to_cpu(general->num_missed_bcon), 370 le32_to_cpu(general->num_missed_bcon),
395 accum_general->num_missed_bcon, 371 accum_general->num_missed_bcon,
396 delta_general->num_missed_bcon, 372 delta_general->num_missed_bcon,
397 max_general->num_missed_bcon); 373 max_general->num_missed_bcon);
398 pos += scnprintf(buf + pos, bufsz - pos, 374 pos += scnprintf(buf + pos, bufsz - pos,
399 " %-30s %10u %10u %10u %10u\n", 375 fmt_table, "adc_rx_saturation_time:",
400 "adc_rx_saturation_time:",
401 le32_to_cpu(general->adc_rx_saturation_time), 376 le32_to_cpu(general->adc_rx_saturation_time),
402 accum_general->adc_rx_saturation_time, 377 accum_general->adc_rx_saturation_time,
403 delta_general->adc_rx_saturation_time, 378 delta_general->adc_rx_saturation_time,
404 max_general->adc_rx_saturation_time); 379 max_general->adc_rx_saturation_time);
405 pos += scnprintf(buf + pos, bufsz - pos, 380 pos += scnprintf(buf + pos, bufsz - pos,
406 " %-30s %10u %10u %10u %10u\n", 381 fmt_table, "ina_detect_search_tm:",
407 "ina_detect_search_tm:",
408 le32_to_cpu(general->ina_detection_search_time), 382 le32_to_cpu(general->ina_detection_search_time),
409 accum_general->ina_detection_search_time, 383 accum_general->ina_detection_search_time,
410 delta_general->ina_detection_search_time, 384 delta_general->ina_detection_search_time,
411 max_general->ina_detection_search_time); 385 max_general->ina_detection_search_time);
412 pos += scnprintf(buf + pos, bufsz - pos, 386 pos += scnprintf(buf + pos, bufsz - pos,
413 " %-30s %10u %10u %10u %10u\n", 387 fmt_table, "beacon_silence_rssi_a:",
414 "beacon_silence_rssi_a:",
415 le32_to_cpu(general->beacon_silence_rssi_a), 388 le32_to_cpu(general->beacon_silence_rssi_a),
416 accum_general->beacon_silence_rssi_a, 389 accum_general->beacon_silence_rssi_a,
417 delta_general->beacon_silence_rssi_a, 390 delta_general->beacon_silence_rssi_a,
418 max_general->beacon_silence_rssi_a); 391 max_general->beacon_silence_rssi_a);
419 pos += scnprintf(buf + pos, bufsz - pos, 392 pos += scnprintf(buf + pos, bufsz - pos,
420 " %-30s %10u %10u %10u %10u\n", 393 fmt_table, "beacon_silence_rssi_b:",
421 "beacon_silence_rssi_b:",
422 le32_to_cpu(general->beacon_silence_rssi_b), 394 le32_to_cpu(general->beacon_silence_rssi_b),
423 accum_general->beacon_silence_rssi_b, 395 accum_general->beacon_silence_rssi_b,
424 delta_general->beacon_silence_rssi_b, 396 delta_general->beacon_silence_rssi_b,
425 max_general->beacon_silence_rssi_b); 397 max_general->beacon_silence_rssi_b);
426 pos += scnprintf(buf + pos, bufsz - pos, 398 pos += scnprintf(buf + pos, bufsz - pos,
427 " %-30s %10u %10u %10u %10u\n", 399 fmt_table, "beacon_silence_rssi_c:",
428 "beacon_silence_rssi_c:",
429 le32_to_cpu(general->beacon_silence_rssi_c), 400 le32_to_cpu(general->beacon_silence_rssi_c),
430 accum_general->beacon_silence_rssi_c, 401 accum_general->beacon_silence_rssi_c,
431 delta_general->beacon_silence_rssi_c, 402 delta_general->beacon_silence_rssi_c,
432 max_general->beacon_silence_rssi_c); 403 max_general->beacon_silence_rssi_c);
433 pos += scnprintf(buf + pos, bufsz - pos, 404 pos += scnprintf(buf + pos, bufsz - pos,
434 " %-30s %10u %10u %10u %10u\n", 405 fmt_table, "interference_data_flag:",
435 "interference_data_flag:",
436 le32_to_cpu(general->interference_data_flag), 406 le32_to_cpu(general->interference_data_flag),
437 accum_general->interference_data_flag, 407 accum_general->interference_data_flag,
438 delta_general->interference_data_flag, 408 delta_general->interference_data_flag,
439 max_general->interference_data_flag); 409 max_general->interference_data_flag);
440 pos += scnprintf(buf + pos, bufsz - pos, 410 pos += scnprintf(buf + pos, bufsz - pos,
441 " %-30s %10u %10u %10u %10u\n", 411 fmt_table, "channel_load:",
442 "channel_load:",
443 le32_to_cpu(general->channel_load), 412 le32_to_cpu(general->channel_load),
444 accum_general->channel_load, 413 accum_general->channel_load,
445 delta_general->channel_load, 414 delta_general->channel_load,
446 max_general->channel_load); 415 max_general->channel_load);
447 pos += scnprintf(buf + pos, bufsz - pos, 416 pos += scnprintf(buf + pos, bufsz - pos,
448 " %-30s %10u %10u %10u %10u\n", 417 fmt_table, "dsp_false_alarms:",
449 "dsp_false_alarms:",
450 le32_to_cpu(general->dsp_false_alarms), 418 le32_to_cpu(general->dsp_false_alarms),
451 accum_general->dsp_false_alarms, 419 accum_general->dsp_false_alarms,
452 delta_general->dsp_false_alarms, 420 delta_general->dsp_false_alarms,
453 max_general->dsp_false_alarms); 421 max_general->dsp_false_alarms);
454 pos += scnprintf(buf + pos, bufsz - pos, 422 pos += scnprintf(buf + pos, bufsz - pos,
455 " %-30s %10u %10u %10u %10u\n", 423 fmt_table, "beacon_rssi_a:",
456 "beacon_rssi_a:",
457 le32_to_cpu(general->beacon_rssi_a), 424 le32_to_cpu(general->beacon_rssi_a),
458 accum_general->beacon_rssi_a, 425 accum_general->beacon_rssi_a,
459 delta_general->beacon_rssi_a, 426 delta_general->beacon_rssi_a,
460 max_general->beacon_rssi_a); 427 max_general->beacon_rssi_a);
461 pos += scnprintf(buf + pos, bufsz - pos, 428 pos += scnprintf(buf + pos, bufsz - pos,
462 " %-30s %10u %10u %10u %10u\n", 429 fmt_table, "beacon_rssi_b:",
463 "beacon_rssi_b:",
464 le32_to_cpu(general->beacon_rssi_b), 430 le32_to_cpu(general->beacon_rssi_b),
465 accum_general->beacon_rssi_b, 431 accum_general->beacon_rssi_b,
466 delta_general->beacon_rssi_b, 432 delta_general->beacon_rssi_b,
467 max_general->beacon_rssi_b); 433 max_general->beacon_rssi_b);
468 pos += scnprintf(buf + pos, bufsz - pos, 434 pos += scnprintf(buf + pos, bufsz - pos,
469 " %-30s %10u %10u %10u %10u\n", 435 fmt_table, "beacon_rssi_c:",
470 "beacon_rssi_c:",
471 le32_to_cpu(general->beacon_rssi_c), 436 le32_to_cpu(general->beacon_rssi_c),
472 accum_general->beacon_rssi_c, 437 accum_general->beacon_rssi_c,
473 delta_general->beacon_rssi_c, 438 delta_general->beacon_rssi_c,
474 max_general->beacon_rssi_c); 439 max_general->beacon_rssi_c);
475 pos += scnprintf(buf + pos, bufsz - pos, 440 pos += scnprintf(buf + pos, bufsz - pos,
476 " %-30s %10u %10u %10u %10u\n", 441 fmt_table, "beacon_energy_a:",
477 "beacon_energy_a:",
478 le32_to_cpu(general->beacon_energy_a), 442 le32_to_cpu(general->beacon_energy_a),
479 accum_general->beacon_energy_a, 443 accum_general->beacon_energy_a,
480 delta_general->beacon_energy_a, 444 delta_general->beacon_energy_a,
481 max_general->beacon_energy_a); 445 max_general->beacon_energy_a);
482 pos += scnprintf(buf + pos, bufsz - pos, 446 pos += scnprintf(buf + pos, bufsz - pos,
483 " %-30s %10u %10u %10u %10u\n", 447 fmt_table, "beacon_energy_b:",
484 "beacon_energy_b:",
485 le32_to_cpu(general->beacon_energy_b), 448 le32_to_cpu(general->beacon_energy_b),
486 accum_general->beacon_energy_b, 449 accum_general->beacon_energy_b,
487 delta_general->beacon_energy_b, 450 delta_general->beacon_energy_b,
488 max_general->beacon_energy_b); 451 max_general->beacon_energy_b);
489 pos += scnprintf(buf + pos, bufsz - pos, 452 pos += scnprintf(buf + pos, bufsz - pos,
490 " %-30s %10u %10u %10u %10u\n", 453 fmt_table, "beacon_energy_c:",
491 "beacon_energy_c:",
492 le32_to_cpu(general->beacon_energy_c), 454 le32_to_cpu(general->beacon_energy_c),
493 accum_general->beacon_energy_c, 455 accum_general->beacon_energy_c,
494 delta_general->beacon_energy_c, 456 delta_general->beacon_energy_c,
495 max_general->beacon_energy_c); 457 max_general->beacon_energy_c);
496 458
497 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Rx - OFDM_HT:\n");
498 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
499 "acumulative delta max\n",
500 "Statistics_Rx - OFDM_HT:");
501 pos += scnprintf(buf + pos, bufsz - pos, 459 pos += scnprintf(buf + pos, bufsz - pos,
502 " %-30s %10u %10u %10u %10u\n", 460 fmt_header, "Statistics_Rx - OFDM_HT:");
503 "plcp_err:", 461 pos += scnprintf(buf + pos, bufsz - pos,
462 fmt_table, "plcp_err:",
504 le32_to_cpu(ht->plcp_err), accum_ht->plcp_err, 463 le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
505 delta_ht->plcp_err, max_ht->plcp_err); 464 delta_ht->plcp_err, max_ht->plcp_err);
506 pos += scnprintf(buf + pos, bufsz - pos, 465 pos += scnprintf(buf + pos, bufsz - pos,
507 " %-30s %10u %10u %10u %10u\n", 466 fmt_table, "overrun_err:",
508 "overrun_err:",
509 le32_to_cpu(ht->overrun_err), accum_ht->overrun_err, 467 le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
510 delta_ht->overrun_err, max_ht->overrun_err); 468 delta_ht->overrun_err, max_ht->overrun_err);
511 pos += scnprintf(buf + pos, bufsz - pos, 469 pos += scnprintf(buf + pos, bufsz - pos,
512 " %-30s %10u %10u %10u %10u\n", 470 fmt_table, "early_overrun_err:",
513 "early_overrun_err:",
514 le32_to_cpu(ht->early_overrun_err), 471 le32_to_cpu(ht->early_overrun_err),
515 accum_ht->early_overrun_err, 472 accum_ht->early_overrun_err,
516 delta_ht->early_overrun_err, 473 delta_ht->early_overrun_err,
517 max_ht->early_overrun_err); 474 max_ht->early_overrun_err);
518 pos += scnprintf(buf + pos, bufsz - pos, 475 pos += scnprintf(buf + pos, bufsz - pos,
519 " %-30s %10u %10u %10u %10u\n", 476 fmt_table, "crc32_good:",
520 "crc32_good:",
521 le32_to_cpu(ht->crc32_good), accum_ht->crc32_good, 477 le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
522 delta_ht->crc32_good, max_ht->crc32_good); 478 delta_ht->crc32_good, max_ht->crc32_good);
523 pos += scnprintf(buf + pos, bufsz - pos, 479 pos += scnprintf(buf + pos, bufsz - pos,
524 " %-30s %10u %10u %10u %10u\n", 480 fmt_table, "crc32_err:",
525 "crc32_err:",
526 le32_to_cpu(ht->crc32_err), accum_ht->crc32_err, 481 le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
527 delta_ht->crc32_err, max_ht->crc32_err); 482 delta_ht->crc32_err, max_ht->crc32_err);
528 pos += scnprintf(buf + pos, bufsz - pos, 483 pos += scnprintf(buf + pos, bufsz - pos,
529 " %-30s %10u %10u %10u %10u\n", 484 fmt_table, "mh_format_err:",
530 "mh_format_err:",
531 le32_to_cpu(ht->mh_format_err), 485 le32_to_cpu(ht->mh_format_err),
532 accum_ht->mh_format_err, 486 accum_ht->mh_format_err,
533 delta_ht->mh_format_err, max_ht->mh_format_err); 487 delta_ht->mh_format_err, max_ht->mh_format_err);
534 pos += scnprintf(buf + pos, bufsz - pos, 488 pos += scnprintf(buf + pos, bufsz - pos,
535 " %-30s %10u %10u %10u %10u\n", 489 fmt_table, "agg_crc32_good:",
536 "agg_crc32_good:",
537 le32_to_cpu(ht->agg_crc32_good), 490 le32_to_cpu(ht->agg_crc32_good),
538 accum_ht->agg_crc32_good, 491 accum_ht->agg_crc32_good,
539 delta_ht->agg_crc32_good, max_ht->agg_crc32_good); 492 delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
540 pos += scnprintf(buf + pos, bufsz - pos, 493 pos += scnprintf(buf + pos, bufsz - pos,
541 " %-30s %10u %10u %10u %10u\n", 494 fmt_table, "agg_mpdu_cnt:",
542 "agg_mpdu_cnt:",
543 le32_to_cpu(ht->agg_mpdu_cnt), 495 le32_to_cpu(ht->agg_mpdu_cnt),
544 accum_ht->agg_mpdu_cnt, 496 accum_ht->agg_mpdu_cnt,
545 delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt); 497 delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
546 pos += scnprintf(buf + pos, bufsz - pos, 498 pos += scnprintf(buf + pos, bufsz - pos,
547 " %-30s %10u %10u %10u %10u\n", 499 fmt_table, "agg_cnt:",
548 "agg_cnt:",
549 le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt, 500 le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
550 delta_ht->agg_cnt, max_ht->agg_cnt); 501 delta_ht->agg_cnt, max_ht->agg_cnt);
551 pos += scnprintf(buf + pos, bufsz - pos, 502 pos += scnprintf(buf + pos, bufsz - pos,
552 " %-30s %10u %10u %10u %10u\n", 503 fmt_table, "unsupport_mcs:",
553 "unsupport_mcs:",
554 le32_to_cpu(ht->unsupport_mcs), 504 le32_to_cpu(ht->unsupport_mcs),
555 accum_ht->unsupport_mcs, 505 accum_ht->unsupport_mcs,
556 delta_ht->unsupport_mcs, max_ht->unsupport_mcs); 506 delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
@@ -597,166 +547,141 @@ ssize_t iwl_ucode_tx_stats_read(struct file *file,
597 } 547 }
598 548
599 pos += iwl_statistics_flag(priv, buf, bufsz); 549 pos += iwl_statistics_flag(priv, buf, bufsz);
600 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
601 "acumulative delta max\n",
602 "Statistics_Tx:");
603 pos += scnprintf(buf + pos, bufsz - pos, 550 pos += scnprintf(buf + pos, bufsz - pos,
604 " %-30s %10u %10u %10u %10u\n", 551 fmt_header, "Statistics_Tx:");
605 "preamble:", 552 pos += scnprintf(buf + pos, bufsz - pos,
553 fmt_table, "preamble:",
606 le32_to_cpu(tx->preamble_cnt), 554 le32_to_cpu(tx->preamble_cnt),
607 accum_tx->preamble_cnt, 555 accum_tx->preamble_cnt,
608 delta_tx->preamble_cnt, max_tx->preamble_cnt); 556 delta_tx->preamble_cnt, max_tx->preamble_cnt);
609 pos += scnprintf(buf + pos, bufsz - pos, 557 pos += scnprintf(buf + pos, bufsz - pos,
610 " %-30s %10u %10u %10u %10u\n", 558 fmt_table, "rx_detected_cnt:",
611 "rx_detected_cnt:",
612 le32_to_cpu(tx->rx_detected_cnt), 559 le32_to_cpu(tx->rx_detected_cnt),
613 accum_tx->rx_detected_cnt, 560 accum_tx->rx_detected_cnt,
614 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); 561 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
615 pos += scnprintf(buf + pos, bufsz - pos, 562 pos += scnprintf(buf + pos, bufsz - pos,
616 " %-30s %10u %10u %10u %10u\n", 563 fmt_table, "bt_prio_defer_cnt:",
617 "bt_prio_defer_cnt:",
618 le32_to_cpu(tx->bt_prio_defer_cnt), 564 le32_to_cpu(tx->bt_prio_defer_cnt),
619 accum_tx->bt_prio_defer_cnt, 565 accum_tx->bt_prio_defer_cnt,
620 delta_tx->bt_prio_defer_cnt, 566 delta_tx->bt_prio_defer_cnt,
621 max_tx->bt_prio_defer_cnt); 567 max_tx->bt_prio_defer_cnt);
622 pos += scnprintf(buf + pos, bufsz - pos, 568 pos += scnprintf(buf + pos, bufsz - pos,
623 " %-30s %10u %10u %10u %10u\n", 569 fmt_table, "bt_prio_kill_cnt:",
624 "bt_prio_kill_cnt:",
625 le32_to_cpu(tx->bt_prio_kill_cnt), 570 le32_to_cpu(tx->bt_prio_kill_cnt),
626 accum_tx->bt_prio_kill_cnt, 571 accum_tx->bt_prio_kill_cnt,
627 delta_tx->bt_prio_kill_cnt, 572 delta_tx->bt_prio_kill_cnt,
628 max_tx->bt_prio_kill_cnt); 573 max_tx->bt_prio_kill_cnt);
629 pos += scnprintf(buf + pos, bufsz - pos, 574 pos += scnprintf(buf + pos, bufsz - pos,
630 " %-30s %10u %10u %10u %10u\n", 575 fmt_table, "few_bytes_cnt:",
631 "few_bytes_cnt:",
632 le32_to_cpu(tx->few_bytes_cnt), 576 le32_to_cpu(tx->few_bytes_cnt),
633 accum_tx->few_bytes_cnt, 577 accum_tx->few_bytes_cnt,
634 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); 578 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
635 pos += scnprintf(buf + pos, bufsz - pos, 579 pos += scnprintf(buf + pos, bufsz - pos,
636 " %-30s %10u %10u %10u %10u\n", 580 fmt_table, "cts_timeout:",
637 "cts_timeout:",
638 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, 581 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
639 delta_tx->cts_timeout, max_tx->cts_timeout); 582 delta_tx->cts_timeout, max_tx->cts_timeout);
640 pos += scnprintf(buf + pos, bufsz - pos, 583 pos += scnprintf(buf + pos, bufsz - pos,
641 " %-30s %10u %10u %10u %10u\n", 584 fmt_table, "ack_timeout:",
642 "ack_timeout:",
643 le32_to_cpu(tx->ack_timeout), 585 le32_to_cpu(tx->ack_timeout),
644 accum_tx->ack_timeout, 586 accum_tx->ack_timeout,
645 delta_tx->ack_timeout, max_tx->ack_timeout); 587 delta_tx->ack_timeout, max_tx->ack_timeout);
646 pos += scnprintf(buf + pos, bufsz - pos, 588 pos += scnprintf(buf + pos, bufsz - pos,
647 " %-30s %10u %10u %10u %10u\n", 589 fmt_table, "expected_ack_cnt:",
648 "expected_ack_cnt:",
649 le32_to_cpu(tx->expected_ack_cnt), 590 le32_to_cpu(tx->expected_ack_cnt),
650 accum_tx->expected_ack_cnt, 591 accum_tx->expected_ack_cnt,
651 delta_tx->expected_ack_cnt, 592 delta_tx->expected_ack_cnt,
652 max_tx->expected_ack_cnt); 593 max_tx->expected_ack_cnt);
653 pos += scnprintf(buf + pos, bufsz - pos, 594 pos += scnprintf(buf + pos, bufsz - pos,
654 " %-30s %10u %10u %10u %10u\n", 595 fmt_table, "actual_ack_cnt:",
655 "actual_ack_cnt:",
656 le32_to_cpu(tx->actual_ack_cnt), 596 le32_to_cpu(tx->actual_ack_cnt),
657 accum_tx->actual_ack_cnt, 597 accum_tx->actual_ack_cnt,
658 delta_tx->actual_ack_cnt, 598 delta_tx->actual_ack_cnt,
659 max_tx->actual_ack_cnt); 599 max_tx->actual_ack_cnt);
660 pos += scnprintf(buf + pos, bufsz - pos, 600 pos += scnprintf(buf + pos, bufsz - pos,
661 " %-30s %10u %10u %10u %10u\n", 601 fmt_table, "dump_msdu_cnt:",
662 "dump_msdu_cnt:",
663 le32_to_cpu(tx->dump_msdu_cnt), 602 le32_to_cpu(tx->dump_msdu_cnt),
664 accum_tx->dump_msdu_cnt, 603 accum_tx->dump_msdu_cnt,
665 delta_tx->dump_msdu_cnt, 604 delta_tx->dump_msdu_cnt,
666 max_tx->dump_msdu_cnt); 605 max_tx->dump_msdu_cnt);
667 pos += scnprintf(buf + pos, bufsz - pos, 606 pos += scnprintf(buf + pos, bufsz - pos,
668 " %-30s %10u %10u %10u %10u\n", 607 fmt_table, "abort_nxt_frame_mismatch:",
669 "abort_nxt_frame_mismatch:",
670 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt), 608 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
671 accum_tx->burst_abort_next_frame_mismatch_cnt, 609 accum_tx->burst_abort_next_frame_mismatch_cnt,
672 delta_tx->burst_abort_next_frame_mismatch_cnt, 610 delta_tx->burst_abort_next_frame_mismatch_cnt,
673 max_tx->burst_abort_next_frame_mismatch_cnt); 611 max_tx->burst_abort_next_frame_mismatch_cnt);
674 pos += scnprintf(buf + pos, bufsz - pos, 612 pos += scnprintf(buf + pos, bufsz - pos,
675 " %-30s %10u %10u %10u %10u\n", 613 fmt_table, "abort_missing_nxt_frame:",
676 "abort_missing_nxt_frame:",
677 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt), 614 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
678 accum_tx->burst_abort_missing_next_frame_cnt, 615 accum_tx->burst_abort_missing_next_frame_cnt,
679 delta_tx->burst_abort_missing_next_frame_cnt, 616 delta_tx->burst_abort_missing_next_frame_cnt,
680 max_tx->burst_abort_missing_next_frame_cnt); 617 max_tx->burst_abort_missing_next_frame_cnt);
681 pos += scnprintf(buf + pos, bufsz - pos, 618 pos += scnprintf(buf + pos, bufsz - pos,
682 " %-30s %10u %10u %10u %10u\n", 619 fmt_table, "cts_timeout_collision:",
683 "cts_timeout_collision:",
684 le32_to_cpu(tx->cts_timeout_collision), 620 le32_to_cpu(tx->cts_timeout_collision),
685 accum_tx->cts_timeout_collision, 621 accum_tx->cts_timeout_collision,
686 delta_tx->cts_timeout_collision, 622 delta_tx->cts_timeout_collision,
687 max_tx->cts_timeout_collision); 623 max_tx->cts_timeout_collision);
688 pos += scnprintf(buf + pos, bufsz - pos, 624 pos += scnprintf(buf + pos, bufsz - pos,
689 " %-30s %10u %10u %10u %10u\n", 625 fmt_table, "ack_ba_timeout_collision:",
690 "ack_ba_timeout_collision:",
691 le32_to_cpu(tx->ack_or_ba_timeout_collision), 626 le32_to_cpu(tx->ack_or_ba_timeout_collision),
692 accum_tx->ack_or_ba_timeout_collision, 627 accum_tx->ack_or_ba_timeout_collision,
693 delta_tx->ack_or_ba_timeout_collision, 628 delta_tx->ack_or_ba_timeout_collision,
694 max_tx->ack_or_ba_timeout_collision); 629 max_tx->ack_or_ba_timeout_collision);
695 pos += scnprintf(buf + pos, bufsz - pos, 630 pos += scnprintf(buf + pos, bufsz - pos,
696 " %-30s %10u %10u %10u %10u\n", 631 fmt_table, "agg ba_timeout:",
697 "agg ba_timeout:",
698 le32_to_cpu(tx->agg.ba_timeout), 632 le32_to_cpu(tx->agg.ba_timeout),
699 accum_tx->agg.ba_timeout, 633 accum_tx->agg.ba_timeout,
700 delta_tx->agg.ba_timeout, 634 delta_tx->agg.ba_timeout,
701 max_tx->agg.ba_timeout); 635 max_tx->agg.ba_timeout);
702 pos += scnprintf(buf + pos, bufsz - pos, 636 pos += scnprintf(buf + pos, bufsz - pos,
703 " %-30s %10u %10u %10u %10u\n", 637 fmt_table, "agg ba_resched_frames:",
704 "agg ba_resched_frames:",
705 le32_to_cpu(tx->agg.ba_reschedule_frames), 638 le32_to_cpu(tx->agg.ba_reschedule_frames),
706 accum_tx->agg.ba_reschedule_frames, 639 accum_tx->agg.ba_reschedule_frames,
707 delta_tx->agg.ba_reschedule_frames, 640 delta_tx->agg.ba_reschedule_frames,
708 max_tx->agg.ba_reschedule_frames); 641 max_tx->agg.ba_reschedule_frames);
709 pos += scnprintf(buf + pos, bufsz - pos, 642 pos += scnprintf(buf + pos, bufsz - pos,
710 " %-30s %10u %10u %10u %10u\n", 643 fmt_table, "agg scd_query_agg_frame:",
711 "agg scd_query_agg_frame:",
712 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt), 644 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
713 accum_tx->agg.scd_query_agg_frame_cnt, 645 accum_tx->agg.scd_query_agg_frame_cnt,
714 delta_tx->agg.scd_query_agg_frame_cnt, 646 delta_tx->agg.scd_query_agg_frame_cnt,
715 max_tx->agg.scd_query_agg_frame_cnt); 647 max_tx->agg.scd_query_agg_frame_cnt);
716 pos += scnprintf(buf + pos, bufsz - pos, 648 pos += scnprintf(buf + pos, bufsz - pos,
717 " %-30s %10u %10u %10u %10u\n", 649 fmt_table, "agg scd_query_no_agg:",
718 "agg scd_query_no_agg:",
719 le32_to_cpu(tx->agg.scd_query_no_agg), 650 le32_to_cpu(tx->agg.scd_query_no_agg),
720 accum_tx->agg.scd_query_no_agg, 651 accum_tx->agg.scd_query_no_agg,
721 delta_tx->agg.scd_query_no_agg, 652 delta_tx->agg.scd_query_no_agg,
722 max_tx->agg.scd_query_no_agg); 653 max_tx->agg.scd_query_no_agg);
723 pos += scnprintf(buf + pos, bufsz - pos, 654 pos += scnprintf(buf + pos, bufsz - pos,
724 " %-30s %10u %10u %10u %10u\n", 655 fmt_table, "agg scd_query_agg:",
725 "agg scd_query_agg:",
726 le32_to_cpu(tx->agg.scd_query_agg), 656 le32_to_cpu(tx->agg.scd_query_agg),
727 accum_tx->agg.scd_query_agg, 657 accum_tx->agg.scd_query_agg,
728 delta_tx->agg.scd_query_agg, 658 delta_tx->agg.scd_query_agg,
729 max_tx->agg.scd_query_agg); 659 max_tx->agg.scd_query_agg);
730 pos += scnprintf(buf + pos, bufsz - pos, 660 pos += scnprintf(buf + pos, bufsz - pos,
731 " %-30s %10u %10u %10u %10u\n", 661 fmt_table, "agg scd_query_mismatch:",
732 "agg scd_query_mismatch:",
733 le32_to_cpu(tx->agg.scd_query_mismatch), 662 le32_to_cpu(tx->agg.scd_query_mismatch),
734 accum_tx->agg.scd_query_mismatch, 663 accum_tx->agg.scd_query_mismatch,
735 delta_tx->agg.scd_query_mismatch, 664 delta_tx->agg.scd_query_mismatch,
736 max_tx->agg.scd_query_mismatch); 665 max_tx->agg.scd_query_mismatch);
737 pos += scnprintf(buf + pos, bufsz - pos, 666 pos += scnprintf(buf + pos, bufsz - pos,
738 " %-30s %10u %10u %10u %10u\n", 667 fmt_table, "agg frame_not_ready:",
739 "agg frame_not_ready:",
740 le32_to_cpu(tx->agg.frame_not_ready), 668 le32_to_cpu(tx->agg.frame_not_ready),
741 accum_tx->agg.frame_not_ready, 669 accum_tx->agg.frame_not_ready,
742 delta_tx->agg.frame_not_ready, 670 delta_tx->agg.frame_not_ready,
743 max_tx->agg.frame_not_ready); 671 max_tx->agg.frame_not_ready);
744 pos += scnprintf(buf + pos, bufsz - pos, 672 pos += scnprintf(buf + pos, bufsz - pos,
745 " %-30s %10u %10u %10u %10u\n", 673 fmt_table, "agg underrun:",
746 "agg underrun:",
747 le32_to_cpu(tx->agg.underrun), 674 le32_to_cpu(tx->agg.underrun),
748 accum_tx->agg.underrun, 675 accum_tx->agg.underrun,
749 delta_tx->agg.underrun, max_tx->agg.underrun); 676 delta_tx->agg.underrun, max_tx->agg.underrun);
750 pos += scnprintf(buf + pos, bufsz - pos, 677 pos += scnprintf(buf + pos, bufsz - pos,
751 " %-30s %10u %10u %10u %10u\n", 678 fmt_table, "agg bt_prio_kill:",
752 "agg bt_prio_kill:",
753 le32_to_cpu(tx->agg.bt_prio_kill), 679 le32_to_cpu(tx->agg.bt_prio_kill),
754 accum_tx->agg.bt_prio_kill, 680 accum_tx->agg.bt_prio_kill,
755 delta_tx->agg.bt_prio_kill, 681 delta_tx->agg.bt_prio_kill,
756 max_tx->agg.bt_prio_kill); 682 max_tx->agg.bt_prio_kill);
757 pos += scnprintf(buf + pos, bufsz - pos, 683 pos += scnprintf(buf + pos, bufsz - pos,
758 " %-30s %10u %10u %10u %10u\n", 684 fmt_table, "agg rx_ba_rsp_cnt:",
759 "agg rx_ba_rsp_cnt:",
760 le32_to_cpu(tx->agg.rx_ba_rsp_cnt), 685 le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
761 accum_tx->agg.rx_ba_rsp_cnt, 686 accum_tx->agg.rx_ba_rsp_cnt,
762 delta_tx->agg.rx_ba_rsp_cnt, 687 delta_tx->agg.rx_ba_rsp_cnt,
@@ -767,15 +692,15 @@ ssize_t iwl_ucode_tx_stats_read(struct file *file,
767 "tx power: (1/2 dB step)\n"); 692 "tx power: (1/2 dB step)\n");
768 if ((priv->cfg->valid_tx_ant & ANT_A) && tx->tx_power.ant_a) 693 if ((priv->cfg->valid_tx_ant & ANT_A) && tx->tx_power.ant_a)
769 pos += scnprintf(buf + pos, bufsz - pos, 694 pos += scnprintf(buf + pos, bufsz - pos,
770 "\tantenna A: 0x%X\n", 695 fmt_hex, "antenna A:",
771 tx->tx_power.ant_a); 696 tx->tx_power.ant_a);
772 if ((priv->cfg->valid_tx_ant & ANT_B) && tx->tx_power.ant_b) 697 if ((priv->cfg->valid_tx_ant & ANT_B) && tx->tx_power.ant_b)
773 pos += scnprintf(buf + pos, bufsz - pos, 698 pos += scnprintf(buf + pos, bufsz - pos,
774 "\tantenna B: 0x%X\n", 699 fmt_hex, "antenna B:",
775 tx->tx_power.ant_b); 700 tx->tx_power.ant_b);
776 if ((priv->cfg->valid_tx_ant & ANT_C) && tx->tx_power.ant_c) 701 if ((priv->cfg->valid_tx_ant & ANT_C) && tx->tx_power.ant_c)
777 pos += scnprintf(buf + pos, bufsz - pos, 702 pos += scnprintf(buf + pos, bufsz - pos,
778 "\tantenna C: 0x%X\n", 703 fmt_hex, "antenna C:",
779 tx->tx_power.ant_c); 704 tx->tx_power.ant_c);
780 } 705 }
781 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 706 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
@@ -838,84 +763,72 @@ ssize_t iwl_ucode_general_stats_read(struct file *file, char __user *user_buf,
838 } 763 }
839 764
840 pos += iwl_statistics_flag(priv, buf, bufsz); 765 pos += iwl_statistics_flag(priv, buf, bufsz);
841 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" 766 pos += scnprintf(buf + pos, bufsz - pos,
842 "acumulative delta max\n", 767 fmt_header, "Statistics_General:");
843 "Statistics_General:"); 768 pos += scnprintf(buf + pos, bufsz - pos,
844 pos += scnprintf(buf + pos, bufsz - pos, " %-30s %10u\n", 769 fmt_value, "temperature:",
845 "temperature:",
846 le32_to_cpu(general->temperature)); 770 le32_to_cpu(general->temperature));
847 pos += scnprintf(buf + pos, bufsz - pos, " %-30s %10u\n", 771 pos += scnprintf(buf + pos, bufsz - pos,
848 "temperature_m:", 772 fmt_value, "temperature_m:",
849 le32_to_cpu(general->temperature_m)); 773 le32_to_cpu(general->temperature_m));
850 pos += scnprintf(buf + pos, bufsz - pos, 774 pos += scnprintf(buf + pos, bufsz - pos,
851 " %-30s %10u %10u %10u %10u\n", 775 fmt_value, "ttl_timestamp:",
852 "burst_check:", 776 le32_to_cpu(general->ttl_timestamp));
777 pos += scnprintf(buf + pos, bufsz - pos,
778 fmt_table, "burst_check:",
853 le32_to_cpu(dbg->burst_check), 779 le32_to_cpu(dbg->burst_check),
854 accum_dbg->burst_check, 780 accum_dbg->burst_check,
855 delta_dbg->burst_check, max_dbg->burst_check); 781 delta_dbg->burst_check, max_dbg->burst_check);
856 pos += scnprintf(buf + pos, bufsz - pos, 782 pos += scnprintf(buf + pos, bufsz - pos,
857 " %-30s %10u %10u %10u %10u\n", 783 fmt_table, "burst_count:",
858 "burst_count:",
859 le32_to_cpu(dbg->burst_count), 784 le32_to_cpu(dbg->burst_count),
860 accum_dbg->burst_count, 785 accum_dbg->burst_count,
861 delta_dbg->burst_count, max_dbg->burst_count); 786 delta_dbg->burst_count, max_dbg->burst_count);
862 pos += scnprintf(buf + pos, bufsz - pos, 787 pos += scnprintf(buf + pos, bufsz - pos,
863 " %-30s %10u %10u %10u %10u\n", 788 fmt_table, "wait_for_silence_timeout_count:",
864 "wait_for_silence_timeout_count:",
865 le32_to_cpu(dbg->wait_for_silence_timeout_cnt), 789 le32_to_cpu(dbg->wait_for_silence_timeout_cnt),
866 accum_dbg->wait_for_silence_timeout_cnt, 790 accum_dbg->wait_for_silence_timeout_cnt,
867 delta_dbg->wait_for_silence_timeout_cnt, 791 delta_dbg->wait_for_silence_timeout_cnt,
868 max_dbg->wait_for_silence_timeout_cnt); 792 max_dbg->wait_for_silence_timeout_cnt);
869 pos += scnprintf(buf + pos, bufsz - pos, 793 pos += scnprintf(buf + pos, bufsz - pos,
870 " %-30s %10u %10u %10u %10u\n", 794 fmt_table, "sleep_time:",
871 "sleep_time:",
872 le32_to_cpu(general->sleep_time), 795 le32_to_cpu(general->sleep_time),
873 accum_general->sleep_time, 796 accum_general->sleep_time,
874 delta_general->sleep_time, max_general->sleep_time); 797 delta_general->sleep_time, max_general->sleep_time);
875 pos += scnprintf(buf + pos, bufsz - pos, 798 pos += scnprintf(buf + pos, bufsz - pos,
876 " %-30s %10u %10u %10u %10u\n", 799 fmt_table, "slots_out:",
877 "slots_out:",
878 le32_to_cpu(general->slots_out), 800 le32_to_cpu(general->slots_out),
879 accum_general->slots_out, 801 accum_general->slots_out,
880 delta_general->slots_out, max_general->slots_out); 802 delta_general->slots_out, max_general->slots_out);
881 pos += scnprintf(buf + pos, bufsz - pos, 803 pos += scnprintf(buf + pos, bufsz - pos,
882 " %-30s %10u %10u %10u %10u\n", 804 fmt_table, "slots_idle:",
883 "slots_idle:",
884 le32_to_cpu(general->slots_idle), 805 le32_to_cpu(general->slots_idle),
885 accum_general->slots_idle, 806 accum_general->slots_idle,
886 delta_general->slots_idle, max_general->slots_idle); 807 delta_general->slots_idle, max_general->slots_idle);
887 pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n",
888 le32_to_cpu(general->ttl_timestamp));
889 pos += scnprintf(buf + pos, bufsz - pos, 808 pos += scnprintf(buf + pos, bufsz - pos,
890 " %-30s %10u %10u %10u %10u\n", 809 fmt_table, "tx_on_a:",
891 "tx_on_a:",
892 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, 810 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
893 delta_div->tx_on_a, max_div->tx_on_a); 811 delta_div->tx_on_a, max_div->tx_on_a);
894 pos += scnprintf(buf + pos, bufsz - pos, 812 pos += scnprintf(buf + pos, bufsz - pos,
895 " %-30s %10u %10u %10u %10u\n", 813 fmt_table, "tx_on_b:",
896 "tx_on_b:",
897 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, 814 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
898 delta_div->tx_on_b, max_div->tx_on_b); 815 delta_div->tx_on_b, max_div->tx_on_b);
899 pos += scnprintf(buf + pos, bufsz - pos, 816 pos += scnprintf(buf + pos, bufsz - pos,
900 " %-30s %10u %10u %10u %10u\n", 817 fmt_table, "exec_time:",
901 "exec_time:",
902 le32_to_cpu(div->exec_time), accum_div->exec_time, 818 le32_to_cpu(div->exec_time), accum_div->exec_time,
903 delta_div->exec_time, max_div->exec_time); 819 delta_div->exec_time, max_div->exec_time);
904 pos += scnprintf(buf + pos, bufsz - pos, 820 pos += scnprintf(buf + pos, bufsz - pos,
905 " %-30s %10u %10u %10u %10u\n", 821 fmt_table, "probe_time:",
906 "probe_time:",
907 le32_to_cpu(div->probe_time), accum_div->probe_time, 822 le32_to_cpu(div->probe_time), accum_div->probe_time,
908 delta_div->probe_time, max_div->probe_time); 823 delta_div->probe_time, max_div->probe_time);
909 pos += scnprintf(buf + pos, bufsz - pos, 824 pos += scnprintf(buf + pos, bufsz - pos,
910 " %-30s %10u %10u %10u %10u\n", 825 fmt_table, "rx_enable_counter:",
911 "rx_enable_counter:",
912 le32_to_cpu(general->rx_enable_counter), 826 le32_to_cpu(general->rx_enable_counter),
913 accum_general->rx_enable_counter, 827 accum_general->rx_enable_counter,
914 delta_general->rx_enable_counter, 828 delta_general->rx_enable_counter,
915 max_general->rx_enable_counter); 829 max_general->rx_enable_counter);
916 pos += scnprintf(buf + pos, bufsz - pos, 830 pos += scnprintf(buf + pos, bufsz - pos,
917 " %-30s %10u %10u %10u %10u\n", 831 fmt_table, "num_of_sos_states:",
918 "num_of_sos_states:",
919 le32_to_cpu(general->num_of_sos_states), 832 le32_to_cpu(general->num_of_sos_states),
920 accum_general->num_of_sos_states, 833 accum_general->num_of_sos_states,
921 delta_general->num_of_sos_states, 834 delta_general->num_of_sos_states,
@@ -1011,3 +924,147 @@ ssize_t iwl_ucode_bt_stats_read(struct file *file,
1011 kfree(buf); 924 kfree(buf);
1012 return ret; 925 return ret;
1013} 926}
927
928ssize_t iwl_reply_tx_error_read(struct file *file,
929 char __user *user_buf,
930 size_t count, loff_t *ppos)
931{
932 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
933 int pos = 0;
934 char *buf;
935 int bufsz = (sizeof(struct reply_tx_error_statistics) * 24) +
936 (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200;
937 ssize_t ret;
938
939 if (!iwl_is_alive(priv))
940 return -EAGAIN;
941
942 buf = kzalloc(bufsz, GFP_KERNEL);
943 if (!buf) {
944 IWL_ERR(priv, "Can not allocate Buffer\n");
945 return -ENOMEM;
946 }
947
948 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n");
949 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n",
950 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY),
951 priv->_agn.reply_tx_stats.pp_delay);
952 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
953 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES),
954 priv->_agn.reply_tx_stats.pp_few_bytes);
955 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
956 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO),
957 priv->_agn.reply_tx_stats.pp_bt_prio);
958 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
959 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD),
960 priv->_agn.reply_tx_stats.pp_quiet_period);
961 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
962 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK),
963 priv->_agn.reply_tx_stats.pp_calc_ttak);
964 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
965 iwl_get_tx_fail_reason(
966 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY),
967 priv->_agn.reply_tx_stats.int_crossed_retry);
968 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
969 iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT),
970 priv->_agn.reply_tx_stats.short_limit);
971 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
972 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT),
973 priv->_agn.reply_tx_stats.long_limit);
974 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
975 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN),
976 priv->_agn.reply_tx_stats.fifo_underrun);
977 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
978 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW),
979 priv->_agn.reply_tx_stats.drain_flow);
980 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
981 iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH),
982 priv->_agn.reply_tx_stats.rfkill_flush);
983 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
984 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE),
985 priv->_agn.reply_tx_stats.life_expire);
986 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
987 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS),
988 priv->_agn.reply_tx_stats.dest_ps);
989 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
990 iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED),
991 priv->_agn.reply_tx_stats.host_abort);
992 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
993 iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY),
994 priv->_agn.reply_tx_stats.pp_delay);
995 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
996 iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID),
997 priv->_agn.reply_tx_stats.sta_invalid);
998 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
999 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED),
1000 priv->_agn.reply_tx_stats.frag_drop);
1001 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1002 iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE),
1003 priv->_agn.reply_tx_stats.tid_disable);
1004 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1005 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED),
1006 priv->_agn.reply_tx_stats.fifo_flush);
1007 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1008 iwl_get_tx_fail_reason(
1009 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL),
1010 priv->_agn.reply_tx_stats.insuff_cf_poll);
1011 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1012 iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX),
1013 priv->_agn.reply_tx_stats.fail_hw_drop);
1014 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1015 iwl_get_tx_fail_reason(
1016 TX_STATUS_FAIL_NO_BEACON_ON_RADAR),
1017 priv->_agn.reply_tx_stats.sta_color_mismatch);
1018 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
1019 priv->_agn.reply_tx_stats.unknown);
1020
1021 pos += scnprintf(buf + pos, bufsz - pos,
1022 "\nStatistics_Agg_TX_Error:\n");
1023
1024 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1025 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK),
1026 priv->_agn.reply_agg_tx_stats.underrun);
1027 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1028 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK),
1029 priv->_agn.reply_agg_tx_stats.bt_prio);
1030 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1031 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK),
1032 priv->_agn.reply_agg_tx_stats.few_bytes);
1033 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1034 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK),
1035 priv->_agn.reply_agg_tx_stats.abort);
1036 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1037 iwl_get_agg_tx_fail_reason(
1038 AGG_TX_STATE_LAST_SENT_TTL_MSK),
1039 priv->_agn.reply_agg_tx_stats.last_sent_ttl);
1040 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1041 iwl_get_agg_tx_fail_reason(
1042 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK),
1043 priv->_agn.reply_agg_tx_stats.last_sent_try);
1044 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1045 iwl_get_agg_tx_fail_reason(
1046 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK),
1047 priv->_agn.reply_agg_tx_stats.last_sent_bt_kill);
1048 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1049 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_SCD_QUERY_MSK),
1050 priv->_agn.reply_agg_tx_stats.scd_query);
1051 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1052 iwl_get_agg_tx_fail_reason(
1053 AGG_TX_STATE_TEST_BAD_CRC32_MSK),
1054 priv->_agn.reply_agg_tx_stats.bad_crc32);
1055 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1056 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK),
1057 priv->_agn.reply_agg_tx_stats.response);
1058 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1059 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK),
1060 priv->_agn.reply_agg_tx_stats.dump_tx);
1061 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1062 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK),
1063 priv->_agn.reply_agg_tx_stats.delay_tx);
1064 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
1065 priv->_agn.reply_agg_tx_stats.unknown);
1066
1067 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1068 kfree(buf);
1069 return ret;
1070}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.h b/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.h
index bbdce5913ac..f2573b5486c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.h
@@ -39,6 +39,8 @@ ssize_t iwl_ucode_general_stats_read(struct file *file, char __user *user_buf,
39 size_t count, loff_t *ppos); 39 size_t count, loff_t *ppos);
40ssize_t iwl_ucode_bt_stats_read(struct file *file, char __user *user_buf, 40ssize_t iwl_ucode_bt_stats_read(struct file *file, char __user *user_buf,
41 size_t count, loff_t *ppos); 41 size_t count, loff_t *ppos);
42ssize_t iwl_reply_tx_error_read(struct file *file, char __user *user_buf,
43 size_t count, loff_t *ppos);
42#else 44#else
43static ssize_t iwl_ucode_rx_stats_read(struct file *file, char __user *user_buf, 45static ssize_t iwl_ucode_rx_stats_read(struct file *file, char __user *user_buf,
44 size_t count, loff_t *ppos) 46 size_t count, loff_t *ppos)
@@ -60,4 +62,9 @@ static ssize_t iwl_ucode_bt_stats_read(struct file *file, char __user *user_buf,
60{ 62{
61 return 0; 63 return 0;
62} 64}
65static ssize_t iwl_reply_tx_error_read(struct file *file, char __user *user_buf,
66 size_t count, loff_t *ppos)
67{
68 return 0;
69}
63#endif 70#endif
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
index 6fb52abafc8..d86902b8363 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
@@ -287,6 +287,15 @@ static int iwlagn_set_pan_params(struct iwl_priv *priv)
287 ctx_bss = &priv->contexts[IWL_RXON_CTX_BSS]; 287 ctx_bss = &priv->contexts[IWL_RXON_CTX_BSS];
288 ctx_pan = &priv->contexts[IWL_RXON_CTX_PAN]; 288 ctx_pan = &priv->contexts[IWL_RXON_CTX_PAN];
289 289
290 /*
291 * If the PAN context is inactive, then we don't need
292 * to update the PAN parameters, the last thing we'll
293 * have done before it goes inactive is making the PAN
294 * parameters be WLAN-only.
295 */
296 if (!ctx_pan->is_active)
297 return 0;
298
290 memset(&cmd, 0, sizeof(cmd)); 299 memset(&cmd, 0, sizeof(cmd));
291 300
292 /* only 2 slots are currently allowed */ 301 /* only 2 slots are currently allowed */
@@ -312,7 +321,7 @@ static int iwlagn_set_pan_params(struct iwl_priv *priv)
312 bcnint = max_t(int, bcnint, 321 bcnint = max_t(int, bcnint,
313 ctx_bss->vif->bss_conf.beacon_int); 322 ctx_bss->vif->bss_conf.beacon_int);
314 if (!bcnint) 323 if (!bcnint)
315 bcnint = 100; 324 bcnint = DEFAULT_BEACON_INTERVAL;
316 slot0 = bcnint / 2; 325 slot0 = bcnint / 2;
317 slot1 = bcnint - slot0; 326 slot1 = bcnint - slot0;
318 327
@@ -330,7 +339,12 @@ static int iwlagn_set_pan_params(struct iwl_priv *priv)
330 slot0 = 0; 339 slot0 = 0;
331 slot1 = max_t(int, 1, ctx_pan->vif->bss_conf.dtim_period) * 340 slot1 = max_t(int, 1, ctx_pan->vif->bss_conf.dtim_period) *
332 ctx_pan->vif->bss_conf.beacon_int; 341 ctx_pan->vif->bss_conf.beacon_int;
333 slot1 = max_t(int, 100, slot1); 342 slot1 = max_t(int, DEFAULT_BEACON_INTERVAL, slot1);
343
344 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
345 slot0 = slot1 * 3 - 20;
346 slot1 = 20;
347 }
334 } 348 }
335 349
336 cmd.slots[0].width = cpu_to_le16(slot0); 350 cmd.slots[0].width = cpu_to_le16(slot0);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index a8f2adfd799..299fd9d5960 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -46,6 +46,181 @@ static inline u32 iwlagn_get_scd_ssn(struct iwl5000_tx_resp *tx_resp)
46 tx_resp->frame_count) & MAX_SN; 46 tx_resp->frame_count) & MAX_SN;
47} 47}
48 48
49static void iwlagn_count_tx_err_status(struct iwl_priv *priv, u16 status)
50{
51 status &= TX_STATUS_MSK;
52
53 switch (status) {
54 case TX_STATUS_POSTPONE_DELAY:
55 priv->_agn.reply_tx_stats.pp_delay++;
56 break;
57 case TX_STATUS_POSTPONE_FEW_BYTES:
58 priv->_agn.reply_tx_stats.pp_few_bytes++;
59 break;
60 case TX_STATUS_POSTPONE_BT_PRIO:
61 priv->_agn.reply_tx_stats.pp_bt_prio++;
62 break;
63 case TX_STATUS_POSTPONE_QUIET_PERIOD:
64 priv->_agn.reply_tx_stats.pp_quiet_period++;
65 break;
66 case TX_STATUS_POSTPONE_CALC_TTAK:
67 priv->_agn.reply_tx_stats.pp_calc_ttak++;
68 break;
69 case TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY:
70 priv->_agn.reply_tx_stats.int_crossed_retry++;
71 break;
72 case TX_STATUS_FAIL_SHORT_LIMIT:
73 priv->_agn.reply_tx_stats.short_limit++;
74 break;
75 case TX_STATUS_FAIL_LONG_LIMIT:
76 priv->_agn.reply_tx_stats.long_limit++;
77 break;
78 case TX_STATUS_FAIL_FIFO_UNDERRUN:
79 priv->_agn.reply_tx_stats.fifo_underrun++;
80 break;
81 case TX_STATUS_FAIL_DRAIN_FLOW:
82 priv->_agn.reply_tx_stats.drain_flow++;
83 break;
84 case TX_STATUS_FAIL_RFKILL_FLUSH:
85 priv->_agn.reply_tx_stats.rfkill_flush++;
86 break;
87 case TX_STATUS_FAIL_LIFE_EXPIRE:
88 priv->_agn.reply_tx_stats.life_expire++;
89 break;
90 case TX_STATUS_FAIL_DEST_PS:
91 priv->_agn.reply_tx_stats.dest_ps++;
92 break;
93 case TX_STATUS_FAIL_HOST_ABORTED:
94 priv->_agn.reply_tx_stats.host_abort++;
95 break;
96 case TX_STATUS_FAIL_BT_RETRY:
97 priv->_agn.reply_tx_stats.bt_retry++;
98 break;
99 case TX_STATUS_FAIL_STA_INVALID:
100 priv->_agn.reply_tx_stats.sta_invalid++;
101 break;
102 case TX_STATUS_FAIL_FRAG_DROPPED:
103 priv->_agn.reply_tx_stats.frag_drop++;
104 break;
105 case TX_STATUS_FAIL_TID_DISABLE:
106 priv->_agn.reply_tx_stats.tid_disable++;
107 break;
108 case TX_STATUS_FAIL_FIFO_FLUSHED:
109 priv->_agn.reply_tx_stats.fifo_flush++;
110 break;
111 case TX_STATUS_FAIL_INSUFFICIENT_CF_POLL:
112 priv->_agn.reply_tx_stats.insuff_cf_poll++;
113 break;
114 case TX_STATUS_FAIL_PASSIVE_NO_RX:
115 priv->_agn.reply_tx_stats.fail_hw_drop++;
116 break;
117 case TX_STATUS_FAIL_NO_BEACON_ON_RADAR:
118 priv->_agn.reply_tx_stats.sta_color_mismatch++;
119 break;
120 default:
121 priv->_agn.reply_tx_stats.unknown++;
122 break;
123 }
124}
125
126static void iwlagn_count_agg_tx_err_status(struct iwl_priv *priv, u16 status)
127{
128 status &= AGG_TX_STATUS_MSK;
129
130 switch (status) {
131 case AGG_TX_STATE_UNDERRUN_MSK:
132 priv->_agn.reply_agg_tx_stats.underrun++;
133 break;
134 case AGG_TX_STATE_BT_PRIO_MSK:
135 priv->_agn.reply_agg_tx_stats.bt_prio++;
136 break;
137 case AGG_TX_STATE_FEW_BYTES_MSK:
138 priv->_agn.reply_agg_tx_stats.few_bytes++;
139 break;
140 case AGG_TX_STATE_ABORT_MSK:
141 priv->_agn.reply_agg_tx_stats.abort++;
142 break;
143 case AGG_TX_STATE_LAST_SENT_TTL_MSK:
144 priv->_agn.reply_agg_tx_stats.last_sent_ttl++;
145 break;
146 case AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK:
147 priv->_agn.reply_agg_tx_stats.last_sent_try++;
148 break;
149 case AGG_TX_STATE_LAST_SENT_BT_KILL_MSK:
150 priv->_agn.reply_agg_tx_stats.last_sent_bt_kill++;
151 break;
152 case AGG_TX_STATE_SCD_QUERY_MSK:
153 priv->_agn.reply_agg_tx_stats.scd_query++;
154 break;
155 case AGG_TX_STATE_TEST_BAD_CRC32_MSK:
156 priv->_agn.reply_agg_tx_stats.bad_crc32++;
157 break;
158 case AGG_TX_STATE_RESPONSE_MSK:
159 priv->_agn.reply_agg_tx_stats.response++;
160 break;
161 case AGG_TX_STATE_DUMP_TX_MSK:
162 priv->_agn.reply_agg_tx_stats.dump_tx++;
163 break;
164 case AGG_TX_STATE_DELAY_TX_MSK:
165 priv->_agn.reply_agg_tx_stats.delay_tx++;
166 break;
167 default:
168 priv->_agn.reply_agg_tx_stats.unknown++;
169 break;
170 }
171}
172
173static void iwlagn_set_tx_status(struct iwl_priv *priv,
174 struct ieee80211_tx_info *info,
175 struct iwl5000_tx_resp *tx_resp,
176 int txq_id, bool is_agg)
177{
178 u16 status = le16_to_cpu(tx_resp->status.status);
179
180 info->status.rates[0].count = tx_resp->failure_frame + 1;
181 if (is_agg)
182 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
183 info->flags |= iwl_tx_status_to_mac80211(status);
184 iwlagn_hwrate_to_tx_control(priv, le32_to_cpu(tx_resp->rate_n_flags),
185 info);
186 if (!iwl_is_tx_success(status))
187 iwlagn_count_tx_err_status(priv, status);
188
189 IWL_DEBUG_TX_REPLY(priv, "TXQ %d status %s (0x%08x) rate_n_flags "
190 "0x%x retries %d\n",
191 txq_id,
192 iwl_get_tx_fail_reason(status), status,
193 le32_to_cpu(tx_resp->rate_n_flags),
194 tx_resp->failure_frame);
195}
196
197#ifdef CONFIG_IWLWIFI_DEBUG
198#define AGG_TX_STATE_FAIL(x) case AGG_TX_STATE_ ## x: return #x
199
200const char *iwl_get_agg_tx_fail_reason(u16 status)
201{
202 status &= AGG_TX_STATUS_MSK;
203 switch (status) {
204 case AGG_TX_STATE_TRANSMITTED:
205 return "SUCCESS";
206 AGG_TX_STATE_FAIL(UNDERRUN_MSK);
207 AGG_TX_STATE_FAIL(BT_PRIO_MSK);
208 AGG_TX_STATE_FAIL(FEW_BYTES_MSK);
209 AGG_TX_STATE_FAIL(ABORT_MSK);
210 AGG_TX_STATE_FAIL(LAST_SENT_TTL_MSK);
211 AGG_TX_STATE_FAIL(LAST_SENT_TRY_CNT_MSK);
212 AGG_TX_STATE_FAIL(LAST_SENT_BT_KILL_MSK);
213 AGG_TX_STATE_FAIL(SCD_QUERY_MSK);
214 AGG_TX_STATE_FAIL(TEST_BAD_CRC32_MSK);
215 AGG_TX_STATE_FAIL(RESPONSE_MSK);
216 AGG_TX_STATE_FAIL(DUMP_TX_MSK);
217 AGG_TX_STATE_FAIL(DELAY_TX_MSK);
218 }
219
220 return "UNKNOWN";
221}
222#endif /* CONFIG_IWLWIFI_DEBUG */
223
49static int iwlagn_tx_status_reply_tx(struct iwl_priv *priv, 224static int iwlagn_tx_status_reply_tx(struct iwl_priv *priv,
50 struct iwl_ht_agg *agg, 225 struct iwl_ht_agg *agg,
51 struct iwl5000_tx_resp *tx_resp, 226 struct iwl5000_tx_resp *tx_resp,
@@ -53,9 +228,7 @@ static int iwlagn_tx_status_reply_tx(struct iwl_priv *priv,
53{ 228{
54 u16 status; 229 u16 status;
55 struct agg_tx_status *frame_status = &tx_resp->status; 230 struct agg_tx_status *frame_status = &tx_resp->status;
56 struct ieee80211_tx_info *info = NULL;
57 struct ieee80211_hdr *hdr = NULL; 231 struct ieee80211_hdr *hdr = NULL;
58 u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
59 int i, sh, idx; 232 int i, sh, idx;
60 u16 seq; 233 u16 seq;
61 234
@@ -64,31 +237,20 @@ static int iwlagn_tx_status_reply_tx(struct iwl_priv *priv,
64 237
65 agg->frame_count = tx_resp->frame_count; 238 agg->frame_count = tx_resp->frame_count;
66 agg->start_idx = start_idx; 239 agg->start_idx = start_idx;
67 agg->rate_n_flags = rate_n_flags; 240 agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
68 agg->bitmap = 0; 241 agg->bitmap = 0;
69 242
70 /* # frames attempted by Tx command */ 243 /* # frames attempted by Tx command */
71 if (agg->frame_count == 1) { 244 if (agg->frame_count == 1) {
72 /* Only one frame was attempted; no block-ack will arrive */ 245 /* Only one frame was attempted; no block-ack will arrive */
73 status = le16_to_cpu(frame_status[0].status);
74 idx = start_idx; 246 idx = start_idx;
75 247
76 /* FIXME: code repetition */
77 IWL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, StartIdx=%d idx=%d\n", 248 IWL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, StartIdx=%d idx=%d\n",
78 agg->frame_count, agg->start_idx, idx); 249 agg->frame_count, agg->start_idx, idx);
79 250 iwlagn_set_tx_status(priv,
80 info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb); 251 IEEE80211_SKB_CB(
81 info->status.rates[0].count = tx_resp->failure_frame + 1; 252 priv->txq[txq_id].txb[idx].skb),
82 info->flags &= ~IEEE80211_TX_CTL_AMPDU; 253 tx_resp, txq_id, true);
83 info->flags |= iwl_tx_status_to_mac80211(status);
84 iwlagn_hwrate_to_tx_control(priv, rate_n_flags, info);
85
86 /* FIXME: code repetition end */
87
88 IWL_DEBUG_TX_REPLY(priv, "1 Frame 0x%x failure :%d\n",
89 status & 0xff, tx_resp->failure_frame);
90 IWL_DEBUG_TX_REPLY(priv, "Rate Info rate_n_flags=%x\n", rate_n_flags);
91
92 agg->wait_for_ba = 0; 254 agg->wait_for_ba = 0;
93 } else { 255 } else {
94 /* Two or more frames were attempted; expect block-ack */ 256 /* Two or more frames were attempted; expect block-ack */
@@ -109,12 +271,20 @@ static int iwlagn_tx_status_reply_tx(struct iwl_priv *priv,
109 idx = SEQ_TO_INDEX(seq); 271 idx = SEQ_TO_INDEX(seq);
110 txq_id = SEQ_TO_QUEUE(seq); 272 txq_id = SEQ_TO_QUEUE(seq);
111 273
274 if (status & AGG_TX_STATUS_MSK)
275 iwlagn_count_agg_tx_err_status(priv, status);
276
112 if (status & (AGG_TX_STATE_FEW_BYTES_MSK | 277 if (status & (AGG_TX_STATE_FEW_BYTES_MSK |
113 AGG_TX_STATE_ABORT_MSK)) 278 AGG_TX_STATE_ABORT_MSK))
114 continue; 279 continue;
115 280
116 IWL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, txq_id=%d idx=%d\n", 281 IWL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, txq_id=%d idx=%d\n",
117 agg->frame_count, txq_id, idx); 282 agg->frame_count, txq_id, idx);
283 IWL_DEBUG_TX_REPLY(priv, "status %s (0x%08x), "
284 "try-count (0x%08x)\n",
285 iwl_get_agg_tx_fail_reason(status),
286 status & AGG_TX_STATUS_MSK,
287 status & AGG_TX_TRY_MSK);
118 288
119 hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx); 289 hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx);
120 if (!hdr) { 290 if (!hdr) {
@@ -281,20 +451,7 @@ static void iwlagn_rx_reply_tx(struct iwl_priv *priv,
281 } 451 }
282 } else { 452 } else {
283 BUG_ON(txq_id != txq->swq_id); 453 BUG_ON(txq_id != txq->swq_id);
284 454 iwlagn_set_tx_status(priv, info, tx_resp, txq_id, false);
285 info->status.rates[0].count = tx_resp->failure_frame + 1;
286 info->flags |= iwl_tx_status_to_mac80211(status);
287 iwlagn_hwrate_to_tx_control(priv,
288 le32_to_cpu(tx_resp->rate_n_flags),
289 info);
290
291 IWL_DEBUG_TX_REPLY(priv, "TXQ %d status %s (0x%08x) rate_n_flags "
292 "0x%x retries %d\n",
293 txq_id,
294 iwl_get_tx_fail_reason(status), status,
295 le32_to_cpu(tx_resp->rate_n_flags),
296 tx_resp->failure_frame);
297
298 freed = iwlagn_tx_queue_reclaim(priv, txq_id, index); 455 freed = iwlagn_tx_queue_reclaim(priv, txq_id, index);
299 iwl_free_tfds_in_queue(priv, sta_id, tid, freed); 456 iwl_free_tfds_in_queue(priv, sta_id, tid, freed);
300 457
@@ -1154,7 +1311,7 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
1154 return added; 1311 return added;
1155} 1312}
1156 1313
1157void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) 1314int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1158{ 1315{
1159 struct iwl_host_cmd cmd = { 1316 struct iwl_host_cmd cmd = {
1160 .id = REPLY_SCAN_CMD, 1317 .id = REPLY_SCAN_CMD,
@@ -1162,7 +1319,6 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1162 .flags = CMD_SIZE_HUGE, 1319 .flags = CMD_SIZE_HUGE,
1163 }; 1320 };
1164 struct iwl_scan_cmd *scan; 1321 struct iwl_scan_cmd *scan;
1165 struct ieee80211_conf *conf = NULL;
1166 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; 1322 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
1167 u32 rate_flags = 0; 1323 u32 rate_flags = 0;
1168 u16 cmd_len; 1324 u16 cmd_len;
@@ -1175,59 +1331,20 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1175 int chan_mod; 1331 int chan_mod;
1176 u8 active_chains; 1332 u8 active_chains;
1177 u8 scan_tx_antennas = priv->hw_params.valid_tx_ant; 1333 u8 scan_tx_antennas = priv->hw_params.valid_tx_ant;
1334 int ret;
1335
1336 lockdep_assert_held(&priv->mutex);
1178 1337
1179 if (vif) 1338 if (vif)
1180 ctx = iwl_rxon_ctx_from_vif(vif); 1339 ctx = iwl_rxon_ctx_from_vif(vif);
1181 1340
1182 conf = ieee80211_get_hw_conf(priv->hw);
1183
1184 cancel_delayed_work(&priv->scan_check);
1185
1186 if (!iwl_is_ready(priv)) {
1187 IWL_WARN(priv, "request scan called when driver not ready.\n");
1188 goto done;
1189 }
1190
1191 /* Make sure the scan wasn't canceled before this queued work
1192 * was given the chance to run... */
1193 if (!test_bit(STATUS_SCANNING, &priv->status))
1194 goto done;
1195
1196 /* This should never be called or scheduled if there is currently
1197 * a scan active in the hardware. */
1198 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
1199 IWL_DEBUG_INFO(priv, "Multiple concurrent scan requests in parallel. "
1200 "Ignoring second request.\n");
1201 goto done;
1202 }
1203
1204 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
1205 IWL_DEBUG_SCAN(priv, "Aborting scan due to device shutdown\n");
1206 goto done;
1207 }
1208
1209 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
1210 IWL_DEBUG_HC(priv, "Scan request while abort pending. Queuing.\n");
1211 goto done;
1212 }
1213
1214 if (iwl_is_rfkill(priv)) {
1215 IWL_DEBUG_HC(priv, "Aborting scan due to RF Kill activation\n");
1216 goto done;
1217 }
1218
1219 if (!test_bit(STATUS_READY, &priv->status)) {
1220 IWL_DEBUG_HC(priv, "Scan request while uninitialized. Queuing.\n");
1221 goto done;
1222 }
1223
1224 if (!priv->scan_cmd) { 1341 if (!priv->scan_cmd) {
1225 priv->scan_cmd = kmalloc(sizeof(struct iwl_scan_cmd) + 1342 priv->scan_cmd = kmalloc(sizeof(struct iwl_scan_cmd) +
1226 IWL_MAX_SCAN_SIZE, GFP_KERNEL); 1343 IWL_MAX_SCAN_SIZE, GFP_KERNEL);
1227 if (!priv->scan_cmd) { 1344 if (!priv->scan_cmd) {
1228 IWL_DEBUG_SCAN(priv, 1345 IWL_DEBUG_SCAN(priv,
1229 "fail to allocate memory for scan\n"); 1346 "fail to allocate memory for scan\n");
1230 goto done; 1347 return -ENOMEM;
1231 } 1348 }
1232 } 1349 }
1233 scan = priv->scan_cmd; 1350 scan = priv->scan_cmd;
@@ -1334,8 +1451,8 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1334 IWL_GOOD_CRC_TH_NEVER; 1451 IWL_GOOD_CRC_TH_NEVER;
1335 break; 1452 break;
1336 default: 1453 default:
1337 IWL_WARN(priv, "Invalid scan band count\n"); 1454 IWL_WARN(priv, "Invalid scan band\n");
1338 goto done; 1455 return -EIO;
1339 } 1456 }
1340 1457
1341 band = priv->scan_band; 1458 band = priv->scan_band;
@@ -1415,7 +1532,7 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1415 } 1532 }
1416 if (scan->channel_count == 0) { 1533 if (scan->channel_count == 0) {
1417 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); 1534 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count);
1418 goto done; 1535 return -EIO;
1419 } 1536 }
1420 1537
1421 cmd.len += le16_to_cpu(scan->tx_cmd.len) + 1538 cmd.len += le16_to_cpu(scan->tx_cmd.len) +
@@ -1423,30 +1540,21 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1423 cmd.data = scan; 1540 cmd.data = scan;
1424 scan->len = cpu_to_le16(cmd.len); 1541 scan->len = cpu_to_le16(cmd.len);
1425 1542
1426 set_bit(STATUS_SCAN_HW, &priv->status); 1543 if (priv->cfg->ops->hcmd->set_pan_params) {
1427 1544 ret = priv->cfg->ops->hcmd->set_pan_params(priv);
1428 if (priv->cfg->ops->hcmd->set_pan_params && 1545 if (ret)
1429 priv->cfg->ops->hcmd->set_pan_params(priv)) 1546 return ret;
1430 goto done; 1547 }
1431 1548
1432 if (iwl_send_cmd_sync(priv, &cmd)) 1549 set_bit(STATUS_SCAN_HW, &priv->status);
1433 goto done; 1550 ret = iwl_send_cmd_sync(priv, &cmd);
1551 if (ret) {
1552 clear_bit(STATUS_SCAN_HW, &priv->status);
1553 if (priv->cfg->ops->hcmd->set_pan_params)
1554 priv->cfg->ops->hcmd->set_pan_params(priv);
1555 }
1434 1556
1435 queue_delayed_work(priv->workqueue, &priv->scan_check, 1557 return ret;
1436 IWL_SCAN_CHECK_WATCHDOG);
1437
1438 return;
1439
1440 done:
1441 /* Cannot perform scan. Make sure we clear scanning
1442 * bits from status so next scan request can be performed.
1443 * If we don't clear scanning status bit here all next scan
1444 * will fail
1445 */
1446 clear_bit(STATUS_SCAN_HW, &priv->status);
1447 clear_bit(STATUS_SCANNING, &priv->status);
1448 /* inform mac80211 scan aborted */
1449 queue_work(priv->workqueue, &priv->scan_completed);
1450} 1558}
1451 1559
1452int iwlagn_manage_ibss_station(struct iwl_priv *priv, 1560int iwlagn_manage_ibss_station(struct iwl_priv *priv,
@@ -1673,6 +1781,8 @@ void iwlagn_send_advance_bt_config(struct iwl_priv *priv)
1673 bt_cmd.kill_ack_mask = priv->kill_ack_mask; 1781 bt_cmd.kill_ack_mask = priv->kill_ack_mask;
1674 bt_cmd.kill_cts_mask = priv->kill_cts_mask; 1782 bt_cmd.kill_cts_mask = priv->kill_cts_mask;
1675 bt_cmd.valid = priv->bt_valid; 1783 bt_cmd.valid = priv->bt_valid;
1784 bt_cmd.tx_prio_boost = 0;
1785 bt_cmd.rx_prio_boost = 0;
1676 1786
1677 /* 1787 /*
1678 * Configure BT coex mode to "no coexistence" when the 1788 * Configure BT coex mode to "no coexistence" when the
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
index 3970ab1deaf..357cdb26f16 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
@@ -453,15 +453,6 @@ static inline u8 first_antenna(u8 mask)
453} 453}
454 454
455 455
456static inline u8 iwl_get_prev_ieee_rate(u8 rate_index)
457{
458 u8 rate = iwl_rates[rate_index].prev_ieee;
459
460 if (rate == IWL_RATE_INVALID)
461 rate = rate_index;
462 return rate;
463}
464
465static inline u8 iwl3945_get_prev_ieee_rate(u8 rate_index) 456static inline u8 iwl3945_get_prev_ieee_rate(u8 rate_index)
466{ 457{
467 u8 rate = iwl3945_rates[rate_index].prev_ieee; 458 u8 rate = iwl3945_rates[rate_index].prev_ieee;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
index a7961bf395f..8bfb0495a76 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
@@ -307,6 +307,17 @@ void iwlagn_init_alive_start(struct iwl_priv *priv)
307 goto restart; 307 goto restart;
308 } 308 }
309 309
310 if (priv->cfg->advanced_bt_coexist) {
311 /*
312 * Tell uCode we are ready to perform calibration
313 * need to perform this before any calibration
314 * no need to close the envlope since we are going
315 * to load the runtime uCode later.
316 */
317 iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN,
318 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2);
319
320 }
310 iwlagn_send_calib_cfg(priv); 321 iwlagn_send_calib_cfg(priv);
311 return; 322 return;
312 323
@@ -364,7 +375,7 @@ static const u8 iwlagn_bt_prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX] = {
364 0, 0, 0, 0, 0, 0, 0 375 0, 0, 0, 0, 0, 0, 0
365}; 376};
366 377
367static void iwlagn_send_prio_tbl(struct iwl_priv *priv) 378void iwlagn_send_prio_tbl(struct iwl_priv *priv)
368{ 379{
369 struct iwl_bt_coex_prio_table_cmd prio_tbl_cmd; 380 struct iwl_bt_coex_prio_table_cmd prio_tbl_cmd;
370 381
@@ -375,7 +386,7 @@ static void iwlagn_send_prio_tbl(struct iwl_priv *priv)
375 IWL_ERR(priv, "failed to send BT prio tbl command\n"); 386 IWL_ERR(priv, "failed to send BT prio tbl command\n");
376} 387}
377 388
378static void iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type) 389void iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type)
379{ 390{
380 struct iwl_bt_coex_prot_env_cmd env_cmd; 391 struct iwl_bt_coex_prot_env_cmd env_cmd;
381 392
@@ -482,25 +493,6 @@ int iwlagn_alive_notify(struct iwl_priv *priv)
482 493
483 spin_unlock_irqrestore(&priv->lock, flags); 494 spin_unlock_irqrestore(&priv->lock, flags);
484 495
485 if (priv->cfg->advanced_bt_coexist) {
486 /* Configure Bluetooth device coexistence support */
487 /* need to perform this before any calibration */
488 priv->bt_valid = IWLAGN_BT_ALL_VALID_MSK;
489 priv->kill_ack_mask = IWLAGN_BT_KILL_ACK_MASK_DEFAULT;
490 priv->kill_cts_mask = IWLAGN_BT_KILL_CTS_MASK_DEFAULT;
491 priv->cfg->ops->hcmd->send_bt_config(priv);
492 priv->bt_valid = IWLAGN_BT_VALID_ENABLE_FLAGS;
493
494 if (bt_coex_active && priv->iw_mode != NL80211_IFTYPE_ADHOC) {
495 iwlagn_send_prio_tbl(priv);
496 iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN,
497 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2);
498 iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_CLOSE,
499 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2);
500 }
501
502 }
503
504 iwlagn_send_wimax_coex(priv); 496 iwlagn_send_wimax_coex(priv);
505 497
506 iwlagn_set_Xtal_calib(priv); 498 iwlagn_set_Xtal_calib(priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index ad0e67f5c0d..646864a26ea 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -110,6 +110,9 @@ int iwl_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
110 if (!iwl_is_alive(priv)) 110 if (!iwl_is_alive(priv))
111 return -EBUSY; 111 return -EBUSY;
112 112
113 if (!ctx->is_active)
114 return 0;
115
113 /* always get timestamp with Rx frame */ 116 /* always get timestamp with Rx frame */
114 ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK; 117 ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK;
115 118
@@ -223,9 +226,8 @@ int iwl_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
223 return ret; 226 return ret;
224 } 227 }
225 } 228 }
226
227 priv->start_calib = 0;
228 if (new_assoc) { 229 if (new_assoc) {
230 priv->start_calib = 0;
229 /* Apply the new configuration 231 /* Apply the new configuration
230 * RXON assoc doesn't clear the station table in uCode, 232 * RXON assoc doesn't clear the station table in uCode,
231 */ 233 */
@@ -369,7 +371,7 @@ static unsigned int iwl_hw_get_beacon_cmd(struct iwl_priv *priv,
369 371
370 if (!priv->beacon_ctx) { 372 if (!priv->beacon_ctx) {
371 IWL_ERR(priv, "trying to build beacon w/o beacon context!\n"); 373 IWL_ERR(priv, "trying to build beacon w/o beacon context!\n");
372 return -EINVAL; 374 return 0;
373 } 375 }
374 376
375 /* Initialize memory */ 377 /* Initialize memory */
@@ -1278,7 +1280,6 @@ static void iwl_irq_tasklet_legacy(struct iwl_priv *priv)
1278 IWL_ERR(priv, "Microcode SW error detected. " 1280 IWL_ERR(priv, "Microcode SW error detected. "
1279 " Restarting 0x%X.\n", inta); 1281 " Restarting 0x%X.\n", inta);
1280 priv->isr_stats.sw++; 1282 priv->isr_stats.sw++;
1281 priv->isr_stats.sw_err = inta;
1282 iwl_irq_handle_error(priv); 1283 iwl_irq_handle_error(priv);
1283 handled |= CSR_INT_BIT_SW_ERR; 1284 handled |= CSR_INT_BIT_SW_ERR;
1284 } 1285 }
@@ -1459,7 +1460,6 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
1459 IWL_ERR(priv, "Microcode SW error detected. " 1460 IWL_ERR(priv, "Microcode SW error detected. "
1460 " Restarting 0x%X.\n", inta); 1461 " Restarting 0x%X.\n", inta);
1461 priv->isr_stats.sw++; 1462 priv->isr_stats.sw++;
1462 priv->isr_stats.sw_err = inta;
1463 iwl_irq_handle_error(priv); 1463 iwl_irq_handle_error(priv);
1464 handled |= CSR_INT_BIT_SW_ERR; 1464 handled |= CSR_INT_BIT_SW_ERR;
1465 } 1465 }
@@ -2467,6 +2467,7 @@ void iwl_dump_nic_error_log(struct iwl_priv *priv)
2467 } 2467 }
2468 2468
2469 desc = iwl_read_targ_mem(priv, base + 1 * sizeof(u32)); 2469 desc = iwl_read_targ_mem(priv, base + 1 * sizeof(u32));
2470 priv->isr_stats.err_code = desc;
2470 pc = iwl_read_targ_mem(priv, base + 2 * sizeof(u32)); 2471 pc = iwl_read_targ_mem(priv, base + 2 * sizeof(u32));
2471 blink1 = iwl_read_targ_mem(priv, base + 3 * sizeof(u32)); 2472 blink1 = iwl_read_targ_mem(priv, base + 3 * sizeof(u32));
2472 blink2 = iwl_read_targ_mem(priv, base + 4 * sizeof(u32)); 2473 blink2 = iwl_read_targ_mem(priv, base + 4 * sizeof(u32));
@@ -2813,6 +2814,22 @@ static void iwl_alive_start(struct iwl_priv *priv)
2813 if (iwl_is_rfkill(priv)) 2814 if (iwl_is_rfkill(priv))
2814 return; 2815 return;
2815 2816
2817 if (priv->cfg->advanced_bt_coexist) {
2818 /* Configure Bluetooth device coexistence support */
2819 priv->bt_valid = IWLAGN_BT_ALL_VALID_MSK;
2820 priv->kill_ack_mask = IWLAGN_BT_KILL_ACK_MASK_DEFAULT;
2821 priv->kill_cts_mask = IWLAGN_BT_KILL_CTS_MASK_DEFAULT;
2822 priv->cfg->ops->hcmd->send_bt_config(priv);
2823 priv->bt_valid = IWLAGN_BT_VALID_ENABLE_FLAGS;
2824 if (bt_coex_active && priv->iw_mode != NL80211_IFTYPE_ADHOC)
2825 iwlagn_send_prio_tbl(priv);
2826
2827 /* FIXME: w/a to force change uCode BT state machine */
2828 iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN,
2829 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2);
2830 iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_CLOSE,
2831 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2);
2832 }
2816 ieee80211_wake_queues(priv->hw); 2833 ieee80211_wake_queues(priv->hw);
2817 2834
2818 priv->active_rate = IWL_RATES_MASK; 2835 priv->active_rate = IWL_RATES_MASK;
@@ -2875,8 +2892,9 @@ static void __iwl_down(struct iwl_priv *priv)
2875 2892
2876 IWL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); 2893 IWL_DEBUG_INFO(priv, DRV_NAME " is going down\n");
2877 2894
2878 if (!exit_pending) 2895 iwl_scan_cancel_timeout(priv, 200);
2879 set_bit(STATUS_EXIT_PENDING, &priv->status); 2896
2897 exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &priv->status);
2880 2898
2881 /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set 2899 /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set
2882 * to prevent rearm timer */ 2900 * to prevent rearm timer */
@@ -3486,15 +3504,6 @@ static void iwl_mac_stop(struct ieee80211_hw *hw)
3486 3504
3487 priv->is_open = 0; 3505 priv->is_open = 0;
3488 3506
3489 if (iwl_is_ready_rf(priv) || test_bit(STATUS_SCAN_HW, &priv->status)) {
3490 /* stop mac, cancel any scan request and clear
3491 * RXON_FILTER_ASSOC_MSK BIT
3492 */
3493 mutex_lock(&priv->mutex);
3494 iwl_scan_cancel_timeout(priv, 100);
3495 mutex_unlock(&priv->mutex);
3496 }
3497
3498 iwl_down(priv); 3507 iwl_down(priv);
3499 3508
3500 flush_workqueue(priv->workqueue); 3509 flush_workqueue(priv->workqueue);
@@ -4062,13 +4071,15 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv)
4062 priv->cfg->ops->lib->cancel_deferred_work(priv); 4071 priv->cfg->ops->lib->cancel_deferred_work(priv);
4063 4072
4064 cancel_delayed_work_sync(&priv->init_alive_start); 4073 cancel_delayed_work_sync(&priv->init_alive_start);
4065 cancel_delayed_work(&priv->scan_check);
4066 cancel_work_sync(&priv->start_internal_scan);
4067 cancel_delayed_work(&priv->alive_start); 4074 cancel_delayed_work(&priv->alive_start);
4068 cancel_work_sync(&priv->run_time_calib_work); 4075 cancel_work_sync(&priv->run_time_calib_work);
4069 cancel_work_sync(&priv->beacon_update); 4076 cancel_work_sync(&priv->beacon_update);
4077
4078 iwl_cancel_scan_deferred_work(priv);
4079
4070 cancel_work_sync(&priv->bt_full_concurrency); 4080 cancel_work_sync(&priv->bt_full_concurrency);
4071 cancel_work_sync(&priv->bt_runtime_config); 4081 cancel_work_sync(&priv->bt_runtime_config);
4082
4072 del_timer_sync(&priv->statistics_periodic); 4083 del_timer_sync(&priv->statistics_periodic);
4073 del_timer_sync(&priv->ucode_trace); 4084 del_timer_sync(&priv->ucode_trace);
4074} 4085}
@@ -4286,6 +4297,8 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
4286 for (i = 0; i < NUM_IWL_RXON_CTX; i++) 4297 for (i = 0; i < NUM_IWL_RXON_CTX; i++)
4287 priv->contexts[i].ctxid = i; 4298 priv->contexts[i].ctxid = i;
4288 4299
4300 priv->contexts[IWL_RXON_CTX_BSS].always_active = true;
4301 priv->contexts[IWL_RXON_CTX_BSS].is_active = true;
4289 priv->contexts[IWL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; 4302 priv->contexts[IWL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON;
4290 priv->contexts[IWL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; 4303 priv->contexts[IWL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING;
4291 priv->contexts[IWL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; 4304 priv->contexts[IWL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index 7c542a8c8f8..a372184ac21 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -134,6 +134,8 @@ void iwlagn_rx_calib_complete(struct iwl_priv *priv,
134void iwlagn_init_alive_start(struct iwl_priv *priv); 134void iwlagn_init_alive_start(struct iwl_priv *priv);
135int iwlagn_alive_notify(struct iwl_priv *priv); 135int iwlagn_alive_notify(struct iwl_priv *priv);
136int iwl_verify_ucode(struct iwl_priv *priv); 136int iwl_verify_ucode(struct iwl_priv *priv);
137void iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type);
138void iwlagn_send_prio_tbl(struct iwl_priv *priv);
137 139
138/* lib */ 140/* lib */
139void iwl_check_abort_status(struct iwl_priv *priv, 141void iwl_check_abort_status(struct iwl_priv *priv,
@@ -217,7 +219,7 @@ void iwl_reply_statistics(struct iwl_priv *priv,
217 struct iwl_rx_mem_buffer *rxb); 219 struct iwl_rx_mem_buffer *rxb);
218 220
219/* scan */ 221/* scan */
220void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif); 222int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif);
221 223
222/* station mgmt */ 224/* station mgmt */
223int iwlagn_manage_ibss_station(struct iwl_priv *priv, 225int iwlagn_manage_ibss_station(struct iwl_priv *priv,
@@ -236,4 +238,9 @@ void iwlagn_bt_rx_handler_setup(struct iwl_priv *priv);
236void iwlagn_bt_setup_deferred_work(struct iwl_priv *priv); 238void iwlagn_bt_setup_deferred_work(struct iwl_priv *priv);
237void iwlagn_bt_cancel_deferred_work(struct iwl_priv *priv); 239void iwlagn_bt_cancel_deferred_work(struct iwl_priv *priv);
238 240
241#ifdef CONFIG_IWLWIFI_DEBUG
242const char *iwl_get_agg_tx_fail_reason(u16 status);
243#else
244static inline const char *iwl_get_agg_tx_fail_reason(u16 status) { return ""; }
245#endif
239#endif /* __iwl_agn_h__ */ 246#endif /* __iwl_agn_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index 3e4ba31b5d5..27e250c8d4b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -1820,13 +1820,8 @@ enum {
1820 TX_STATUS_FAIL_TID_DISABLE = 0x8d, 1820 TX_STATUS_FAIL_TID_DISABLE = 0x8d,
1821 TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e, 1821 TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e,
1822 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f, 1822 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
1823 /* uCode drop due to FW drop request */ 1823 TX_STATUS_FAIL_PASSIVE_NO_RX = 0x90,
1824 TX_STATUS_FAIL_FW_DROP = 0x90, 1824 TX_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
1825 /*
1826 * uCode drop due to station color mismatch
1827 * between tx command and station table
1828 */
1829 TX_STATUS_FAIL_STA_COLOR_MISMATCH_DROP = 0x91,
1830}; 1825};
1831 1826
1832#define TX_PACKET_MODE_REGULAR 0x0000 1827#define TX_PACKET_MODE_REGULAR 0x0000
@@ -1868,6 +1863,9 @@ enum {
1868 AGG_TX_STATE_DELAY_TX_MSK = 0x400 1863 AGG_TX_STATE_DELAY_TX_MSK = 0x400
1869}; 1864};
1870 1865
1866#define AGG_TX_STATUS_MSK 0x00000fff /* bits 0:11 */
1867#define AGG_TX_TRY_MSK 0x0000f000 /* bits 12:15 */
1868
1871#define AGG_TX_STATE_LAST_SENT_MSK (AGG_TX_STATE_LAST_SENT_TTL_MSK | \ 1869#define AGG_TX_STATE_LAST_SENT_MSK (AGG_TX_STATE_LAST_SENT_TTL_MSK | \
1872 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \ 1870 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \
1873 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK) 1871 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
@@ -2488,7 +2486,12 @@ struct iwlagn_bt_cmd {
2488 __le16 bt4_decision_time; /* unused */ 2486 __le16 bt4_decision_time; /* unused */
2489 __le16 valid; 2487 __le16 valid;
2490 u8 prio_boost; 2488 u8 prio_boost;
2491 u8 reserved[3]; 2489 /*
2490 * set IWLAGN_BT_VALID_BOOST to "1" in "valid" bitmask
2491 * if configure the following patterns
2492 */
2493 u8 tx_prio_boost; /* SW boost of WiFi tx priority */
2494 __le16 rx_prio_boost; /* SW boost of WiFi rx priority */
2492}; 2495};
2493 2496
2494#define IWLAGN_BT_SCO_ACTIVE cpu_to_le32(BIT(0)) 2497#define IWLAGN_BT_SCO_ACTIVE cpu_to_le32(BIT(0))
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 87a2e40972b..393f02d94c4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -196,6 +196,9 @@ static void iwl_update_qos(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
196 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 196 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
197 return; 197 return;
198 198
199 if (!ctx->is_active)
200 return;
201
199 ctx->qos_data.def_qos_parm.qos_flags = 0; 202 ctx->qos_data.def_qos_parm.qos_flags = 0;
200 203
201 if (ctx->qos_data.qos_active) 204 if (ctx->qos_data.qos_active)
@@ -488,8 +491,29 @@ EXPORT_SYMBOL(iwl_is_ht40_tx_allowed);
488 491
489static u16 iwl_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) 492static u16 iwl_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val)
490{ 493{
491 u16 new_val = 0; 494 u16 new_val;
492 u16 beacon_factor = 0; 495 u16 beacon_factor;
496
497 /*
498 * If mac80211 hasn't given us a beacon interval, program
499 * the default into the device (not checking this here
500 * would cause the adjustment below to return the maximum
501 * value, which may break PAN.)
502 */
503 if (!beacon_val)
504 return DEFAULT_BEACON_INTERVAL;
505
506 /*
507 * If the beacon interval we obtained from the peer
508 * is too large, we'll have to wake up more often
509 * (and in IBSS case, we'll beacon too much)
510 *
511 * For example, if max_beacon_val is 4096, and the
512 * requested beacon interval is 7000, we'll have to
513 * use 3500 to be able to wake up on the beacons.
514 *
515 * This could badly influence beacon detection stats.
516 */
493 517
494 beacon_factor = (beacon_val + max_beacon_val) / max_beacon_val; 518 beacon_factor = (beacon_val + max_beacon_val) / max_beacon_val;
495 new_val = beacon_val / beacon_factor; 519 new_val = beacon_val / beacon_factor;
@@ -526,10 +550,22 @@ int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
526 ctx->timing.atim_window = 0; 550 ctx->timing.atim_window = 0;
527 551
528 if (ctx->ctxid == IWL_RXON_CTX_PAN && 552 if (ctx->ctxid == IWL_RXON_CTX_PAN &&
529 (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION)) { 553 (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION) &&
554 iwl_is_associated(priv, IWL_RXON_CTX_BSS) &&
555 priv->contexts[IWL_RXON_CTX_BSS].vif &&
556 priv->contexts[IWL_RXON_CTX_BSS].vif->bss_conf.beacon_int) {
530 ctx->timing.beacon_interval = 557 ctx->timing.beacon_interval =
531 priv->contexts[IWL_RXON_CTX_BSS].timing.beacon_interval; 558 priv->contexts[IWL_RXON_CTX_BSS].timing.beacon_interval;
532 beacon_int = le16_to_cpu(ctx->timing.beacon_interval); 559 beacon_int = le16_to_cpu(ctx->timing.beacon_interval);
560 } else if (ctx->ctxid == IWL_RXON_CTX_BSS &&
561 iwl_is_associated(priv, IWL_RXON_CTX_PAN) &&
562 priv->contexts[IWL_RXON_CTX_PAN].vif &&
563 priv->contexts[IWL_RXON_CTX_PAN].vif->bss_conf.beacon_int &&
564 (!iwl_is_associated_ctx(ctx) || !ctx->vif ||
565 !ctx->vif->bss_conf.beacon_int)) {
566 ctx->timing.beacon_interval =
567 priv->contexts[IWL_RXON_CTX_PAN].timing.beacon_interval;
568 beacon_int = le16_to_cpu(ctx->timing.beacon_interval);
533 } else { 569 } else {
534 beacon_int = iwl_adjust_beacon_interval(beacon_int, 570 beacon_int = iwl_adjust_beacon_interval(beacon_int,
535 priv->hw_params.max_beacon_itrvl * TIME_UNIT); 571 priv->hw_params.max_beacon_itrvl * TIME_UNIT);
@@ -1797,9 +1833,8 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
1797 priv->ibss_beacon = ieee80211_beacon_get(hw, vif); 1833 priv->ibss_beacon = ieee80211_beacon_get(hw, vif);
1798 } 1834 }
1799 1835
1800 if (changes & BSS_CHANGED_BEACON_INT) { 1836 if (changes & BSS_CHANGED_BEACON_INT && vif->type == NL80211_IFTYPE_AP)
1801 /* TODO: in AP mode, do something to make this take effect */ 1837 iwl_send_rxon_timing(priv, ctx);
1802 }
1803 1838
1804 if (changes & BSS_CHANGED_BSSID) { 1839 if (changes & BSS_CHANGED_BSSID) {
1805 IWL_DEBUG_MAC80211(priv, "BSSID %pM\n", bss_conf->bssid); 1840 IWL_DEBUG_MAC80211(priv, "BSSID %pM\n", bss_conf->bssid);
@@ -2009,9 +2044,14 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
2009 */ 2044 */
2010 priv->iw_mode = vif->type; 2045 priv->iw_mode = vif->type;
2011 2046
2047 ctx->is_active = true;
2048
2012 err = iwl_set_mode(priv, vif); 2049 err = iwl_set_mode(priv, vif);
2013 if (err) 2050 if (err) {
2051 if (!ctx->always_active)
2052 ctx->is_active = false;
2014 goto out_err; 2053 goto out_err;
2054 }
2015 2055
2016 if (priv->cfg->advanced_bt_coexist && 2056 if (priv->cfg->advanced_bt_coexist &&
2017 vif->type == NL80211_IFTYPE_ADHOC) { 2057 vif->type == NL80211_IFTYPE_ADHOC) {
@@ -2041,7 +2081,6 @@ void iwl_mac_remove_interface(struct ieee80211_hw *hw,
2041{ 2081{
2042 struct iwl_priv *priv = hw->priv; 2082 struct iwl_priv *priv = hw->priv;
2043 struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); 2083 struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
2044 bool scan_completed = false;
2045 2084
2046 IWL_DEBUG_MAC80211(priv, "enter\n"); 2085 IWL_DEBUG_MAC80211(priv, "enter\n");
2047 2086
@@ -2050,14 +2089,14 @@ void iwl_mac_remove_interface(struct ieee80211_hw *hw,
2050 WARN_ON(ctx->vif != vif); 2089 WARN_ON(ctx->vif != vif);
2051 ctx->vif = NULL; 2090 ctx->vif = NULL;
2052 2091
2053 iwl_scan_cancel_timeout(priv, 100);
2054 iwl_set_mode(priv, vif);
2055
2056 if (priv->scan_vif == vif) { 2092 if (priv->scan_vif == vif) {
2057 scan_completed = true; 2093 iwl_scan_cancel_timeout(priv, 200);
2058 priv->scan_vif = NULL; 2094 iwl_force_scan_end(priv);
2059 priv->scan_request = NULL;
2060 } 2095 }
2096 iwl_set_mode(priv, vif);
2097
2098 if (!ctx->always_active)
2099 ctx->is_active = false;
2061 2100
2062 /* 2101 /*
2063 * When removing the IBSS interface, overwrite the 2102 * When removing the IBSS interface, overwrite the
@@ -2072,9 +2111,6 @@ void iwl_mac_remove_interface(struct ieee80211_hw *hw,
2072 memset(priv->bssid, 0, ETH_ALEN); 2111 memset(priv->bssid, 0, ETH_ALEN);
2073 mutex_unlock(&priv->mutex); 2112 mutex_unlock(&priv->mutex);
2074 2113
2075 if (scan_completed)
2076 ieee80211_scan_completed(priv->hw, true);
2077
2078 IWL_DEBUG_MAC80211(priv, "leave\n"); 2114 IWL_DEBUG_MAC80211(priv, "leave\n");
2079 2115
2080} 2116}
@@ -2255,6 +2291,7 @@ void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
2255 2291
2256 spin_unlock_irqrestore(&priv->lock, flags); 2292 spin_unlock_irqrestore(&priv->lock, flags);
2257 2293
2294 iwl_scan_cancel_timeout(priv, 100);
2258 if (!iwl_is_ready_rf(priv)) { 2295 if (!iwl_is_ready_rf(priv)) {
2259 IWL_DEBUG_MAC80211(priv, "leave - not ready\n"); 2296 IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
2260 mutex_unlock(&priv->mutex); 2297 mutex_unlock(&priv->mutex);
@@ -2264,7 +2301,6 @@ void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
2264 /* we are restarting association process 2301 /* we are restarting association process
2265 * clear RXON_FILTER_ASSOC_MSK bit 2302 * clear RXON_FILTER_ASSOC_MSK bit
2266 */ 2303 */
2267 iwl_scan_cancel_timeout(priv, 100);
2268 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2304 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
2269 iwlcore_commit_rxon(priv, ctx); 2305 iwlcore_commit_rxon(priv, ctx);
2270 2306
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index f7b57ed84f6..f0302bfe85f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -111,7 +111,7 @@ struct iwl_hcmd_utils_ops {
111 __le16 fc, __le32 *tx_flags); 111 __le16 fc, __le32 *tx_flags);
112 int (*calc_rssi)(struct iwl_priv *priv, 112 int (*calc_rssi)(struct iwl_priv *priv,
113 struct iwl_rx_phy_res *rx_resp); 113 struct iwl_rx_phy_res *rx_resp);
114 void (*request_scan)(struct iwl_priv *priv, struct ieee80211_vif *vif); 114 int (*request_scan)(struct iwl_priv *priv, struct ieee80211_vif *vif);
115}; 115};
116 116
117struct iwl_apm_ops { 117struct iwl_apm_ops {
@@ -130,6 +130,8 @@ struct iwl_debugfs_ops {
130 size_t count, loff_t *ppos); 130 size_t count, loff_t *ppos);
131 ssize_t (*bt_stats_read)(struct file *file, char __user *user_buf, 131 ssize_t (*bt_stats_read)(struct file *file, char __user *user_buf,
132 size_t count, loff_t *ppos); 132 size_t count, loff_t *ppos);
133 ssize_t (*reply_tx_error)(struct file *file, char __user *user_buf,
134 size_t count, loff_t *ppos);
133}; 135};
134 136
135struct iwl_temp_ops { 137struct iwl_temp_ops {
@@ -553,6 +555,7 @@ static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags)
553void iwl_init_scan_params(struct iwl_priv *priv); 555void iwl_init_scan_params(struct iwl_priv *priv);
554int iwl_scan_cancel(struct iwl_priv *priv); 556int iwl_scan_cancel(struct iwl_priv *priv);
555int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); 557int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms);
558void iwl_force_scan_end(struct iwl_priv *priv);
556int iwl_mac_hw_scan(struct ieee80211_hw *hw, 559int iwl_mac_hw_scan(struct ieee80211_hw *hw,
557 struct ieee80211_vif *vif, 560 struct ieee80211_vif *vif,
558 struct cfg80211_scan_request *req); 561 struct cfg80211_scan_request *req);
@@ -568,6 +571,7 @@ u16 iwl_get_passive_dwell_time(struct iwl_priv *priv,
568 enum ieee80211_band band, 571 enum ieee80211_band band,
569 struct ieee80211_vif *vif); 572 struct ieee80211_vif *vif);
570void iwl_setup_scan_deferred_work(struct iwl_priv *priv); 573void iwl_setup_scan_deferred_work(struct iwl_priv *priv);
574void iwl_cancel_scan_deferred_work(struct iwl_priv *priv);
571 575
572/* For faster active scanning, scan will move to the next channel if fewer than 576/* For faster active scanning, scan will move to the next channel if fewer than
573 * PLCP_QUIET_THRESH packets are heard on this channel within 577 * PLCP_QUIET_THRESH packets are heard on this channel within
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 0ee8f516c4a..265ad01a443 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -575,10 +575,10 @@ static ssize_t iwl_dbgfs_interrupt_read(struct file *file,
575 priv->isr_stats.hw); 575 priv->isr_stats.hw);
576 pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", 576 pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n",
577 priv->isr_stats.sw); 577 priv->isr_stats.sw);
578 if (priv->isr_stats.sw > 0) { 578 if (priv->isr_stats.sw || priv->isr_stats.hw) {
579 pos += scnprintf(buf + pos, bufsz - pos, 579 pos += scnprintf(buf + pos, bufsz - pos,
580 "\tLast Restarting Code: 0x%X\n", 580 "\tLast Restarting Code: 0x%X\n",
581 priv->isr_stats.sw_err); 581 priv->isr_stats.err_code);
582 } 582 }
583#ifdef CONFIG_IWLWIFI_DEBUG 583#ifdef CONFIG_IWLWIFI_DEBUG
584 pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", 584 pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n",
@@ -1604,6 +1604,56 @@ static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file,
1604 return ret; 1604 return ret;
1605} 1605}
1606 1606
1607static ssize_t iwl_dbgfs_protection_mode_read(struct file *file,
1608 char __user *user_buf,
1609 size_t count, loff_t *ppos)
1610{
1611 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1612
1613 int pos = 0;
1614 char buf[40];
1615 const size_t bufsz = sizeof(buf);
1616
1617 pos += scnprintf(buf + pos, bufsz - pos, "use %s for aggregation\n",
1618 (priv->cfg->use_rts_for_aggregation) ? "rts/cts" :
1619 "cts-to-self");
1620 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1621}
1622
1623static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
1624 const char __user *user_buf,
1625 size_t count, loff_t *ppos) {
1626
1627 struct iwl_priv *priv = file->private_data;
1628 char buf[8];
1629 int buf_size;
1630 int rts;
1631
1632 memset(buf, 0, sizeof(buf));
1633 buf_size = min(count, sizeof(buf) - 1);
1634 if (copy_from_user(buf, user_buf, buf_size))
1635 return -EFAULT;
1636 if (sscanf(buf, "%d", &rts) != 1)
1637 return -EINVAL;
1638 if (rts)
1639 priv->cfg->use_rts_for_aggregation = true;
1640 else
1641 priv->cfg->use_rts_for_aggregation = false;
1642 return count;
1643}
1644
1645static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file,
1646 char __user *user_buf,
1647 size_t count, loff_t *ppos)
1648{
1649 struct iwl_priv *priv = file->private_data;
1650
1651 if (priv->cfg->ops->lib->debugfs_ops.reply_tx_error)
1652 return priv->cfg->ops->lib->debugfs_ops.reply_tx_error(
1653 file, user_buf, count, ppos);
1654 else
1655 return -ENODATA;
1656}
1607DEBUGFS_READ_FILE_OPS(rx_statistics); 1657DEBUGFS_READ_FILE_OPS(rx_statistics);
1608DEBUGFS_READ_FILE_OPS(tx_statistics); 1658DEBUGFS_READ_FILE_OPS(tx_statistics);
1609DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); 1659DEBUGFS_READ_WRITE_FILE_OPS(traffic_log);
@@ -1629,6 +1679,8 @@ DEBUGFS_WRITE_FILE_OPS(txfifo_flush);
1629DEBUGFS_READ_FILE_OPS(ucode_bt_stats); 1679DEBUGFS_READ_FILE_OPS(ucode_bt_stats);
1630DEBUGFS_WRITE_FILE_OPS(monitor_period); 1680DEBUGFS_WRITE_FILE_OPS(monitor_period);
1631DEBUGFS_READ_FILE_OPS(bt_traffic); 1681DEBUGFS_READ_FILE_OPS(bt_traffic);
1682DEBUGFS_READ_WRITE_FILE_OPS(protection_mode);
1683DEBUGFS_READ_FILE_OPS(reply_tx_error);
1632 1684
1633/* 1685/*
1634 * Create the debugfs files and directories 1686 * Create the debugfs files and directories
@@ -1689,6 +1741,7 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
1689 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); 1741 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
1690 if (priv->cfg->ops->lib->dev_txfifo_flush) 1742 if (priv->cfg->ops->lib->dev_txfifo_flush)
1691 DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR); 1743 DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR);
1744 DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR);
1692 1745
1693 if (priv->cfg->sensitivity_calib_by_driver) 1746 if (priv->cfg->sensitivity_calib_by_driver)
1694 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); 1747 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
@@ -1698,6 +1751,7 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
1698 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR); 1751 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
1699 if (priv->cfg->bt_statistics) 1752 if (priv->cfg->bt_statistics)
1700 DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR); 1753 DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR);
1754 DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR);
1701 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); 1755 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
1702 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); 1756 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
1703 DEBUGFS_ADD_FILE(monitor_period, dir_debug, S_IWUSR); 1757 DEBUGFS_ADD_FILE(monitor_period, dir_debug, S_IWUSR);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 4dd38b7b8b7..74d25bcbfcb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -945,7 +945,7 @@ enum iwl_pa_type {
945struct isr_statistics { 945struct isr_statistics {
946 u32 hw; 946 u32 hw;
947 u32 sw; 947 u32 sw;
948 u32 sw_err; 948 u32 err_code;
949 u32 sch; 949 u32 sch;
950 u32 alive; 950 u32 alive;
951 u32 rfkill; 951 u32 rfkill;
@@ -957,6 +957,50 @@ struct isr_statistics {
957 u32 unhandled; 957 u32 unhandled;
958}; 958};
959 959
960/* reply_tx_statistics (for _agn devices) */
961struct reply_tx_error_statistics {
962 u32 pp_delay;
963 u32 pp_few_bytes;
964 u32 pp_bt_prio;
965 u32 pp_quiet_period;
966 u32 pp_calc_ttak;
967 u32 int_crossed_retry;
968 u32 short_limit;
969 u32 long_limit;
970 u32 fifo_underrun;
971 u32 drain_flow;
972 u32 rfkill_flush;
973 u32 life_expire;
974 u32 dest_ps;
975 u32 host_abort;
976 u32 bt_retry;
977 u32 sta_invalid;
978 u32 frag_drop;
979 u32 tid_disable;
980 u32 fifo_flush;
981 u32 insuff_cf_poll;
982 u32 fail_hw_drop;
983 u32 sta_color_mismatch;
984 u32 unknown;
985};
986
987/* reply_agg_tx_statistics (for _agn devices) */
988struct reply_agg_tx_error_statistics {
989 u32 underrun;
990 u32 bt_prio;
991 u32 few_bytes;
992 u32 abort;
993 u32 last_sent_ttl;
994 u32 last_sent_try;
995 u32 last_sent_bt_kill;
996 u32 scd_query;
997 u32 bad_crc32;
998 u32 response;
999 u32 dump_tx;
1000 u32 delay_tx;
1001 u32 unknown;
1002};
1003
960#ifdef CONFIG_IWLWIFI_DEBUGFS 1004#ifdef CONFIG_IWLWIFI_DEBUGFS
961/* management statistics */ 1005/* management statistics */
962enum iwl_mgmt_stats { 1006enum iwl_mgmt_stats {
@@ -1116,6 +1160,13 @@ struct iwl_rxon_context {
1116 const u8 *ac_to_queue; 1160 const u8 *ac_to_queue;
1117 u8 mcast_queue; 1161 u8 mcast_queue;
1118 1162
1163 /*
1164 * We could use the vif to indicate active, but we
1165 * also need it to be active during disabling when
1166 * we already removed the vif for type setting.
1167 */
1168 bool always_active, is_active;
1169
1119 enum iwl_rxon_context_id ctxid; 1170 enum iwl_rxon_context_id ctxid;
1120 1171
1121 u32 interface_modes, exclusive_interface_modes; 1172 u32 interface_modes, exclusive_interface_modes;
@@ -1408,6 +1459,9 @@ struct iwl_priv {
1408 1459
1409 struct iwl_notif_statistics statistics; 1460 struct iwl_notif_statistics statistics;
1410 struct iwl_bt_notif_statistics statistics_bt; 1461 struct iwl_bt_notif_statistics statistics_bt;
1462 /* counts reply_tx error */
1463 struct reply_tx_error_statistics reply_tx_stats;
1464 struct reply_agg_tx_error_statistics reply_agg_tx_stats;
1411#ifdef CONFIG_IWLWIFI_DEBUGFS 1465#ifdef CONFIG_IWLWIFI_DEBUGFS
1412 struct iwl_notif_statistics accum_statistics; 1466 struct iwl_notif_statistics accum_statistics;
1413 struct iwl_notif_statistics delta_statistics; 1467 struct iwl_notif_statistics delta_statistics;
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 7727f0966d3..c54c20023e7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -54,100 +54,134 @@
54#define IWL_PASSIVE_DWELL_BASE (100) 54#define IWL_PASSIVE_DWELL_BASE (100)
55#define IWL_CHANNEL_TUNE_TIME 5 55#define IWL_CHANNEL_TUNE_TIME 5
56 56
57static int iwl_send_scan_abort(struct iwl_priv *priv)
58{
59 int ret;
60 struct iwl_rx_packet *pkt;
61 struct iwl_host_cmd cmd = {
62 .id = REPLY_SCAN_ABORT_CMD,
63 .flags = CMD_WANT_SKB,
64 };
57 65
66 /* Exit instantly with error when device is not ready
67 * to receive scan abort command or it does not perform
68 * hardware scan currently */
69 if (!test_bit(STATUS_READY, &priv->status) ||
70 !test_bit(STATUS_GEO_CONFIGURED, &priv->status) ||
71 !test_bit(STATUS_SCAN_HW, &priv->status) ||
72 test_bit(STATUS_FW_ERROR, &priv->status) ||
73 test_bit(STATUS_EXIT_PENDING, &priv->status))
74 return -EIO;
58 75
59/** 76 ret = iwl_send_cmd_sync(priv, &cmd);
60 * iwl_scan_cancel - Cancel any currently executing HW scan 77 if (ret)
61 * 78 return ret;
62 * NOTE: priv->mutex is not required before calling this function 79
63 */ 80 pkt = (struct iwl_rx_packet *)cmd.reply_page;
64int iwl_scan_cancel(struct iwl_priv *priv) 81 if (pkt->u.status != CAN_ABORT_STATUS) {
82 /* The scan abort will return 1 for success or
83 * 2 for "failure". A failure condition can be
84 * due to simply not being in an active scan which
85 * can occur if we send the scan abort before we
86 * the microcode has notified us that a scan is
87 * completed. */
88 IWL_DEBUG_SCAN(priv, "SCAN_ABORT ret %d.\n", pkt->u.status);
89 ret = -EIO;
90 }
91
92 iwl_free_pages(priv, cmd.reply_page);
93 return ret;
94}
95
96static void iwl_complete_scan(struct iwl_priv *priv, bool aborted)
65{ 97{
66 if (!test_bit(STATUS_SCAN_HW, &priv->status)) { 98 /* check if scan was requested from mac80211 */
67 clear_bit(STATUS_SCANNING, &priv->status); 99 if (priv->scan_request) {
68 return 0; 100 IWL_DEBUG_SCAN(priv, "Complete scan in mac80211\n");
101 ieee80211_scan_completed(priv->hw, aborted);
69 } 102 }
70 103
71 if (test_bit(STATUS_SCANNING, &priv->status)) { 104 priv->is_internal_short_scan = false;
72 if (!test_and_set_bit(STATUS_SCAN_ABORTING, &priv->status)) { 105 priv->scan_vif = NULL;
73 IWL_DEBUG_SCAN(priv, "Queuing scan abort.\n"); 106 priv->scan_request = NULL;
74 queue_work(priv->workqueue, &priv->abort_scan); 107}
75 108
76 } else 109void iwl_force_scan_end(struct iwl_priv *priv)
77 IWL_DEBUG_SCAN(priv, "Scan abort already in progress.\n"); 110{
111 lockdep_assert_held(&priv->mutex);
78 112
79 return test_bit(STATUS_SCANNING, &priv->status); 113 if (!test_bit(STATUS_SCANNING, &priv->status)) {
114 IWL_DEBUG_SCAN(priv, "Forcing scan end while not scanning\n");
115 return;
80 } 116 }
81 117
118 IWL_DEBUG_SCAN(priv, "Forcing scan end\n");
119 clear_bit(STATUS_SCANNING, &priv->status);
120 clear_bit(STATUS_SCAN_HW, &priv->status);
121 clear_bit(STATUS_SCAN_ABORTING, &priv->status);
122 iwl_complete_scan(priv, true);
123}
124EXPORT_SYMBOL(iwl_force_scan_end);
125
126static void iwl_do_scan_abort(struct iwl_priv *priv)
127{
128 int ret;
129
130 lockdep_assert_held(&priv->mutex);
131
132 if (!test_bit(STATUS_SCANNING, &priv->status)) {
133 IWL_DEBUG_SCAN(priv, "Not performing scan to abort\n");
134 return;
135 }
136
137 if (test_and_set_bit(STATUS_SCAN_ABORTING, &priv->status)) {
138 IWL_DEBUG_SCAN(priv, "Scan abort in progress\n");
139 return;
140 }
141
142 ret = iwl_send_scan_abort(priv);
143 if (ret) {
144 IWL_DEBUG_SCAN(priv, "Send scan abort failed %d\n", ret);
145 iwl_force_scan_end(priv);
146 } else
147 IWL_DEBUG_SCAN(priv, "Sucessfully send scan abort\n");
148}
149
150/**
151 * iwl_scan_cancel - Cancel any currently executing HW scan
152 */
153int iwl_scan_cancel(struct iwl_priv *priv)
154{
155 IWL_DEBUG_SCAN(priv, "Queuing abort scan\n");
156 queue_work(priv->workqueue, &priv->abort_scan);
82 return 0; 157 return 0;
83} 158}
84EXPORT_SYMBOL(iwl_scan_cancel); 159EXPORT_SYMBOL(iwl_scan_cancel);
160
85/** 161/**
86 * iwl_scan_cancel_timeout - Cancel any currently executing HW scan 162 * iwl_scan_cancel_timeout - Cancel any currently executing HW scan
87 * @ms: amount of time to wait (in milliseconds) for scan to abort 163 * @ms: amount of time to wait (in milliseconds) for scan to abort
88 * 164 *
89 * NOTE: priv->mutex must be held before calling this function
90 */ 165 */
91int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms) 166int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms)
92{ 167{
93 unsigned long now = jiffies; 168 unsigned long timeout = jiffies + msecs_to_jiffies(ms);
94 int ret;
95
96 ret = iwl_scan_cancel(priv);
97 if (ret && ms) {
98 mutex_unlock(&priv->mutex);
99 while (!time_after(jiffies, now + msecs_to_jiffies(ms)) &&
100 test_bit(STATUS_SCANNING, &priv->status))
101 msleep(1);
102 mutex_lock(&priv->mutex);
103
104 return test_bit(STATUS_SCANNING, &priv->status);
105 }
106 169
107 return ret; 170 lockdep_assert_held(&priv->mutex);
108}
109EXPORT_SYMBOL(iwl_scan_cancel_timeout);
110 171
111static int iwl_send_scan_abort(struct iwl_priv *priv) 172 IWL_DEBUG_SCAN(priv, "Scan cancel timeout\n");
112{
113 int ret = 0;
114 struct iwl_rx_packet *pkt;
115 struct iwl_host_cmd cmd = {
116 .id = REPLY_SCAN_ABORT_CMD,
117 .flags = CMD_WANT_SKB,
118 };
119 173
120 /* If there isn't a scan actively going on in the hardware 174 iwl_do_scan_abort(priv);
121 * then we are in between scan bands and not actually
122 * actively scanning, so don't send the abort command */
123 if (!test_bit(STATUS_SCAN_HW, &priv->status)) {
124 clear_bit(STATUS_SCAN_ABORTING, &priv->status);
125 return 0;
126 }
127
128 ret = iwl_send_cmd_sync(priv, &cmd);
129 if (ret) {
130 clear_bit(STATUS_SCAN_ABORTING, &priv->status);
131 return ret;
132 }
133 175
134 pkt = (struct iwl_rx_packet *)cmd.reply_page; 176 while (time_before_eq(jiffies, timeout)) {
135 if (pkt->u.status != CAN_ABORT_STATUS) { 177 if (!test_bit(STATUS_SCAN_HW, &priv->status))
136 /* The scan abort will return 1 for success or 178 break;
137 * 2 for "failure". A failure condition can be 179 msleep(20);
138 * due to simply not being in an active scan which
139 * can occur if we send the scan abort before we
140 * the microcode has notified us that a scan is
141 * completed. */
142 IWL_DEBUG_INFO(priv, "SCAN_ABORT returned %d.\n", pkt->u.status);
143 clear_bit(STATUS_SCAN_ABORTING, &priv->status);
144 clear_bit(STATUS_SCAN_HW, &priv->status);
145 } 180 }
146 181
147 iwl_free_pages(priv, cmd.reply_page); 182 return test_bit(STATUS_SCAN_HW, &priv->status);
148
149 return ret;
150} 183}
184EXPORT_SYMBOL(iwl_scan_cancel_timeout);
151 185
152/* Service response to REPLY_SCAN_CMD (0x80) */ 186/* Service response to REPLY_SCAN_CMD (0x80) */
153static void iwl_rx_reply_scan(struct iwl_priv *priv, 187static void iwl_rx_reply_scan(struct iwl_priv *priv,
@@ -158,7 +192,7 @@ static void iwl_rx_reply_scan(struct iwl_priv *priv,
158 struct iwl_scanreq_notification *notif = 192 struct iwl_scanreq_notification *notif =
159 (struct iwl_scanreq_notification *)pkt->u.raw; 193 (struct iwl_scanreq_notification *)pkt->u.raw;
160 194
161 IWL_DEBUG_RX(priv, "Scan request status = 0x%x\n", notif->status); 195 IWL_DEBUG_SCAN(priv, "Scan request status = 0x%x\n", notif->status);
162#endif 196#endif
163} 197}
164 198
@@ -217,26 +251,16 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
217 /* The HW is no longer scanning */ 251 /* The HW is no longer scanning */
218 clear_bit(STATUS_SCAN_HW, &priv->status); 252 clear_bit(STATUS_SCAN_HW, &priv->status);
219 253
220 IWL_DEBUG_INFO(priv, "Scan on %sGHz took %dms\n", 254 IWL_DEBUG_SCAN(priv, "Scan on %sGHz took %dms\n",
221 (priv->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", 255 (priv->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2",
222 jiffies_to_msecs(elapsed_jiffies 256 jiffies_to_msecs(elapsed_jiffies
223 (priv->scan_start, jiffies))); 257 (priv->scan_start, jiffies)));
224 258
225 /* 259 queue_work(priv->workqueue, &priv->scan_completed);
226 * If a request to abort was given, or the scan did not succeed
227 * then we reset the scan state machine and terminate,
228 * re-queuing another scan if one has been requested
229 */
230 if (test_and_clear_bit(STATUS_SCAN_ABORTING, &priv->status))
231 IWL_DEBUG_INFO(priv, "Aborted scan completed.\n");
232
233 IWL_DEBUG_INFO(priv, "Setting scan to off\n");
234
235 clear_bit(STATUS_SCANNING, &priv->status);
236 260
237 if (priv->iw_mode != NL80211_IFTYPE_ADHOC && 261 if (priv->iw_mode != NL80211_IFTYPE_ADHOC &&
238 priv->cfg->advanced_bt_coexist && priv->bt_status != 262 priv->cfg->advanced_bt_coexist &&
239 scan_notif->bt_status) { 263 priv->bt_status != scan_notif->bt_status) {
240 if (scan_notif->bt_status) { 264 if (scan_notif->bt_status) {
241 /* BT on */ 265 /* BT on */
242 if (!priv->bt_ch_announce) 266 if (!priv->bt_ch_announce)
@@ -254,7 +278,6 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
254 priv->bt_status = scan_notif->bt_status; 278 priv->bt_status = scan_notif->bt_status;
255 queue_work(priv->workqueue, &priv->bt_traffic_change_work); 279 queue_work(priv->workqueue, &priv->bt_traffic_change_work);
256 } 280 }
257 queue_work(priv->workqueue, &priv->scan_completed);
258} 281}
259 282
260void iwl_setup_rx_scan_handlers(struct iwl_priv *priv) 283void iwl_setup_rx_scan_handlers(struct iwl_priv *priv)
@@ -324,19 +347,53 @@ void iwl_init_scan_params(struct iwl_priv *priv)
324} 347}
325EXPORT_SYMBOL(iwl_init_scan_params); 348EXPORT_SYMBOL(iwl_init_scan_params);
326 349
327static int iwl_scan_initiate(struct iwl_priv *priv, struct ieee80211_vif *vif) 350static int __must_check iwl_scan_initiate(struct iwl_priv *priv,
351 struct ieee80211_vif *vif,
352 bool internal,
353 enum ieee80211_band band)
328{ 354{
355 int ret;
356
329 lockdep_assert_held(&priv->mutex); 357 lockdep_assert_held(&priv->mutex);
330 358
331 IWL_DEBUG_INFO(priv, "Starting scan...\n"); 359 if (WARN_ON(!priv->cfg->ops->utils->request_scan))
360 return -EOPNOTSUPP;
361
362 cancel_delayed_work(&priv->scan_check);
363
364 if (!iwl_is_ready_rf(priv)) {
365 IWL_WARN(priv, "Request scan called when driver not ready.\n");
366 return -EIO;
367 }
368
369 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
370 IWL_DEBUG_SCAN(priv,
371 "Multiple concurrent scan requests in parallel.\n");
372 return -EBUSY;
373 }
374
375 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
376 IWL_DEBUG_SCAN(priv, "Scan request while abort pending.\n");
377 return -EBUSY;
378 }
379
380 IWL_DEBUG_SCAN(priv, "Starting %sscan...\n",
381 internal ? "internal short " : "");
382
332 set_bit(STATUS_SCANNING, &priv->status); 383 set_bit(STATUS_SCANNING, &priv->status);
333 priv->is_internal_short_scan = false; 384 priv->is_internal_short_scan = internal;
334 priv->scan_start = jiffies; 385 priv->scan_start = jiffies;
386 priv->scan_band = band;
335 387
336 if (WARN_ON(!priv->cfg->ops->utils->request_scan)) 388 ret = priv->cfg->ops->utils->request_scan(priv, vif);
337 return -EOPNOTSUPP; 389 if (ret) {
390 clear_bit(STATUS_SCANNING, &priv->status);
391 priv->is_internal_short_scan = false;
392 return ret;
393 }
338 394
339 priv->cfg->ops->utils->request_scan(priv, vif); 395 queue_delayed_work(priv->workqueue, &priv->scan_check,
396 IWL_SCAN_CHECK_WATCHDOG);
340 397
341 return 0; 398 return 0;
342} 399}
@@ -355,12 +412,6 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
355 412
356 mutex_lock(&priv->mutex); 413 mutex_lock(&priv->mutex);
357 414
358 if (!iwl_is_ready_rf(priv)) {
359 ret = -EIO;
360 IWL_DEBUG_MAC80211(priv, "leave - not ready or exit pending\n");
361 goto out_unlock;
362 }
363
364 if (test_bit(STATUS_SCANNING, &priv->status) && 415 if (test_bit(STATUS_SCANNING, &priv->status) &&
365 !priv->is_internal_short_scan) { 416 !priv->is_internal_short_scan) {
366 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n"); 417 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
@@ -368,14 +419,7 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
368 goto out_unlock; 419 goto out_unlock;
369 } 420 }
370 421
371 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
372 IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n");
373 ret = -EAGAIN;
374 goto out_unlock;
375 }
376
377 /* mac80211 will only ask for one band at a time */ 422 /* mac80211 will only ask for one band at a time */
378 priv->scan_band = req->channels[0]->band;
379 priv->scan_request = req; 423 priv->scan_request = req;
380 priv->scan_vif = vif; 424 priv->scan_vif = vif;
381 425
@@ -383,10 +427,12 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
383 * If an internal scan is in progress, just set 427 * If an internal scan is in progress, just set
384 * up the scan_request as per above. 428 * up the scan_request as per above.
385 */ 429 */
386 if (priv->is_internal_short_scan) 430 if (priv->is_internal_short_scan) {
431 IWL_DEBUG_SCAN(priv, "SCAN request during internal scan\n");
387 ret = 0; 432 ret = 0;
388 else 433 } else
389 ret = iwl_scan_initiate(priv, vif); 434 ret = iwl_scan_initiate(priv, vif, false,
435 req->channels[0]->band);
390 436
391 IWL_DEBUG_MAC80211(priv, "leave\n"); 437 IWL_DEBUG_MAC80211(priv, "leave\n");
392 438
@@ -411,6 +457,8 @@ static void iwl_bg_start_internal_scan(struct work_struct *work)
411 struct iwl_priv *priv = 457 struct iwl_priv *priv =
412 container_of(work, struct iwl_priv, start_internal_scan); 458 container_of(work, struct iwl_priv, start_internal_scan);
413 459
460 IWL_DEBUG_SCAN(priv, "Start internal scan\n");
461
414 mutex_lock(&priv->mutex); 462 mutex_lock(&priv->mutex);
415 463
416 if (priv->is_internal_short_scan == true) { 464 if (priv->is_internal_short_scan == true) {
@@ -418,31 +466,13 @@ static void iwl_bg_start_internal_scan(struct work_struct *work)
418 goto unlock; 466 goto unlock;
419 } 467 }
420 468
421 if (!iwl_is_ready_rf(priv)) {
422 IWL_DEBUG_SCAN(priv, "not ready or exit pending\n");
423 goto unlock;
424 }
425
426 if (test_bit(STATUS_SCANNING, &priv->status)) { 469 if (test_bit(STATUS_SCANNING, &priv->status)) {
427 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n"); 470 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
428 goto unlock; 471 goto unlock;
429 } 472 }
430 473
431 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 474 if (iwl_scan_initiate(priv, NULL, true, priv->band))
432 IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n"); 475 IWL_DEBUG_SCAN(priv, "failed to start internal short scan\n");
433 goto unlock;
434 }
435
436 priv->scan_band = priv->band;
437
438 IWL_DEBUG_SCAN(priv, "Start internal short scan...\n");
439 set_bit(STATUS_SCANNING, &priv->status);
440 priv->is_internal_short_scan = true;
441
442 if (WARN_ON(!priv->cfg->ops->utils->request_scan))
443 goto unlock;
444
445 priv->cfg->ops->utils->request_scan(priv, NULL);
446 unlock: 476 unlock:
447 mutex_unlock(&priv->mutex); 477 mutex_unlock(&priv->mutex);
448} 478}
@@ -452,18 +482,13 @@ static void iwl_bg_scan_check(struct work_struct *data)
452 struct iwl_priv *priv = 482 struct iwl_priv *priv =
453 container_of(data, struct iwl_priv, scan_check.work); 483 container_of(data, struct iwl_priv, scan_check.work);
454 484
455 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 485 IWL_DEBUG_SCAN(priv, "Scan check work\n");
456 return;
457 486
487 /* Since we are here firmware does not finish scan and
488 * most likely is in bad shape, so we don't bother to
489 * send abort command, just force scan complete to mac80211 */
458 mutex_lock(&priv->mutex); 490 mutex_lock(&priv->mutex);
459 if (test_bit(STATUS_SCANNING, &priv->status) && 491 iwl_force_scan_end(priv);
460 !test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
461 IWL_DEBUG_SCAN(priv, "Scan completion watchdog (%dms)\n",
462 jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG));
463
464 if (!test_bit(STATUS_EXIT_PENDING, &priv->status))
465 iwl_send_scan_abort(priv);
466 }
467 mutex_unlock(&priv->mutex); 492 mutex_unlock(&priv->mutex);
468} 493}
469 494
@@ -519,15 +544,12 @@ static void iwl_bg_abort_scan(struct work_struct *work)
519{ 544{
520 struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan); 545 struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan);
521 546
522 if (!test_bit(STATUS_READY, &priv->status) || 547 IWL_DEBUG_SCAN(priv, "Abort scan work\n");
523 !test_bit(STATUS_GEO_CONFIGURED, &priv->status))
524 return;
525
526 cancel_delayed_work(&priv->scan_check);
527 548
549 /* We keep scan_check work queued in case when firmware will not
550 * report back scan completed notification */
528 mutex_lock(&priv->mutex); 551 mutex_lock(&priv->mutex);
529 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) 552 iwl_scan_cancel_timeout(priv, 200);
530 iwl_send_scan_abort(priv);
531 mutex_unlock(&priv->mutex); 553 mutex_unlock(&priv->mutex);
532} 554}
533 555
@@ -535,30 +557,52 @@ static void iwl_bg_scan_completed(struct work_struct *work)
535{ 557{
536 struct iwl_priv *priv = 558 struct iwl_priv *priv =
537 container_of(work, struct iwl_priv, scan_completed); 559 container_of(work, struct iwl_priv, scan_completed);
538 bool internal = false; 560 bool aborted;
539 bool scan_completed = false;
540 struct iwl_rxon_context *ctx; 561 struct iwl_rxon_context *ctx;
541 562
542 IWL_DEBUG_SCAN(priv, "SCAN complete scan\n"); 563 IWL_DEBUG_SCAN(priv, "Completed %sscan.\n",
564 priv->is_internal_short_scan ? "internal short " : "");
543 565
544 cancel_delayed_work(&priv->scan_check); 566 cancel_delayed_work(&priv->scan_check);
545 567
546 mutex_lock(&priv->mutex); 568 mutex_lock(&priv->mutex);
547 if (priv->is_internal_short_scan) { 569
548 priv->is_internal_short_scan = false; 570 aborted = test_and_clear_bit(STATUS_SCAN_ABORTING, &priv->status);
549 IWL_DEBUG_SCAN(priv, "internal short scan completed\n"); 571 if (aborted)
550 internal = true; 572 IWL_DEBUG_SCAN(priv, "Aborted scan completed.\n");
551 } else if (priv->scan_request) { 573
552 scan_completed = true; 574 if (!test_and_clear_bit(STATUS_SCANNING, &priv->status)) {
553 priv->scan_request = NULL; 575 IWL_DEBUG_SCAN(priv, "Scan already completed.\n");
554 priv->scan_vif = NULL; 576 goto out_settings;
555 } 577 }
556 578
557 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 579 if (priv->is_internal_short_scan && !aborted) {
580 int err;
581
582 /* Check if mac80211 requested scan during our internal scan */
583 if (priv->scan_request == NULL)
584 goto out_complete;
585
586 /* If so request a new scan */
587 err = iwl_scan_initiate(priv, priv->scan_vif, false,
588 priv->scan_request->channels[0]->band);
589 if (err) {
590 IWL_DEBUG_SCAN(priv,
591 "failed to initiate pending scan: %d\n", err);
592 aborted = true;
593 goto out_complete;
594 }
595
558 goto out; 596 goto out;
597 }
598
599out_complete:
600 iwl_complete_scan(priv, aborted);
559 601
560 if (internal && priv->scan_request) 602out_settings:
561 iwl_scan_initiate(priv, priv->scan_vif); 603 /* Can we still talk to firmware ? */
604 if (!iwl_is_ready_rf(priv))
605 goto out;
562 606
563 /* Since setting the TXPOWER may have been deferred while 607 /* Since setting the TXPOWER may have been deferred while
564 * performing the scan, fire one off */ 608 * performing the scan, fire one off */
@@ -571,19 +615,11 @@ static void iwl_bg_scan_completed(struct work_struct *work)
571 for_each_context(priv, ctx) 615 for_each_context(priv, ctx)
572 iwlcore_commit_rxon(priv, ctx); 616 iwlcore_commit_rxon(priv, ctx);
573 617
574 out:
575 if (priv->cfg->ops->hcmd->set_pan_params) 618 if (priv->cfg->ops->hcmd->set_pan_params)
576 priv->cfg->ops->hcmd->set_pan_params(priv); 619 priv->cfg->ops->hcmd->set_pan_params(priv);
577 620
621 out:
578 mutex_unlock(&priv->mutex); 622 mutex_unlock(&priv->mutex);
579
580 /*
581 * Do not hold mutex here since this will cause mac80211 to call
582 * into driver again into functions that will attempt to take
583 * mutex.
584 */
585 if (scan_completed)
586 ieee80211_scan_completed(priv->hw, false);
587} 623}
588 624
589void iwl_setup_scan_deferred_work(struct iwl_priv *priv) 625void iwl_setup_scan_deferred_work(struct iwl_priv *priv)
@@ -595,3 +631,16 @@ void iwl_setup_scan_deferred_work(struct iwl_priv *priv)
595} 631}
596EXPORT_SYMBOL(iwl_setup_scan_deferred_work); 632EXPORT_SYMBOL(iwl_setup_scan_deferred_work);
597 633
634void iwl_cancel_scan_deferred_work(struct iwl_priv *priv)
635{
636 cancel_work_sync(&priv->start_internal_scan);
637 cancel_work_sync(&priv->abort_scan);
638 cancel_work_sync(&priv->scan_completed);
639
640 if (cancel_delayed_work_sync(&priv->scan_check)) {
641 mutex_lock(&priv->mutex);
642 iwl_force_scan_end(priv);
643 mutex_unlock(&priv->mutex);
644 }
645}
646EXPORT_SYMBOL(iwl_cancel_scan_deferred_work);
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index ccd09027c7c..6edd0341dfe 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -386,7 +386,8 @@ static struct iwl_link_quality_cmd *iwl_sta_alloc_lq(struct iwl_priv *priv,
386{ 386{
387 int i, r; 387 int i, r;
388 struct iwl_link_quality_cmd *link_cmd; 388 struct iwl_link_quality_cmd *link_cmd;
389 u32 rate_flags; 389 u32 rate_flags = 0;
390 __le32 rate_n_flags;
390 391
391 link_cmd = kzalloc(sizeof(struct iwl_link_quality_cmd), GFP_KERNEL); 392 link_cmd = kzalloc(sizeof(struct iwl_link_quality_cmd), GFP_KERNEL);
392 if (!link_cmd) { 393 if (!link_cmd) {
@@ -400,18 +401,14 @@ static struct iwl_link_quality_cmd *iwl_sta_alloc_lq(struct iwl_priv *priv,
400 else 401 else
401 r = IWL_RATE_1M_INDEX; 402 r = IWL_RATE_1M_INDEX;
402 403
403 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { 404 if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE)
404 rate_flags = 0; 405 rate_flags |= RATE_MCS_CCK_MSK;
405 if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE)
406 rate_flags |= RATE_MCS_CCK_MSK;
407 406
408 rate_flags |= first_antenna(priv->hw_params.valid_tx_ant) << 407 rate_flags |= first_antenna(priv->hw_params.valid_tx_ant) <<
409 RATE_MCS_ANT_POS; 408 RATE_MCS_ANT_POS;
410 409 rate_n_flags = iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags);
411 link_cmd->rs_table[i].rate_n_flags = 410 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++)
412 iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags); 411 link_cmd->rs_table[i].rate_n_flags = rate_n_flags;
413 r = iwl_get_prev_ieee_rate(r);
414 }
415 412
416 link_cmd->general_params.single_stream_ant_msk = 413 link_cmd->general_params.single_stream_ant_msk =
417 first_antenna(priv->hw_params.valid_tx_ant); 414 first_antenna(priv->hw_params.valid_tx_ant);
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 347d3dc6a01..3290b1552f5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -666,8 +666,8 @@ const char *iwl_get_tx_fail_reason(u32 status)
666 TX_STATUS_FAIL(TID_DISABLE); 666 TX_STATUS_FAIL(TID_DISABLE);
667 TX_STATUS_FAIL(FIFO_FLUSHED); 667 TX_STATUS_FAIL(FIFO_FLUSHED);
668 TX_STATUS_FAIL(INSUFFICIENT_CF_POLL); 668 TX_STATUS_FAIL(INSUFFICIENT_CF_POLL);
669 TX_STATUS_FAIL(FW_DROP); 669 TX_STATUS_FAIL(PASSIVE_NO_RX);
670 TX_STATUS_FAIL(STA_COLOR_MISMATCH_DROP); 670 TX_STATUS_FAIL(NO_BEACON_ON_RADAR);
671 } 671 }
672 672
673 return "UNKNOWN"; 673 return "UNKNOWN";
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 68e624afb98..116777122a7 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -1730,7 +1730,6 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
1730 IWL_ERR(priv, "Microcode SW error detected. " 1730 IWL_ERR(priv, "Microcode SW error detected. "
1731 "Restarting 0x%X.\n", inta); 1731 "Restarting 0x%X.\n", inta);
1732 priv->isr_stats.sw++; 1732 priv->isr_stats.sw++;
1733 priv->isr_stats.sw_err = inta;
1734 iwl_irq_handle_error(priv); 1733 iwl_irq_handle_error(priv);
1735 handled |= CSR_INT_BIT_SW_ERR; 1734 handled |= CSR_INT_BIT_SW_ERR;
1736 } 1735 }
@@ -2568,15 +2567,13 @@ static void iwl3945_cancel_deferred_work(struct iwl_priv *priv);
2568static void __iwl3945_down(struct iwl_priv *priv) 2567static void __iwl3945_down(struct iwl_priv *priv)
2569{ 2568{
2570 unsigned long flags; 2569 unsigned long flags;
2571 int exit_pending = test_bit(STATUS_EXIT_PENDING, &priv->status); 2570 int exit_pending;
2572 struct ieee80211_conf *conf = NULL;
2573 2571
2574 IWL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); 2572 IWL_DEBUG_INFO(priv, DRV_NAME " is going down\n");
2575 2573
2576 conf = ieee80211_get_hw_conf(priv->hw); 2574 iwl_scan_cancel_timeout(priv, 200);
2577 2575
2578 if (!exit_pending) 2576 exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &priv->status);
2579 set_bit(STATUS_EXIT_PENDING, &priv->status);
2580 2577
2581 /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set 2578 /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set
2582 * to prevent rearm timer */ 2579 * to prevent rearm timer */
@@ -2820,7 +2817,7 @@ static void iwl3945_rfkill_poll(struct work_struct *data)
2820 2817
2821} 2818}
2822 2819
2823void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) 2820int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
2824{ 2821{
2825 struct iwl_host_cmd cmd = { 2822 struct iwl_host_cmd cmd = {
2826 .id = REPLY_SCAN_CMD, 2823 .id = REPLY_SCAN_CMD,
@@ -2828,61 +2825,19 @@ void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
2828 .flags = CMD_SIZE_HUGE, 2825 .flags = CMD_SIZE_HUGE,
2829 }; 2826 };
2830 struct iwl3945_scan_cmd *scan; 2827 struct iwl3945_scan_cmd *scan;
2831 struct ieee80211_conf *conf = NULL;
2832 u8 n_probes = 0; 2828 u8 n_probes = 0;
2833 enum ieee80211_band band; 2829 enum ieee80211_band band;
2834 bool is_active = false; 2830 bool is_active = false;
2831 int ret;
2835 2832
2836 conf = ieee80211_get_hw_conf(priv->hw); 2833 lockdep_assert_held(&priv->mutex);
2837
2838 cancel_delayed_work(&priv->scan_check);
2839
2840 if (!iwl_is_ready(priv)) {
2841 IWL_WARN(priv, "request scan called when driver not ready.\n");
2842 goto done;
2843 }
2844
2845 /* Make sure the scan wasn't canceled before this queued work
2846 * was given the chance to run... */
2847 if (!test_bit(STATUS_SCANNING, &priv->status))
2848 goto done;
2849
2850 /* This should never be called or scheduled if there is currently
2851 * a scan active in the hardware. */
2852 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
2853 IWL_DEBUG_INFO(priv, "Multiple concurrent scan requests "
2854 "Ignoring second request.\n");
2855 goto done;
2856 }
2857
2858 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
2859 IWL_DEBUG_SCAN(priv, "Aborting scan due to device shutdown\n");
2860 goto done;
2861 }
2862
2863 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
2864 IWL_DEBUG_HC(priv,
2865 "Scan request while abort pending. Queuing.\n");
2866 goto done;
2867 }
2868
2869 if (iwl_is_rfkill(priv)) {
2870 IWL_DEBUG_HC(priv, "Aborting scan due to RF Kill activation\n");
2871 goto done;
2872 }
2873
2874 if (!test_bit(STATUS_READY, &priv->status)) {
2875 IWL_DEBUG_HC(priv,
2876 "Scan request while uninitialized. Queuing.\n");
2877 goto done;
2878 }
2879 2834
2880 if (!priv->scan_cmd) { 2835 if (!priv->scan_cmd) {
2881 priv->scan_cmd = kmalloc(sizeof(struct iwl3945_scan_cmd) + 2836 priv->scan_cmd = kmalloc(sizeof(struct iwl3945_scan_cmd) +
2882 IWL_MAX_SCAN_SIZE, GFP_KERNEL); 2837 IWL_MAX_SCAN_SIZE, GFP_KERNEL);
2883 if (!priv->scan_cmd) { 2838 if (!priv->scan_cmd) {
2884 IWL_DEBUG_SCAN(priv, "Fail to allocate scan memory\n"); 2839 IWL_DEBUG_SCAN(priv, "Fail to allocate scan memory\n");
2885 goto done; 2840 return -ENOMEM;
2886 } 2841 }
2887 } 2842 }
2888 scan = priv->scan_cmd; 2843 scan = priv->scan_cmd;
@@ -2977,7 +2932,7 @@ void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
2977 break; 2932 break;
2978 default: 2933 default:
2979 IWL_WARN(priv, "Invalid scan band\n"); 2934 IWL_WARN(priv, "Invalid scan band\n");
2980 goto done; 2935 return -EIO;
2981 } 2936 }
2982 2937
2983 if (!priv->is_internal_short_scan) { 2938 if (!priv->is_internal_short_scan) {
@@ -3012,7 +2967,7 @@ void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
3012 2967
3013 if (scan->channel_count == 0) { 2968 if (scan->channel_count == 0) {
3014 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); 2969 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count);
3015 goto done; 2970 return -EIO;
3016 } 2971 }
3017 2972
3018 cmd.len += le16_to_cpu(scan->tx_cmd.len) + 2973 cmd.len += le16_to_cpu(scan->tx_cmd.len) +
@@ -3021,25 +2976,10 @@ void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
3021 scan->len = cpu_to_le16(cmd.len); 2976 scan->len = cpu_to_le16(cmd.len);
3022 2977
3023 set_bit(STATUS_SCAN_HW, &priv->status); 2978 set_bit(STATUS_SCAN_HW, &priv->status);
3024 if (iwl_send_cmd_sync(priv, &cmd)) 2979 ret = iwl_send_cmd_sync(priv, &cmd);
3025 goto done; 2980 if (ret)
3026 2981 clear_bit(STATUS_SCAN_HW, &priv->status);
3027 queue_delayed_work(priv->workqueue, &priv->scan_check, 2982 return ret;
3028 IWL_SCAN_CHECK_WATCHDOG);
3029
3030 return;
3031
3032 done:
3033 /* can not perform scan make sure we clear scanning
3034 * bits from status so next scan request can be performed.
3035 * if we dont clear scanning status bit here all next scan
3036 * will fail
3037 */
3038 clear_bit(STATUS_SCAN_HW, &priv->status);
3039 clear_bit(STATUS_SCANNING, &priv->status);
3040
3041 /* inform mac80211 scan aborted */
3042 queue_work(priv->workqueue, &priv->scan_completed);
3043} 2983}
3044 2984
3045static void iwl3945_bg_restart(struct work_struct *data) 2985static void iwl3945_bg_restart(struct work_struct *data)
@@ -3233,15 +3173,6 @@ static void iwl3945_mac_stop(struct ieee80211_hw *hw)
3233 3173
3234 priv->is_open = 0; 3174 priv->is_open = 0;
3235 3175
3236 if (iwl_is_ready_rf(priv)) {
3237 /* stop mac, cancel any scan request and clear
3238 * RXON_FILTER_ASSOC_MSK BIT
3239 */
3240 mutex_lock(&priv->mutex);
3241 iwl_scan_cancel_timeout(priv, 100);
3242 mutex_unlock(&priv->mutex);
3243 }
3244
3245 iwl3945_down(priv); 3176 iwl3945_down(priv);
3246 3177
3247 flush_workqueue(priv->workqueue); 3178 flush_workqueue(priv->workqueue);
@@ -3831,10 +3762,10 @@ static void iwl3945_cancel_deferred_work(struct iwl_priv *priv)
3831 iwl3945_hw_cancel_deferred_work(priv); 3762 iwl3945_hw_cancel_deferred_work(priv);
3832 3763
3833 cancel_delayed_work_sync(&priv->init_alive_start); 3764 cancel_delayed_work_sync(&priv->init_alive_start);
3834 cancel_delayed_work(&priv->scan_check);
3835 cancel_delayed_work(&priv->alive_start); 3765 cancel_delayed_work(&priv->alive_start);
3836 cancel_work_sync(&priv->start_internal_scan);
3837 cancel_work_sync(&priv->beacon_update); 3766 cancel_work_sync(&priv->beacon_update);
3767
3768 iwl_cancel_scan_deferred_work(priv);
3838} 3769}
3839 3770
3840static struct attribute *iwl3945_sysfs_entries[] = { 3771static struct attribute *iwl3945_sysfs_entries[] = {