aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorBen Cahill <ben.m.cahill@intel.com>2007-11-28 22:09:47 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:05:17 -0500
commit9fbab5163aa8cb3a5aef845fbf67b0c1c85030b6 (patch)
tree6e078dc2ea37ea4aff9b2fb262ef278ae12b61b5 /drivers/net
parent40ac81a35c3a19f6a78f0a9f58368d36048df35b (diff)
iwlwifi: clean up and clarify some comments after 3945/4965 split
Clean up and clarify some comments after 3945/4965 split. Signed-off-by: Ben Cahill <ben.m.cahill@intel.com> Signed-off-by: Zhu Yi <yi.zhu@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.h11
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965-rs.h5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c126
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c163
4 files changed, 132 insertions, 173 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.h b/drivers/net/wireless/iwlwifi/iwl-3945-rs.h
index 075f7de0976e..e21a5bae687f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.h
@@ -28,8 +28,8 @@
28#define __iwl_3945_rs_h__ 28#define __iwl_3945_rs_h__
29 29
30struct iwl3945_rate_info { 30struct iwl3945_rate_info {
31 u8 plcp; 31 u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */
32 u8 ieee; 32 u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */
33 u8 prev_ieee; /* previous rate in IEEE speeds */ 33 u8 prev_ieee; /* previous rate in IEEE speeds */
34 u8 next_ieee; /* next rate in IEEE speeds */ 34 u8 next_ieee; /* next rate in IEEE speeds */
35 u8 prev_rs; /* previous rate used in rs algo */ 35 u8 prev_rs; /* previous rate used in rs algo */
@@ -38,9 +38,12 @@ struct iwl3945_rate_info {
38 u8 next_rs_tgg; /* next rate used in TGG rs algo */ 38 u8 next_rs_tgg; /* next rate used in TGG rs algo */
39 u8 table_rs_index; /* index in rate scale table cmd */ 39 u8 table_rs_index; /* index in rate scale table cmd */
40 u8 prev_table_rs; /* prev in rate table cmd */ 40 u8 prev_table_rs; /* prev in rate table cmd */
41
42}; 41};
43 42
43/*
44 * These serve as indexes into
45 * struct iwl3945_rate_info iwl3945_rates[IWL_RATE_COUNT];
46 */
44enum { 47enum {
45 IWL_RATE_1M_INDEX = 0, 48 IWL_RATE_1M_INDEX = 0,
46 IWL_RATE_2M_INDEX, 49 IWL_RATE_2M_INDEX,
@@ -96,6 +99,7 @@ enum {
96#define IWL_RATE_5M_MASK (1<<IWL_RATE_5M_INDEX) 99#define IWL_RATE_5M_MASK (1<<IWL_RATE_5M_INDEX)
97#define IWL_RATE_11M_MASK (1<<IWL_RATE_11M_INDEX) 100#define IWL_RATE_11M_MASK (1<<IWL_RATE_11M_INDEX)
98 101
102/* 3945 uCode API values for (legacy) bit rates, both OFDM and CCK */
99enum { 103enum {
100 IWL_RATE_6M_PLCP = 13, 104 IWL_RATE_6M_PLCP = 13,
101 IWL_RATE_9M_PLCP = 15, 105 IWL_RATE_9M_PLCP = 15,
@@ -111,6 +115,7 @@ enum {
111 IWL_RATE_11M_PLCP = 110, 115 IWL_RATE_11M_PLCP = 110,
112}; 116};
113 117
118/* MAC header values for bit rates */
114enum { 119enum {
115 IWL_RATE_6M_IEEE = 12, 120 IWL_RATE_6M_IEEE = 12,
116 IWL_RATE_9M_IEEE = 18, 121 IWL_RATE_9M_IEEE = 18,
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.h b/drivers/net/wireless/iwlwifi/iwl-4965-rs.h
index 86f62d809058..0c9552b26c40 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.h
@@ -42,7 +42,10 @@ struct iwl4965_rate_info {
42 u8 next_rs_tgg; /* next rate used in TGG rs algo */ 42 u8 next_rs_tgg; /* next rate used in TGG rs algo */
43}; 43};
44 44
45/* For driver (not uCode API) */ 45/*
46 * These serve as indexes into
47 * struct iwl4965_rate_info iwl4965_rates[IWL_RATE_COUNT];
48 */
46enum { 49enum {
47 IWL_RATE_1M_INDEX = 0, 50 IWL_RATE_1M_INDEX = 0,
48 IWL_RATE_2M_INDEX, 51 IWL_RATE_2M_INDEX,
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index e8d198047185..ba5146ffdf4d 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -27,16 +27,6 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30/*
31 * NOTE: This file (iwl-base.c) is used to build to multiple hardware targets
32 * by defining IWL to either 3945 or 4965. The Makefile used when building
33 * the base targets will create base-3945.o and base-4965.o
34 *
35 * The eventual goal is to move as many of the #if IWL / #endif blocks out of
36 * this file and into the hardware specific implementation files (iwl-XXXX.c)
37 * and leave only the common (non #ifdef sprinkled) code in this file
38 */
39
40#include <linux/kernel.h> 30#include <linux/kernel.h>
41#include <linux/module.h> 31#include <linux/module.h>
42#include <linux/version.h> 32#include <linux/version.h>
@@ -75,9 +65,9 @@ static int iwl3945_tx_queue_update_write_ptr(struct iwl3945_priv *priv,
75/* module parameters */ 65/* module parameters */
76static int iwl3945_param_disable_hw_scan; 66static int iwl3945_param_disable_hw_scan;
77static int iwl3945_param_debug; 67static int iwl3945_param_debug;
78static int iwl3945_param_disable; /* def: enable radio */ 68static int iwl3945_param_disable; /* def: enable radio */
79static int iwl3945_param_antenna; /* def: 0 = both antennas (use diversity) */ 69static int iwl3945_param_antenna; /* def: 0 = both antennas (use diversity) */
80int iwl3945_param_hwcrypto; /* def: using software encryption */ 70int iwl3945_param_hwcrypto; /* def: using software encryption */
81static int iwl3945_param_qos_enable = 1; 71static int iwl3945_param_qos_enable = 1;
82int iwl3945_param_queues_num = IWL_MAX_NUM_QUEUES; 72int iwl3945_param_queues_num = IWL_MAX_NUM_QUEUES;
83 73
@@ -396,11 +386,7 @@ void iwl3945_tx_queue_free(struct iwl3945_priv *priv, struct iwl3945_tx_queue *t
396const u8 iwl3945_broadcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 386const u8 iwl3945_broadcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
397 387
398/*************** STATION TABLE MANAGEMENT **** 388/*************** STATION TABLE MANAGEMENT ****
399 * 389 * mac80211 should be examined to determine if sta_info is duplicating
400 * NOTE: This needs to be overhauled to better synchronize between
401 * how the iwl-4965.c is using iwl3945_hw_find_station vs. iwl-3945.c
402 *
403 * mac80211 should also be examined to determine if sta_info is duplicating
404 * the functionality provided here 390 * the functionality provided here
405 */ 391 */
406 392
@@ -956,12 +942,12 @@ static int iwl3945_check_rxon_cmd(struct iwl3945_rxon_cmd *rxon)
956} 942}
957 943
958/** 944/**
959 * iwl3945_full_rxon_required - determine if RXON_ASSOC can be used in RXON commit 945 * iwl3945_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed
960 * @priv: staging_rxon is compared to active_rxon 946 * @priv: staging_rxon is compared to active_rxon
961 * 947 *
962 * If the RXON structure is changing sufficient to require a new 948 * If the RXON structure is changing enough to require a new tune,
963 * tune or to clear and reset the RXON_FILTER_ASSOC_MSK then return 1 949 * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that
964 * to indicate a new tune is required. 950 * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required.
965 */ 951 */
966static int iwl3945_full_rxon_required(struct iwl3945_priv *priv) 952static int iwl3945_full_rxon_required(struct iwl3945_priv *priv)
967{ 953{
@@ -1235,7 +1221,7 @@ static int iwl3945_card_state_sync_callback(struct iwl3945_priv *priv,
1235/* 1221/*
1236 * CARD_STATE_CMD 1222 * CARD_STATE_CMD
1237 * 1223 *
1238 * Use: Sets the internal card state to enable, disable, or halt 1224 * Use: Sets the device's internal card state to enable, disable, or halt
1239 * 1225 *
1240 * When in the 'enable' state the card operates as normal. 1226 * When in the 'enable' state the card operates as normal.
1241 * When in the 'disable' state, the card enters into a low power mode. 1227 * When in the 'disable' state, the card enters into a low power mode.
@@ -1589,14 +1575,9 @@ int iwl3945_eeprom_init(struct iwl3945_priv *priv)
1589/** 1575/**
1590 * iwl3945_report_frame - dump frame to syslog during debug sessions 1576 * iwl3945_report_frame - dump frame to syslog during debug sessions
1591 * 1577 *
1592 * hack this function to show different aspects of received frames, 1578 * You may hack this function to show different aspects of received frames,
1593 * including selective frame dumps. 1579 * including selective frame dumps.
1594 * group100 parameter selects whether to show 1 out of 100 good frames. 1580 * group100 parameter selects whether to show 1 out of 100 good frames.
1595 *
1596 * TODO: ieee80211_hdr stuff is common to 3945 and 4965, so frame type
1597 * info output is okay, but some of this stuff (e.g. iwl3945_rx_frame_stats)
1598 * is 3945-specific and gives bad output for 4965. Need to split the
1599 * functionality, keep common stuff here.
1600 */ 1581 */
1601void iwl3945_report_frame(struct iwl3945_priv *priv, 1582void iwl3945_report_frame(struct iwl3945_priv *priv,
1602 struct iwl3945_rx_packet *pkt, 1583 struct iwl3945_rx_packet *pkt,
@@ -3775,13 +3756,10 @@ static void iwl3945_setup_rx_handlers(struct iwl3945_priv *priv)
3775 iwl3945_rx_pm_debug_statistics_notif; 3756 iwl3945_rx_pm_debug_statistics_notif;
3776 priv->rx_handlers[BEACON_NOTIFICATION] = iwl3945_rx_beacon_notif; 3757 priv->rx_handlers[BEACON_NOTIFICATION] = iwl3945_rx_beacon_notif;
3777 3758
3778 /* NOTE: iwl3945_rx_statistics is different based on whether 3759 /*
3779 * the build is for the 3945 or the 4965. See the 3760 * The same handler is used for both the REPLY to a discrete
3780 * corresponding implementation in iwl-XXXX.c 3761 * statistics request from the host as well as for the periodic
3781 * 3762 * statistics notifications (after received beacons) from the uCode.
3782 * The same handler is used for both the REPLY to a
3783 * discrete statistics request from the host as well as
3784 * for the periodic statistics notification from the uCode
3785 */ 3763 */
3786 priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl3945_hw_rx_statistics; 3764 priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl3945_hw_rx_statistics;
3787 priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl3945_hw_rx_statistics; 3765 priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl3945_hw_rx_statistics;
@@ -3795,7 +3773,7 @@ static void iwl3945_setup_rx_handlers(struct iwl3945_priv *priv)
3795 priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl3945_rx_card_state_notif; 3773 priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl3945_rx_card_state_notif;
3796 priv->rx_handlers[REPLY_TX] = iwl3945_rx_reply_tx; 3774 priv->rx_handlers[REPLY_TX] = iwl3945_rx_reply_tx;
3797 3775
3798 /* Setup hardware specific Rx handlers */ 3776 /* Set up hardware specific Rx handlers */
3799 iwl3945_hw_rx_handler_setup(priv); 3777 iwl3945_hw_rx_handler_setup(priv);
3800} 3778}
3801 3779
@@ -3867,10 +3845,10 @@ static void iwl3945_tx_cmd_complete(struct iwl3945_priv *priv,
3867 * The queue is empty (no good data) if WRITE = READ - 1, and is full if 3845 * The queue is empty (no good data) if WRITE = READ - 1, and is full if
3868 * WRITE = READ. 3846 * WRITE = READ.
3869 * 3847 *
3870 * During initialization the host sets up the READ queue position to the first 3848 * During initialization, the host sets up the READ queue position to the first
3871 * INDEX position, and WRITE to the last (READ - 1 wrapped) 3849 * INDEX position, and WRITE to the last (READ - 1 wrapped)
3872 * 3850 *
3873 * When the firmware places a packet in a buffer it will advance the READ index 3851 * When the firmware places a packet in a buffer, it will advance the READ index
3874 * and fire the RX interrupt. The driver can then query the READ index and 3852 * and fire the RX interrupt. The driver can then query the READ index and
3875 * process as many packets as possible, moving the WRITE index forward as it 3853 * process as many packets as possible, moving the WRITE index forward as it
3876 * resets the Rx queue buffers with new memory. 3854 * resets the Rx queue buffers with new memory.
@@ -3892,16 +3870,16 @@ static void iwl3945_tx_cmd_complete(struct iwl3945_priv *priv,
3892 * 3870 *
3893 * Driver sequence: 3871 * Driver sequence:
3894 * 3872 *
3895 * iwl3945_rx_queue_alloc() Allocates rx_free 3873 * iwl3945_rx_queue_alloc() Allocates rx_free
3896 * iwl3945_rx_replenish() Replenishes rx_free list from rx_used, and calls 3874 * iwl3945_rx_replenish() Replenishes rx_free list from rx_used, and calls
3897 * iwl3945_rx_queue_restock 3875 * iwl3945_rx_queue_restock
3898 * iwl3945_rx_queue_restock() Moves available buffers from rx_free into Rx 3876 * iwl3945_rx_queue_restock() Moves available buffers from rx_free into Rx
3899 * queue, updates firmware pointers, and updates 3877 * queue, updates firmware pointers, and updates
3900 * the WRITE index. If insufficient rx_free buffers 3878 * the WRITE index. If insufficient rx_free buffers
3901 * are available, schedules iwl3945_rx_replenish 3879 * are available, schedules iwl3945_rx_replenish
3902 * 3880 *
3903 * -- enable interrupts -- 3881 * -- enable interrupts --
3904 * ISR - iwl3945_rx() Detach iwl3945_rx_mem_buffers from pool up to the 3882 * ISR - iwl3945_rx() Detach iwl3945_rx_mem_buffers from pool up to the
3905 * READ INDEX, detaching the SKB from the pool. 3883 * READ INDEX, detaching the SKB from the pool.
3906 * Moves the packet buffer from queue to rx_used. 3884 * Moves the packet buffer from queue to rx_used.
3907 * Calls iwl3945_rx_queue_restock to refill any empty 3885 * Calls iwl3945_rx_queue_restock to refill any empty
@@ -3927,12 +3905,6 @@ static int iwl3945_rx_queue_space(const struct iwl3945_rx_queue *q)
3927 3905
3928/** 3906/**
3929 * iwl3945_rx_queue_update_write_ptr - Update the write pointer for the RX queue 3907 * iwl3945_rx_queue_update_write_ptr - Update the write pointer for the RX queue
3930 *
3931 * NOTE: This function has 3945 and 4965 specific code sections
3932 * but is declared in base due to the majority of the
3933 * implementation being the same (only a numeric constant is
3934 * different)
3935 *
3936 */ 3908 */
3937int iwl3945_rx_queue_update_write_ptr(struct iwl3945_priv *priv, struct iwl3945_rx_queue *q) 3909int iwl3945_rx_queue_update_write_ptr(struct iwl3945_priv *priv, struct iwl3945_rx_queue *q)
3938{ 3910{
@@ -3973,9 +3945,7 @@ int iwl3945_rx_queue_update_write_ptr(struct iwl3945_priv *priv, struct iwl3945_
3973} 3945}
3974 3946
3975/** 3947/**
3976 * iwl3945_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer pointer. 3948 * iwl3945_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr
3977 *
3978 * NOTE: This function has 3945 and 4965 specific code paths in it.
3979 */ 3949 */
3980static inline __le32 iwl3945_dma_addr2rbd_ptr(struct iwl3945_priv *priv, 3950static inline __le32 iwl3945_dma_addr2rbd_ptr(struct iwl3945_priv *priv,
3981 dma_addr_t dma_addr) 3951 dma_addr_t dma_addr)
@@ -3986,9 +3956,9 @@ static inline __le32 iwl3945_dma_addr2rbd_ptr(struct iwl3945_priv *priv,
3986/** 3956/**
3987 * iwl3945_rx_queue_restock - refill RX queue from pre-allocated pool 3957 * iwl3945_rx_queue_restock - refill RX queue from pre-allocated pool
3988 * 3958 *
3989 * If there are slots in the RX queue that need to be restocked, 3959 * If there are slots in the RX queue that need to be restocked,
3990 * and we have free pre-allocated buffers, fill the ranks as much 3960 * and we have free pre-allocated buffers, fill the ranks as much
3991 * as we can pulling from rx_free. 3961 * as we can, pulling from rx_free.
3992 * 3962 *
3993 * This moves the 'write' index forward to catch up with 'processed', and 3963 * This moves the 'write' index forward to catch up with 'processed', and
3994 * also updates the memory address in the firmware to reference the new 3964 * also updates the memory address in the firmware to reference the new
@@ -4080,7 +4050,7 @@ void iwl3945_rx_replenish(void *data)
4080} 4050}
4081 4051
4082/* Assumes that the skb field of the buffers in 'pool' is kept accurate. 4052/* Assumes that the skb field of the buffers in 'pool' is kept accurate.
4083 * If an SKB has been detached, the POOL needs to have it's SKB set to NULL 4053 * If an SKB has been detached, the POOL needs to have its SKB set to NULL
4084 * This free routine walks the list of POOL entries and if SKB is set to 4054 * This free routine walks the list of POOL entries and if SKB is set to
4085 * non NULL it is unmapped and freed 4055 * non NULL it is unmapped and freed
4086 */ 4056 */
@@ -4232,7 +4202,7 @@ int iwl3945_calc_sig_qual(int rssi_dbm, int noise_dbm)
4232} 4202}
4233 4203
4234/** 4204/**
4235 * iwl3945_rx_handle - Main entry function for receiving responses from the uCode 4205 * iwl3945_rx_handle - Main entry function for receiving responses from uCode
4236 * 4206 *
4237 * Uses the priv->rx_handlers callback function array to invoke 4207 * Uses the priv->rx_handlers callback function array to invoke
4238 * the appropriate handlers, including command responses, 4208 * the appropriate handlers, including command responses,
@@ -4257,7 +4227,7 @@ static void iwl3945_rx_handle(struct iwl3945_priv *priv)
4257 while (i != r) { 4227 while (i != r) {
4258 rxb = rxq->queue[i]; 4228 rxb = rxq->queue[i];
4259 4229
4260 /* If an RXB doesn't have a queue slot associated with it 4230 /* If an RXB doesn't have a Rx queue slot associated with it,
4261 * then a bug has been introduced in the queue refilling 4231 * then a bug has been introduced in the queue refilling
4262 * routines -- catch it here */ 4232 * routines -- catch it here */
4263 BUG_ON(rxb == NULL); 4233 BUG_ON(rxb == NULL);
@@ -4296,8 +4266,8 @@ static void iwl3945_rx_handle(struct iwl3945_priv *priv)
4296 } 4266 }
4297 4267
4298 if (reclaim) { 4268 if (reclaim) {
4299 /* Invoke any callbacks, transfer the skb to caller, 4269 /* Invoke any callbacks, transfer the skb to caller, and
4300 * and fire off the (possibly) blocking iwl3945_send_cmd() 4270 * fire off the (possibly) blocking iwl3945_send_cmd()
4301 * as we reclaim the driver command queue */ 4271 * as we reclaim the driver command queue */
4302 if (rxb && rxb->skb) 4272 if (rxb && rxb->skb)
4303 iwl3945_tx_cmd_complete(priv, rxb); 4273 iwl3945_tx_cmd_complete(priv, rxb);
@@ -4671,7 +4641,8 @@ static void iwl3945_irq_tasklet(struct iwl3945_priv *priv)
4671 4641
4672#ifdef CONFIG_IWL3945_DEBUG 4642#ifdef CONFIG_IWL3945_DEBUG
4673 if (iwl3945_debug_level & IWL_DL_ISR) { 4643 if (iwl3945_debug_level & IWL_DL_ISR) {
4674 inta_mask = iwl3945_read32(priv, CSR_INT_MASK); /* just for debug */ 4644 /* just for debug */
4645 inta_mask = iwl3945_read32(priv, CSR_INT_MASK);
4675 IWL_DEBUG_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", 4646 IWL_DEBUG_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n",
4676 inta, inta_mask, inta_fh); 4647 inta, inta_mask, inta_fh);
4677 } 4648 }
@@ -4901,11 +4872,11 @@ static const u8 iwl3945_eeprom_band_1[14] = {
4901}; 4872};
4902 4873
4903/* 5.2 GHz bands */ 4874/* 5.2 GHz bands */
4904static const u8 iwl3945_eeprom_band_2[] = { 4875static const u8 iwl3945_eeprom_band_2[] = { /* 4915-5080MHz */
4905 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16 4876 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16
4906}; 4877};
4907 4878
4908static const u8 iwl3945_eeprom_band_3[] = { /* 5205-5320MHz */ 4879static const u8 iwl3945_eeprom_band_3[] = { /* 5170-5320MHz */
4909 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 4880 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
4910}; 4881};
4911 4882
@@ -4929,7 +4900,7 @@ static void iwl3945_init_band_reference(const struct iwl3945_priv *priv, int ban
4929 *eeprom_ch_info = priv->eeprom.band_1_channels; 4900 *eeprom_ch_info = priv->eeprom.band_1_channels;
4930 *eeprom_ch_index = iwl3945_eeprom_band_1; 4901 *eeprom_ch_index = iwl3945_eeprom_band_1;
4931 break; 4902 break;
4932 case 2: /* 5.2GHz band */ 4903 case 2: /* 4.9GHz band */
4933 *eeprom_ch_count = ARRAY_SIZE(iwl3945_eeprom_band_2); 4904 *eeprom_ch_count = ARRAY_SIZE(iwl3945_eeprom_band_2);
4934 *eeprom_ch_info = priv->eeprom.band_2_channels; 4905 *eeprom_ch_info = priv->eeprom.band_2_channels;
4935 *eeprom_ch_index = iwl3945_eeprom_band_2; 4906 *eeprom_ch_index = iwl3945_eeprom_band_2;
@@ -4939,12 +4910,12 @@ static void iwl3945_init_band_reference(const struct iwl3945_priv *priv, int ban
4939 *eeprom_ch_info = priv->eeprom.band_3_channels; 4910 *eeprom_ch_info = priv->eeprom.band_3_channels;
4940 *eeprom_ch_index = iwl3945_eeprom_band_3; 4911 *eeprom_ch_index = iwl3945_eeprom_band_3;
4941 break; 4912 break;
4942 case 4: /* 5.2GHz band */ 4913 case 4: /* 5.5GHz band */
4943 *eeprom_ch_count = ARRAY_SIZE(iwl3945_eeprom_band_4); 4914 *eeprom_ch_count = ARRAY_SIZE(iwl3945_eeprom_band_4);
4944 *eeprom_ch_info = priv->eeprom.band_4_channels; 4915 *eeprom_ch_info = priv->eeprom.band_4_channels;
4945 *eeprom_ch_index = iwl3945_eeprom_band_4; 4916 *eeprom_ch_index = iwl3945_eeprom_band_4;
4946 break; 4917 break;
4947 case 5: /* 5.2GHz band */ 4918 case 5: /* 5.7GHz band */
4948 *eeprom_ch_count = ARRAY_SIZE(iwl3945_eeprom_band_5); 4919 *eeprom_ch_count = ARRAY_SIZE(iwl3945_eeprom_band_5);
4949 *eeprom_ch_info = priv->eeprom.band_5_channels; 4920 *eeprom_ch_info = priv->eeprom.band_5_channels;
4950 *eeprom_ch_index = iwl3945_eeprom_band_5; 4921 *eeprom_ch_index = iwl3945_eeprom_band_5;
@@ -5207,7 +5178,7 @@ static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv, int phymode,
5207 scan_ch->active_dwell = cpu_to_le16(active_dwell); 5178 scan_ch->active_dwell = cpu_to_le16(active_dwell);
5208 scan_ch->passive_dwell = cpu_to_le16(passive_dwell); 5179 scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
5209 5180
5210 /* Set power levels to defaults */ 5181 /* Set txpower levels to defaults */
5211 scan_ch->tpc.dsp_atten = 110; 5182 scan_ch->tpc.dsp_atten = 110;
5212 /* scan_pwr_info->tpc.dsp_atten; */ 5183 /* scan_pwr_info->tpc.dsp_atten; */
5213 5184
@@ -5217,8 +5188,8 @@ static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv, int phymode,
5217 else { 5188 else {
5218 scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3)); 5189 scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3));
5219 /* NOTE: if we were doing 6Mb OFDM for scans we'd use 5190 /* NOTE: if we were doing 6Mb OFDM for scans we'd use
5220 * power level 5191 * power level:
5221 scan_ch->tpc.tx_gain = ((1<<5) | (2 << 3)) | 3; 5192 * scan_ch->tpc.tx_gain = ((1<<5) | (2 << 3)) | 3;
5222 */ 5193 */
5223 } 5194 }
5224 5195
@@ -5602,8 +5573,9 @@ static int iwl3945_verify_ucode(struct iwl3945_priv *priv)
5602 5573
5603 IWL_ERROR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); 5574 IWL_ERROR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n");
5604 5575
5605 /* Show first several data entries in instruction SRAM. 5576 /* Since nothing seems to match, show first several data entries in
5606 * Selection of bootstrap image is arbitrary. */ 5577 * instruction SRAM, so maybe visual inspection will give a clue.
5578 * Selection of bootstrap image (vs. other images) is arbitrary. */
5607 image = (__le32 *)priv->ucode_boot.v_addr; 5579 image = (__le32 *)priv->ucode_boot.v_addr;
5608 len = priv->ucode_boot.len; 5580 len = priv->ucode_boot.len;
5609 rc = iwl3945_verify_inst_full(priv, image, len); 5581 rc = iwl3945_verify_inst_full(priv, image, len);
@@ -5695,7 +5667,7 @@ static int iwl3945_load_bsm(struct iwl3945_priv *priv)
5695 return -EINVAL; 5667 return -EINVAL;
5696 5668
5697 /* Tell bootstrap uCode where to find the "Initialize" uCode 5669 /* Tell bootstrap uCode where to find the "Initialize" uCode
5698 * in host DRAM ... bits 31:0 for 3945, bits 35:4 for 4965. 5670 * in host DRAM ... host DRAM physical address bits 31:0 for 3945.
5699 * NOTE: iwl3945_initialize_alive_start() will replace these values, 5671 * NOTE: iwl3945_initialize_alive_start() will replace these values,
5700 * after the "initialize" uCode has run, to point to 5672 * after the "initialize" uCode has run, to point to
5701 * runtime/protocol instructions and backup data cache. */ 5673 * runtime/protocol instructions and backup data cache. */
@@ -6020,12 +5992,8 @@ static int iwl3945_set_ucode_ptrs(struct iwl3945_priv *priv)
6020 * 5992 *
6021 * Called after REPLY_ALIVE notification received from "initialize" uCode. 5993 * Called after REPLY_ALIVE notification received from "initialize" uCode.
6022 * 5994 *
6023 * The 4965 "initialize" ALIVE reply contains calibration data for:
6024 * Voltage, temperature, and MIMO tx gain correction, now stored in priv
6025 * (3945 does not contain this data).
6026 *
6027 * Tell "initialize" uCode to go ahead and load the runtime uCode. 5995 * Tell "initialize" uCode to go ahead and load the runtime uCode.
6028*/ 5996 */
6029static void iwl3945_init_alive_start(struct iwl3945_priv *priv) 5997static void iwl3945_init_alive_start(struct iwl3945_priv *priv)
6030{ 5998{
6031 /* Check alive response for "valid" sign from uCode */ 5999 /* Check alive response for "valid" sign from uCode */
@@ -6120,7 +6088,7 @@ static void iwl3945_alive_start(struct iwl3945_priv *priv)
6120 } else 6088 } else
6121 set_bit(STATUS_RF_KILL_HW, &priv->status); 6089 set_bit(STATUS_RF_KILL_HW, &priv->status);
6122 6090
6123 /* After the ALIVE response, we can process host commands */ 6091 /* After the ALIVE response, we can send commands to 3945 uCode */
6124 set_bit(STATUS_ALIVE, &priv->status); 6092 set_bit(STATUS_ALIVE, &priv->status);
6125 6093
6126 /* Clear out the uCode error bit if it is set */ 6094 /* Clear out the uCode error bit if it is set */
@@ -6177,7 +6145,7 @@ static void iwl3945_alive_start(struct iwl3945_priv *priv)
6177 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN); 6145 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
6178 } 6146 }
6179 6147
6180 /* Configure BT coexistence */ 6148 /* Configure Bluetooth device coexistence support */
6181 iwl3945_send_bt_config(priv); 6149 iwl3945_send_bt_config(priv);
6182 6150
6183 /* Configure the adapter for unassociated operation */ 6151 /* Configure the adapter for unassociated operation */
@@ -6365,7 +6333,7 @@ static int __iwl3945_up(struct iwl3945_priv *priv)
6365 /* start card; "initialize" will load runtime ucode */ 6333 /* start card; "initialize" will load runtime ucode */
6366 iwl3945_nic_start(priv); 6334 iwl3945_nic_start(priv);
6367 6335
6368 /* MAC Address location in EEPROM same for 3945/4965 */ 6336 /* MAC Address location in EEPROM is same for 3945/4965 */
6369 get_eeprom_mac(priv, priv->mac_addr); 6337 get_eeprom_mac(priv, priv->mac_addr);
6370 IWL_DEBUG_INFO("MAC address: %s\n", 6338 IWL_DEBUG_INFO("MAC address: %s\n",
6371 print_mac(mac, priv->mac_addr)); 6339 print_mac(mac, priv->mac_addr));
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index 33eace757435..74c3d3917fe1 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -27,16 +27,6 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30/*
31 * NOTE: This file (iwl-base.c) is used to build to multiple hardware targets
32 * by defining IWL to either 3945 or 4965. The Makefile used when building
33 * the base targets will create base-3945.o and base-4965.o
34 *
35 * The eventual goal is to move as many of the #if IWL / #endif blocks out of
36 * this file and into the hardware specific implementation files (iwl-XXXX.c)
37 * and leave only the common (non #ifdef sprinkled) code in this file
38 */
39
40#include <linux/kernel.h> 30#include <linux/kernel.h>
41#include <linux/module.h> 31#include <linux/module.h>
42#include <linux/version.h> 32#include <linux/version.h>
@@ -75,9 +65,9 @@ static int iwl4965_tx_queue_update_write_ptr(struct iwl4965_priv *priv,
75/* module parameters */ 65/* module parameters */
76static int iwl4965_param_disable_hw_scan; 66static int iwl4965_param_disable_hw_scan;
77static int iwl4965_param_debug; 67static int iwl4965_param_debug;
78static int iwl4965_param_disable; /* def: enable radio */ 68static int iwl4965_param_disable; /* def: enable radio */
79static int iwl4965_param_antenna; /* def: 0 = both antennas (use diversity) */ 69static int iwl4965_param_antenna; /* def: 0 = both antennas (use diversity) */
80int iwl4965_param_hwcrypto; /* def: using software encryption */ 70int iwl4965_param_hwcrypto; /* def: using software encryption */
81static int iwl4965_param_qos_enable = 1; 71static int iwl4965_param_qos_enable = 1;
82int iwl4965_param_queues_num = IWL_MAX_NUM_QUEUES; 72int iwl4965_param_queues_num = IWL_MAX_NUM_QUEUES;
83 73
@@ -395,11 +385,7 @@ void iwl4965_tx_queue_free(struct iwl4965_priv *priv, struct iwl4965_tx_queue *t
395const u8 iwl4965_broadcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 385const u8 iwl4965_broadcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
396 386
397/*************** STATION TABLE MANAGEMENT **** 387/*************** STATION TABLE MANAGEMENT ****
398 * 388 * mac80211 should be examined to determine if sta_info is duplicating
399 * NOTE: This needs to be overhauled to better synchronize between
400 * how the iwl-4965.c is using iwl4965_hw_find_station vs. iwl-3945.c
401 *
402 * mac80211 should also be examined to determine if sta_info is duplicating
403 * the functionality provided here 389 * the functionality provided here
404 */ 390 */
405 391
@@ -482,8 +468,8 @@ u8 iwl4965_add_station_flags(struct iwl4965_priv *priv, const u8 *addr, int is_a
482 } 468 }
483 469
484 470
485 /* These two conditions has the same outcome but keep them separate 471 /* These two conditions have the same outcome, but keep them separate
486 since they have different meaning */ 472 since they have different meanings */
487 if (unlikely(index == IWL_INVALID_STATION)) { 473 if (unlikely(index == IWL_INVALID_STATION)) {
488 spin_unlock_irqrestore(&priv->sta_lock, flags_spin); 474 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
489 return index; 475 return index;
@@ -843,8 +829,8 @@ int iwl4965_send_statistics_request(struct iwl4965_priv *priv)
843 * iwl4965_rxon_add_station - add station into station table. 829 * iwl4965_rxon_add_station - add station into station table.
844 * 830 *
845 * there is only one AP station with id= IWL_AP_ID 831 * there is only one AP station with id= IWL_AP_ID
846 * NOTE: mutex must be held before calling the this fnction 832 * NOTE: mutex must be held before calling this fnction
847*/ 833 */
848static int iwl4965_rxon_add_station(struct iwl4965_priv *priv, 834static int iwl4965_rxon_add_station(struct iwl4965_priv *priv,
849 const u8 *addr, int is_ap) 835 const u8 *addr, int is_ap)
850{ 836{
@@ -866,7 +852,8 @@ static int iwl4965_rxon_add_station(struct iwl4965_priv *priv,
866 * NOTE: Does not commit to the hardware; it sets appropriate bit fields 852 * NOTE: Does not commit to the hardware; it sets appropriate bit fields
867 * in the staging RXON flag structure based on the phymode 853 * in the staging RXON flag structure based on the phymode
868 */ 854 */
869static int iwl4965_set_rxon_channel(struct iwl4965_priv *priv, u8 phymode, u16 channel) 855static int iwl4965_set_rxon_channel(struct iwl4965_priv *priv, u8 phymode,
856 u16 channel)
870{ 857{
871 if (!iwl4965_get_channel_info(priv, phymode, channel)) { 858 if (!iwl4965_get_channel_info(priv, phymode, channel)) {
872 IWL_DEBUG_INFO("Could not set channel to %d [%d]\n", 859 IWL_DEBUG_INFO("Could not set channel to %d [%d]\n",
@@ -965,12 +952,12 @@ static int iwl4965_check_rxon_cmd(struct iwl4965_rxon_cmd *rxon)
965} 952}
966 953
967/** 954/**
968 * iwl4965_full_rxon_required - determine if RXON_ASSOC can be used in RXON commit 955 * iwl4965_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed
969 * @priv: staging_rxon is compared to active_rxon 956 * @priv: staging_rxon is compared to active_rxon
970 * 957 *
971 * If the RXON structure is changing sufficient to require a new 958 * If the RXON structure is changing enough to require a new tune,
972 * tune or to clear and reset the RXON_FILTER_ASSOC_MSK then return 1 959 * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that
973 * to indicate a new tune is required. 960 * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required.
974 */ 961 */
975static int iwl4965_full_rxon_required(struct iwl4965_priv *priv) 962static int iwl4965_full_rxon_required(struct iwl4965_priv *priv)
976{ 963{
@@ -1267,7 +1254,7 @@ static int iwl4965_card_state_sync_callback(struct iwl4965_priv *priv,
1267/* 1254/*
1268 * CARD_STATE_CMD 1255 * CARD_STATE_CMD
1269 * 1256 *
1270 * Use: Sets the internal card state to enable, disable, or halt 1257 * Use: Sets the device's internal card state to enable, disable, or halt
1271 * 1258 *
1272 * When in the 'enable' state the card operates as normal. 1259 * When in the 'enable' state the card operates as normal.
1273 * When in the 'disable' state, the card enters into a low power mode. 1260 * When in the 'disable' state, the card enters into a low power mode.
@@ -1643,14 +1630,12 @@ done:
1643/** 1630/**
1644 * iwl4965_report_frame - dump frame to syslog during debug sessions 1631 * iwl4965_report_frame - dump frame to syslog during debug sessions
1645 * 1632 *
1646 * hack this function to show different aspects of received frames, 1633 * You may hack this function to show different aspects of received frames,
1647 * including selective frame dumps. 1634 * including selective frame dumps.
1648 * group100 parameter selects whether to show 1 out of 100 good frames. 1635 * group100 parameter selects whether to show 1 out of 100 good frames.
1649 * 1636 *
1650 * TODO: ieee80211_hdr stuff is common to 3945 and 4965, so frame type 1637 * TODO: This was originally written for 3945, need to audit for
1651 * info output is okay, but some of this stuff (e.g. iwl4965_rx_frame_stats) 1638 * proper operation with 4965.
1652 * is 3945-specific and gives bad output for 4965. Need to split the
1653 * functionality, keep common stuff here.
1654 */ 1639 */
1655void iwl4965_report_frame(struct iwl4965_priv *priv, 1640void iwl4965_report_frame(struct iwl4965_priv *priv,
1656 struct iwl4965_rx_packet *pkt, 1641 struct iwl4965_rx_packet *pkt,
@@ -2742,7 +2727,8 @@ static void iwl4965_build_tx_cmd_basic(struct iwl4965_priv *priv,
2742 cmd->cmd.tx.next_frame_len = 0; 2727 cmd->cmd.tx.next_frame_len = 0;
2743} 2728}
2744 2729
2745static int iwl4965_get_sta_id(struct iwl4965_priv *priv, struct ieee80211_hdr *hdr) 2730static int iwl4965_get_sta_id(struct iwl4965_priv *priv,
2731 struct ieee80211_hdr *hdr)
2746{ 2732{
2747 int sta_id; 2733 int sta_id;
2748 u16 fc = le16_to_cpu(hdr->frame_control); 2734 u16 fc = le16_to_cpu(hdr->frame_control);
@@ -4104,13 +4090,10 @@ static void iwl4965_setup_rx_handlers(struct iwl4965_priv *priv)
4104 iwl4965_rx_pm_debug_statistics_notif; 4090 iwl4965_rx_pm_debug_statistics_notif;
4105 priv->rx_handlers[BEACON_NOTIFICATION] = iwl4965_rx_beacon_notif; 4091 priv->rx_handlers[BEACON_NOTIFICATION] = iwl4965_rx_beacon_notif;
4106 4092
4107 /* NOTE: iwl4965_rx_statistics is different based on whether 4093 /*
4108 * the build is for the 3945 or the 4965. See the 4094 * The same handler is used for both the REPLY to a discrete
4109 * corresponding implementation in iwl-XXXX.c 4095 * statistics request from the host as well as for the periodic
4110 * 4096 * statistics notifications (after received beacons) from the uCode.
4111 * The same handler is used for both the REPLY to a
4112 * discrete statistics request from the host as well as
4113 * for the periodic statistics notification from the uCode
4114 */ 4097 */
4115 priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl4965_hw_rx_statistics; 4098 priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl4965_hw_rx_statistics;
4116 priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl4965_hw_rx_statistics; 4099 priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl4965_hw_rx_statistics;
@@ -4124,7 +4107,7 @@ static void iwl4965_setup_rx_handlers(struct iwl4965_priv *priv)
4124 priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl4965_rx_card_state_notif; 4107 priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl4965_rx_card_state_notif;
4125 priv->rx_handlers[REPLY_TX] = iwl4965_rx_reply_tx; 4108 priv->rx_handlers[REPLY_TX] = iwl4965_rx_reply_tx;
4126 4109
4127 /* Setup hardware specific Rx handlers */ 4110 /* Set up hardware specific Rx handlers */
4128 iwl4965_hw_rx_handler_setup(priv); 4111 iwl4965_hw_rx_handler_setup(priv);
4129} 4112}
4130 4113
@@ -4178,9 +4161,11 @@ static void iwl4965_tx_cmd_complete(struct iwl4965_priv *priv,
4178/* 4161/*
4179 * Rx theory of operation 4162 * Rx theory of operation
4180 * 4163 *
4181 * The host allocates 32 DMA target addresses and passes the host address 4164 * Driver allocates a circular buffer of Receive Buffer Descriptors (RBDs),
4182 * to the firmware at register IWL_RFDS_TABLE_LOWER + N * RFD_SIZE where N is 4165 * each of which point to Receive Buffers to be filled by 4965. These get
4183 * 0 to 31 4166 * used not only for Rx frames, but for any command response or notification
4167 * from the 4965. The driver and 4965 manage the Rx buffers by means
4168 * of indexes into the circular buffer.
4184 * 4169 *
4185 * Rx Queue Indexes 4170 * Rx Queue Indexes
4186 * The host/firmware share two index registers for managing the Rx buffers. 4171 * The host/firmware share two index registers for managing the Rx buffers.
@@ -4196,10 +4181,10 @@ static void iwl4965_tx_cmd_complete(struct iwl4965_priv *priv,
4196 * The queue is empty (no good data) if WRITE = READ - 1, and is full if 4181 * The queue is empty (no good data) if WRITE = READ - 1, and is full if
4197 * WRITE = READ. 4182 * WRITE = READ.
4198 * 4183 *
4199 * During initialization the host sets up the READ queue position to the first 4184 * During initialization, the host sets up the READ queue position to the first
4200 * INDEX position, and WRITE to the last (READ - 1 wrapped) 4185 * INDEX position, and WRITE to the last (READ - 1 wrapped)
4201 * 4186 *
4202 * When the firmware places a packet in a buffer it will advance the READ index 4187 * When the firmware places a packet in a buffer, it will advance the READ index
4203 * and fire the RX interrupt. The driver can then query the READ index and 4188 * and fire the RX interrupt. The driver can then query the READ index and
4204 * process as many packets as possible, moving the WRITE index forward as it 4189 * process as many packets as possible, moving the WRITE index forward as it
4205 * resets the Rx queue buffers with new memory. 4190 * resets the Rx queue buffers with new memory.
@@ -4221,16 +4206,16 @@ static void iwl4965_tx_cmd_complete(struct iwl4965_priv *priv,
4221 * 4206 *
4222 * Driver sequence: 4207 * Driver sequence:
4223 * 4208 *
4224 * iwl4965_rx_queue_alloc() Allocates rx_free 4209 * iwl4965_rx_queue_alloc() Allocates rx_free
4225 * iwl4965_rx_replenish() Replenishes rx_free list from rx_used, and calls 4210 * iwl4965_rx_replenish() Replenishes rx_free list from rx_used, and calls
4226 * iwl4965_rx_queue_restock 4211 * iwl4965_rx_queue_restock
4227 * iwl4965_rx_queue_restock() Moves available buffers from rx_free into Rx 4212 * iwl4965_rx_queue_restock() Moves available buffers from rx_free into Rx
4228 * queue, updates firmware pointers, and updates 4213 * queue, updates firmware pointers, and updates
4229 * the WRITE index. If insufficient rx_free buffers 4214 * the WRITE index. If insufficient rx_free buffers
4230 * are available, schedules iwl4965_rx_replenish 4215 * are available, schedules iwl4965_rx_replenish
4231 * 4216 *
4232 * -- enable interrupts -- 4217 * -- enable interrupts --
4233 * ISR - iwl4965_rx() Detach iwl4965_rx_mem_buffers from pool up to the 4218 * ISR - iwl4965_rx() Detach iwl4965_rx_mem_buffers from pool up to the
4234 * READ INDEX, detaching the SKB from the pool. 4219 * READ INDEX, detaching the SKB from the pool.
4235 * Moves the packet buffer from queue to rx_used. 4220 * Moves the packet buffer from queue to rx_used.
4236 * Calls iwl4965_rx_queue_restock to refill any empty 4221 * Calls iwl4965_rx_queue_restock to refill any empty
@@ -4256,12 +4241,6 @@ static int iwl4965_rx_queue_space(const struct iwl4965_rx_queue *q)
4256 4241
4257/** 4242/**
4258 * iwl4965_rx_queue_update_write_ptr - Update the write pointer for the RX queue 4243 * iwl4965_rx_queue_update_write_ptr - Update the write pointer for the RX queue
4259 *
4260 * NOTE: This function has 3945 and 4965 specific code sections
4261 * but is declared in base due to the majority of the
4262 * implementation being the same (only a numeric constant is
4263 * different)
4264 *
4265 */ 4244 */
4266int iwl4965_rx_queue_update_write_ptr(struct iwl4965_priv *priv, struct iwl4965_rx_queue *q) 4245int iwl4965_rx_queue_update_write_ptr(struct iwl4965_priv *priv, struct iwl4965_rx_queue *q)
4267{ 4246{
@@ -4302,9 +4281,7 @@ int iwl4965_rx_queue_update_write_ptr(struct iwl4965_priv *priv, struct iwl4965_
4302} 4281}
4303 4282
4304/** 4283/**
4305 * iwl4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer pointer. 4284 * iwl4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr
4306 *
4307 * NOTE: This function has 3945 and 4965 specific code paths in it.
4308 */ 4285 */
4309static inline __le32 iwl4965_dma_addr2rbd_ptr(struct iwl4965_priv *priv, 4286static inline __le32 iwl4965_dma_addr2rbd_ptr(struct iwl4965_priv *priv,
4310 dma_addr_t dma_addr) 4287 dma_addr_t dma_addr)
@@ -4316,9 +4293,9 @@ static inline __le32 iwl4965_dma_addr2rbd_ptr(struct iwl4965_priv *priv,
4316/** 4293/**
4317 * iwl4965_rx_queue_restock - refill RX queue from pre-allocated pool 4294 * iwl4965_rx_queue_restock - refill RX queue from pre-allocated pool
4318 * 4295 *
4319 * If there are slots in the RX queue that need to be restocked, 4296 * If there are slots in the RX queue that need to be restocked,
4320 * and we have free pre-allocated buffers, fill the ranks as much 4297 * and we have free pre-allocated buffers, fill the ranks as much
4321 * as we can pulling from rx_free. 4298 * as we can, pulling from rx_free.
4322 * 4299 *
4323 * This moves the 'write' index forward to catch up with 'processed', and 4300 * This moves the 'write' index forward to catch up with 'processed', and
4324 * also updates the memory address in the firmware to reference the new 4301 * also updates the memory address in the firmware to reference the new
@@ -4410,7 +4387,7 @@ void iwl4965_rx_replenish(void *data)
4410} 4387}
4411 4388
4412/* Assumes that the skb field of the buffers in 'pool' is kept accurate. 4389/* Assumes that the skb field of the buffers in 'pool' is kept accurate.
4413 * If an SKB has been detached, the POOL needs to have it's SKB set to NULL 4390 * If an SKB has been detached, the POOL needs to have its SKB set to NULL
4414 * This free routine walks the list of POOL entries and if SKB is set to 4391 * This free routine walks the list of POOL entries and if SKB is set to
4415 * non NULL it is unmapped and freed 4392 * non NULL it is unmapped and freed
4416 */ 4393 */
@@ -4562,7 +4539,7 @@ int iwl4965_calc_sig_qual(int rssi_dbm, int noise_dbm)
4562} 4539}
4563 4540
4564/** 4541/**
4565 * iwl4965_rx_handle - Main entry function for receiving responses from the uCode 4542 * iwl4965_rx_handle - Main entry function for receiving responses from uCode
4566 * 4543 *
4567 * Uses the priv->rx_handlers callback function array to invoke 4544 * Uses the priv->rx_handlers callback function array to invoke
4568 * the appropriate handlers, including command responses, 4545 * the appropriate handlers, including command responses,
@@ -4587,7 +4564,7 @@ static void iwl4965_rx_handle(struct iwl4965_priv *priv)
4587 while (i != r) { 4564 while (i != r) {
4588 rxb = rxq->queue[i]; 4565 rxb = rxq->queue[i];
4589 4566
4590 /* If an RXB doesn't have a queue slot associated with it 4567 /* If an RXB doesn't have a Rx queue slot associated with it,
4591 * then a bug has been introduced in the queue refilling 4568 * then a bug has been introduced in the queue refilling
4592 * routines -- catch it here */ 4569 * routines -- catch it here */
4593 BUG_ON(rxb == NULL); 4570 BUG_ON(rxb == NULL);
@@ -4629,8 +4606,8 @@ static void iwl4965_rx_handle(struct iwl4965_priv *priv)
4629 } 4606 }
4630 4607
4631 if (reclaim) { 4608 if (reclaim) {
4632 /* Invoke any callbacks, transfer the skb to caller, 4609 /* Invoke any callbacks, transfer the skb to caller, and
4633 * and fire off the (possibly) blocking iwl4965_send_cmd() 4610 * fire off the (possibly) blocking iwl4965_send_cmd()
4634 * as we reclaim the driver command queue */ 4611 * as we reclaim the driver command queue */
4635 if (rxb && rxb->skb) 4612 if (rxb && rxb->skb)
4636 iwl4965_tx_cmd_complete(priv, rxb); 4613 iwl4965_tx_cmd_complete(priv, rxb);
@@ -4996,7 +4973,8 @@ static void iwl4965_irq_tasklet(struct iwl4965_priv *priv)
4996 4973
4997#ifdef CONFIG_IWL4965_DEBUG 4974#ifdef CONFIG_IWL4965_DEBUG
4998 if (iwl4965_debug_level & IWL_DL_ISR) { 4975 if (iwl4965_debug_level & IWL_DL_ISR) {
4999 inta_mask = iwl4965_read32(priv, CSR_INT_MASK); /* just for debug */ 4976 /* just for debug */
4977 inta_mask = iwl4965_read32(priv, CSR_INT_MASK);
5000 IWL_DEBUG_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", 4978 IWL_DEBUG_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n",
5001 inta, inta_mask, inta_fh); 4979 inta, inta_mask, inta_fh);
5002 } 4980 }
@@ -5041,7 +5019,7 @@ static void iwl4965_irq_tasklet(struct iwl4965_priv *priv)
5041 /* Safely ignore these bits for debug checks below */ 5019 /* Safely ignore these bits for debug checks below */
5042 inta &= ~(CSR_INT_BIT_MAC_CLK_ACTV | CSR_INT_BIT_ALIVE); 5020 inta &= ~(CSR_INT_BIT_MAC_CLK_ACTV | CSR_INT_BIT_ALIVE);
5043 5021
5044 /* HW RF KILL switch toggled (4965 only) */ 5022 /* HW RF KILL switch toggled */
5045 if (inta & CSR_INT_BIT_RF_KILL) { 5023 if (inta & CSR_INT_BIT_RF_KILL) {
5046 int hw_rf_kill = 0; 5024 int hw_rf_kill = 0;
5047 if (!(iwl4965_read32(priv, CSR_GP_CNTRL) & 5025 if (!(iwl4965_read32(priv, CSR_GP_CNTRL) &
@@ -5064,7 +5042,7 @@ static void iwl4965_irq_tasklet(struct iwl4965_priv *priv)
5064 handled |= CSR_INT_BIT_RF_KILL; 5042 handled |= CSR_INT_BIT_RF_KILL;
5065 } 5043 }
5066 5044
5067 /* Chip got too hot and stopped itself (4965 only) */ 5045 /* Chip got too hot and stopped itself */
5068 if (inta & CSR_INT_BIT_CT_KILL) { 5046 if (inta & CSR_INT_BIT_CT_KILL) {
5069 IWL_ERROR("Microcode CT kill error detected.\n"); 5047 IWL_ERROR("Microcode CT kill error detected.\n");
5070 handled |= CSR_INT_BIT_CT_KILL; 5048 handled |= CSR_INT_BIT_CT_KILL;
@@ -5219,11 +5197,11 @@ static const u8 iwl4965_eeprom_band_1[14] = {
5219}; 5197};
5220 5198
5221/* 5.2 GHz bands */ 5199/* 5.2 GHz bands */
5222static const u8 iwl4965_eeprom_band_2[] = { 5200static const u8 iwl4965_eeprom_band_2[] = { /* 4915-5080MHz */
5223 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16 5201 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16
5224}; 5202};
5225 5203
5226static const u8 iwl4965_eeprom_band_3[] = { /* 5205-5320MHz */ 5204static const u8 iwl4965_eeprom_band_3[] = { /* 5170-5320MHz */
5227 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 5205 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
5228}; 5206};
5229 5207
@@ -5243,7 +5221,8 @@ static u8 iwl4965_eeprom_band_7[] = { /* 5.2 FAT channel */
5243 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157 5221 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157
5244}; 5222};
5245 5223
5246static void iwl4965_init_band_reference(const struct iwl4965_priv *priv, int band, 5224static void iwl4965_init_band_reference(const struct iwl4965_priv *priv,
5225 int band,
5247 int *eeprom_ch_count, 5226 int *eeprom_ch_count,
5248 const struct iwl4965_eeprom_channel 5227 const struct iwl4965_eeprom_channel
5249 **eeprom_ch_info, 5228 **eeprom_ch_info,
@@ -5255,7 +5234,7 @@ static void iwl4965_init_band_reference(const struct iwl4965_priv *priv, int ban
5255 *eeprom_ch_info = priv->eeprom.band_1_channels; 5234 *eeprom_ch_info = priv->eeprom.band_1_channels;
5256 *eeprom_ch_index = iwl4965_eeprom_band_1; 5235 *eeprom_ch_index = iwl4965_eeprom_band_1;
5257 break; 5236 break;
5258 case 2: /* 5.2GHz band */ 5237 case 2: /* 4.9GHz band */
5259 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_2); 5238 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_2);
5260 *eeprom_ch_info = priv->eeprom.band_2_channels; 5239 *eeprom_ch_info = priv->eeprom.band_2_channels;
5261 *eeprom_ch_index = iwl4965_eeprom_band_2; 5240 *eeprom_ch_index = iwl4965_eeprom_band_2;
@@ -5265,22 +5244,22 @@ static void iwl4965_init_band_reference(const struct iwl4965_priv *priv, int ban
5265 *eeprom_ch_info = priv->eeprom.band_3_channels; 5244 *eeprom_ch_info = priv->eeprom.band_3_channels;
5266 *eeprom_ch_index = iwl4965_eeprom_band_3; 5245 *eeprom_ch_index = iwl4965_eeprom_band_3;
5267 break; 5246 break;
5268 case 4: /* 5.2GHz band */ 5247 case 4: /* 5.5GHz band */
5269 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_4); 5248 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_4);
5270 *eeprom_ch_info = priv->eeprom.band_4_channels; 5249 *eeprom_ch_info = priv->eeprom.band_4_channels;
5271 *eeprom_ch_index = iwl4965_eeprom_band_4; 5250 *eeprom_ch_index = iwl4965_eeprom_band_4;
5272 break; 5251 break;
5273 case 5: /* 5.2GHz band */ 5252 case 5: /* 5.7GHz band */
5274 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_5); 5253 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_5);
5275 *eeprom_ch_info = priv->eeprom.band_5_channels; 5254 *eeprom_ch_info = priv->eeprom.band_5_channels;
5276 *eeprom_ch_index = iwl4965_eeprom_band_5; 5255 *eeprom_ch_index = iwl4965_eeprom_band_5;
5277 break; 5256 break;
5278 case 6: 5257 case 6: /* 2.4GHz FAT channels */
5279 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_6); 5258 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_6);
5280 *eeprom_ch_info = priv->eeprom.band_24_channels; 5259 *eeprom_ch_info = priv->eeprom.band_24_channels;
5281 *eeprom_ch_index = iwl4965_eeprom_band_6; 5260 *eeprom_ch_index = iwl4965_eeprom_band_6;
5282 break; 5261 break;
5283 case 7: 5262 case 7: /* 5 GHz FAT channels */
5284 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_7); 5263 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_7);
5285 *eeprom_ch_info = priv->eeprom.band_52_channels; 5264 *eeprom_ch_info = priv->eeprom.band_52_channels;
5286 *eeprom_ch_index = iwl4965_eeprom_band_7; 5265 *eeprom_ch_index = iwl4965_eeprom_band_7;
@@ -5549,7 +5528,8 @@ static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, int phymode,
5549 5528
5550 scan_ch->channel = channels[i].chan; 5529 scan_ch->channel = channels[i].chan;
5551 5530
5552 ch_info = iwl4965_get_channel_info(priv, phymode, scan_ch->channel); 5531 ch_info = iwl4965_get_channel_info(priv, phymode,
5532 scan_ch->channel);
5553 if (!is_channel_valid(ch_info)) { 5533 if (!is_channel_valid(ch_info)) {
5554 IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n", 5534 IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n",
5555 scan_ch->channel); 5535 scan_ch->channel);
@@ -5571,7 +5551,7 @@ static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, int phymode,
5571 scan_ch->active_dwell = cpu_to_le16(active_dwell); 5551 scan_ch->active_dwell = cpu_to_le16(active_dwell);
5572 scan_ch->passive_dwell = cpu_to_le16(passive_dwell); 5552 scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
5573 5553
5574 /* Set power levels to defaults */ 5554 /* Set txpower levels to defaults */
5575 scan_ch->tpc.dsp_atten = 110; 5555 scan_ch->tpc.dsp_atten = 110;
5576 /* scan_pwr_info->tpc.dsp_atten; */ 5556 /* scan_pwr_info->tpc.dsp_atten; */
5577 5557
@@ -5581,8 +5561,8 @@ static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, int phymode,
5581 else { 5561 else {
5582 scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3)); 5562 scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3));
5583 /* NOTE: if we were doing 6Mb OFDM for scans we'd use 5563 /* NOTE: if we were doing 6Mb OFDM for scans we'd use
5584 * power level 5564 * power level:
5585 scan_ch->tpc.tx_gain = ((1<<5) | (2 << 3)) | 3; 5565 * scan_ch->tpc.tx_gain = ((1<<5) | (2 << 3)) | 3;
5586 */ 5566 */
5587 } 5567 }
5588 5568
@@ -5859,7 +5839,8 @@ static void iwl4965_dealloc_ucode_pci(struct iwl4965_priv *priv)
5859 * iwl4965_verify_inst_full - verify runtime uCode image in card vs. host, 5839 * iwl4965_verify_inst_full - verify runtime uCode image in card vs. host,
5860 * looking at all data. 5840 * looking at all data.
5861 */ 5841 */
5862static int iwl4965_verify_inst_full(struct iwl4965_priv *priv, __le32 * image, u32 len) 5842static int iwl4965_verify_inst_full(struct iwl4965_priv *priv, __le32 * image,
5843 u32 len)
5863{ 5844{
5864 u32 val; 5845 u32 val;
5865 u32 save_len = len; 5846 u32 save_len = len;
@@ -5984,8 +5965,9 @@ static int iwl4965_verify_ucode(struct iwl4965_priv *priv)
5984 5965
5985 IWL_ERROR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); 5966 IWL_ERROR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n");
5986 5967
5987 /* Show first several data entries in instruction SRAM. 5968 /* Since nothing seems to match, show first several data entries in
5988 * Selection of bootstrap image is arbitrary. */ 5969 * instruction SRAM, so maybe visual inspection will give a clue.
5970 * Selection of bootstrap image (vs. other images) is arbitrary. */
5989 image = (__le32 *)priv->ucode_boot.v_addr; 5971 image = (__le32 *)priv->ucode_boot.v_addr;
5990 len = priv->ucode_boot.len; 5972 len = priv->ucode_boot.len;
5991 rc = iwl4965_verify_inst_full(priv, image, len); 5973 rc = iwl4965_verify_inst_full(priv, image, len);
@@ -6077,7 +6059,7 @@ static int iwl4965_load_bsm(struct iwl4965_priv *priv)
6077 return -EINVAL; 6059 return -EINVAL;
6078 6060
6079 /* Tell bootstrap uCode where to find the "Initialize" uCode 6061 /* Tell bootstrap uCode where to find the "Initialize" uCode
6080 * in host DRAM ... bits 31:0 for 3945, bits 35:4 for 4965. 6062 * in host DRAM ... host DRAM physical address bits 35:4 for 4965.
6081 * NOTE: iwl4965_initialize_alive_start() will replace these values, 6063 * NOTE: iwl4965_initialize_alive_start() will replace these values,
6082 * after the "initialize" uCode has run, to point to 6064 * after the "initialize" uCode has run, to point to
6083 * runtime/protocol instructions and backup data cache. */ 6065 * runtime/protocol instructions and backup data cache. */
@@ -6487,7 +6469,7 @@ static void iwl4965_alive_start(struct iwl4965_priv *priv)
6487 goto restart; 6469 goto restart;
6488 } 6470 }
6489 6471
6490 /* After the ALIVE response, we can process host commands */ 6472 /* After the ALIVE response, we can send host commands to 4965 uCode */
6491 set_bit(STATUS_ALIVE, &priv->status); 6473 set_bit(STATUS_ALIVE, &priv->status);
6492 6474
6493 /* Clear out the uCode error bit if it is set */ 6475 /* Clear out the uCode error bit if it is set */
@@ -6544,7 +6526,7 @@ static void iwl4965_alive_start(struct iwl4965_priv *priv)
6544 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN); 6526 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
6545 } 6527 }
6546 6528
6547 /* Configure BT coexistence */ 6529 /* Configure Bluetooth device coexistence support */
6548 iwl4965_send_bt_config(priv); 6530 iwl4965_send_bt_config(priv);
6549 6531
6550 /* Configure the adapter for unassociated operation */ 6532 /* Configure the adapter for unassociated operation */
@@ -6624,7 +6606,8 @@ static void __iwl4965_down(struct iwl4965_priv *priv)
6624 STATUS_FW_ERROR; 6606 STATUS_FW_ERROR;
6625 6607
6626 spin_lock_irqsave(&priv->lock, flags); 6608 spin_lock_irqsave(&priv->lock, flags);
6627 iwl4965_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); 6609 iwl4965_clear_bit(priv, CSR_GP_CNTRL,
6610 CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
6628 spin_unlock_irqrestore(&priv->lock, flags); 6611 spin_unlock_irqrestore(&priv->lock, flags);
6629 6612
6630 iwl4965_hw_txq_ctx_stop(priv); 6613 iwl4965_hw_txq_ctx_stop(priv);
@@ -6744,7 +6727,7 @@ static int __iwl4965_up(struct iwl4965_priv *priv)
6744 /* start card; "initialize" will load runtime ucode */ 6727 /* start card; "initialize" will load runtime ucode */
6745 iwl4965_nic_start(priv); 6728 iwl4965_nic_start(priv);
6746 6729
6747 /* MAC Address location in EEPROM same for 3945/4965 */ 6730 /* MAC Address location in EEPROM is same for 3945/4965 */
6748 get_eeprom_mac(priv, priv->mac_addr); 6731 get_eeprom_mac(priv, priv->mac_addr);
6749 IWL_DEBUG_INFO("MAC address: %s\n", 6732 IWL_DEBUG_INFO("MAC address: %s\n",
6750 print_mac(mac, priv->mac_addr)); 6733 print_mac(mac, priv->mac_addr));