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