aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-12-06 01:23:34 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-06 01:23:34 -0500
commit098401a600b6344771900fe164c5eafb668ce99c (patch)
treec03077ee357cf6191bcd9f44ead4e6e4ce8f0495 /drivers/net/wireless/iwlwifi
parentcb7b48f671f9c7582993a6c0ff6e989078048561 (diff)
parentc112d0c5b89037dd618083b5fdf4bb36b0c51d77 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6
Diffstat (limited to 'drivers/net/wireless/iwlwifi')
-rw-r--r--drivers/net/wireless/iwlwifi/Makefile2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-commands.h140
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-core.h26
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.c145
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c43
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h18
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c26
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c111
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-hcmd-check.c108
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c232
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h234
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c26
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h38
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debug.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c76
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h15
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c11
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c130
19 files changed, 864 insertions, 519 deletions
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index 8b45b30e6d5c..0be9e6b66aa0 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -8,7 +8,7 @@ iwlcore-$(CONFIG_IWLWIFI_RFKILL) += iwl-rfkill.o
8iwlcore-$(CONFIG_IWLAGN_SPECTRUM_MEASUREMENT) += iwl-spectrum.o 8iwlcore-$(CONFIG_IWLAGN_SPECTRUM_MEASUREMENT) += iwl-spectrum.o
9 9
10obj-$(CONFIG_IWLAGN) += iwlagn.o 10obj-$(CONFIG_IWLAGN) += iwlagn.o
11iwlagn-objs := iwl-agn.o iwl-agn-rs.o 11iwlagn-objs := iwl-agn.o iwl-agn-rs.o iwl-agn-hcmd-check.o
12 12
13iwlagn-$(CONFIG_IWL4965) += iwl-4965.o 13iwlagn-$(CONFIG_IWL4965) += iwl-4965.o
14iwlagn-$(CONFIG_IWL5000) += iwl-5000.o 14iwlagn-$(CONFIG_IWL5000) += iwl-5000.o
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-commands.h b/drivers/net/wireless/iwlwifi/iwl-3945-commands.h
index 8772d9d7d6e7..daf99ea88e90 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-commands.h
@@ -69,6 +69,12 @@
69#ifndef __iwl_3945_commands_h__ 69#ifndef __iwl_3945_commands_h__
70#define __iwl_3945_commands_h__ 70#define __iwl_3945_commands_h__
71 71
72/* uCode version contains 4 values: Major/Minor/API/Serial */
73#define IWL_UCODE_MAJOR(ver) (((ver) & 0xFF000000) >> 24)
74#define IWL_UCODE_MINOR(ver) (((ver) & 0x00FF0000) >> 16)
75#define IWL_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8)
76#define IWL_UCODE_SERIAL(ver) ((ver) & 0x000000FF)
77
72enum { 78enum {
73 REPLY_ALIVE = 0x1, 79 REPLY_ALIVE = 0x1,
74 REPLY_ERROR = 0x2, 80 REPLY_ERROR = 0x2,
@@ -220,7 +226,7 @@ struct iwl3945_power_per_rate {
220 * 226 *
221 *****************************************************************************/ 227 *****************************************************************************/
222 228
223#define UCODE_VALID_OK __constant_cpu_to_le32(0x1) 229#define UCODE_VALID_OK cpu_to_le32(0x1)
224#define INITIALIZE_SUBTYPE (9) 230#define INITIALIZE_SUBTYPE (9)
225 231
226/* 232/*
@@ -322,42 +328,42 @@ enum {
322 328
323/* rx_config flags */ 329/* rx_config flags */
324/* band & modulation selection */ 330/* band & modulation selection */
325#define RXON_FLG_BAND_24G_MSK __constant_cpu_to_le32(1 << 0) 331#define RXON_FLG_BAND_24G_MSK cpu_to_le32(1 << 0)
326#define RXON_FLG_CCK_MSK __constant_cpu_to_le32(1 << 1) 332#define RXON_FLG_CCK_MSK cpu_to_le32(1 << 1)
327/* auto detection enable */ 333/* auto detection enable */
328#define RXON_FLG_AUTO_DETECT_MSK __constant_cpu_to_le32(1 << 2) 334#define RXON_FLG_AUTO_DETECT_MSK cpu_to_le32(1 << 2)
329/* TGg protection when tx */ 335/* TGg protection when tx */
330#define RXON_FLG_TGG_PROTECT_MSK __constant_cpu_to_le32(1 << 3) 336#define RXON_FLG_TGG_PROTECT_MSK cpu_to_le32(1 << 3)
331/* cck short slot & preamble */ 337/* cck short slot & preamble */
332#define RXON_FLG_SHORT_SLOT_MSK __constant_cpu_to_le32(1 << 4) 338#define RXON_FLG_SHORT_SLOT_MSK cpu_to_le32(1 << 4)
333#define RXON_FLG_SHORT_PREAMBLE_MSK __constant_cpu_to_le32(1 << 5) 339#define RXON_FLG_SHORT_PREAMBLE_MSK cpu_to_le32(1 << 5)
334/* antenna selection */ 340/* antenna selection */
335#define RXON_FLG_DIS_DIV_MSK __constant_cpu_to_le32(1 << 7) 341#define RXON_FLG_DIS_DIV_MSK cpu_to_le32(1 << 7)
336#define RXON_FLG_ANT_SEL_MSK __constant_cpu_to_le32(0x0f00) 342#define RXON_FLG_ANT_SEL_MSK cpu_to_le32(0x0f00)
337#define RXON_FLG_ANT_A_MSK __constant_cpu_to_le32(1 << 8) 343#define RXON_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
338#define RXON_FLG_ANT_B_MSK __constant_cpu_to_le32(1 << 9) 344#define RXON_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
339/* radar detection enable */ 345/* radar detection enable */
340#define RXON_FLG_RADAR_DETECT_MSK __constant_cpu_to_le32(1 << 12) 346#define RXON_FLG_RADAR_DETECT_MSK cpu_to_le32(1 << 12)
341#define RXON_FLG_TGJ_NARROW_BAND_MSK __constant_cpu_to_le32(1 << 13) 347#define RXON_FLG_TGJ_NARROW_BAND_MSK cpu_to_le32(1 << 13)
342/* rx response to host with 8-byte TSF 348/* rx response to host with 8-byte TSF
343* (according to ON_AIR deassertion) */ 349* (according to ON_AIR deassertion) */
344#define RXON_FLG_TSF2HOST_MSK __constant_cpu_to_le32(1 << 15) 350#define RXON_FLG_TSF2HOST_MSK cpu_to_le32(1 << 15)
345 351
346/* rx_config filter flags */ 352/* rx_config filter flags */
347/* accept all data frames */ 353/* accept all data frames */
348#define RXON_FILTER_PROMISC_MSK __constant_cpu_to_le32(1 << 0) 354#define RXON_FILTER_PROMISC_MSK cpu_to_le32(1 << 0)
349/* pass control & management to host */ 355/* pass control & management to host */
350#define RXON_FILTER_CTL2HOST_MSK __constant_cpu_to_le32(1 << 1) 356#define RXON_FILTER_CTL2HOST_MSK cpu_to_le32(1 << 1)
351/* accept multi-cast */ 357/* accept multi-cast */
352#define RXON_FILTER_ACCEPT_GRP_MSK __constant_cpu_to_le32(1 << 2) 358#define RXON_FILTER_ACCEPT_GRP_MSK cpu_to_le32(1 << 2)
353/* don't decrypt uni-cast frames */ 359/* don't decrypt uni-cast frames */
354#define RXON_FILTER_DIS_DECRYPT_MSK __constant_cpu_to_le32(1 << 3) 360#define RXON_FILTER_DIS_DECRYPT_MSK cpu_to_le32(1 << 3)
355/* don't decrypt multi-cast frames */ 361/* don't decrypt multi-cast frames */
356#define RXON_FILTER_DIS_GRP_DECRYPT_MSK __constant_cpu_to_le32(1 << 4) 362#define RXON_FILTER_DIS_GRP_DECRYPT_MSK cpu_to_le32(1 << 4)
357/* STA is associated */ 363/* STA is associated */
358#define RXON_FILTER_ASSOC_MSK __constant_cpu_to_le32(1 << 5) 364#define RXON_FILTER_ASSOC_MSK cpu_to_le32(1 << 5)
359/* transfer to host non bssid beacons in associated state */ 365/* transfer to host non bssid beacons in associated state */
360#define RXON_FILTER_BCON_AWARE_MSK __constant_cpu_to_le32(1 << 6) 366#define RXON_FILTER_BCON_AWARE_MSK cpu_to_le32(1 << 6)
361 367
362/** 368/**
363 * REPLY_RXON = 0x10 (command, has simple generic response) 369 * REPLY_RXON = 0x10 (command, has simple generic response)
@@ -471,9 +477,9 @@ struct iwl3945_ac_qos {
471} __attribute__ ((packed)); 477} __attribute__ ((packed));
472 478
473/* QoS flags defines */ 479/* QoS flags defines */
474#define QOS_PARAM_FLG_UPDATE_EDCA_MSK __constant_cpu_to_le32(0x01) 480#define QOS_PARAM_FLG_UPDATE_EDCA_MSK cpu_to_le32(0x01)
475#define QOS_PARAM_FLG_TGN_MSK __constant_cpu_to_le32(0x02) 481#define QOS_PARAM_FLG_TGN_MSK cpu_to_le32(0x02)
476#define QOS_PARAM_FLG_TXOP_TYPE_MSK __constant_cpu_to_le32(0x10) 482#define QOS_PARAM_FLG_TXOP_TYPE_MSK cpu_to_le32(0x10)
477 483
478/* Number of Access Categories (AC) (EDCA), queues 0..3 */ 484/* Number of Access Categories (AC) (EDCA), queues 0..3 */
479#define AC_NUM 4 485#define AC_NUM 4
@@ -508,27 +514,27 @@ struct iwl3945_qosparam_cmd {
508#define IWL_STATION_COUNT 32 /* MAX(3945,4965)*/ 514#define IWL_STATION_COUNT 32 /* MAX(3945,4965)*/
509#define IWL_INVALID_STATION 255 515#define IWL_INVALID_STATION 255
510 516
511#define STA_FLG_TX_RATE_MSK __constant_cpu_to_le32(1 << 2); 517#define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2);
512#define STA_FLG_PWR_SAVE_MSK __constant_cpu_to_le32(1 << 8); 518#define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8);
513 519
514/* Use in mode field. 1: modify existing entry, 0: add new station entry */ 520/* Use in mode field. 1: modify existing entry, 0: add new station entry */
515#define STA_CONTROL_MODIFY_MSK 0x01 521#define STA_CONTROL_MODIFY_MSK 0x01
516 522
517/* key flags __le16*/ 523/* key flags __le16*/
518#define STA_KEY_FLG_ENCRYPT_MSK __constant_cpu_to_le16(0x0007) 524#define STA_KEY_FLG_ENCRYPT_MSK cpu_to_le16(0x0007)
519#define STA_KEY_FLG_NO_ENC __constant_cpu_to_le16(0x0000) 525#define STA_KEY_FLG_NO_ENC cpu_to_le16(0x0000)
520#define STA_KEY_FLG_WEP __constant_cpu_to_le16(0x0001) 526#define STA_KEY_FLG_WEP cpu_to_le16(0x0001)
521#define STA_KEY_FLG_CCMP __constant_cpu_to_le16(0x0002) 527#define STA_KEY_FLG_CCMP cpu_to_le16(0x0002)
522#define STA_KEY_FLG_TKIP __constant_cpu_to_le16(0x0003) 528#define STA_KEY_FLG_TKIP cpu_to_le16(0x0003)
523 529
524#define STA_KEY_FLG_KEYID_POS 8 530#define STA_KEY_FLG_KEYID_POS 8
525#define STA_KEY_FLG_INVALID __constant_cpu_to_le16(0x0800) 531#define STA_KEY_FLG_INVALID cpu_to_le16(0x0800)
526/* wep key is either from global key (0) or from station info array (1) */ 532/* wep key is either from global key (0) or from station info array (1) */
527#define STA_KEY_FLG_WEP_KEY_MAP_MSK __constant_cpu_to_le16(0x0008) 533#define STA_KEY_FLG_WEP_KEY_MAP_MSK cpu_to_le16(0x0008)
528 534
529/* wep key in STA: 5-bytes (0) or 13-bytes (1) */ 535/* wep key in STA: 5-bytes (0) or 13-bytes (1) */
530#define STA_KEY_FLG_KEY_SIZE_MSK __constant_cpu_to_le16(0x1000) 536#define STA_KEY_FLG_KEY_SIZE_MSK cpu_to_le16(0x1000)
531#define STA_KEY_MULTICAST_MSK __constant_cpu_to_le16(0x4000) 537#define STA_KEY_MULTICAST_MSK cpu_to_le16(0x4000)
532 538
533/* Flags indicate whether to modify vs. don't change various station params */ 539/* Flags indicate whether to modify vs. don't change various station params */
534#define STA_MODIFY_KEY_MASK 0x01 540#define STA_MODIFY_KEY_MASK 0x01
@@ -666,14 +672,14 @@ struct iwl3945_rx_frame_hdr {
666 u8 payload[0]; 672 u8 payload[0];
667} __attribute__ ((packed)); 673} __attribute__ ((packed));
668 674
669#define RX_RES_STATUS_NO_CRC32_ERROR __constant_cpu_to_le32(1 << 0) 675#define RX_RES_STATUS_NO_CRC32_ERROR cpu_to_le32(1 << 0)
670#define RX_RES_STATUS_NO_RXE_OVERFLOW __constant_cpu_to_le32(1 << 1) 676#define RX_RES_STATUS_NO_RXE_OVERFLOW cpu_to_le32(1 << 1)
671 677
672#define RX_RES_PHY_FLAGS_BAND_24_MSK __constant_cpu_to_le16(1 << 0) 678#define RX_RES_PHY_FLAGS_BAND_24_MSK cpu_to_le16(1 << 0)
673#define RX_RES_PHY_FLAGS_MOD_CCK_MSK __constant_cpu_to_le16(1 << 1) 679#define RX_RES_PHY_FLAGS_MOD_CCK_MSK cpu_to_le16(1 << 1)
674#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK __constant_cpu_to_le16(1 << 2) 680#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK cpu_to_le16(1 << 2)
675#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK __constant_cpu_to_le16(1 << 3) 681#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK cpu_to_le16(1 << 3)
676#define RX_RES_PHY_FLAGS_ANTENNA_MSK __constant_cpu_to_le16(0xf0) 682#define RX_RES_PHY_FLAGS_ANTENNA_MSK cpu_to_le16(0xf0)
677 683
678#define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8) 684#define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8)
679#define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8) 685#define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8)
@@ -733,57 +739,57 @@ struct iwl3945_rx_frame {
733 739
734/* 1: Use Request-To-Send protocol before this frame. 740/* 1: Use Request-To-Send protocol before this frame.
735 * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK. */ 741 * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK. */
736#define TX_CMD_FLG_RTS_MSK __constant_cpu_to_le32(1 << 1) 742#define TX_CMD_FLG_RTS_MSK cpu_to_le32(1 << 1)
737 743
738/* 1: Transmit Clear-To-Send to self before this frame. 744/* 1: Transmit Clear-To-Send to self before this frame.
739 * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames. 745 * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames.
740 * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK. */ 746 * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK. */
741#define TX_CMD_FLG_CTS_MSK __constant_cpu_to_le32(1 << 2) 747#define TX_CMD_FLG_CTS_MSK cpu_to_le32(1 << 2)
742 748
743/* 1: Expect ACK from receiving station 749/* 1: Expect ACK from receiving station
744 * 0: Don't expect ACK (MAC header's duration field s/b 0) 750 * 0: Don't expect ACK (MAC header's duration field s/b 0)
745 * Set this for unicast frames, but not broadcast/multicast. */ 751 * Set this for unicast frames, but not broadcast/multicast. */
746#define TX_CMD_FLG_ACK_MSK __constant_cpu_to_le32(1 << 3) 752#define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3)
747 753
748/* 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD). 754/* 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD).
749 * Tx command's initial_rate_index indicates first rate to try; 755 * Tx command's initial_rate_index indicates first rate to try;
750 * uCode walks through table for additional Tx attempts. 756 * uCode walks through table for additional Tx attempts.
751 * 0: Use Tx rate/MCS from Tx command's rate_n_flags field. 757 * 0: Use Tx rate/MCS from Tx command's rate_n_flags field.
752 * This rate will be used for all Tx attempts; it will not be scaled. */ 758 * This rate will be used for all Tx attempts; it will not be scaled. */
753#define TX_CMD_FLG_STA_RATE_MSK __constant_cpu_to_le32(1 << 4) 759#define TX_CMD_FLG_STA_RATE_MSK cpu_to_le32(1 << 4)
754 760
755/* 1: Expect immediate block-ack. 761/* 1: Expect immediate block-ack.
756 * Set when Txing a block-ack request frame. Also set TX_CMD_FLG_ACK_MSK. */ 762 * Set when Txing a block-ack request frame. Also set TX_CMD_FLG_ACK_MSK. */
757#define TX_CMD_FLG_IMM_BA_RSP_MASK __constant_cpu_to_le32(1 << 6) 763#define TX_CMD_FLG_IMM_BA_RSP_MASK cpu_to_le32(1 << 6)
758 764
759/* 1: Frame requires full Tx-Op protection. 765/* 1: Frame requires full Tx-Op protection.
760 * Set this if either RTS or CTS Tx Flag gets set. */ 766 * Set this if either RTS or CTS Tx Flag gets set. */
761#define TX_CMD_FLG_FULL_TXOP_PROT_MSK __constant_cpu_to_le32(1 << 7) 767#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7)
762 768
763/* Tx antenna selection field; used only for 3945, reserved (0) for 4965. 769/* Tx antenna selection field; used only for 3945, reserved (0) for 4965.
764 * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */ 770 * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */
765#define TX_CMD_FLG_ANT_SEL_MSK __constant_cpu_to_le32(0xf00) 771#define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00)
766#define TX_CMD_FLG_ANT_A_MSK __constant_cpu_to_le32(1 << 8) 772#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
767#define TX_CMD_FLG_ANT_B_MSK __constant_cpu_to_le32(1 << 9) 773#define TX_CMD_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
768 774
769/* 1: Ignore Bluetooth priority for this frame. 775/* 1: Ignore Bluetooth priority for this frame.
770 * 0: Delay Tx until Bluetooth device is done (normal usage). */ 776 * 0: Delay Tx until Bluetooth device is done (normal usage). */
771#define TX_CMD_FLG_BT_DIS_MSK __constant_cpu_to_le32(1 << 12) 777#define TX_CMD_FLG_BT_DIS_MSK cpu_to_le32(1 << 12)
772 778
773/* 1: uCode overrides sequence control field in MAC header. 779/* 1: uCode overrides sequence control field in MAC header.
774 * 0: Driver provides sequence control field in MAC header. 780 * 0: Driver provides sequence control field in MAC header.
775 * Set this for management frames, non-QOS data frames, non-unicast frames, 781 * Set this for management frames, non-QOS data frames, non-unicast frames,
776 * and also in Tx command embedded in REPLY_SCAN_CMD for active scans. */ 782 * and also in Tx command embedded in REPLY_SCAN_CMD for active scans. */
777#define TX_CMD_FLG_SEQ_CTL_MSK __constant_cpu_to_le32(1 << 13) 783#define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13)
778 784
779/* 1: This frame is non-last MPDU; more fragments are coming. 785/* 1: This frame is non-last MPDU; more fragments are coming.
780 * 0: Last fragment, or not using fragmentation. */ 786 * 0: Last fragment, or not using fragmentation. */
781#define TX_CMD_FLG_MORE_FRAG_MSK __constant_cpu_to_le32(1 << 14) 787#define TX_CMD_FLG_MORE_FRAG_MSK cpu_to_le32(1 << 14)
782 788
783/* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame. 789/* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame.
784 * 0: No TSF required in outgoing frame. 790 * 0: No TSF required in outgoing frame.
785 * Set this for transmitting beacons and probe responses. */ 791 * Set this for transmitting beacons and probe responses. */
786#define TX_CMD_FLG_TSF_MSK __constant_cpu_to_le32(1 << 16) 792#define TX_CMD_FLG_TSF_MSK cpu_to_le32(1 << 16)
787 793
788/* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword 794/* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword
789 * alignment of frame's payload data field. 795 * alignment of frame's payload data field.
@@ -791,10 +797,10 @@ struct iwl3945_rx_frame {
791 * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4 797 * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4
792 * field (but not both). Driver must align frame data (i.e. data following 798 * field (but not both). Driver must align frame data (i.e. data following
793 * MAC header) to DWORD boundary. */ 799 * MAC header) to DWORD boundary. */
794#define TX_CMD_FLG_MH_PAD_MSK __constant_cpu_to_le32(1 << 20) 800#define TX_CMD_FLG_MH_PAD_MSK cpu_to_le32(1 << 20)
795 801
796/* HCCA-AP - disable duration overwriting. */ 802/* HCCA-AP - disable duration overwriting. */
797#define TX_CMD_FLG_DUR_MSK __constant_cpu_to_le32(1 << 25) 803#define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25)
798 804
799/* 805/*
800 * TX command security control 806 * TX command security control
@@ -1158,9 +1164,9 @@ struct iwl3945_spectrum_notification {
1158 */ 1164 */
1159#define IWL_POWER_VEC_SIZE 5 1165#define IWL_POWER_VEC_SIZE 5
1160 1166
1161#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK __constant_cpu_to_le32(1 << 0) 1167#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le32(1 << 0)
1162#define IWL_POWER_SLEEP_OVER_DTIM_MSK __constant_cpu_to_le32(1 << 2) 1168#define IWL_POWER_SLEEP_OVER_DTIM_MSK cpu_to_le32(1 << 2)
1163#define IWL_POWER_PCI_PM_MSK __constant_cpu_to_le32(1 << 3) 1169#define IWL_POWER_PCI_PM_MSK cpu_to_le32(1 << 3)
1164struct iwl3945_powertable_cmd { 1170struct iwl3945_powertable_cmd {
1165 __le32 flags; 1171 __le32 flags;
1166 __le32 rx_data_timeout; 1172 __le32 rx_data_timeout;
@@ -1278,8 +1284,8 @@ struct iwl3945_ssid_ie {
1278} __attribute__ ((packed)); 1284} __attribute__ ((packed));
1279 1285
1280#define PROBE_OPTION_MAX 0x4 1286#define PROBE_OPTION_MAX 0x4
1281#define TX_CMD_LIFE_TIME_INFINITE __constant_cpu_to_le32(0xFFFFFFFF) 1287#define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF)
1282#define IWL_GOOD_CRC_TH __constant_cpu_to_le16(1) 1288#define IWL_GOOD_CRC_TH cpu_to_le16(1)
1283#define IWL_MAX_SCAN_SIZE 1024 1289#define IWL_MAX_SCAN_SIZE 1024
1284 1290
1285/* 1291/*
@@ -1379,7 +1385,7 @@ struct iwl3945_scan_cmd {
1379} __attribute__ ((packed)); 1385} __attribute__ ((packed));
1380 1386
1381/* Can abort will notify by complete notification with abort status. */ 1387/* Can abort will notify by complete notification with abort status. */
1382#define CAN_ABORT_STATUS __constant_cpu_to_le32(0x1) 1388#define CAN_ABORT_STATUS cpu_to_le32(0x1)
1383/* complete notification statuses */ 1389/* complete notification statuses */
1384#define ABORT_STATUS 0x2 1390#define ABORT_STATUS 0x2
1385 1391
@@ -1572,8 +1578,8 @@ struct statistics_general {
1572 * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag 1578 * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag
1573 * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself. 1579 * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
1574 */ 1580 */
1575#define IWL_STATS_CONF_CLEAR_STATS __constant_cpu_to_le32(0x1) /* see above */ 1581#define IWL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */
1576#define IWL_STATS_CONF_DISABLE_NOTIF __constant_cpu_to_le32(0x2)/* see above */ 1582#define IWL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */
1577struct iwl3945_statistics_cmd { 1583struct iwl3945_statistics_cmd {
1578 __le32 configuration_flags; /* IWL_STATS_CONF_* */ 1584 __le32 configuration_flags; /* IWL_STATS_CONF_* */
1579} __attribute__ ((packed)); 1585} __attribute__ ((packed));
@@ -1593,8 +1599,8 @@ struct iwl3945_statistics_cmd {
1593 * appropriately so that each notification contains statistics for only the 1599 * appropriately so that each notification contains statistics for only the
1594 * one channel that has just been scanned. 1600 * one channel that has just been scanned.
1595 */ 1601 */
1596#define STATISTICS_REPLY_FLG_BAND_24G_MSK __constant_cpu_to_le32(0x2) 1602#define STATISTICS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2)
1597#define STATISTICS_REPLY_FLG_FAT_MODE_MSK __constant_cpu_to_le32(0x8) 1603#define STATISTICS_REPLY_FLG_FAT_MODE_MSK cpu_to_le32(0x8)
1598struct iwl3945_notif_statistics { 1604struct iwl3945_notif_statistics {
1599 __le32 flag; 1605 __le32 flag;
1600 struct statistics_rx rx; 1606 struct statistics_rx rx;
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-core.h b/drivers/net/wireless/iwlwifi/iwl-3945-core.h
index bc12f97ba0b1..edac6c6a9110 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-core.h
@@ -71,9 +71,33 @@
71#define IWL_SKU_G 0x1 71#define IWL_SKU_G 0x1
72#define IWL_SKU_A 0x2 72#define IWL_SKU_A 0x2
73 73
74/**
75 * struct iwl_3945_cfg
76 * @fw_name_pre: Firmware filename prefix. The api version and extension
77 * (.ucode) will be added to filename before loading from disk. The
78 * filename is constructed as fw_name_pre<api>.ucode.
79 * @ucode_api_max: Highest version of uCode API supported by driver.
80 * @ucode_api_min: Lowest version of uCode API supported by driver.
81 *
82 * We enable the driver to be backward compatible wrt API version. The
83 * driver specifies which APIs it supports (with @ucode_api_max being the
84 * highest and @ucode_api_min the lowest). Firmware will only be loaded if
85 * it has a supported API version. The firmware's API version will be
86 * stored in @iwl_priv, enabling the driver to make runtime changes based
87 * on firmware version used.
88 *
89 * For example,
90 * if (IWL_UCODE_API(priv->ucode_ver) >= 2) {
91 * Driver interacts with Firmware API version >= 2.
92 * } else {
93 * Driver interacts with Firmware API version 1.
94 * }
95 */
74struct iwl_3945_cfg { 96struct iwl_3945_cfg {
75 const char *name; 97 const char *name;
76 const char *fw_name; 98 const char *fw_name_pre;
99 const unsigned int ucode_api_max;
100 const unsigned int ucode_api_min;
77 unsigned int sku; 101 unsigned int sku;
78}; 102};
79 103
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index bfeef701b1fd..b03dd06ceabf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -63,6 +63,9 @@ struct iwl3945_rs_sta {
63 u8 ibss_sta_added; 63 u8 ibss_sta_added;
64 struct timer_list rate_scale_flush; 64 struct timer_list rate_scale_flush;
65 struct iwl3945_rate_scale_data win[IWL_RATE_COUNT]; 65 struct iwl3945_rate_scale_data win[IWL_RATE_COUNT];
66#ifdef CONFIG_MAC80211_DEBUGFS
67 struct dentry *rs_sta_dbgfs_stats_table_file;
68#endif
66 69
67 /* used to be in sta_info */ 70 /* used to be in sta_info */
68 int last_txrate_idx; 71 int last_txrate_idx;
@@ -114,9 +117,11 @@ static struct iwl3945_tpt_entry iwl3945_tpt_table_g[] = {
114}; 117};
115 118
116#define IWL_RATE_MAX_WINDOW 62 119#define IWL_RATE_MAX_WINDOW 62
117#define IWL_RATE_FLUSH (3*HZ/10) 120#define IWL_RATE_FLUSH (3*HZ)
118#define IWL_RATE_WIN_FLUSH (HZ/2) 121#define IWL_RATE_WIN_FLUSH (HZ/2)
119#define IWL_RATE_HIGH_TH 11520 122#define IWL_RATE_HIGH_TH 11520
123#define IWL_SUCCESS_UP_TH 8960
124#define IWL_SUCCESS_DOWN_TH 10880
120#define IWL_RATE_MIN_FAILURE_TH 8 125#define IWL_RATE_MIN_FAILURE_TH 8
121#define IWL_RATE_MIN_SUCCESS_TH 8 126#define IWL_RATE_MIN_SUCCESS_TH 8
122#define IWL_RATE_DECREASE_TH 1920 127#define IWL_RATE_DECREASE_TH 1920
@@ -203,6 +208,7 @@ static int iwl3945_rate_scale_flush_windows(struct iwl3945_rs_sta *rs_sta)
203 208
204#define IWL_RATE_FLUSH_MAX 5000 /* msec */ 209#define IWL_RATE_FLUSH_MAX 5000 /* msec */
205#define IWL_RATE_FLUSH_MIN 50 /* msec */ 210#define IWL_RATE_FLUSH_MIN 50 /* msec */
211#define IWL_AVERAGE_PACKETS 1500
206 212
207static void iwl3945_bg_rate_scale_flush(unsigned long data) 213static void iwl3945_bg_rate_scale_flush(unsigned long data)
208{ 214{
@@ -217,8 +223,6 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)
217 223
218 spin_lock_irqsave(&rs_sta->lock, flags); 224 spin_lock_irqsave(&rs_sta->lock, flags);
219 225
220 rs_sta->flush_pending = 0;
221
222 /* Number of packets Rx'd since last time this timer ran */ 226 /* Number of packets Rx'd since last time this timer ran */
223 packet_count = (rs_sta->tx_packets - rs_sta->last_tx_packets) + 1; 227 packet_count = (rs_sta->tx_packets - rs_sta->last_tx_packets) + 1;
224 228
@@ -227,7 +231,6 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)
227 if (unflushed) { 231 if (unflushed) {
228 duration = 232 duration =
229 jiffies_to_msecs(jiffies - rs_sta->last_partial_flush); 233 jiffies_to_msecs(jiffies - rs_sta->last_partial_flush);
230/* duration = jiffies_to_msecs(rs_sta->flush_time); */
231 234
232 IWL_DEBUG_RATE("Tx'd %d packets in %dms\n", 235 IWL_DEBUG_RATE("Tx'd %d packets in %dms\n",
233 packet_count, duration); 236 packet_count, duration);
@@ -239,9 +242,11 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)
239 pps = 0; 242 pps = 0;
240 243
241 if (pps) { 244 if (pps) {
242 duration = IWL_RATE_FLUSH_MAX / pps; 245 duration = (IWL_AVERAGE_PACKETS * 1000) / pps;
243 if (duration < IWL_RATE_FLUSH_MIN) 246 if (duration < IWL_RATE_FLUSH_MIN)
244 duration = IWL_RATE_FLUSH_MIN; 247 duration = IWL_RATE_FLUSH_MIN;
248 else if (duration > IWL_RATE_FLUSH_MAX)
249 duration = IWL_RATE_FLUSH_MAX;
245 } else 250 } else
246 duration = IWL_RATE_FLUSH_MAX; 251 duration = IWL_RATE_FLUSH_MAX;
247 252
@@ -254,8 +259,10 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)
254 rs_sta->flush_time); 259 rs_sta->flush_time);
255 260
256 rs_sta->last_partial_flush = jiffies; 261 rs_sta->last_partial_flush = jiffies;
262 } else {
263 rs_sta->flush_time = IWL_RATE_FLUSH;
264 rs_sta->flush_pending = 0;
257 } 265 }
258
259 /* If there weren't any unflushed entries, we don't schedule the timer 266 /* If there weren't any unflushed entries, we don't schedule the timer
260 * to run again */ 267 * to run again */
261 268
@@ -275,17 +282,18 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)
275 */ 282 */
276static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta, 283static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta,
277 struct iwl3945_rate_scale_data *window, 284 struct iwl3945_rate_scale_data *window,
278 int success, int retries) 285 int success, int retries, int index)
279{ 286{
280 unsigned long flags; 287 unsigned long flags;
288 s32 fail_count;
281 289
282 if (!retries) { 290 if (!retries) {
283 IWL_DEBUG_RATE("leave: retries == 0 -- should be at least 1\n"); 291 IWL_DEBUG_RATE("leave: retries == 0 -- should be at least 1\n");
284 return; 292 return;
285 } 293 }
286 294
295 spin_lock_irqsave(&rs_sta->lock, flags);
287 while (retries--) { 296 while (retries--) {
288 spin_lock_irqsave(&rs_sta->lock, flags);
289 297
290 /* If we have filled up the window then subtract one from the 298 /* If we have filled up the window then subtract one from the
291 * success counter if the high-bit is counting toward 299 * success counter if the high-bit is counting toward
@@ -313,8 +321,18 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta,
313 /* Tag this window as having been updated */ 321 /* Tag this window as having been updated */
314 window->stamp = jiffies; 322 window->stamp = jiffies;
315 323
316 spin_unlock_irqrestore(&rs_sta->lock, flags);
317 } 324 }
325
326 fail_count = window->counter - window->success_counter;
327 if ((fail_count >= IWL_RATE_MIN_FAILURE_TH) ||
328 (window->success_counter >= IWL_RATE_MIN_SUCCESS_TH))
329 window->average_tpt = ((window->success_ratio *
330 rs_sta->expected_tpt[index] + 64) / 128);
331 else
332 window->average_tpt = IWL_INV_TPT;
333
334 spin_unlock_irqrestore(&rs_sta->lock, flags);
335
318} 336}
319 337
320static void rs_rate_init(void *priv, struct ieee80211_supported_band *sband, 338static void rs_rate_init(void *priv, struct ieee80211_supported_band *sband,
@@ -426,19 +444,16 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
426 struct ieee80211_sta *sta, void *priv_sta, 444 struct ieee80211_sta *sta, void *priv_sta,
427 struct sk_buff *skb) 445 struct sk_buff *skb)
428{ 446{
429 u8 retries = 0, current_count; 447 s8 retries = 0, current_count;
430 int scale_rate_index, first_index, last_index; 448 int scale_rate_index, first_index, last_index;
431 unsigned long flags; 449 unsigned long flags;
432 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; 450 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate;
433 struct iwl3945_rs_sta *rs_sta = priv_sta; 451 struct iwl3945_rs_sta *rs_sta = priv_sta;
434 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 452 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
435 int i;
436 453
437 IWL_DEBUG_RATE("enter\n"); 454 IWL_DEBUG_RATE("enter\n");
438 455
439 for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) 456 retries = info->status.rates[0].count;
440 retries += info->status.rates[i].count;
441 retries--;
442 457
443 first_index = sband->bitrates[info->status.rates[0].idx].hw_value; 458 first_index = sband->bitrates[info->status.rates[0].idx].hw_value;
444 if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { 459 if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) {
@@ -466,9 +481,9 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
466 * at which the frame was finally transmitted (or failed if no 481 * at which the frame was finally transmitted (or failed if no
467 * ACK) 482 * ACK)
468 */ 483 */
469 while (retries > 0) { 484 while (retries > 1) {
470 if (retries < priv->retry_rate) { 485 if ((retries - 1) < priv->retry_rate) {
471 current_count = retries; 486 current_count = (retries - 1);
472 last_index = scale_rate_index; 487 last_index = scale_rate_index;
473 } else { 488 } else {
474 current_count = priv->retry_rate; 489 current_count = priv->retry_rate;
@@ -480,15 +495,13 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
480 * as was used for it (per current_count) */ 495 * as was used for it (per current_count) */
481 iwl3945_collect_tx_data(rs_sta, 496 iwl3945_collect_tx_data(rs_sta,
482 &rs_sta->win[scale_rate_index], 497 &rs_sta->win[scale_rate_index],
483 0, current_count); 498 0, current_count, scale_rate_index);
484 IWL_DEBUG_RATE("Update rate %d for %d retries.\n", 499 IWL_DEBUG_RATE("Update rate %d for %d retries.\n",
485 scale_rate_index, current_count); 500 scale_rate_index, current_count);
486 501
487 retries -= current_count; 502 retries -= current_count;
488 503
489 if (retries) 504 scale_rate_index = last_index;
490 scale_rate_index =
491 iwl3945_rs_next_rate(priv, scale_rate_index);
492 } 505 }
493 506
494 507
@@ -499,7 +512,7 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
499 "success" : "failure"); 512 "success" : "failure");
500 iwl3945_collect_tx_data(rs_sta, 513 iwl3945_collect_tx_data(rs_sta,
501 &rs_sta->win[last_index], 514 &rs_sta->win[last_index],
502 info->flags & IEEE80211_TX_STAT_ACK, 1); 515 info->flags & IEEE80211_TX_STAT_ACK, 1, last_index);
503 516
504 /* We updated the rate scale window -- if its been more than 517 /* We updated the rate scale window -- if its been more than
505 * flush_time since the last run, schedule the flush 518 * flush_time since the last run, schedule the flush
@@ -507,9 +520,10 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
507 spin_lock_irqsave(&rs_sta->lock, flags); 520 spin_lock_irqsave(&rs_sta->lock, flags);
508 521
509 if (!rs_sta->flush_pending && 522 if (!rs_sta->flush_pending &&
510 time_after(jiffies, rs_sta->last_partial_flush + 523 time_after(jiffies, rs_sta->last_flush +
511 rs_sta->flush_time)) { 524 rs_sta->flush_time)) {
512 525
526 rs_sta->last_partial_flush = jiffies;
513 rs_sta->flush_pending = 1; 527 rs_sta->flush_pending = 1;
514 mod_timer(&rs_sta->rate_scale_flush, 528 mod_timer(&rs_sta->rate_scale_flush,
515 jiffies + rs_sta->flush_time); 529 jiffies + rs_sta->flush_time);
@@ -657,8 +671,13 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
657 671
658 spin_lock_irqsave(&rs_sta->lock, flags); 672 spin_lock_irqsave(&rs_sta->lock, flags);
659 673
674 /* for recent assoc, choose best rate regarding
675 * to rssi value
676 */
660 if (rs_sta->start_rate != IWL_RATE_INVALID) { 677 if (rs_sta->start_rate != IWL_RATE_INVALID) {
661 index = rs_sta->start_rate; 678 if (rs_sta->start_rate < index &&
679 (rate_mask & (1 << rs_sta->start_rate)))
680 index = rs_sta->start_rate;
662 rs_sta->start_rate = IWL_RATE_INVALID; 681 rs_sta->start_rate = IWL_RATE_INVALID;
663 } 682 }
664 683
@@ -668,7 +687,6 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
668 687
669 if (((fail_count <= IWL_RATE_MIN_FAILURE_TH) && 688 if (((fail_count <= IWL_RATE_MIN_FAILURE_TH) &&
670 (window->success_counter < IWL_RATE_MIN_SUCCESS_TH))) { 689 (window->success_counter < IWL_RATE_MIN_SUCCESS_TH))) {
671 window->average_tpt = IWL_INV_TPT;
672 spin_unlock_irqrestore(&rs_sta->lock, flags); 690 spin_unlock_irqrestore(&rs_sta->lock, flags);
673 691
674 IWL_DEBUG_RATE("Invalid average_tpt on rate %d: " 692 IWL_DEBUG_RATE("Invalid average_tpt on rate %d: "
@@ -682,8 +700,6 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
682 700
683 } 701 }
684 702
685 window->average_tpt = ((window->success_ratio *
686 rs_sta->expected_tpt[index] + 64) / 128);
687 current_tpt = window->average_tpt; 703 current_tpt = window->average_tpt;
688 704
689 high_low = iwl3945_get_adjacent_rate(rs_sta, index, rate_mask, 705 high_low = iwl3945_get_adjacent_rate(rs_sta, index, rate_mask,
@@ -731,13 +747,15 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
731 } 747 }
732 } 748 }
733 749
734 if ((window->success_ratio > IWL_RATE_HIGH_TH) || 750 if (scale_action == -1) {
735 (current_tpt > window->average_tpt)) { 751 if (window->success_ratio > IWL_SUCCESS_DOWN_TH)
736 IWL_DEBUG_RATE("No action -- success_ratio [%d] > HIGH_TH or " 752 scale_action = 0;
737 "current_tpt [%d] > average_tpt [%d]\n", 753 } else if (scale_action == 1) {
738 window->success_ratio, 754 if (window->success_ratio < IWL_SUCCESS_UP_TH) {
739 current_tpt, window->average_tpt); 755 IWL_DEBUG_RATE("No action -- success_ratio [%d] < "
740 scale_action = 0; 756 "SUCCESS UP\n", window->success_ratio);
757 scale_action = 0;
758 }
741 } 759 }
742 760
743 switch (scale_action) { 761 switch (scale_action) {
@@ -772,6 +790,60 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
772 IWL_DEBUG_RATE("leave: %d\n", index); 790 IWL_DEBUG_RATE("leave: %d\n", index);
773} 791}
774 792
793#ifdef CONFIG_MAC80211_DEBUGFS
794static int iwl3945_open_file_generic(struct inode *inode, struct file *file)
795{
796 file->private_data = inode->i_private;
797 return 0;
798}
799
800static ssize_t iwl3945_sta_dbgfs_stats_table_read(struct file *file,
801 char __user *user_buf,
802 size_t count, loff_t *ppos)
803{
804 char buff[1024];
805 int desc = 0;
806 int j;
807 struct iwl3945_rs_sta *lq_sta = file->private_data;
808
809 desc += sprintf(buff + desc, "tx packets=%d last rate index=%d\n"
810 "rate=0x%X flush time %d\n",
811 lq_sta->tx_packets,
812 lq_sta->last_txrate_idx,
813 lq_sta->start_rate, jiffies_to_msecs(lq_sta->flush_time));
814 for (j = 0; j < IWL_RATE_COUNT; j++) {
815 desc += sprintf(buff+desc,
816 "counter=%d success=%d %%=%d\n",
817 lq_sta->win[j].counter,
818 lq_sta->win[j].success_counter,
819 lq_sta->win[j].success_ratio);
820 }
821 return simple_read_from_buffer(user_buf, count, ppos, buff, desc);
822}
823
824static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
825 .read = iwl3945_sta_dbgfs_stats_table_read,
826 .open = iwl3945_open_file_generic,
827};
828
829static void iwl3945_add_debugfs(void *priv, void *priv_sta,
830 struct dentry *dir)
831{
832 struct iwl3945_rs_sta *lq_sta = priv_sta;
833
834 lq_sta->rs_sta_dbgfs_stats_table_file =
835 debugfs_create_file("rate_stats_table", 0600, dir,
836 lq_sta, &rs_sta_dbgfs_stats_table_ops);
837
838}
839
840static void iwl3945_remove_debugfs(void *priv, void *priv_sta)
841{
842 struct iwl3945_rs_sta *lq_sta = priv_sta;
843 debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file);
844}
845#endif
846
775static struct rate_control_ops rs_ops = { 847static struct rate_control_ops rs_ops = {
776 .module = NULL, 848 .module = NULL,
777 .name = RS_NAME, 849 .name = RS_NAME,
@@ -782,6 +854,11 @@ static struct rate_control_ops rs_ops = {
782 .free = rs_free, 854 .free = rs_free,
783 .alloc_sta = rs_alloc_sta, 855 .alloc_sta = rs_alloc_sta,
784 .free_sta = rs_free_sta, 856 .free_sta = rs_free_sta,
857#ifdef CONFIG_MAC80211_DEBUGFS
858 .add_sta_debugfs = iwl3945_add_debugfs,
859 .remove_sta_debugfs = iwl3945_remove_debugfs,
860#endif
861
785}; 862};
786 863
787void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) 864void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index af77ea70d737..4e6b7154c223 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -337,7 +337,7 @@ static void iwl3945_rx_reply_tx(struct iwl3945_priv *priv,
337 struct iwl3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; 337 struct iwl3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
338 u32 status = le32_to_cpu(tx_resp->status); 338 u32 status = le32_to_cpu(tx_resp->status);
339 int rate_idx; 339 int rate_idx;
340 int fail, i; 340 int fail;
341 341
342 if ((index >= txq->q.n_bd) || (iwl3945_x2_queue_used(&txq->q, index) == 0)) { 342 if ((index >= txq->q.n_bd) || (iwl3945_x2_queue_used(&txq->q, index) == 0)) {
343 IWL_ERROR("Read index for DMA queue txq_id (%d) index %d " 343 IWL_ERROR("Read index for DMA queue txq_id (%d) index %d "
@@ -356,27 +356,9 @@ static void iwl3945_rx_reply_tx(struct iwl3945_priv *priv,
356 rate_idx -= IWL_FIRST_OFDM_RATE; 356 rate_idx -= IWL_FIRST_OFDM_RATE;
357 357
358 fail = tx_resp->failure_frame; 358 fail = tx_resp->failure_frame;
359 for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
360 int next = iwl3945_rs_next_rate(priv, rate_idx);
361 359
362 info->status.rates[i].idx = rate_idx; 360 info->status.rates[0].idx = rate_idx;
363 361 info->status.rates[0].count = fail + 1; /* add final attempt */
364 /*
365 * Put remaining into the last count as best approximation
366 * of saying exactly what the hardware would have done...
367 */
368 if ((rate_idx == next) || (i == IEEE80211_TX_MAX_RATES - 1)) {
369 info->status.rates[i].count = fail;
370 break;
371 }
372
373 info->status.rates[i].count = priv->retry_rate;
374 fail -= priv->retry_rate;
375 rate_idx = next;
376 if (fail <= 0)
377 break;
378 }
379 info->status.rates[i].count++; /* add final attempt */
380 362
381 /* tx_status->rts_retry_count = tx_resp->failure_rts; */ 363 /* tx_status->rts_retry_count = tx_resp->failure_rts; */
382 info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? 364 info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ?
@@ -809,12 +791,19 @@ int iwl3945_hw_txq_free_tfd(struct iwl3945_priv *priv, struct iwl3945_tx_queue *
809 791
810u8 iwl3945_hw_find_station(struct iwl3945_priv *priv, const u8 *addr) 792u8 iwl3945_hw_find_station(struct iwl3945_priv *priv, const u8 *addr)
811{ 793{
812 int i; 794 int i, start = IWL_AP_ID;
813 int ret = IWL_INVALID_STATION; 795 int ret = IWL_INVALID_STATION;
814 unsigned long flags; 796 unsigned long flags;
815 797
798 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) ||
799 (priv->iw_mode == NL80211_IFTYPE_AP))
800 start = IWL_STA_ID;
801
802 if (is_broadcast_ether_addr(addr))
803 return priv->hw_setting.bcast_sta_id;
804
816 spin_lock_irqsave(&priv->sta_lock, flags); 805 spin_lock_irqsave(&priv->sta_lock, flags);
817 for (i = IWL_STA_ID; i < priv->hw_setting.max_stations; i++) 806 for (i = start; i < priv->hw_setting.max_stations; i++)
818 if ((priv->stations[i].used) && 807 if ((priv->stations[i].used) &&
819 (!compare_ether_addr 808 (!compare_ether_addr
820 (priv->stations[i].sta.sta.addr, addr))) { 809 (priv->stations[i].sta.sta.addr, addr))) {
@@ -2519,13 +2508,17 @@ void iwl3945_hw_cancel_deferred_work(struct iwl3945_priv *priv)
2519 2508
2520static struct iwl_3945_cfg iwl3945_bg_cfg = { 2509static struct iwl_3945_cfg iwl3945_bg_cfg = {
2521 .name = "3945BG", 2510 .name = "3945BG",
2522 .fw_name = "iwlwifi-3945" IWL3945_UCODE_API ".ucode", 2511 .fw_name_pre = IWL3945_FW_PRE,
2512 .ucode_api_max = IWL3945_UCODE_API_MAX,
2513 .ucode_api_min = IWL3945_UCODE_API_MIN,
2523 .sku = IWL_SKU_G, 2514 .sku = IWL_SKU_G,
2524}; 2515};
2525 2516
2526static struct iwl_3945_cfg iwl3945_abg_cfg = { 2517static struct iwl_3945_cfg iwl3945_abg_cfg = {
2527 .name = "3945ABG", 2518 .name = "3945ABG",
2528 .fw_name = "iwlwifi-3945" IWL3945_UCODE_API ".ucode", 2519 .fw_name_pre = IWL3945_FW_PRE,
2520 .ucode_api_max = IWL3945_UCODE_API_MAX,
2521 .ucode_api_min = IWL3945_UCODE_API_MIN,
2529 .sku = IWL_SKU_A|IWL_SKU_G, 2522 .sku = IWL_SKU_A|IWL_SKU_G,
2530}; 2523};
2531 2524
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index 2a924c10ff93..5c2c15e65a63 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -50,11 +50,15 @@ extern struct pci_device_id iwl3945_hw_card_ids[];
50#include "iwl-3945-debug.h" 50#include "iwl-3945-debug.h"
51#include "iwl-3945-led.h" 51#include "iwl-3945-led.h"
52 52
53/* Change firmware file name, using "-" and incrementing number, 53/* Highest firmware API version supported */
54 * *only* when uCode interface or architecture changes so that it 54#define IWL3945_UCODE_API_MAX 2
55 * is not compatible with earlier drivers. 55
56 * This number will also appear in << 8 position of 1st dword of uCode file */ 56/* Lowest firmware API version supported */
57#define IWL3945_UCODE_API "-1" 57#define IWL3945_UCODE_API_MIN 1
58
59#define IWL3945_FW_PRE "iwlwifi-3945-"
60#define _IWL3945_MODULE_FIRMWARE(api) IWL3945_FW_PRE #api ".ucode"
61#define IWL3945_MODULE_FIRMWARE(api) _IWL3945_MODULE_FIRMWARE(api)
58 62
59/* Default noise level to report when noise measurement is not available. 63/* Default noise level to report when noise measurement is not available.
60 * This may be because we're: 64 * This may be because we're:
@@ -505,7 +509,7 @@ struct fw_desc {
505 509
506/* uCode file layout */ 510/* uCode file layout */
507struct iwl3945_ucode { 511struct iwl3945_ucode {
508 __le32 ver; /* major/minor/subminor */ 512 __le32 ver; /* major/minor/API/serial */
509 __le32 inst_size; /* bytes of runtime instructions */ 513 __le32 inst_size; /* bytes of runtime instructions */
510 __le32 data_size; /* bytes of runtime data */ 514 __le32 data_size; /* bytes of runtime data */
511 __le32 init_size; /* bytes of initialization instructions */ 515 __le32 init_size; /* bytes of initialization instructions */
@@ -762,6 +766,8 @@ struct iwl3945_priv {
762 void __iomem *hw_base; 766 void __iomem *hw_base;
763 767
764 /* uCode images, save to reload in case of failure */ 768 /* uCode images, save to reload in case of failure */
769 u32 ucode_ver; /* ucode version, copy of
770 iwl3945_ucode.ver */
765 struct fw_desc ucode_code; /* runtime inst */ 771 struct fw_desc ucode_code; /* runtime inst */
766 struct fw_desc ucode_data; /* runtime data original */ 772 struct fw_desc ucode_data; /* runtime data original */
767 struct fw_desc ucode_data_backup; /* runtime data save/restore */ 773 struct fw_desc ucode_data_backup; /* runtime data save/restore */
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index ab0b40531989..87c7bb0d5044 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -48,12 +48,15 @@
48static int iwl4965_send_tx_power(struct iwl_priv *priv); 48static int iwl4965_send_tx_power(struct iwl_priv *priv);
49static int iwl4965_hw_get_temperature(const struct iwl_priv *priv); 49static int iwl4965_hw_get_temperature(const struct iwl_priv *priv);
50 50
51/* Change firmware file name, using "-" and incrementing number, 51/* Highest firmware API version supported */
52 * *only* when uCode interface or architecture changes so that it 52#define IWL4965_UCODE_API_MAX 2
53 * is not compatible with earlier drivers. 53
54 * This number will also appear in << 8 position of 1st dword of uCode file */ 54/* Lowest firmware API version supported */
55#define IWL4965_UCODE_API "-2" 55#define IWL4965_UCODE_API_MIN 2
56#define IWL4965_MODULE_FIRMWARE "iwlwifi-4965" IWL4965_UCODE_API ".ucode" 56
57#define IWL4965_FW_PRE "iwlwifi-4965-"
58#define _IWL4965_MODULE_FIRMWARE(api) IWL4965_FW_PRE #api ".ucode"
59#define IWL4965_MODULE_FIRMWARE(api) _IWL4965_MODULE_FIRMWARE(api)
57 60
58 61
59/* module parameters */ 62/* module parameters */
@@ -523,7 +526,7 @@ static void iwl4965_chain_noise_reset(struct iwl_priv *priv)
523 struct iwl_calib_diff_gain_cmd cmd; 526 struct iwl_calib_diff_gain_cmd cmd;
524 527
525 memset(&cmd, 0, sizeof(cmd)); 528 memset(&cmd, 0, sizeof(cmd));
526 cmd.opCode = IWL_PHY_CALIBRATE_DIFF_GAIN_CMD; 529 cmd.hdr.op_code = IWL_PHY_CALIBRATE_DIFF_GAIN_CMD;
527 cmd.diff_gain_a = 0; 530 cmd.diff_gain_a = 0;
528 cmd.diff_gain_b = 0; 531 cmd.diff_gain_b = 0;
529 cmd.diff_gain_c = 0; 532 cmd.diff_gain_c = 0;
@@ -574,7 +577,7 @@ static void iwl4965_gain_computation(struct iwl_priv *priv,
574 data->radio_write = 1; 577 data->radio_write = 1;
575 578
576 memset(&cmd, 0, sizeof(cmd)); 579 memset(&cmd, 0, sizeof(cmd));
577 cmd.opCode = IWL_PHY_CALIBRATE_DIFF_GAIN_CMD; 580 cmd.hdr.op_code = IWL_PHY_CALIBRATE_DIFF_GAIN_CMD;
578 cmd.diff_gain_a = data->delta_gain_code[0]; 581 cmd.diff_gain_a = data->delta_gain_code[0];
579 cmd.diff_gain_b = data->delta_gain_code[1]; 582 cmd.diff_gain_b = data->delta_gain_code[1];
580 cmd.diff_gain_c = data->delta_gain_code[2]; 583 cmd.diff_gain_c = data->delta_gain_code[2];
@@ -816,6 +819,7 @@ static int iwl4965_hw_set_hw_params(struct iwl_priv *priv)
816 } 819 }
817 820
818 priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues; 821 priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues;
822 priv->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM;
819 priv->hw_params.scd_bc_tbls_size = 823 priv->hw_params.scd_bc_tbls_size =
820 IWL49_NUM_QUEUES * sizeof(struct iwl4965_scd_bc_tbl); 824 IWL49_NUM_QUEUES * sizeof(struct iwl4965_scd_bc_tbl);
821 priv->hw_params.max_stations = IWL4965_STATION_COUNT; 825 priv->hw_params.max_stations = IWL4965_STATION_COUNT;
@@ -2335,7 +2339,9 @@ static struct iwl_ops iwl4965_ops = {
2335 2339
2336struct iwl_cfg iwl4965_agn_cfg = { 2340struct iwl_cfg iwl4965_agn_cfg = {
2337 .name = "4965AGN", 2341 .name = "4965AGN",
2338 .fw_name = IWL4965_MODULE_FIRMWARE, 2342 .fw_name_pre = IWL4965_FW_PRE,
2343 .ucode_api_max = IWL4965_UCODE_API_MAX,
2344 .ucode_api_min = IWL4965_UCODE_API_MIN,
2339 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, 2345 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
2340 .eeprom_size = IWL4965_EEPROM_IMG_SIZE, 2346 .eeprom_size = IWL4965_EEPROM_IMG_SIZE,
2341 .eeprom_ver = EEPROM_4965_EEPROM_VERSION, 2347 .eeprom_ver = EEPROM_4965_EEPROM_VERSION,
@@ -2345,7 +2351,7 @@ struct iwl_cfg iwl4965_agn_cfg = {
2345}; 2351};
2346 2352
2347/* Module firmware */ 2353/* Module firmware */
2348MODULE_FIRMWARE(IWL4965_MODULE_FIRMWARE); 2354MODULE_FIRMWARE(IWL4965_MODULE_FIRMWARE(IWL4965_UCODE_API_MAX));
2349 2355
2350module_param_named(antenna, iwl4965_mod_params.antenna, int, 0444); 2356module_param_named(antenna, iwl4965_mod_params.antenna, int, 0444);
2351MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])"); 2357MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])");
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index a738886b434f..438e4bd0a9a8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -44,9 +44,21 @@
44#include "iwl-helpers.h" 44#include "iwl-helpers.h"
45#include "iwl-5000-hw.h" 45#include "iwl-5000-hw.h"
46 46
47#define IWL5000_UCODE_API "-1" 47/* Highest firmware API version supported */
48#define IWL5000_UCODE_API_MAX 1
49#define IWL5150_UCODE_API_MAX 1
48 50
49#define IWL5000_MODULE_FIRMWARE "iwlwifi-5000" IWL5000_UCODE_API ".ucode" 51/* Lowest firmware API version supported */
52#define IWL5000_UCODE_API_MIN 1
53#define IWL5150_UCODE_API_MIN 1
54
55#define IWL5000_FW_PRE "iwlwifi-5000-"
56#define _IWL5000_MODULE_FIRMWARE(api) IWL5000_FW_PRE #api ".ucode"
57#define IWL5000_MODULE_FIRMWARE(api) _IWL5000_MODULE_FIRMWARE(api)
58
59#define IWL5150_FW_PRE "iwlwifi-5150-"
60#define _IWL5150_MODULE_FIRMWARE(api) IWL5150_FW_PRE #api ".ucode"
61#define IWL5150_MODULE_FIRMWARE(api) _IWL5150_MODULE_FIRMWARE(api)
50 62
51static const u16 iwl5000_default_queue_to_tx_fifo[] = { 63static const u16 iwl5000_default_queue_to_tx_fifo[] = {
52 IWL_TX_FIFO_AC3, 64 IWL_TX_FIFO_AC3,
@@ -338,9 +350,13 @@ static void iwl5000_gain_computation(struct iwl_priv *priv,
338 350
339 if (!data->radio_write) { 351 if (!data->radio_write) {
340 struct iwl_calib_chain_noise_gain_cmd cmd; 352 struct iwl_calib_chain_noise_gain_cmd cmd;
353
341 memset(&cmd, 0, sizeof(cmd)); 354 memset(&cmd, 0, sizeof(cmd));
342 355
343 cmd.op_code = IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD; 356 cmd.hdr.op_code = IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD;
357 cmd.hdr.first_group = 0;
358 cmd.hdr.groups_num = 1;
359 cmd.hdr.data_valid = 1;
344 cmd.delta_gain_1 = data->delta_gain_code[1]; 360 cmd.delta_gain_1 = data->delta_gain_code[1];
345 cmd.delta_gain_2 = data->delta_gain_code[2]; 361 cmd.delta_gain_2 = data->delta_gain_code[2];
346 iwl_send_cmd_pdu_async(priv, REPLY_PHY_CALIBRATION_CMD, 362 iwl_send_cmd_pdu_async(priv, REPLY_PHY_CALIBRATION_CMD,
@@ -362,14 +378,19 @@ static void iwl5000_gain_computation(struct iwl_priv *priv,
362static void iwl5000_chain_noise_reset(struct iwl_priv *priv) 378static void iwl5000_chain_noise_reset(struct iwl_priv *priv)
363{ 379{
364 struct iwl_chain_noise_data *data = &priv->chain_noise_data; 380 struct iwl_chain_noise_data *data = &priv->chain_noise_data;
381 int ret;
365 382
366 if ((data->state == IWL_CHAIN_NOISE_ALIVE) && iwl_is_associated(priv)) { 383 if ((data->state == IWL_CHAIN_NOISE_ALIVE) && iwl_is_associated(priv)) {
367 struct iwl_calib_chain_noise_reset_cmd cmd; 384 struct iwl_calib_chain_noise_reset_cmd cmd;
368
369 memset(&cmd, 0, sizeof(cmd)); 385 memset(&cmd, 0, sizeof(cmd));
370 cmd.op_code = IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD; 386
371 if (iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, 387 cmd.hdr.op_code = IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD;
372 sizeof(cmd), &cmd)) 388 cmd.hdr.first_group = 0;
389 cmd.hdr.groups_num = 1;
390 cmd.hdr.data_valid = 1;
391 ret = iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
392 sizeof(cmd), &cmd);
393 if (ret)
373 IWL_ERROR("Could not send REPLY_PHY_CALIBRATION_CMD\n"); 394 IWL_ERROR("Could not send REPLY_PHY_CALIBRATION_CMD\n");
374 data->state = IWL_CHAIN_NOISE_ACCUMULATE; 395 data->state = IWL_CHAIN_NOISE_ACCUMULATE;
375 IWL_DEBUG_CALIB("Run chain_noise_calibrate\n"); 396 IWL_DEBUG_CALIB("Run chain_noise_calibrate\n");
@@ -415,22 +436,33 @@ static const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv,
415 return &priv->eeprom[address]; 436 return &priv->eeprom[address];
416} 437}
417 438
439static s32 iwl5150_get_ct_threshold(struct iwl_priv *priv)
440{
441 const s32 volt2temp_coef = -5;
442 u16 *temp_calib = (u16 *)iwl_eeprom_query_addr(priv,
443 EEPROM_5000_TEMPERATURE);
444 /* offset = temperate - voltage / coef */
445 s32 offset = temp_calib[0] - temp_calib[1] / volt2temp_coef;
446 s32 threshold = (s32)CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD) - offset;
447 return threshold * volt2temp_coef;
448}
449
418/* 450/*
419 * Calibration 451 * Calibration
420 */ 452 */
421static int iwl5000_set_Xtal_calib(struct iwl_priv *priv) 453static int iwl5000_set_Xtal_calib(struct iwl_priv *priv)
422{ 454{
423 u8 data[sizeof(struct iwl_calib_hdr) + 455 struct iwl_calib_xtal_freq_cmd cmd;
424 sizeof(struct iwl_cal_xtal_freq)];
425 struct iwl_calib_cmd *cmd = (struct iwl_calib_cmd *)data;
426 struct iwl_cal_xtal_freq *xtal = (struct iwl_cal_xtal_freq *)cmd->data;
427 u16 *xtal_calib = (u16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_XTAL); 456 u16 *xtal_calib = (u16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_XTAL);
428 457
429 cmd->hdr.op_code = IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD; 458 cmd.hdr.op_code = IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD;
430 xtal->cap_pin1 = (u8)xtal_calib[0]; 459 cmd.hdr.first_group = 0;
431 xtal->cap_pin2 = (u8)xtal_calib[1]; 460 cmd.hdr.groups_num = 1;
461 cmd.hdr.data_valid = 1;
462 cmd.cap_pin1 = (u8)xtal_calib[0];
463 cmd.cap_pin2 = (u8)xtal_calib[1];
432 return iwl_calib_set(&priv->calib_results[IWL_CALIB_XTAL], 464 return iwl_calib_set(&priv->calib_results[IWL_CALIB_XTAL],
433 data, sizeof(data)); 465 (u8 *)&cmd, sizeof(cmd));
434} 466}
435 467
436static int iwl5000_send_calib_cfg(struct iwl_priv *priv) 468static int iwl5000_send_calib_cfg(struct iwl_priv *priv)
@@ -466,6 +498,9 @@ static void iwl5000_rx_calib_result(struct iwl_priv *priv,
466 * uCode. iwl_send_calib_results sends them in a row according to their 498 * uCode. iwl_send_calib_results sends them in a row according to their
467 * index. We sort them here */ 499 * index. We sort them here */
468 switch (hdr->op_code) { 500 switch (hdr->op_code) {
501 case IWL_PHY_CALIBRATE_DC_CMD:
502 index = IWL_CALIB_DC;
503 break;
469 case IWL_PHY_CALIBRATE_LO_CMD: 504 case IWL_PHY_CALIBRATE_LO_CMD:
470 index = IWL_CALIB_LO; 505 index = IWL_CALIB_LO;
471 break; 506 break;
@@ -802,6 +837,7 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
802 } 837 }
803 838
804 priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues; 839 priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues;
840 priv->hw_params.dma_chnl_num = FH50_TCSR_CHNL_NUM;
805 priv->hw_params.scd_bc_tbls_size = 841 priv->hw_params.scd_bc_tbls_size =
806 IWL50_NUM_QUEUES * sizeof(struct iwl5000_scd_bc_tbl); 842 IWL50_NUM_QUEUES * sizeof(struct iwl5000_scd_bc_tbl);
807 priv->hw_params.max_stations = IWL5000_STATION_COUNT; 843 priv->hw_params.max_stations = IWL5000_STATION_COUNT;
@@ -845,7 +881,7 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
845 case CSR_HW_REV_TYPE_5150: 881 case CSR_HW_REV_TYPE_5150:
846 /* 5150 wants in Kelvin */ 882 /* 5150 wants in Kelvin */
847 priv->hw_params.ct_kill_threshold = 883 priv->hw_params.ct_kill_threshold =
848 CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD); 884 iwl5150_get_ct_threshold(priv);
849 break; 885 break;
850 } 886 }
851 887
@@ -862,7 +898,12 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
862 BIT(IWL_CALIB_BASE_BAND); 898 BIT(IWL_CALIB_BASE_BAND);
863 break; 899 break;
864 case CSR_HW_REV_TYPE_5150: 900 case CSR_HW_REV_TYPE_5150:
865 priv->hw_params.calib_init_cfg = 0; 901 priv->hw_params.calib_init_cfg =
902 BIT(IWL_CALIB_DC) |
903 BIT(IWL_CALIB_LO) |
904 BIT(IWL_CALIB_TX_IQ) |
905 BIT(IWL_CALIB_BASE_BAND);
906
866 break; 907 break;
867 } 908 }
868 909
@@ -1501,7 +1542,9 @@ static struct iwl_mod_params iwl50_mod_params = {
1501 1542
1502struct iwl_cfg iwl5300_agn_cfg = { 1543struct iwl_cfg iwl5300_agn_cfg = {
1503 .name = "5300AGN", 1544 .name = "5300AGN",
1504 .fw_name = IWL5000_MODULE_FIRMWARE, 1545 .fw_name_pre = IWL5000_FW_PRE,
1546 .ucode_api_max = IWL5000_UCODE_API_MAX,
1547 .ucode_api_min = IWL5000_UCODE_API_MIN,
1505 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, 1548 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
1506 .ops = &iwl5000_ops, 1549 .ops = &iwl5000_ops,
1507 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, 1550 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
@@ -1512,7 +1555,9 @@ struct iwl_cfg iwl5300_agn_cfg = {
1512 1555
1513struct iwl_cfg iwl5100_bg_cfg = { 1556struct iwl_cfg iwl5100_bg_cfg = {
1514 .name = "5100BG", 1557 .name = "5100BG",
1515 .fw_name = IWL5000_MODULE_FIRMWARE, 1558 .fw_name_pre = IWL5000_FW_PRE,
1559 .ucode_api_max = IWL5000_UCODE_API_MAX,
1560 .ucode_api_min = IWL5000_UCODE_API_MIN,
1516 .sku = IWL_SKU_G, 1561 .sku = IWL_SKU_G,
1517 .ops = &iwl5000_ops, 1562 .ops = &iwl5000_ops,
1518 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, 1563 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
@@ -1523,7 +1568,9 @@ struct iwl_cfg iwl5100_bg_cfg = {
1523 1568
1524struct iwl_cfg iwl5100_abg_cfg = { 1569struct iwl_cfg iwl5100_abg_cfg = {
1525 .name = "5100ABG", 1570 .name = "5100ABG",
1526 .fw_name = IWL5000_MODULE_FIRMWARE, 1571 .fw_name_pre = IWL5000_FW_PRE,
1572 .ucode_api_max = IWL5000_UCODE_API_MAX,
1573 .ucode_api_min = IWL5000_UCODE_API_MIN,
1527 .sku = IWL_SKU_A|IWL_SKU_G, 1574 .sku = IWL_SKU_A|IWL_SKU_G,
1528 .ops = &iwl5000_ops, 1575 .ops = &iwl5000_ops,
1529 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, 1576 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
@@ -1534,7 +1581,9 @@ struct iwl_cfg iwl5100_abg_cfg = {
1534 1581
1535struct iwl_cfg iwl5100_agn_cfg = { 1582struct iwl_cfg iwl5100_agn_cfg = {
1536 .name = "5100AGN", 1583 .name = "5100AGN",
1537 .fw_name = IWL5000_MODULE_FIRMWARE, 1584 .fw_name_pre = IWL5000_FW_PRE,
1585 .ucode_api_max = IWL5000_UCODE_API_MAX,
1586 .ucode_api_min = IWL5000_UCODE_API_MIN,
1538 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, 1587 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
1539 .ops = &iwl5000_ops, 1588 .ops = &iwl5000_ops,
1540 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, 1589 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
@@ -1545,7 +1594,22 @@ struct iwl_cfg iwl5100_agn_cfg = {
1545 1594
1546struct iwl_cfg iwl5350_agn_cfg = { 1595struct iwl_cfg iwl5350_agn_cfg = {
1547 .name = "5350AGN", 1596 .name = "5350AGN",
1548 .fw_name = IWL5000_MODULE_FIRMWARE, 1597 .fw_name_pre = IWL5000_FW_PRE,
1598 .ucode_api_max = IWL5000_UCODE_API_MAX,
1599 .ucode_api_min = IWL5000_UCODE_API_MIN,
1600 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
1601 .ops = &iwl5000_ops,
1602 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
1603 .eeprom_ver = EEPROM_5050_EEPROM_VERSION,
1604 .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION,
1605 .mod_params = &iwl50_mod_params,
1606};
1607
1608struct iwl_cfg iwl5150_agn_cfg = {
1609 .name = "5150AGN",
1610 .fw_name_pre = IWL5150_FW_PRE,
1611 .ucode_api_max = IWL5150_UCODE_API_MAX,
1612 .ucode_api_min = IWL5150_UCODE_API_MIN,
1549 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, 1613 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
1550 .ops = &iwl5000_ops, 1614 .ops = &iwl5000_ops,
1551 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, 1615 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
@@ -1554,7 +1618,8 @@ struct iwl_cfg iwl5350_agn_cfg = {
1554 .mod_params = &iwl50_mod_params, 1618 .mod_params = &iwl50_mod_params,
1555}; 1619};
1556 1620
1557MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE); 1621MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX));
1622MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE(IWL5150_UCODE_API_MAX));
1558 1623
1559module_param_named(disable50, iwl50_mod_params.disable, int, 0444); 1624module_param_named(disable50, iwl50_mod_params.disable, int, 0444);
1560MODULE_PARM_DESC(disable50, 1625MODULE_PARM_DESC(disable50,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd-check.c b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd-check.c
new file mode 100644
index 000000000000..c50494a74f67
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd-check.c
@@ -0,0 +1,108 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 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 * Tomas Winkler <tomas.winkler@intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
29#include <linux/kernel.h>
30#include <net/mac80211.h>
31#include "iwl-dev.h"
32#include "iwl-debug.h"
33#include "iwl-commands.h"
34
35
36/**
37 * iwl_check_rxon_cmd - validate RXON structure is valid
38 *
39 * NOTE: This is really only useful during development and can eventually
40 * be #ifdef'd out once the driver is stable and folks aren't actively
41 * making changes
42 */
43int iwl_agn_check_rxon_cmd(struct iwl_rxon_cmd *rxon)
44{
45 int error = 0;
46 int counter = 1;
47
48 if (rxon->flags & RXON_FLG_BAND_24G_MSK) {
49 error |= le32_to_cpu(rxon->flags &
50 (RXON_FLG_TGJ_NARROW_BAND_MSK |
51 RXON_FLG_RADAR_DETECT_MSK));
52 if (error)
53 IWL_WARNING("check 24G fields %d | %d\n",
54 counter++, error);
55 } else {
56 error |= (rxon->flags & RXON_FLG_SHORT_SLOT_MSK) ?
57 0 : le32_to_cpu(RXON_FLG_SHORT_SLOT_MSK);
58 if (error)
59 IWL_WARNING("check 52 fields %d | %d\n",
60 counter++, error);
61 error |= le32_to_cpu(rxon->flags & RXON_FLG_CCK_MSK);
62 if (error)
63 IWL_WARNING("check 52 CCK %d | %d\n",
64 counter++, error);
65 }
66 error |= (rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1;
67 if (error)
68 IWL_WARNING("check mac addr %d | %d\n", counter++, error);
69
70 /* make sure basic rates 6Mbps and 1Mbps are supported */
71 error |= (((rxon->ofdm_basic_rates & IWL_RATE_6M_MASK) == 0) &&
72 ((rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0));
73 if (error)
74 IWL_WARNING("check basic rate %d | %d\n", counter++, error);
75
76 error |= (le16_to_cpu(rxon->assoc_id) > 2007);
77 if (error)
78 IWL_WARNING("check assoc id %d | %d\n", counter++, error);
79
80 error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK))
81 == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK));
82 if (error)
83 IWL_WARNING("check CCK and short slot %d | %d\n",
84 counter++, error);
85
86 error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK))
87 == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK));
88 if (error)
89 IWL_WARNING("check CCK & auto detect %d | %d\n",
90 counter++, error);
91
92 error |= ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK |
93 RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK);
94 if (error)
95 IWL_WARNING("check TGG and auto detect %d | %d\n",
96 counter++, error);
97
98 if (error)
99 IWL_WARNING("Tuning to channel %d\n",
100 le16_to_cpu(rxon->channel));
101
102 if (error) {
103 IWL_ERROR("Not a valid iwl4965_rxon_assoc_cmd field values\n");
104 return -1;
105 }
106 return 0;
107}
108
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 7888250117dc..b3c263d2724f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -108,79 +108,6 @@ static void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt)
108} 108}
109 109
110/** 110/**
111 * iwl_check_rxon_cmd - validate RXON structure is valid
112 *
113 * NOTE: This is really only useful during development and can eventually
114 * be #ifdef'd out once the driver is stable and folks aren't actively
115 * making changes
116 */
117static int iwl_check_rxon_cmd(struct iwl_rxon_cmd *rxon)
118{
119 int error = 0;
120 int counter = 1;
121
122 if (rxon->flags & RXON_FLG_BAND_24G_MSK) {
123 error |= le32_to_cpu(rxon->flags &
124 (RXON_FLG_TGJ_NARROW_BAND_MSK |
125 RXON_FLG_RADAR_DETECT_MSK));
126 if (error)
127 IWL_WARNING("check 24G fields %d | %d\n",
128 counter++, error);
129 } else {
130 error |= (rxon->flags & RXON_FLG_SHORT_SLOT_MSK) ?
131 0 : le32_to_cpu(RXON_FLG_SHORT_SLOT_MSK);
132 if (error)
133 IWL_WARNING("check 52 fields %d | %d\n",
134 counter++, error);
135 error |= le32_to_cpu(rxon->flags & RXON_FLG_CCK_MSK);
136 if (error)
137 IWL_WARNING("check 52 CCK %d | %d\n",
138 counter++, error);
139 }
140 error |= (rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1;
141 if (error)
142 IWL_WARNING("check mac addr %d | %d\n", counter++, error);
143
144 /* make sure basic rates 6Mbps and 1Mbps are supported */
145 error |= (((rxon->ofdm_basic_rates & IWL_RATE_6M_MASK) == 0) &&
146 ((rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0));
147 if (error)
148 IWL_WARNING("check basic rate %d | %d\n", counter++, error);
149
150 error |= (le16_to_cpu(rxon->assoc_id) > 2007);
151 if (error)
152 IWL_WARNING("check assoc id %d | %d\n", counter++, error);
153
154 error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK))
155 == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK));
156 if (error)
157 IWL_WARNING("check CCK and short slot %d | %d\n",
158 counter++, error);
159
160 error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK))
161 == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK));
162 if (error)
163 IWL_WARNING("check CCK & auto detect %d | %d\n",
164 counter++, error);
165
166 error |= ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK |
167 RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK);
168 if (error)
169 IWL_WARNING("check TGG and auto detect %d | %d\n",
170 counter++, error);
171
172 if (error)
173 IWL_WARNING("Tuning to channel %d\n",
174 le16_to_cpu(rxon->channel));
175
176 if (error) {
177 IWL_ERROR("Not a valid iwl_rxon_assoc_cmd field values\n");
178 return -1;
179 }
180 return 0;
181}
182
183/**
184 * iwl_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed 111 * iwl_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed
185 * @priv: staging_rxon is compared to active_rxon 112 * @priv: staging_rxon is compared to active_rxon
186 * 113 *
@@ -252,7 +179,7 @@ static int iwl_commit_rxon(struct iwl_priv *priv)
252 * 5000, but will not damage 4965 */ 179 * 5000, but will not damage 4965 */
253 priv->staging_rxon.flags |= RXON_FLG_SELF_CTS_EN; 180 priv->staging_rxon.flags |= RXON_FLG_SELF_CTS_EN;
254 181
255 ret = iwl_check_rxon_cmd(&priv->staging_rxon); 182 ret = iwl_agn_check_rxon_cmd(&priv->staging_rxon);
256 if (ret) { 183 if (ret) {
257 IWL_ERROR("Invalid RXON configuration. Not committing.\n"); 184 IWL_ERROR("Invalid RXON configuration. Not committing.\n");
258 return -EINVAL; 185 return -EINVAL;
@@ -1328,13 +1255,6 @@ static void iwl_print_rx_config_cmd(struct iwl_priv *priv)
1328} 1255}
1329#endif 1256#endif
1330 1257
1331static void iwl_enable_interrupts(struct iwl_priv *priv)
1332{
1333 IWL_DEBUG_ISR("Enabling interrupts\n");
1334 set_bit(STATUS_INT_ENABLED, &priv->status);
1335 iwl_write32(priv, CSR_INT_MASK, CSR_INI_SET_MASK);
1336}
1337
1338/* call this function to flush any scheduled tasklet */ 1258/* call this function to flush any scheduled tasklet */
1339static inline void iwl_synchronize_irq(struct iwl_priv *priv) 1259static inline void iwl_synchronize_irq(struct iwl_priv *priv)
1340{ 1260{
@@ -1343,21 +1263,6 @@ static inline void iwl_synchronize_irq(struct iwl_priv *priv)
1343 tasklet_kill(&priv->irq_tasklet); 1263 tasklet_kill(&priv->irq_tasklet);
1344} 1264}
1345 1265
1346static inline void iwl_disable_interrupts(struct iwl_priv *priv)
1347{
1348 clear_bit(STATUS_INT_ENABLED, &priv->status);
1349
1350 /* disable interrupts from uCode/NIC to host */
1351 iwl_write32(priv, CSR_INT_MASK, 0x00000000);
1352
1353 /* acknowledge/clear/reset any interrupts still pending
1354 * from uCode or flow handler (Rx/Tx DMA) */
1355 iwl_write32(priv, CSR_INT, 0xffffffff);
1356 iwl_write32(priv, CSR_FH_INT_STATUS, 0xffffffff);
1357 IWL_DEBUG_ISR("Disabled interrupts\n");
1358}
1359
1360
1361/** 1266/**
1362 * iwl_irq_handle_error - called for HW or SW error interrupt from card 1267 * iwl_irq_handle_error - called for HW or SW error interrupt from card
1363 */ 1268 */
@@ -1608,7 +1513,7 @@ static irqreturn_t iwl_isr(int irq, void *data)
1608 if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) { 1513 if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) {
1609 /* Hardware disappeared. It might have already raised 1514 /* Hardware disappeared. It might have already raised
1610 * an interrupt */ 1515 * an interrupt */
1611 IWL_WARNING("HARDWARE GONE?? INTA == 0x%080x\n", inta); 1516 IWL_WARNING("HARDWARE GONE?? INTA == 0x%08x\n", inta);
1612 goto unplugged; 1517 goto unplugged;
1613 } 1518 }
1614 1519
@@ -1665,24 +1570,40 @@ static void iwl_nic_start(struct iwl_priv *priv)
1665static int iwl_read_ucode(struct iwl_priv *priv) 1570static int iwl_read_ucode(struct iwl_priv *priv)
1666{ 1571{
1667 struct iwl_ucode *ucode; 1572 struct iwl_ucode *ucode;
1668 int ret; 1573 int ret = -EINVAL, index;
1669 const struct firmware *ucode_raw; 1574 const struct firmware *ucode_raw;
1670 const char *name = priv->cfg->fw_name; 1575 const char *name_pre = priv->cfg->fw_name_pre;
1576 const unsigned int api_max = priv->cfg->ucode_api_max;
1577 const unsigned int api_min = priv->cfg->ucode_api_min;
1578 char buf[25];
1671 u8 *src; 1579 u8 *src;
1672 size_t len; 1580 size_t len;
1673 u32 ver, inst_size, data_size, init_size, init_data_size, boot_size; 1581 u32 api_ver, inst_size, data_size, init_size, init_data_size, boot_size;
1674 1582
1675 /* Ask kernel firmware_class module to get the boot firmware off disk. 1583 /* Ask kernel firmware_class module to get the boot firmware off disk.
1676 * request_firmware() is synchronous, file is in memory on return. */ 1584 * request_firmware() is synchronous, file is in memory on return. */
1677 ret = request_firmware(&ucode_raw, name, &priv->pci_dev->dev); 1585 for (index = api_max; index >= api_min; index--) {
1678 if (ret < 0) { 1586 sprintf(buf, "%s%d%s", name_pre, index, ".ucode");
1679 IWL_ERROR("%s firmware file req failed: Reason %d\n", 1587 ret = request_firmware(&ucode_raw, buf, &priv->pci_dev->dev);
1680 name, ret); 1588 if (ret < 0) {
1681 goto error; 1589 IWL_ERROR("%s firmware file req failed: Reason %d\n",
1590 buf, ret);
1591 if (ret == -ENOENT)
1592 continue;
1593 else
1594 goto error;
1595 } else {
1596 if (index < api_max)
1597 IWL_ERROR("Loaded firmware %s, which is deprecated. Please use API v%u instead.\n",
1598 buf, api_max);
1599 IWL_DEBUG_INFO("Got firmware '%s' file (%zd bytes) from disk\n",
1600 buf, ucode_raw->size);
1601 break;
1602 }
1682 } 1603 }
1683 1604
1684 IWL_DEBUG_INFO("Got firmware '%s' file (%zd bytes) from disk\n", 1605 if (ret < 0)
1685 name, ucode_raw->size); 1606 goto error;
1686 1607
1687 /* Make sure that we got at least our header! */ 1608 /* Make sure that we got at least our header! */
1688 if (ucode_raw->size < sizeof(*ucode)) { 1609 if (ucode_raw->size < sizeof(*ucode)) {
@@ -1694,14 +1615,40 @@ static int iwl_read_ucode(struct iwl_priv *priv)
1694 /* Data from ucode file: header followed by uCode images */ 1615 /* Data from ucode file: header followed by uCode images */
1695 ucode = (void *)ucode_raw->data; 1616 ucode = (void *)ucode_raw->data;
1696 1617
1697 ver = le32_to_cpu(ucode->ver); 1618 priv->ucode_ver = le32_to_cpu(ucode->ver);
1619 api_ver = IWL_UCODE_API(priv->ucode_ver);
1698 inst_size = le32_to_cpu(ucode->inst_size); 1620 inst_size = le32_to_cpu(ucode->inst_size);
1699 data_size = le32_to_cpu(ucode->data_size); 1621 data_size = le32_to_cpu(ucode->data_size);
1700 init_size = le32_to_cpu(ucode->init_size); 1622 init_size = le32_to_cpu(ucode->init_size);
1701 init_data_size = le32_to_cpu(ucode->init_data_size); 1623 init_data_size = le32_to_cpu(ucode->init_data_size);
1702 boot_size = le32_to_cpu(ucode->boot_size); 1624 boot_size = le32_to_cpu(ucode->boot_size);
1703 1625
1704 IWL_DEBUG_INFO("f/w package hdr ucode version = 0x%x\n", ver); 1626 /* api_ver should match the api version forming part of the
1627 * firmware filename ... but we don't check for that and only rely
1628 * on the API version read from firware header from here on forward */
1629
1630 if (api_ver < api_min || api_ver > api_max) {
1631 IWL_ERROR("Driver unable to support your firmware API. "
1632 "Driver supports v%u, firmware is v%u.\n",
1633 api_max, api_ver);
1634 priv->ucode_ver = 0;
1635 ret = -EINVAL;
1636 goto err_release;
1637 }
1638 if (api_ver != api_max)
1639 IWL_ERROR("Firmware has old API version. Expected v%u, "
1640 "got v%u. New firmware can be obtained "
1641 "from http://www.intellinuxwireless.org.\n",
1642 api_max, api_ver);
1643
1644 printk(KERN_INFO DRV_NAME " loaded firmware version %u.%u.%u.%u\n",
1645 IWL_UCODE_MAJOR(priv->ucode_ver),
1646 IWL_UCODE_MINOR(priv->ucode_ver),
1647 IWL_UCODE_API(priv->ucode_ver),
1648 IWL_UCODE_SERIAL(priv->ucode_ver));
1649
1650 IWL_DEBUG_INFO("f/w package hdr ucode version raw = 0x%x\n",
1651 priv->ucode_ver);
1705 IWL_DEBUG_INFO("f/w package hdr runtime inst size = %u\n", 1652 IWL_DEBUG_INFO("f/w package hdr runtime inst size = %u\n",
1706 inst_size); 1653 inst_size);
1707 IWL_DEBUG_INFO("f/w package hdr runtime data size = %u\n", 1654 IWL_DEBUG_INFO("f/w package hdr runtime data size = %u\n",
@@ -3675,68 +3622,6 @@ static ssize_t show_power_level(struct device *d,
3675static DEVICE_ATTR(power_level, S_IWUSR | S_IRUSR, show_power_level, 3622static DEVICE_ATTR(power_level, S_IWUSR | S_IRUSR, show_power_level,
3676 store_power_level); 3623 store_power_level);
3677 3624
3678static ssize_t show_channels(struct device *d,
3679 struct device_attribute *attr, char *buf)
3680{
3681
3682 struct iwl_priv *priv = dev_get_drvdata(d);
3683 struct ieee80211_channel *channels = NULL;
3684 const struct ieee80211_supported_band *supp_band = NULL;
3685 int len = 0, i;
3686 int count = 0;
3687
3688 if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status))
3689 return -EAGAIN;
3690
3691 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
3692 channels = supp_band->channels;
3693 count = supp_band->n_channels;
3694
3695 len += sprintf(&buf[len],
3696 "Displaying %d channels in 2.4GHz band "
3697 "(802.11bg):\n", count);
3698
3699 for (i = 0; i < count; i++)
3700 len += sprintf(&buf[len], "%d: %ddBm: BSS%s%s, %s.\n",
3701 ieee80211_frequency_to_channel(
3702 channels[i].center_freq),
3703 channels[i].max_power,
3704 channels[i].flags & IEEE80211_CHAN_RADAR ?
3705 " (IEEE 802.11h required)" : "",
3706 (!(channels[i].flags & IEEE80211_CHAN_NO_IBSS)
3707 || (channels[i].flags &
3708 IEEE80211_CHAN_RADAR)) ? "" :
3709 ", IBSS",
3710 channels[i].flags &
3711 IEEE80211_CHAN_PASSIVE_SCAN ?
3712 "passive only" : "active/passive");
3713
3714 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
3715 channels = supp_band->channels;
3716 count = supp_band->n_channels;
3717
3718 len += sprintf(&buf[len], "Displaying %d channels in 5.2GHz band "
3719 "(802.11a):\n", count);
3720
3721 for (i = 0; i < count; i++)
3722 len += sprintf(&buf[len], "%d: %ddBm: BSS%s%s, %s.\n",
3723 ieee80211_frequency_to_channel(
3724 channels[i].center_freq),
3725 channels[i].max_power,
3726 channels[i].flags & IEEE80211_CHAN_RADAR ?
3727 " (IEEE 802.11h required)" : "",
3728 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
3729 || (channels[i].flags &
3730 IEEE80211_CHAN_RADAR)) ? "" :
3731 ", IBSS",
3732 channels[i].flags &
3733 IEEE80211_CHAN_PASSIVE_SCAN ?
3734 "passive only" : "active/passive");
3735
3736 return len;
3737}
3738
3739static DEVICE_ATTR(channels, S_IRUSR, show_channels, NULL);
3740 3625
3741static ssize_t show_statistics(struct device *d, 3626static ssize_t show_statistics(struct device *d,
3742 struct device_attribute *attr, char *buf) 3627 struct device_attribute *attr, char *buf)
@@ -3836,7 +3721,6 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv)
3836} 3721}
3837 3722
3838static struct attribute *iwl_sysfs_entries[] = { 3723static struct attribute *iwl_sysfs_entries[] = {
3839 &dev_attr_channels.attr,
3840 &dev_attr_flags.attr, 3724 &dev_attr_flags.attr,
3841 &dev_attr_filter_flags.attr, 3725 &dev_attr_filter_flags.attr,
3842 &dev_attr_power_level.attr, 3726 &dev_attr_power_level.attr,
@@ -4210,7 +4094,11 @@ static struct pci_device_id iwl_hw_card_ids[] = {
4210 {IWL_PCI_DEVICE(0x423A, 0x1001, iwl5350_agn_cfg)}, 4094 {IWL_PCI_DEVICE(0x423A, 0x1001, iwl5350_agn_cfg)},
4211 {IWL_PCI_DEVICE(0x423A, 0x1021, iwl5350_agn_cfg)}, 4095 {IWL_PCI_DEVICE(0x423A, 0x1021, iwl5350_agn_cfg)},
4212 {IWL_PCI_DEVICE(0x423B, 0x1011, iwl5350_agn_cfg)}, 4096 {IWL_PCI_DEVICE(0x423B, 0x1011, iwl5350_agn_cfg)},
4097/* 5150 Wifi/WiMax */
4098 {IWL_PCI_DEVICE(0x423C, PCI_ANY_ID, iwl5150_agn_cfg)},
4099 {IWL_PCI_DEVICE(0x423D, PCI_ANY_ID, iwl5150_agn_cfg)},
4213#endif /* CONFIG_IWL5000 */ 4100#endif /* CONFIG_IWL5000 */
4101
4214 {0} 4102 {0}
4215}; 4103};
4216MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids); 4104MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids);
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index 1fe83d45443a..528bcab49d13 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -69,6 +69,12 @@
69#ifndef __iwl_commands_h__ 69#ifndef __iwl_commands_h__
70#define __iwl_commands_h__ 70#define __iwl_commands_h__
71 71
72/* uCode version contains 4 values: Major/Minor/API/Serial */
73#define IWL_UCODE_MAJOR(ver) (((ver) & 0xFF000000) >> 24)
74#define IWL_UCODE_MINOR(ver) (((ver) & 0x00FF0000) >> 16)
75#define IWL_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8)
76#define IWL_UCODE_SERIAL(ver) ((ver) & 0x000000FF)
77
72enum { 78enum {
73 REPLY_ALIVE = 0x1, 79 REPLY_ALIVE = 0x1,
74 REPLY_ERROR = 0x2, 80 REPLY_ERROR = 0x2,
@@ -172,8 +178,8 @@ enum {
172#define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8) 178#define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8)
173#define SEQ_TO_INDEX(s) ((s) & 0xff) 179#define SEQ_TO_INDEX(s) ((s) & 0xff)
174#define INDEX_TO_SEQ(i) ((i) & 0xff) 180#define INDEX_TO_SEQ(i) ((i) & 0xff)
175#define SEQ_HUGE_FRAME __constant_cpu_to_le16(0x4000) 181#define SEQ_HUGE_FRAME cpu_to_le16(0x4000)
176#define SEQ_RX_FRAME __constant_cpu_to_le16(0x8000) 182#define SEQ_RX_FRAME cpu_to_le16(0x8000)
177 183
178/** 184/**
179 * struct iwl_cmd_header 185 * struct iwl_cmd_header
@@ -368,7 +374,7 @@ struct iwl5000_tx_power_dbm_cmd {
368 * 374 *
369 *****************************************************************************/ 375 *****************************************************************************/
370 376
371#define UCODE_VALID_OK __constant_cpu_to_le32(0x1) 377#define UCODE_VALID_OK cpu_to_le32(0x1)
372#define INITIALIZE_SUBTYPE (9) 378#define INITIALIZE_SUBTYPE (9)
373 379
374/* 380/*
@@ -517,75 +523,75 @@ enum {
517}; 523};
518 524
519 525
520#define RXON_RX_CHAIN_DRIVER_FORCE_MSK __constant_cpu_to_le16(0x1 << 0) 526#define RXON_RX_CHAIN_DRIVER_FORCE_MSK cpu_to_le16(0x1 << 0)
521#define RXON_RX_CHAIN_VALID_MSK __constant_cpu_to_le16(0x7 << 1) 527#define RXON_RX_CHAIN_VALID_MSK cpu_to_le16(0x7 << 1)
522#define RXON_RX_CHAIN_VALID_POS (1) 528#define RXON_RX_CHAIN_VALID_POS (1)
523#define RXON_RX_CHAIN_FORCE_SEL_MSK __constant_cpu_to_le16(0x7 << 4) 529#define RXON_RX_CHAIN_FORCE_SEL_MSK cpu_to_le16(0x7 << 4)
524#define RXON_RX_CHAIN_FORCE_SEL_POS (4) 530#define RXON_RX_CHAIN_FORCE_SEL_POS (4)
525#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK __constant_cpu_to_le16(0x7 << 7) 531#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK cpu_to_le16(0x7 << 7)
526#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7) 532#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7)
527#define RXON_RX_CHAIN_CNT_MSK __constant_cpu_to_le16(0x3 << 10) 533#define RXON_RX_CHAIN_CNT_MSK cpu_to_le16(0x3 << 10)
528#define RXON_RX_CHAIN_CNT_POS (10) 534#define RXON_RX_CHAIN_CNT_POS (10)
529#define RXON_RX_CHAIN_MIMO_CNT_MSK __constant_cpu_to_le16(0x3 << 12) 535#define RXON_RX_CHAIN_MIMO_CNT_MSK cpu_to_le16(0x3 << 12)
530#define RXON_RX_CHAIN_MIMO_CNT_POS (12) 536#define RXON_RX_CHAIN_MIMO_CNT_POS (12)
531#define RXON_RX_CHAIN_MIMO_FORCE_MSK __constant_cpu_to_le16(0x1 << 14) 537#define RXON_RX_CHAIN_MIMO_FORCE_MSK cpu_to_le16(0x1 << 14)
532#define RXON_RX_CHAIN_MIMO_FORCE_POS (14) 538#define RXON_RX_CHAIN_MIMO_FORCE_POS (14)
533 539
534/* rx_config flags */ 540/* rx_config flags */
535/* band & modulation selection */ 541/* band & modulation selection */
536#define RXON_FLG_BAND_24G_MSK __constant_cpu_to_le32(1 << 0) 542#define RXON_FLG_BAND_24G_MSK cpu_to_le32(1 << 0)
537#define RXON_FLG_CCK_MSK __constant_cpu_to_le32(1 << 1) 543#define RXON_FLG_CCK_MSK cpu_to_le32(1 << 1)
538/* auto detection enable */ 544/* auto detection enable */
539#define RXON_FLG_AUTO_DETECT_MSK __constant_cpu_to_le32(1 << 2) 545#define RXON_FLG_AUTO_DETECT_MSK cpu_to_le32(1 << 2)
540/* TGg protection when tx */ 546/* TGg protection when tx */
541#define RXON_FLG_TGG_PROTECT_MSK __constant_cpu_to_le32(1 << 3) 547#define RXON_FLG_TGG_PROTECT_MSK cpu_to_le32(1 << 3)
542/* cck short slot & preamble */ 548/* cck short slot & preamble */
543#define RXON_FLG_SHORT_SLOT_MSK __constant_cpu_to_le32(1 << 4) 549#define RXON_FLG_SHORT_SLOT_MSK cpu_to_le32(1 << 4)
544#define RXON_FLG_SHORT_PREAMBLE_MSK __constant_cpu_to_le32(1 << 5) 550#define RXON_FLG_SHORT_PREAMBLE_MSK cpu_to_le32(1 << 5)
545/* antenna selection */ 551/* antenna selection */
546#define RXON_FLG_DIS_DIV_MSK __constant_cpu_to_le32(1 << 7) 552#define RXON_FLG_DIS_DIV_MSK cpu_to_le32(1 << 7)
547#define RXON_FLG_ANT_SEL_MSK __constant_cpu_to_le32(0x0f00) 553#define RXON_FLG_ANT_SEL_MSK cpu_to_le32(0x0f00)
548#define RXON_FLG_ANT_A_MSK __constant_cpu_to_le32(1 << 8) 554#define RXON_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
549#define RXON_FLG_ANT_B_MSK __constant_cpu_to_le32(1 << 9) 555#define RXON_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
550/* radar detection enable */ 556/* radar detection enable */
551#define RXON_FLG_RADAR_DETECT_MSK __constant_cpu_to_le32(1 << 12) 557#define RXON_FLG_RADAR_DETECT_MSK cpu_to_le32(1 << 12)
552#define RXON_FLG_TGJ_NARROW_BAND_MSK __constant_cpu_to_le32(1 << 13) 558#define RXON_FLG_TGJ_NARROW_BAND_MSK cpu_to_le32(1 << 13)
553/* rx response to host with 8-byte TSF 559/* rx response to host with 8-byte TSF
554* (according to ON_AIR deassertion) */ 560* (according to ON_AIR deassertion) */
555#define RXON_FLG_TSF2HOST_MSK __constant_cpu_to_le32(1 << 15) 561#define RXON_FLG_TSF2HOST_MSK cpu_to_le32(1 << 15)
556 562
557 563
558/* HT flags */ 564/* HT flags */
559#define RXON_FLG_CTRL_CHANNEL_LOC_POS (22) 565#define RXON_FLG_CTRL_CHANNEL_LOC_POS (22)
560#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK __constant_cpu_to_le32(0x1 << 22) 566#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK cpu_to_le32(0x1 << 22)
561 567
562#define RXON_FLG_HT_OPERATING_MODE_POS (23) 568#define RXON_FLG_HT_OPERATING_MODE_POS (23)
563 569
564#define RXON_FLG_HT_PROT_MSK __constant_cpu_to_le32(0x1 << 23) 570#define RXON_FLG_HT_PROT_MSK cpu_to_le32(0x1 << 23)
565#define RXON_FLG_FAT_PROT_MSK __constant_cpu_to_le32(0x2 << 23) 571#define RXON_FLG_FAT_PROT_MSK cpu_to_le32(0x2 << 23)
566 572
567#define RXON_FLG_CHANNEL_MODE_POS (25) 573#define RXON_FLG_CHANNEL_MODE_POS (25)
568#define RXON_FLG_CHANNEL_MODE_MSK __constant_cpu_to_le32(0x3 << 25) 574#define RXON_FLG_CHANNEL_MODE_MSK cpu_to_le32(0x3 << 25)
569#define RXON_FLG_CHANNEL_MODE_PURE_40_MSK __constant_cpu_to_le32(0x1 << 25) 575#define RXON_FLG_CHANNEL_MODE_PURE_40_MSK cpu_to_le32(0x1 << 25)
570#define RXON_FLG_CHANNEL_MODE_MIXED_MSK __constant_cpu_to_le32(0x2 << 25) 576#define RXON_FLG_CHANNEL_MODE_MIXED_MSK cpu_to_le32(0x2 << 25)
571/* CTS to self (if spec allows) flag */ 577/* CTS to self (if spec allows) flag */
572#define RXON_FLG_SELF_CTS_EN __constant_cpu_to_le32(0x1<<30) 578#define RXON_FLG_SELF_CTS_EN cpu_to_le32(0x1<<30)
573 579
574/* rx_config filter flags */ 580/* rx_config filter flags */
575/* accept all data frames */ 581/* accept all data frames */
576#define RXON_FILTER_PROMISC_MSK __constant_cpu_to_le32(1 << 0) 582#define RXON_FILTER_PROMISC_MSK cpu_to_le32(1 << 0)
577/* pass control & management to host */ 583/* pass control & management to host */
578#define RXON_FILTER_CTL2HOST_MSK __constant_cpu_to_le32(1 << 1) 584#define RXON_FILTER_CTL2HOST_MSK cpu_to_le32(1 << 1)
579/* accept multi-cast */ 585/* accept multi-cast */
580#define RXON_FILTER_ACCEPT_GRP_MSK __constant_cpu_to_le32(1 << 2) 586#define RXON_FILTER_ACCEPT_GRP_MSK cpu_to_le32(1 << 2)
581/* don't decrypt uni-cast frames */ 587/* don't decrypt uni-cast frames */
582#define RXON_FILTER_DIS_DECRYPT_MSK __constant_cpu_to_le32(1 << 3) 588#define RXON_FILTER_DIS_DECRYPT_MSK cpu_to_le32(1 << 3)
583/* don't decrypt multi-cast frames */ 589/* don't decrypt multi-cast frames */
584#define RXON_FILTER_DIS_GRP_DECRYPT_MSK __constant_cpu_to_le32(1 << 4) 590#define RXON_FILTER_DIS_GRP_DECRYPT_MSK cpu_to_le32(1 << 4)
585/* STA is associated */ 591/* STA is associated */
586#define RXON_FILTER_ASSOC_MSK __constant_cpu_to_le32(1 << 5) 592#define RXON_FILTER_ASSOC_MSK cpu_to_le32(1 << 5)
587/* transfer to host non bssid beacons in associated state */ 593/* transfer to host non bssid beacons in associated state */
588#define RXON_FILTER_BCON_AWARE_MSK __constant_cpu_to_le32(1 << 6) 594#define RXON_FILTER_BCON_AWARE_MSK cpu_to_le32(1 << 6)
589 595
590/** 596/**
591 * REPLY_RXON = 0x10 (command, has simple generic response) 597 * REPLY_RXON = 0x10 (command, has simple generic response)
@@ -745,9 +751,9 @@ struct iwl_ac_qos {
745} __attribute__ ((packed)); 751} __attribute__ ((packed));
746 752
747/* QoS flags defines */ 753/* QoS flags defines */
748#define QOS_PARAM_FLG_UPDATE_EDCA_MSK __constant_cpu_to_le32(0x01) 754#define QOS_PARAM_FLG_UPDATE_EDCA_MSK cpu_to_le32(0x01)
749#define QOS_PARAM_FLG_TGN_MSK __constant_cpu_to_le32(0x02) 755#define QOS_PARAM_FLG_TGN_MSK cpu_to_le32(0x02)
750#define QOS_PARAM_FLG_TXOP_TYPE_MSK __constant_cpu_to_le32(0x10) 756#define QOS_PARAM_FLG_TXOP_TYPE_MSK cpu_to_le32(0x10)
751 757
752/* Number of Access Categories (AC) (EDCA), queues 0..3 */ 758/* Number of Access Categories (AC) (EDCA), queues 0..3 */
753#define AC_NUM 4 759#define AC_NUM 4
@@ -784,34 +790,34 @@ struct iwl_qosparam_cmd {
784#define IWL_STATION_COUNT 32 /* MAX(3945,4965)*/ 790#define IWL_STATION_COUNT 32 /* MAX(3945,4965)*/
785#define IWL_INVALID_STATION 255 791#define IWL_INVALID_STATION 255
786 792
787#define STA_FLG_PWR_SAVE_MSK __constant_cpu_to_le32(1 << 8); 793#define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8);
788#define STA_FLG_RTS_MIMO_PROT_MSK __constant_cpu_to_le32(1 << 17) 794#define STA_FLG_RTS_MIMO_PROT_MSK cpu_to_le32(1 << 17)
789#define STA_FLG_AGG_MPDU_8US_MSK __constant_cpu_to_le32(1 << 18) 795#define STA_FLG_AGG_MPDU_8US_MSK cpu_to_le32(1 << 18)
790#define STA_FLG_MAX_AGG_SIZE_POS (19) 796#define STA_FLG_MAX_AGG_SIZE_POS (19)
791#define STA_FLG_MAX_AGG_SIZE_MSK __constant_cpu_to_le32(3 << 19) 797#define STA_FLG_MAX_AGG_SIZE_MSK cpu_to_le32(3 << 19)
792#define STA_FLG_FAT_EN_MSK __constant_cpu_to_le32(1 << 21) 798#define STA_FLG_FAT_EN_MSK cpu_to_le32(1 << 21)
793#define STA_FLG_MIMO_DIS_MSK __constant_cpu_to_le32(1 << 22) 799#define STA_FLG_MIMO_DIS_MSK cpu_to_le32(1 << 22)
794#define STA_FLG_AGG_MPDU_DENSITY_POS (23) 800#define STA_FLG_AGG_MPDU_DENSITY_POS (23)
795#define STA_FLG_AGG_MPDU_DENSITY_MSK __constant_cpu_to_le32(7 << 23) 801#define STA_FLG_AGG_MPDU_DENSITY_MSK cpu_to_le32(7 << 23)
796 802
797/* Use in mode field. 1: modify existing entry, 0: add new station entry */ 803/* Use in mode field. 1: modify existing entry, 0: add new station entry */
798#define STA_CONTROL_MODIFY_MSK 0x01 804#define STA_CONTROL_MODIFY_MSK 0x01
799 805
800/* key flags __le16*/ 806/* key flags __le16*/
801#define STA_KEY_FLG_ENCRYPT_MSK __constant_cpu_to_le16(0x0007) 807#define STA_KEY_FLG_ENCRYPT_MSK cpu_to_le16(0x0007)
802#define STA_KEY_FLG_NO_ENC __constant_cpu_to_le16(0x0000) 808#define STA_KEY_FLG_NO_ENC cpu_to_le16(0x0000)
803#define STA_KEY_FLG_WEP __constant_cpu_to_le16(0x0001) 809#define STA_KEY_FLG_WEP cpu_to_le16(0x0001)
804#define STA_KEY_FLG_CCMP __constant_cpu_to_le16(0x0002) 810#define STA_KEY_FLG_CCMP cpu_to_le16(0x0002)
805#define STA_KEY_FLG_TKIP __constant_cpu_to_le16(0x0003) 811#define STA_KEY_FLG_TKIP cpu_to_le16(0x0003)
806 812
807#define STA_KEY_FLG_KEYID_POS 8 813#define STA_KEY_FLG_KEYID_POS 8
808#define STA_KEY_FLG_INVALID __constant_cpu_to_le16(0x0800) 814#define STA_KEY_FLG_INVALID cpu_to_le16(0x0800)
809/* wep key is either from global key (0) or from station info array (1) */ 815/* wep key is either from global key (0) or from station info array (1) */
810#define STA_KEY_FLG_MAP_KEY_MSK __constant_cpu_to_le16(0x0008) 816#define STA_KEY_FLG_MAP_KEY_MSK cpu_to_le16(0x0008)
811 817
812/* wep key in STA: 5-bytes (0) or 13-bytes (1) */ 818/* wep key in STA: 5-bytes (0) or 13-bytes (1) */
813#define STA_KEY_FLG_KEY_SIZE_MSK __constant_cpu_to_le16(0x1000) 819#define STA_KEY_FLG_KEY_SIZE_MSK cpu_to_le16(0x1000)
814#define STA_KEY_MULTICAST_MSK __constant_cpu_to_le16(0x4000) 820#define STA_KEY_MULTICAST_MSK cpu_to_le16(0x4000)
815#define STA_KEY_MAX_NUM 8 821#define STA_KEY_MAX_NUM 8
816 822
817/* Flags indicate whether to modify vs. don't change various station params */ 823/* Flags indicate whether to modify vs. don't change various station params */
@@ -1036,14 +1042,14 @@ struct iwl4965_rx_frame_hdr {
1036 u8 payload[0]; 1042 u8 payload[0];
1037} __attribute__ ((packed)); 1043} __attribute__ ((packed));
1038 1044
1039#define RX_RES_STATUS_NO_CRC32_ERROR __constant_cpu_to_le32(1 << 0) 1045#define RX_RES_STATUS_NO_CRC32_ERROR cpu_to_le32(1 << 0)
1040#define RX_RES_STATUS_NO_RXE_OVERFLOW __constant_cpu_to_le32(1 << 1) 1046#define RX_RES_STATUS_NO_RXE_OVERFLOW cpu_to_le32(1 << 1)
1041 1047
1042#define RX_RES_PHY_FLAGS_BAND_24_MSK __constant_cpu_to_le16(1 << 0) 1048#define RX_RES_PHY_FLAGS_BAND_24_MSK cpu_to_le16(1 << 0)
1043#define RX_RES_PHY_FLAGS_MOD_CCK_MSK __constant_cpu_to_le16(1 << 1) 1049#define RX_RES_PHY_FLAGS_MOD_CCK_MSK cpu_to_le16(1 << 1)
1044#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK __constant_cpu_to_le16(1 << 2) 1050#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK cpu_to_le16(1 << 2)
1045#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK __constant_cpu_to_le16(1 << 3) 1051#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK cpu_to_le16(1 << 3)
1046#define RX_RES_PHY_FLAGS_ANTENNA_MSK __constant_cpu_to_le16(0xf0) 1052#define RX_RES_PHY_FLAGS_ANTENNA_MSK cpu_to_le16(0xf0)
1047 1053
1048#define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8) 1054#define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8)
1049#define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8) 1055#define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8)
@@ -1174,21 +1180,21 @@ struct iwl4965_rx_mpdu_res_start {
1174/* 1: Use RTS/CTS protocol or CTS-to-self if spec allows it 1180/* 1: Use RTS/CTS protocol or CTS-to-self if spec allows it
1175 * before this frame. if CTS-to-self required check 1181 * before this frame. if CTS-to-self required check
1176 * RXON_FLG_SELF_CTS_EN status. */ 1182 * RXON_FLG_SELF_CTS_EN status. */
1177#define TX_CMD_FLG_RTS_CTS_MSK __constant_cpu_to_le32(1 << 0) 1183#define TX_CMD_FLG_RTS_CTS_MSK cpu_to_le32(1 << 0)
1178 1184
1179/* 1: Use Request-To-Send protocol before this frame. 1185/* 1: Use Request-To-Send protocol before this frame.
1180 * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK. */ 1186 * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK. */
1181#define TX_CMD_FLG_RTS_MSK __constant_cpu_to_le32(1 << 1) 1187#define TX_CMD_FLG_RTS_MSK cpu_to_le32(1 << 1)
1182 1188
1183/* 1: Transmit Clear-To-Send to self before this frame. 1189/* 1: Transmit Clear-To-Send to self before this frame.
1184 * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames. 1190 * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames.
1185 * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK. */ 1191 * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK. */
1186#define TX_CMD_FLG_CTS_MSK __constant_cpu_to_le32(1 << 2) 1192#define TX_CMD_FLG_CTS_MSK cpu_to_le32(1 << 2)
1187 1193
1188/* 1: Expect ACK from receiving station 1194/* 1: Expect ACK from receiving station
1189 * 0: Don't expect ACK (MAC header's duration field s/b 0) 1195 * 0: Don't expect ACK (MAC header's duration field s/b 0)
1190 * Set this for unicast frames, but not broadcast/multicast. */ 1196 * Set this for unicast frames, but not broadcast/multicast. */
1191#define TX_CMD_FLG_ACK_MSK __constant_cpu_to_le32(1 << 3) 1197#define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3)
1192 1198
1193/* For 4965: 1199/* For 4965:
1194 * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD). 1200 * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD).
@@ -1196,40 +1202,40 @@ struct iwl4965_rx_mpdu_res_start {
1196 * uCode walks through table for additional Tx attempts. 1202 * uCode walks through table for additional Tx attempts.
1197 * 0: Use Tx rate/MCS from Tx command's rate_n_flags field. 1203 * 0: Use Tx rate/MCS from Tx command's rate_n_flags field.
1198 * This rate will be used for all Tx attempts; it will not be scaled. */ 1204 * This rate will be used for all Tx attempts; it will not be scaled. */
1199#define TX_CMD_FLG_STA_RATE_MSK __constant_cpu_to_le32(1 << 4) 1205#define TX_CMD_FLG_STA_RATE_MSK cpu_to_le32(1 << 4)
1200 1206
1201/* 1: Expect immediate block-ack. 1207/* 1: Expect immediate block-ack.
1202 * Set when Txing a block-ack request frame. Also set TX_CMD_FLG_ACK_MSK. */ 1208 * Set when Txing a block-ack request frame. Also set TX_CMD_FLG_ACK_MSK. */
1203#define TX_CMD_FLG_IMM_BA_RSP_MASK __constant_cpu_to_le32(1 << 6) 1209#define TX_CMD_FLG_IMM_BA_RSP_MASK cpu_to_le32(1 << 6)
1204 1210
1205/* 1: Frame requires full Tx-Op protection. 1211/* 1: Frame requires full Tx-Op protection.
1206 * Set this if either RTS or CTS Tx Flag gets set. */ 1212 * Set this if either RTS or CTS Tx Flag gets set. */
1207#define TX_CMD_FLG_FULL_TXOP_PROT_MSK __constant_cpu_to_le32(1 << 7) 1213#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7)
1208 1214
1209/* Tx antenna selection field; used only for 3945, reserved (0) for 4965. 1215/* Tx antenna selection field; used only for 3945, reserved (0) for 4965.
1210 * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */ 1216 * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */
1211#define TX_CMD_FLG_ANT_SEL_MSK __constant_cpu_to_le32(0xf00) 1217#define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00)
1212#define TX_CMD_FLG_ANT_A_MSK __constant_cpu_to_le32(1 << 8) 1218#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
1213#define TX_CMD_FLG_ANT_B_MSK __constant_cpu_to_le32(1 << 9) 1219#define TX_CMD_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
1214 1220
1215/* 1: Ignore Bluetooth priority for this frame. 1221/* 1: Ignore Bluetooth priority for this frame.
1216 * 0: Delay Tx until Bluetooth device is done (normal usage). */ 1222 * 0: Delay Tx until Bluetooth device is done (normal usage). */
1217#define TX_CMD_FLG_BT_DIS_MSK __constant_cpu_to_le32(1 << 12) 1223#define TX_CMD_FLG_BT_DIS_MSK cpu_to_le32(1 << 12)
1218 1224
1219/* 1: uCode overrides sequence control field in MAC header. 1225/* 1: uCode overrides sequence control field in MAC header.
1220 * 0: Driver provides sequence control field in MAC header. 1226 * 0: Driver provides sequence control field in MAC header.
1221 * Set this for management frames, non-QOS data frames, non-unicast frames, 1227 * Set this for management frames, non-QOS data frames, non-unicast frames,
1222 * and also in Tx command embedded in REPLY_SCAN_CMD for active scans. */ 1228 * and also in Tx command embedded in REPLY_SCAN_CMD for active scans. */
1223#define TX_CMD_FLG_SEQ_CTL_MSK __constant_cpu_to_le32(1 << 13) 1229#define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13)
1224 1230
1225/* 1: This frame is non-last MPDU; more fragments are coming. 1231/* 1: This frame is non-last MPDU; more fragments are coming.
1226 * 0: Last fragment, or not using fragmentation. */ 1232 * 0: Last fragment, or not using fragmentation. */
1227#define TX_CMD_FLG_MORE_FRAG_MSK __constant_cpu_to_le32(1 << 14) 1233#define TX_CMD_FLG_MORE_FRAG_MSK cpu_to_le32(1 << 14)
1228 1234
1229/* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame. 1235/* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame.
1230 * 0: No TSF required in outgoing frame. 1236 * 0: No TSF required in outgoing frame.
1231 * Set this for transmitting beacons and probe responses. */ 1237 * Set this for transmitting beacons and probe responses. */
1232#define TX_CMD_FLG_TSF_MSK __constant_cpu_to_le32(1 << 16) 1238#define TX_CMD_FLG_TSF_MSK cpu_to_le32(1 << 16)
1233 1239
1234/* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword 1240/* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword
1235 * alignment of frame's payload data field. 1241 * alignment of frame's payload data field.
@@ -1237,14 +1243,14 @@ struct iwl4965_rx_mpdu_res_start {
1237 * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4 1243 * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4
1238 * field (but not both). Driver must align frame data (i.e. data following 1244 * field (but not both). Driver must align frame data (i.e. data following
1239 * MAC header) to DWORD boundary. */ 1245 * MAC header) to DWORD boundary. */
1240#define TX_CMD_FLG_MH_PAD_MSK __constant_cpu_to_le32(1 << 20) 1246#define TX_CMD_FLG_MH_PAD_MSK cpu_to_le32(1 << 20)
1241 1247
1242/* accelerate aggregation support 1248/* accelerate aggregation support
1243 * 0 - no CCMP encryption; 1 - CCMP encryption */ 1249 * 0 - no CCMP encryption; 1 - CCMP encryption */
1244#define TX_CMD_FLG_AGG_CCMP_MSK __constant_cpu_to_le32(1 << 22) 1250#define TX_CMD_FLG_AGG_CCMP_MSK cpu_to_le32(1 << 22)
1245 1251
1246/* HCCA-AP - disable duration overwriting. */ 1252/* HCCA-AP - disable duration overwriting. */
1247#define TX_CMD_FLG_DUR_MSK __constant_cpu_to_le32(1 << 25) 1253#define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25)
1248 1254
1249 1255
1250/* 1256/*
@@ -2076,10 +2082,10 @@ struct iwl4965_spectrum_notification {
2076 */ 2082 */
2077#define IWL_POWER_VEC_SIZE 5 2083#define IWL_POWER_VEC_SIZE 5
2078 2084
2079#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK __constant_cpu_to_le16(1 << 0) 2085#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(1 << 0)
2080#define IWL_POWER_SLEEP_OVER_DTIM_MSK __constant_cpu_to_le16(1 << 2) 2086#define IWL_POWER_SLEEP_OVER_DTIM_MSK cpu_to_le16(1 << 2)
2081#define IWL_POWER_PCI_PM_MSK __constant_cpu_to_le16(1 << 3) 2087#define IWL_POWER_PCI_PM_MSK cpu_to_le16(1 << 3)
2082#define IWL_POWER_FAST_PD __constant_cpu_to_le16(1 << 4) 2088#define IWL_POWER_FAST_PD cpu_to_le16(1 << 4)
2083 2089
2084struct iwl_powertable_cmd { 2090struct iwl_powertable_cmd {
2085 __le16 flags; 2091 __le16 flags;
@@ -2153,8 +2159,8 @@ struct iwl_ct_kill_config {
2153 * 2159 *
2154 *****************************************************************************/ 2160 *****************************************************************************/
2155 2161
2156#define SCAN_CHANNEL_TYPE_PASSIVE __constant_cpu_to_le32(0) 2162#define SCAN_CHANNEL_TYPE_PASSIVE cpu_to_le32(0)
2157#define SCAN_CHANNEL_TYPE_ACTIVE __constant_cpu_to_le32(1) 2163#define SCAN_CHANNEL_TYPE_ACTIVE cpu_to_le32(1)
2158 2164
2159/** 2165/**
2160 * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table 2166 * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table
@@ -2205,8 +2211,8 @@ struct iwl_ssid_ie {
2205} __attribute__ ((packed)); 2211} __attribute__ ((packed));
2206 2212
2207#define PROBE_OPTION_MAX 0x14 2213#define PROBE_OPTION_MAX 0x14
2208#define TX_CMD_LIFE_TIME_INFINITE __constant_cpu_to_le32(0xFFFFFFFF) 2214#define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF)
2209#define IWL_GOOD_CRC_TH __constant_cpu_to_le16(1) 2215#define IWL_GOOD_CRC_TH cpu_to_le16(1)
2210#define IWL_MAX_SCAN_SIZE 1024 2216#define IWL_MAX_SCAN_SIZE 1024
2211 2217
2212/* 2218/*
@@ -2306,7 +2312,7 @@ struct iwl_scan_cmd {
2306} __attribute__ ((packed)); 2312} __attribute__ ((packed));
2307 2313
2308/* Can abort will notify by complete notification with abort status. */ 2314/* Can abort will notify by complete notification with abort status. */
2309#define CAN_ABORT_STATUS __constant_cpu_to_le32(0x1) 2315#define CAN_ABORT_STATUS cpu_to_le32(0x1)
2310/* complete notification statuses */ 2316/* complete notification statuses */
2311#define ABORT_STATUS 0x2 2317#define ABORT_STATUS 0x2
2312 2318
@@ -2568,8 +2574,8 @@ struct statistics_general {
2568 * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag 2574 * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag
2569 * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself. 2575 * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
2570 */ 2576 */
2571#define IWL_STATS_CONF_CLEAR_STATS __constant_cpu_to_le32(0x1) /* see above */ 2577#define IWL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */
2572#define IWL_STATS_CONF_DISABLE_NOTIF __constant_cpu_to_le32(0x2)/* see above */ 2578#define IWL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */
2573struct iwl_statistics_cmd { 2579struct iwl_statistics_cmd {
2574 __le32 configuration_flags; /* IWL_STATS_CONF_* */ 2580 __le32 configuration_flags; /* IWL_STATS_CONF_* */
2575} __attribute__ ((packed)); 2581} __attribute__ ((packed));
@@ -2589,8 +2595,8 @@ struct iwl_statistics_cmd {
2589 * appropriately so that each notification contains statistics for only the 2595 * appropriately so that each notification contains statistics for only the
2590 * one channel that has just been scanned. 2596 * one channel that has just been scanned.
2591 */ 2597 */
2592#define STATISTICS_REPLY_FLG_BAND_24G_MSK __constant_cpu_to_le32(0x2) 2598#define STATISTICS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2)
2593#define STATISTICS_REPLY_FLG_FAT_MODE_MSK __constant_cpu_to_le32(0x8) 2599#define STATISTICS_REPLY_FLG_FAT_MODE_MSK cpu_to_le32(0x8)
2594struct iwl_notif_statistics { 2600struct iwl_notif_statistics {
2595 __le32 flag; 2601 __le32 flag;
2596 struct statistics_rx rx; 2602 struct statistics_rx rx;
@@ -2806,8 +2812,8 @@ struct iwl4965_missed_beacon_notif {
2806#define HD_OFDM_ENERGY_TH_IN_INDEX (10) 2812#define HD_OFDM_ENERGY_TH_IN_INDEX (10)
2807 2813
2808/* Control field in struct iwl_sensitivity_cmd */ 2814/* Control field in struct iwl_sensitivity_cmd */
2809#define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE __constant_cpu_to_le16(0) 2815#define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE cpu_to_le16(0)
2810#define SENSITIVITY_CMD_CONTROL_WORK_TABLE __constant_cpu_to_le16(1) 2816#define SENSITIVITY_CMD_CONTROL_WORK_TABLE cpu_to_le16(1)
2811 2817
2812/** 2818/**
2813 * struct iwl_sensitivity_cmd 2819 * struct iwl_sensitivity_cmd
@@ -2896,12 +2902,7 @@ enum {
2896}; 2902};
2897 2903
2898 2904
2899struct iwl_cal_xtal_freq { 2905#define IWL_CALIB_INIT_CFG_ALL cpu_to_le32(0xffffffff)
2900 u8 cap_pin1;
2901 u8 cap_pin2;
2902} __attribute__ ((packed));
2903
2904#define IWL_CALIB_INIT_CFG_ALL __constant_cpu_to_le32(0xffffffff)
2905 2906
2906struct iwl_calib_cfg_elmnt_s { 2907struct iwl_calib_cfg_elmnt_s {
2907 __le32 is_enable; 2908 __le32 is_enable;
@@ -2935,31 +2936,34 @@ struct iwl_calib_cmd {
2935 u8 data[0]; 2936 u8 data[0];
2936} __attribute__ ((packed)); 2937} __attribute__ ((packed));
2937 2938
2938/* "Differential Gain" opcode used in REPLY_PHY_CALIBRATION_CMD. */ 2939/* IWL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
2939
2940struct iwl_calib_diff_gain_cmd { 2940struct iwl_calib_diff_gain_cmd {
2941 u8 opCode; /* IWL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */ 2941 struct iwl_calib_hdr hdr;
2942 u8 flags; /* not used */
2943 __le16 reserved;
2944 s8 diff_gain_a; /* see above */ 2942 s8 diff_gain_a; /* see above */
2945 s8 diff_gain_b; 2943 s8 diff_gain_b;
2946 s8 diff_gain_c; 2944 s8 diff_gain_c;
2947 u8 reserved1; 2945 u8 reserved1;
2948} __attribute__ ((packed)); 2946} __attribute__ ((packed));
2949 2947
2950struct iwl_calib_chain_noise_reset_cmd { 2948struct iwl_calib_xtal_freq_cmd {
2951 u8 op_code; /* IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */ 2949 struct iwl_calib_hdr hdr;
2952 u8 flags; /* not used */ 2950 u8 cap_pin1;
2953 __le16 reserved; 2951 u8 cap_pin2;
2952 u8 pad[2];
2954} __attribute__ ((packed)); 2953} __attribute__ ((packed));
2955 2954
2955/* IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */
2956struct iwl_calib_chain_noise_reset_cmd {
2957 struct iwl_calib_hdr hdr;
2958 u8 data[0];
2959};
2960
2961/* IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD */
2956struct iwl_calib_chain_noise_gain_cmd { 2962struct iwl_calib_chain_noise_gain_cmd {
2957 u8 op_code; /* IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD */ 2963 struct iwl_calib_hdr hdr;
2958 u8 flags; /* not used */
2959 __le16 reserved;
2960 u8 delta_gain_1; 2964 u8 delta_gain_1;
2961 u8 delta_gain_2; 2965 u8 delta_gain_2;
2962 __le16 reserved1; 2966 u8 pad[2];
2963} __attribute__ ((packed)); 2967} __attribute__ ((packed));
2964 2968
2965/****************************************************************************** 2969/******************************************************************************
@@ -3066,4 +3070,6 @@ struct iwl_rx_packet {
3066 3070
3067#define IWL_RX_FRAME_SIZE (4 + sizeof(struct iwl4965_rx_frame)) 3071#define IWL_RX_FRAME_SIZE (4 + sizeof(struct iwl4965_rx_frame))
3068 3072
3073int iwl_agn_check_rxon_cmd(struct iwl_rxon_cmd *rxon);
3074
3069#endif /* __iwl_commands_h__ */ 3075#endif /* __iwl_commands_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 6aa332bebc5f..1b021ca74e25 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -808,7 +808,6 @@ int iwl_setup_mac(struct iwl_priv *priv)
808 IEEE80211_HW_NOISE_DBM | 808 IEEE80211_HW_NOISE_DBM |
809 IEEE80211_HW_AMPDU_AGGREGATION; 809 IEEE80211_HW_AMPDU_AGGREGATION;
810 hw->wiphy->interface_modes = 810 hw->wiphy->interface_modes =
811 BIT(NL80211_IFTYPE_AP) |
812 BIT(NL80211_IFTYPE_STATION) | 811 BIT(NL80211_IFTYPE_STATION) |
813 BIT(NL80211_IFTYPE_ADHOC); 812 BIT(NL80211_IFTYPE_ADHOC);
814 813
@@ -962,6 +961,30 @@ void iwl_uninit_drv(struct iwl_priv *priv)
962} 961}
963EXPORT_SYMBOL(iwl_uninit_drv); 962EXPORT_SYMBOL(iwl_uninit_drv);
964 963
964
965void iwl_disable_interrupts(struct iwl_priv *priv)
966{
967 clear_bit(STATUS_INT_ENABLED, &priv->status);
968
969 /* disable interrupts from uCode/NIC to host */
970 iwl_write32(priv, CSR_INT_MASK, 0x00000000);
971
972 /* acknowledge/clear/reset any interrupts still pending
973 * from uCode or flow handler (Rx/Tx DMA) */
974 iwl_write32(priv, CSR_INT, 0xffffffff);
975 iwl_write32(priv, CSR_FH_INT_STATUS, 0xffffffff);
976 IWL_DEBUG_ISR("Disabled interrupts\n");
977}
978EXPORT_SYMBOL(iwl_disable_interrupts);
979
980void iwl_enable_interrupts(struct iwl_priv *priv)
981{
982 IWL_DEBUG_ISR("Enabling interrupts\n");
983 set_bit(STATUS_INT_ENABLED, &priv->status);
984 iwl_write32(priv, CSR_INT_MASK, CSR_INI_SET_MASK);
985}
986EXPORT_SYMBOL(iwl_enable_interrupts);
987
965int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags) 988int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags)
966{ 989{
967 u32 stat_flags = 0; 990 u32 stat_flags = 0;
@@ -1337,6 +1360,7 @@ void iwl_rf_kill_ct_config(struct iwl_priv *priv)
1337} 1360}
1338EXPORT_SYMBOL(iwl_rf_kill_ct_config); 1361EXPORT_SYMBOL(iwl_rf_kill_ct_config);
1339 1362
1363
1340/* 1364/*
1341 * CARD_STATE_CMD 1365 * CARD_STATE_CMD
1342 * 1366 *
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 82bf263b6f5a..81ddca077175 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -164,9 +164,39 @@ struct iwl_mod_params {
164 int restart_fw; /* def: 1 = restart firmware */ 164 int restart_fw; /* def: 1 = restart firmware */
165}; 165};
166 166
167/**
168 * struct iwl_cfg
169 * @fw_name_pre: Firmware filename prefix. The api version and extension
170 * (.ucode) will be added to filename before loading from disk. The
171 * filename is constructed as fw_name_pre<api>.ucode.
172 * @ucode_api_max: Highest version of uCode API supported by driver.
173 * @ucode_api_min: Lowest version of uCode API supported by driver.
174 *
175 * We enable the driver to be backward compatible wrt API version. The
176 * driver specifies which APIs it supports (with @ucode_api_max being the
177 * highest and @ucode_api_min the lowest). Firmware will only be loaded if
178 * it has a supported API version. The firmware's API version will be
179 * stored in @iwl_priv, enabling the driver to make runtime changes based
180 * on firmware version used.
181 *
182 * For example,
183 * if (IWL_UCODE_API(priv->ucode_ver) >= 2) {
184 * Driver interacts with Firmware API version >= 2.
185 * } else {
186 * Driver interacts with Firmware API version 1.
187 * }
188 *
189 * The ideal usage of this infrastructure is to treat a new ucode API
190 * release as a new hardware revision. That is, through utilizing the
191 * iwl_hcmd_utils_ops etc. we accommodate different command structures
192 * and flows between hardware versions (4965/5000) as well as their API
193 * versions.
194 */
167struct iwl_cfg { 195struct iwl_cfg {
168 const char *name; 196 const char *name;
169 const char *fw_name; 197 const char *fw_name_pre;
198 const unsigned int ucode_api_max;
199 const unsigned int ucode_api_min;
170 unsigned int sku; 200 unsigned int sku;
171 int eeprom_size; 201 int eeprom_size;
172 u16 eeprom_ver; 202 u16 eeprom_ver;
@@ -313,6 +343,12 @@ int iwl_send_cmd_pdu_async(struct iwl_priv *priv, u8 id, u16 len,
313int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd); 343int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
314 344
315/***************************************************** 345/*****************************************************
346 * PCI *
347 *****************************************************/
348void iwl_disable_interrupts(struct iwl_priv *priv);
349void iwl_enable_interrupts(struct iwl_priv *priv);
350
351/*****************************************************
316* Error Handling Debugging 352* Error Handling Debugging
317******************************************************/ 353******************************************************/
318void iwl_dump_nic_error_log(struct iwl_priv *priv); 354void iwl_dump_nic_error_log(struct iwl_priv *priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index 0e79a6ab4c81..a115dc64f6a6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -60,6 +60,7 @@ struct iwl_debugfs {
60 struct dentry *file_rx_statistics; 60 struct dentry *file_rx_statistics;
61 struct dentry *file_tx_statistics; 61 struct dentry *file_tx_statistics;
62 struct dentry *file_log_event; 62 struct dentry *file_log_event;
63 struct dentry *file_channels;
63 } dbgfs_data_files; 64 } dbgfs_data_files;
64 struct dir_rf_files { 65 struct dir_rf_files {
65 struct dentry *file_disable_sensitivity; 66 struct dentry *file_disable_sensitivity;
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index c3df5aa8df91..370b66c444b3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -348,12 +348,86 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
348 return count; 348 return count;
349} 349}
350 350
351
352
353static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
354 size_t count, loff_t *ppos)
355{
356 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
357 struct ieee80211_channel *channels = NULL;
358 const struct ieee80211_supported_band *supp_band = NULL;
359 int pos = 0, i, bufsz = PAGE_SIZE;
360 char *buf;
361 ssize_t ret;
362
363 if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status))
364 return -EAGAIN;
365
366 buf = kzalloc(bufsz, GFP_KERNEL);
367 if (!buf) {
368 IWL_ERROR("Can not allocate Buffer\n");
369 return -ENOMEM;
370 }
371
372 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
373 channels = supp_band->channels;
374
375 pos += scnprintf(buf + pos, bufsz - pos,
376 "Displaying %d channels in 2.4GHz band 802.11bg):\n",
377 supp_band->n_channels);
378
379 for (i = 0; i < supp_band->n_channels; i++)
380 pos += scnprintf(buf + pos, bufsz - pos,
381 "%d: %ddBm: BSS%s%s, %s.\n",
382 ieee80211_frequency_to_channel(
383 channels[i].center_freq),
384 channels[i].max_power,
385 channels[i].flags & IEEE80211_CHAN_RADAR ?
386 " (IEEE 802.11h required)" : "",
387 (!(channels[i].flags & IEEE80211_CHAN_NO_IBSS)
388 || (channels[i].flags &
389 IEEE80211_CHAN_RADAR)) ? "" :
390 ", IBSS",
391 channels[i].flags &
392 IEEE80211_CHAN_PASSIVE_SCAN ?
393 "passive only" : "active/passive");
394
395 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
396 channels = supp_band->channels;
397
398 pos += scnprintf(buf + pos, bufsz - pos,
399 "Displaying %d channels in 5.2GHz band (802.11a)\n",
400 supp_band->n_channels);
401
402 for (i = 0; i < supp_band->n_channels; i++)
403 pos += scnprintf(buf + pos, bufsz - pos,
404 "%d: %ddBm: BSS%s%s, %s.\n",
405 ieee80211_frequency_to_channel(
406 channels[i].center_freq),
407 channels[i].max_power,
408 channels[i].flags & IEEE80211_CHAN_RADAR ?
409 " (IEEE 802.11h required)" : "",
410 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
411 || (channels[i].flags &
412 IEEE80211_CHAN_RADAR)) ? "" :
413 ", IBSS",
414 channels[i].flags &
415 IEEE80211_CHAN_PASSIVE_SCAN ?
416 "passive only" : "active/passive");
417
418 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
419 kfree(buf);
420 return ret;
421}
422
423
351DEBUGFS_READ_WRITE_FILE_OPS(sram); 424DEBUGFS_READ_WRITE_FILE_OPS(sram);
352DEBUGFS_WRITE_FILE_OPS(log_event); 425DEBUGFS_WRITE_FILE_OPS(log_event);
353DEBUGFS_READ_FILE_OPS(eeprom); 426DEBUGFS_READ_FILE_OPS(eeprom);
354DEBUGFS_READ_FILE_OPS(stations); 427DEBUGFS_READ_FILE_OPS(stations);
355DEBUGFS_READ_FILE_OPS(rx_statistics); 428DEBUGFS_READ_FILE_OPS(rx_statistics);
356DEBUGFS_READ_FILE_OPS(tx_statistics); 429DEBUGFS_READ_FILE_OPS(tx_statistics);
430DEBUGFS_READ_FILE_OPS(channels);
357 431
358/* 432/*
359 * Create the debugfs files and directories 433 * Create the debugfs files and directories
@@ -387,6 +461,7 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
387 DEBUGFS_ADD_FILE(stations, data); 461 DEBUGFS_ADD_FILE(stations, data);
388 DEBUGFS_ADD_FILE(rx_statistics, data); 462 DEBUGFS_ADD_FILE(rx_statistics, data);
389 DEBUGFS_ADD_FILE(tx_statistics, data); 463 DEBUGFS_ADD_FILE(tx_statistics, data);
464 DEBUGFS_ADD_FILE(channels, data);
390 DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal); 465 DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal);
391 DEBUGFS_ADD_BOOL(disable_chain_noise, rf, 466 DEBUGFS_ADD_BOOL(disable_chain_noise, rf,
392 &priv->disable_chain_noise_cal); 467 &priv->disable_chain_noise_cal);
@@ -415,6 +490,7 @@ void iwl_dbgfs_unregister(struct iwl_priv *priv)
415 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram); 490 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram);
416 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_log_event); 491 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_log_event);
417 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations); 492 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations);
493 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_channels);
418 DEBUGFS_REMOVE(priv->dbgfs->dir_data); 494 DEBUGFS_REMOVE(priv->dbgfs->dir_data);
419 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity); 495 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity);
420 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise); 496 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 4da988e0eae0..a19fbb5eaae4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -54,6 +54,7 @@ extern struct iwl_cfg iwl5100_agn_cfg;
54extern struct iwl_cfg iwl5350_agn_cfg; 54extern struct iwl_cfg iwl5350_agn_cfg;
55extern struct iwl_cfg iwl5100_bg_cfg; 55extern struct iwl_cfg iwl5100_bg_cfg;
56extern struct iwl_cfg iwl5100_abg_cfg; 56extern struct iwl_cfg iwl5100_abg_cfg;
57extern struct iwl_cfg iwl5150_agn_cfg;
57 58
58/* CT-KILL constants */ 59/* CT-KILL constants */
59#define CT_KILL_THRESHOLD 110 /* in Celsius */ 60#define CT_KILL_THRESHOLD 110 /* in Celsius */
@@ -461,7 +462,7 @@ struct fw_desc {
461 462
462/* uCode file layout */ 463/* uCode file layout */
463struct iwl_ucode { 464struct iwl_ucode {
464 __le32 ver; /* major/minor/subminor */ 465 __le32 ver; /* major/minor/API/serial */
465 __le32 inst_size; /* bytes of runtime instructions */ 466 __le32 inst_size; /* bytes of runtime instructions */
466 __le32 data_size; /* bytes of runtime data */ 467 __le32 data_size; /* bytes of runtime data */
467 __le32 init_size; /* bytes of initialization instructions */ 468 __le32 init_size; /* bytes of initialization instructions */
@@ -507,6 +508,7 @@ struct iwl_sensitivity_ranges {
507/** 508/**
508 * struct iwl_hw_params 509 * struct iwl_hw_params
509 * @max_txq_num: Max # Tx queues supported 510 * @max_txq_num: Max # Tx queues supported
511 * @dma_chnl_num: Number of Tx DMA/FIFO channels
510 * @scd_bc_tbls_size: size of scheduler byte count tables 512 * @scd_bc_tbls_size: size of scheduler byte count tables
511 * @tx/rx_chains_num: Number of TX/RX chains 513 * @tx/rx_chains_num: Number of TX/RX chains
512 * @valid_tx/rx_ant: usable antennas 514 * @valid_tx/rx_ant: usable antennas
@@ -524,7 +526,8 @@ struct iwl_sensitivity_ranges {
524 * @struct iwl_sensitivity_ranges: range of sensitivity values 526 * @struct iwl_sensitivity_ranges: range of sensitivity values
525 */ 527 */
526struct iwl_hw_params { 528struct iwl_hw_params {
527 u16 max_txq_num; 529 u8 max_txq_num;
530 u8 dma_chnl_num;
528 u16 scd_bc_tbls_size; 531 u16 scd_bc_tbls_size;
529 u8 tx_chains_num; 532 u8 tx_chains_num;
530 u8 rx_chains_num; 533 u8 rx_chains_num;
@@ -692,6 +695,7 @@ struct statistics_general_data {
692 */ 695 */
693enum iwl_calib { 696enum iwl_calib {
694 IWL_CALIB_XTAL, 697 IWL_CALIB_XTAL,
698 IWL_CALIB_DC,
695 IWL_CALIB_LO, 699 IWL_CALIB_LO,
696 IWL_CALIB_TX_IQ, 700 IWL_CALIB_TX_IQ,
697 IWL_CALIB_TX_IQ_PERD, 701 IWL_CALIB_TX_IQ_PERD,
@@ -839,6 +843,8 @@ struct iwl_priv {
839 u8 rev_id; 843 u8 rev_id;
840 844
841 /* uCode images, save to reload in case of failure */ 845 /* uCode images, save to reload in case of failure */
846 u32 ucode_ver; /* version of ucode, copy of
847 iwl_ucode.ver */
842 struct fw_desc ucode_code; /* runtime inst */ 848 struct fw_desc ucode_code; /* runtime inst */
843 struct fw_desc ucode_data; /* runtime data original */ 849 struct fw_desc ucode_data; /* runtime data original */
844 struct fw_desc ucode_data_backup; /* runtime data save/restore */ 850 struct fw_desc ucode_data_backup; /* runtime data save/restore */
@@ -1084,9 +1090,4 @@ static inline int is_channel_ibss(const struct iwl_channel_info *ch)
1084 return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0; 1090 return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
1085} 1091}
1086 1092
1087extern const struct iwl_channel_info *iwl_get_channel_info(
1088 const struct iwl_priv *priv, enum ieee80211_band band, u16 channel);
1089
1090/* Requires full declaration of iwl_priv before including */
1091
1092#endif /* __iwl_dev_h__ */ 1093#endif /* __iwl_dev_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
index 997f23c8db2e..8f6b05fa2330 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
@@ -147,6 +147,7 @@ struct iwl_eeprom_channel {
147/*5000 calibrations */ 147/*5000 calibrations */
148#define EEPROM_5000_CALIB_ALL (INDIRECT_ADDRESS | INDIRECT_CALIBRATION) 148#define EEPROM_5000_CALIB_ALL (INDIRECT_ADDRESS | INDIRECT_CALIBRATION)
149#define EEPROM_5000_XTAL ((2*0x128) | EEPROM_5000_CALIB_ALL) 149#define EEPROM_5000_XTAL ((2*0x128) | EEPROM_5000_CALIB_ALL)
150#define EEPROM_5000_TEMPERATURE ((2*0x12A) | EEPROM_5000_CALIB_ALL)
150 151
151/* 5000 links */ 152/* 5000 links */
152#define EEPROM_5000_LINK_HOST (2*0x64) 153#define EEPROM_5000_LINK_HOST (2*0x64)
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index e045dfeaa1fe..18d6cf67d9b7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -611,7 +611,7 @@ int iwl_txq_ctx_reset(struct iwl_priv *priv)
611 */ 611 */
612void iwl_txq_ctx_stop(struct iwl_priv *priv) 612void iwl_txq_ctx_stop(struct iwl_priv *priv)
613{ 613{
614 int txq_id; 614 int ch;
615 unsigned long flags; 615 unsigned long flags;
616 616
617 /* Turn off all Tx DMA fifos */ 617 /* Turn off all Tx DMA fifos */
@@ -624,12 +624,11 @@ void iwl_txq_ctx_stop(struct iwl_priv *priv)
624 priv->cfg->ops->lib->txq_set_sched(priv, 0); 624 priv->cfg->ops->lib->txq_set_sched(priv, 0);
625 625
626 /* Stop each Tx DMA channel, and wait for it to be idle */ 626 /* Stop each Tx DMA channel, and wait for it to be idle */
627 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { 627 for (ch = 0; ch < priv->hw_params.dma_chnl_num; ch++) {
628 iwl_write_direct32(priv, 628 iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0);
629 FH_TCSR_CHNL_TX_CONFIG_REG(txq_id), 0x0);
630 iwl_poll_direct_bit(priv, FH_TSSR_TX_STATUS_REG, 629 iwl_poll_direct_bit(priv, FH_TSSR_TX_STATUS_REG,
631 FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE 630 FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch),
632 (txq_id), 200); 631 200);
633 } 632 }
634 iwl_release_nic_access(priv); 633 iwl_release_nic_access(priv);
635 spin_unlock_irqrestore(&priv->lock, flags); 634 spin_unlock_irqrestore(&priv->lock, flags);
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 69fda64c6503..1a411c2d83e6 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -4311,35 +4311,6 @@ static void iwl3945_irq_tasklet(struct iwl3945_priv *priv)
4311 /* Safely ignore these bits for debug checks below */ 4311 /* Safely ignore these bits for debug checks below */
4312 inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE); 4312 inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE);
4313 4313
4314 /* HW RF KILL switch toggled (4965 only) */
4315 if (inta & CSR_INT_BIT_RF_KILL) {
4316 int hw_rf_kill = 0;
4317 if (!(iwl3945_read32(priv, CSR_GP_CNTRL) &
4318 CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW))
4319 hw_rf_kill = 1;
4320
4321 IWL_DEBUG(IWL_DL_INFO | IWL_DL_RF_KILL | IWL_DL_ISR,
4322 "RF_KILL bit toggled to %s.\n",
4323 hw_rf_kill ? "disable radio" : "enable radio");
4324
4325 /* Queue restart only if RF_KILL switch was set to "kill"
4326 * when we loaded driver, and is now set to "enable".
4327 * After we're Alive, RF_KILL gets handled by
4328 * iwl3945_rx_card_state_notif() */
4329 if (!hw_rf_kill && !test_bit(STATUS_ALIVE, &priv->status)) {
4330 clear_bit(STATUS_RF_KILL_HW, &priv->status);
4331 queue_work(priv->workqueue, &priv->restart);
4332 }
4333
4334 handled |= CSR_INT_BIT_RF_KILL;
4335 }
4336
4337 /* Chip got too hot and stopped itself (4965 only) */
4338 if (inta & CSR_INT_BIT_CT_KILL) {
4339 IWL_ERROR("Microcode CT kill error detected.\n");
4340 handled |= CSR_INT_BIT_CT_KILL;
4341 }
4342
4343 /* Error detected by uCode */ 4314 /* Error detected by uCode */
4344 if (inta & CSR_INT_BIT_SW_ERR) { 4315 if (inta & CSR_INT_BIT_SW_ERR) {
4345 IWL_ERROR("Microcode SW error detected. Restarting 0x%X.\n", 4316 IWL_ERROR("Microcode SW error detected. Restarting 0x%X.\n",
@@ -4440,7 +4411,7 @@ static irqreturn_t iwl3945_isr(int irq, void *data)
4440 4411
4441 if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) { 4412 if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) {
4442 /* Hardware disappeared */ 4413 /* Hardware disappeared */
4443 IWL_WARNING("HARDWARE GONE?? INTA == 0x%080x\n", inta); 4414 IWL_WARNING("HARDWARE GONE?? INTA == 0x%08x\n", inta);
4444 goto unplugged; 4415 goto unplugged;
4445 } 4416 }
4446 4417
@@ -4814,17 +4785,33 @@ static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv,
4814 continue; 4785 continue;
4815 } 4786 }
4816 4787
4788 scan_ch->active_dwell = cpu_to_le16(active_dwell);
4789 scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
4790 /* If passive , set up for auto-switch
4791 * and use long active_dwell time.
4792 */
4817 if (!is_active || is_channel_passive(ch_info) || 4793 if (!is_active || is_channel_passive(ch_info) ||
4818 (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN)) 4794 (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN)) {
4819 scan_ch->type = 0; /* passive */ 4795 scan_ch->type = 0; /* passive */
4820 else 4796 if (IWL_UCODE_API(priv->ucode_ver) == 1)
4797 scan_ch->active_dwell = cpu_to_le16(passive_dwell - 1);
4798 } else {
4821 scan_ch->type = 1; /* active */ 4799 scan_ch->type = 1; /* active */
4800 }
4822 4801
4823 if ((scan_ch->type & 1) && n_probes) 4802 /* Set direct probe bits. These may be used both for active
4824 scan_ch->type |= IWL_SCAN_PROBE_MASK(n_probes); 4803 * scan channels (probes gets sent right away),
4825 4804 * or for passive channels (probes get se sent only after
4826 scan_ch->active_dwell = cpu_to_le16(active_dwell); 4805 * hearing clear Rx packet).*/
4827 scan_ch->passive_dwell = cpu_to_le16(passive_dwell); 4806 if (IWL_UCODE_API(priv->ucode_ver) >= 2) {
4807 if (n_probes)
4808 scan_ch->type |= IWL_SCAN_PROBE_MASK(n_probes);
4809 } else {
4810 /* uCode v1 does not allow setting direct probe bits on
4811 * passive channel. */
4812 if ((scan_ch->type & 1) && n_probes)
4813 scan_ch->type |= IWL_SCAN_PROBE_MASK(n_probes);
4814 }
4828 4815
4829 /* Set txpower levels to defaults */ 4816 /* Set txpower levels to defaults */
4830 scan_ch->tpc.dsp_atten = 110; 4817 scan_ch->tpc.dsp_atten = 110;
@@ -5325,25 +5312,41 @@ static void iwl3945_nic_start(struct iwl3945_priv *priv)
5325static int iwl3945_read_ucode(struct iwl3945_priv *priv) 5312static int iwl3945_read_ucode(struct iwl3945_priv *priv)
5326{ 5313{
5327 struct iwl3945_ucode *ucode; 5314 struct iwl3945_ucode *ucode;
5328 int ret = 0; 5315 int ret = -EINVAL, index;
5329 const struct firmware *ucode_raw; 5316 const struct firmware *ucode_raw;
5330 /* firmware file name contains uCode/driver compatibility version */ 5317 /* firmware file name contains uCode/driver compatibility version */
5331 const char *name = priv->cfg->fw_name; 5318 const char *name_pre = priv->cfg->fw_name_pre;
5319 const unsigned int api_max = priv->cfg->ucode_api_max;
5320 const unsigned int api_min = priv->cfg->ucode_api_min;
5321 char buf[25];
5332 u8 *src; 5322 u8 *src;
5333 size_t len; 5323 size_t len;
5334 u32 ver, inst_size, data_size, init_size, init_data_size, boot_size; 5324 u32 api_ver, inst_size, data_size, init_size, init_data_size, boot_size;
5335 5325
5336 /* Ask kernel firmware_class module to get the boot firmware off disk. 5326 /* Ask kernel firmware_class module to get the boot firmware off disk.
5337 * request_firmware() is synchronous, file is in memory on return. */ 5327 * request_firmware() is synchronous, file is in memory on return. */
5338 ret = request_firmware(&ucode_raw, name, &priv->pci_dev->dev); 5328 for (index = api_max; index >= api_min; index--) {
5339 if (ret < 0) { 5329 sprintf(buf, "%s%u%s", name_pre, index, ".ucode");
5340 IWL_ERROR("%s firmware file req failed: Reason %d\n", 5330 ret = request_firmware(&ucode_raw, buf, &priv->pci_dev->dev);
5341 name, ret); 5331 if (ret < 0) {
5342 goto error; 5332 IWL_ERROR("%s firmware file req failed: Reason %d\n",
5333 buf, ret);
5334 if (ret == -ENOENT)
5335 continue;
5336 else
5337 goto error;
5338 } else {
5339 if (index < api_max)
5340 IWL_ERROR("Loaded firmware %s, which is deprecated. Please use API v%u instead.\n",
5341 buf, api_max);
5342 IWL_DEBUG_INFO("Got firmware '%s' file (%zd bytes) from disk\n",
5343 buf, ucode_raw->size);
5344 break;
5345 }
5343 } 5346 }
5344 5347
5345 IWL_DEBUG_INFO("Got firmware '%s' file (%zd bytes) from disk\n", 5348 if (ret < 0)
5346 name, ucode_raw->size); 5349 goto error;
5347 5350
5348 /* Make sure that we got at least our header! */ 5351 /* Make sure that we got at least our header! */
5349 if (ucode_raw->size < sizeof(*ucode)) { 5352 if (ucode_raw->size < sizeof(*ucode)) {
@@ -5355,20 +5358,46 @@ static int iwl3945_read_ucode(struct iwl3945_priv *priv)
5355 /* Data from ucode file: header followed by uCode images */ 5358 /* Data from ucode file: header followed by uCode images */
5356 ucode = (void *)ucode_raw->data; 5359 ucode = (void *)ucode_raw->data;
5357 5360
5358 ver = le32_to_cpu(ucode->ver); 5361 priv->ucode_ver = le32_to_cpu(ucode->ver);
5362 api_ver = IWL_UCODE_API(priv->ucode_ver);
5359 inst_size = le32_to_cpu(ucode->inst_size); 5363 inst_size = le32_to_cpu(ucode->inst_size);
5360 data_size = le32_to_cpu(ucode->data_size); 5364 data_size = le32_to_cpu(ucode->data_size);
5361 init_size = le32_to_cpu(ucode->init_size); 5365 init_size = le32_to_cpu(ucode->init_size);
5362 init_data_size = le32_to_cpu(ucode->init_data_size); 5366 init_data_size = le32_to_cpu(ucode->init_data_size);
5363 boot_size = le32_to_cpu(ucode->boot_size); 5367 boot_size = le32_to_cpu(ucode->boot_size);
5364 5368
5365 IWL_DEBUG_INFO("f/w package hdr ucode version = 0x%x\n", ver); 5369 /* api_ver should match the api version forming part of the
5370 * firmware filename ... but we don't check for that and only rely
5371 * on the API version read from firware header from here on forward */
5372
5373 if (api_ver < api_min || api_ver > api_max) {
5374 IWL_ERROR("Driver unable to support your firmware API. "
5375 "Driver supports v%u, firmware is v%u.\n",
5376 api_max, api_ver);
5377 priv->ucode_ver = 0;
5378 ret = -EINVAL;
5379 goto err_release;
5380 }
5381 if (api_ver != api_max)
5382 IWL_ERROR("Firmware has old API version. Expected %u, "
5383 "got %u. New firmware can be obtained "
5384 "from http://www.intellinuxwireless.org.\n",
5385 api_max, api_ver);
5386
5387 printk(KERN_INFO DRV_NAME " loaded firmware version %u.%u.%u.%u\n",
5388 IWL_UCODE_MAJOR(priv->ucode_ver),
5389 IWL_UCODE_MINOR(priv->ucode_ver),
5390 IWL_UCODE_API(priv->ucode_ver),
5391 IWL_UCODE_SERIAL(priv->ucode_ver));
5392 IWL_DEBUG_INFO("f/w package hdr ucode version raw = 0x%x\n",
5393 priv->ucode_ver);
5366 IWL_DEBUG_INFO("f/w package hdr runtime inst size = %u\n", inst_size); 5394 IWL_DEBUG_INFO("f/w package hdr runtime inst size = %u\n", inst_size);
5367 IWL_DEBUG_INFO("f/w package hdr runtime data size = %u\n", data_size); 5395 IWL_DEBUG_INFO("f/w package hdr runtime data size = %u\n", data_size);
5368 IWL_DEBUG_INFO("f/w package hdr init inst size = %u\n", init_size); 5396 IWL_DEBUG_INFO("f/w package hdr init inst size = %u\n", init_size);
5369 IWL_DEBUG_INFO("f/w package hdr init data size = %u\n", init_data_size); 5397 IWL_DEBUG_INFO("f/w package hdr init data size = %u\n", init_data_size);
5370 IWL_DEBUG_INFO("f/w package hdr boot inst size = %u\n", boot_size); 5398 IWL_DEBUG_INFO("f/w package hdr boot inst size = %u\n", boot_size);
5371 5399
5400
5372 /* Verify size of file vs. image size info in file's header */ 5401 /* Verify size of file vs. image size info in file's header */
5373 if (ucode_raw->size < sizeof(*ucode) + 5402 if (ucode_raw->size < sizeof(*ucode) +
5374 inst_size + data_size + init_size + 5403 inst_size + data_size + init_size +
@@ -7843,7 +7872,6 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7843 IEEE80211_HW_NOISE_DBM; 7872 IEEE80211_HW_NOISE_DBM;
7844 7873
7845 hw->wiphy->interface_modes = 7874 hw->wiphy->interface_modes =
7846 BIT(NL80211_IFTYPE_AP) |
7847 BIT(NL80211_IFTYPE_STATION) | 7875 BIT(NL80211_IFTYPE_STATION) |
7848 BIT(NL80211_IFTYPE_ADHOC); 7876 BIT(NL80211_IFTYPE_ADHOC);
7849 7877
@@ -8328,7 +8356,7 @@ static void __exit iwl3945_exit(void)
8328 iwl3945_rate_control_unregister(); 8356 iwl3945_rate_control_unregister();
8329} 8357}
8330 8358
8331MODULE_FIRMWARE("iwlwifi-3945" IWL3945_UCODE_API ".ucode"); 8359MODULE_FIRMWARE(IWL3945_MODULE_FIRMWARE(IWL3945_UCODE_API_MAX));
8332 8360
8333module_param_named(antenna, iwl3945_param_antenna, int, 0444); 8361module_param_named(antenna, iwl3945_param_antenna, int, 0444);
8334MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])"); 8362MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])");