aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2008-12-18 21:37:15 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 15:59:01 -0500
commitd20b3c65f2a3e18ea86542e6ca4fe1c6d16c91df (patch)
tree78f8c8e4861160f0751240a8c65e2d8b0d9ab785 /drivers/net/wireless/iwlwifi
parent1125eff3ae26b2e39c6bf940b5e0b8774ebd2896 (diff)
iwl3945: iwl3945_queue and iwl3945_channel_info replacement
This patch replaces the queue and channel info 3945 structures with the iwl ones. The initial goal was to replace the channel info structure. Once we do that, and then include iwl-dev.h instead of iwl-3945.h, we still get build errors due to several routines and macro redefinitions. This is why this patch also includes: - TFD39_MAX_PAYLOAD definition for 3945. - CMD_SIZE, CMD_HUGE, CMD_SKB duplication removal. - iwl3945_queue replacement in order to also get rid of the duplicated get_cmd_index routine. Getting rid of any of those needs the iwl-dev.h inclusion which then creates build errors due to definitions duplication. This is why we include all those in the same patch. Signed-off-by: Samuel Ortiz <samuel.ortiz@intel.com> Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-hw.h3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c20
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h155
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h33
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c69
5 files changed, 71 insertions, 209 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
index 1182e6847a05..5d461bd77567 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
@@ -265,9 +265,6 @@ struct iwl3945_eeprom {
265#define TFD_TX_CMD_SLOTS 256 265#define TFD_TX_CMD_SLOTS 256
266#define TFD_CMD_SLOTS 32 266#define TFD_CMD_SLOTS 32
267 267
268#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl3945_cmd) - \
269 sizeof(struct iwl3945_cmd_meta))
270
271/* 268/*
272 * RX related structures and functions 269 * RX related structures and functions
273 */ 270 */
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index d7d40ecc6b64..14f0923a4751 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -306,7 +306,7 @@ static void iwl3945_tx_queue_reclaim(struct iwl3945_priv *priv,
306 int txq_id, int index) 306 int txq_id, int index)
307{ 307{
308 struct iwl3945_tx_queue *txq = &priv->txq[txq_id]; 308 struct iwl3945_tx_queue *txq = &priv->txq[txq_id];
309 struct iwl3945_queue *q = &txq->q; 309 struct iwl_queue *q = &txq->q;
310 struct iwl3945_tx_info *tx_info; 310 struct iwl3945_tx_info *tx_info;
311 311
312 BUG_ON(txq_id == IWL_CMD_QUEUE_NUM); 312 BUG_ON(txq_id == IWL_CMD_QUEUE_NUM);
@@ -320,7 +320,7 @@ static void iwl3945_tx_queue_reclaim(struct iwl3945_priv *priv,
320 iwl3945_hw_txq_free_tfd(priv, txq); 320 iwl3945_hw_txq_free_tfd(priv, txq);
321 } 321 }
322 322
323 if (iwl3945_queue_space(q) > q->low_mark && (txq_id >= 0) && 323 if (iwl_queue_space(q) > q->low_mark && (txq_id >= 0) &&
324 (txq_id != IWL_CMD_QUEUE_NUM) && 324 (txq_id != IWL_CMD_QUEUE_NUM) &&
325 priv->mac80211_registered) 325 priv->mac80211_registered)
326 ieee80211_wake_queue(priv->hw, txq_id); 326 ieee80211_wake_queue(priv->hw, txq_id);
@@ -1618,7 +1618,7 @@ static inline u8 iwl3945_hw_reg_fix_power_index(int index)
1618 */ 1618 */
1619static void iwl3945_hw_reg_set_scan_power(struct iwl3945_priv *priv, u32 scan_tbl_index, 1619static void iwl3945_hw_reg_set_scan_power(struct iwl3945_priv *priv, u32 scan_tbl_index,
1620 s32 rate_index, const s8 *clip_pwrs, 1620 s32 rate_index, const s8 *clip_pwrs,
1621 struct iwl3945_channel_info *ch_info, 1621 struct iwl_channel_info *ch_info,
1622 int band_index) 1622 int band_index)
1623{ 1623{
1624 struct iwl3945_scan_power_info *scan_power_info; 1624 struct iwl3945_scan_power_info *scan_power_info;
@@ -1675,7 +1675,7 @@ static void iwl3945_hw_reg_set_scan_power(struct iwl3945_priv *priv, u32 scan_tb
1675int iwl3945_hw_reg_send_txpower(struct iwl3945_priv *priv) 1675int iwl3945_hw_reg_send_txpower(struct iwl3945_priv *priv)
1676{ 1676{
1677 int rate_idx, i; 1677 int rate_idx, i;
1678 const struct iwl3945_channel_info *ch_info = NULL; 1678 const struct iwl_channel_info *ch_info = NULL;
1679 struct iwl3945_txpowertable_cmd txpower = { 1679 struct iwl3945_txpowertable_cmd txpower = {
1680 .channel = priv->active_rxon.channel, 1680 .channel = priv->active_rxon.channel,
1681 }; 1681 };
@@ -1748,7 +1748,7 @@ int iwl3945_hw_reg_send_txpower(struct iwl3945_priv *priv)
1748 * and send changes to NIC 1748 * and send changes to NIC
1749 */ 1749 */
1750static int iwl3945_hw_reg_set_new_power(struct iwl3945_priv *priv, 1750static int iwl3945_hw_reg_set_new_power(struct iwl3945_priv *priv,
1751 struct iwl3945_channel_info *ch_info) 1751 struct iwl_channel_info *ch_info)
1752{ 1752{
1753 struct iwl3945_channel_power_info *power_info; 1753 struct iwl3945_channel_power_info *power_info;
1754 int power_changed = 0; 1754 int power_changed = 0;
@@ -1810,7 +1810,7 @@ static int iwl3945_hw_reg_set_new_power(struct iwl3945_priv *priv,
1810 * based strictly on regulatory (eeprom and spectrum mgt) limitations 1810 * based strictly on regulatory (eeprom and spectrum mgt) limitations
1811 * (no consideration for h/w clipping limitations). 1811 * (no consideration for h/w clipping limitations).
1812 */ 1812 */
1813static int iwl3945_hw_reg_get_ch_txpower_limit(struct iwl3945_channel_info *ch_info) 1813static int iwl3945_hw_reg_get_ch_txpower_limit(struct iwl_channel_info *ch_info)
1814{ 1814{
1815 s8 max_power; 1815 s8 max_power;
1816 1816
@@ -1840,7 +1840,7 @@ static int iwl3945_hw_reg_get_ch_txpower_limit(struct iwl3945_channel_info *ch_i
1840 */ 1840 */
1841static int iwl3945_hw_reg_comp_txpower_temp(struct iwl3945_priv *priv) 1841static int iwl3945_hw_reg_comp_txpower_temp(struct iwl3945_priv *priv)
1842{ 1842{
1843 struct iwl3945_channel_info *ch_info = NULL; 1843 struct iwl_channel_info *ch_info = NULL;
1844 int delta_index; 1844 int delta_index;
1845 const s8 *clip_pwrs; /* array of h/w max power levels for each rate */ 1845 const s8 *clip_pwrs; /* array of h/w max power levels for each rate */
1846 u8 a_band; 1846 u8 a_band;
@@ -1901,7 +1901,7 @@ static int iwl3945_hw_reg_comp_txpower_temp(struct iwl3945_priv *priv)
1901 1901
1902int iwl3945_hw_reg_set_txpower(struct iwl3945_priv *priv, s8 power) 1902int iwl3945_hw_reg_set_txpower(struct iwl3945_priv *priv, s8 power)
1903{ 1903{
1904 struct iwl3945_channel_info *ch_info; 1904 struct iwl_channel_info *ch_info;
1905 s8 max_power; 1905 s8 max_power;
1906 u8 a_band; 1906 u8 a_band;
1907 u8 i; 1907 u8 i;
@@ -1999,7 +1999,7 @@ static void iwl3945_bg_reg_txpower_periodic(struct work_struct *work)
1999 * channel in each group 1-4. Group 5 All B/G channels are in group 0. 1999 * channel in each group 1-4. Group 5 All B/G channels are in group 0.
2000 */ 2000 */
2001static u16 iwl3945_hw_reg_get_ch_grp_index(struct iwl3945_priv *priv, 2001static u16 iwl3945_hw_reg_get_ch_grp_index(struct iwl3945_priv *priv,
2002 const struct iwl3945_channel_info *ch_info) 2002 const struct iwl_channel_info *ch_info)
2003{ 2003{
2004 struct iwl3945_eeprom_txpower_group *ch_grp = &priv->eeprom.groups[0]; 2004 struct iwl3945_eeprom_txpower_group *ch_grp = &priv->eeprom.groups[0];
2005 u8 group; 2005 u8 group;
@@ -2162,7 +2162,7 @@ static void iwl3945_hw_reg_init_channel_groups(struct iwl3945_priv *priv)
2162 */ 2162 */
2163int iwl3945_txpower_set_from_eeprom(struct iwl3945_priv *priv) 2163int iwl3945_txpower_set_from_eeprom(struct iwl3945_priv *priv)
2164{ 2164{
2165 struct iwl3945_channel_info *ch_info = NULL; 2165 struct iwl_channel_info *ch_info = NULL;
2166 struct iwl3945_channel_power_info *pwr_info; 2166 struct iwl3945_channel_power_info *pwr_info;
2167 int delta_index; 2167 int delta_index;
2168 u8 rate_index; 2168 u8 rate_index;
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index dd15b3203a6f..46bbd8180bad 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -48,6 +48,7 @@ extern struct pci_device_id iwl3945_hw_card_ids[];
48#include "iwl-3945-hw.h" 48#include "iwl-3945-hw.h"
49#include "iwl-debug.h" 49#include "iwl-debug.h"
50#include "iwl-power.h" 50#include "iwl-power.h"
51#include "iwl-dev.h"
51#include "iwl-3945-led.h" 52#include "iwl-3945-led.h"
52 53
53/* Highest firmware API version supported */ 54/* Highest firmware API version supported */
@@ -111,26 +112,7 @@ struct iwl3945_rx_mem_buffer {
111 struct list_head list; 112 struct list_head list;
112}; 113};
113 114
114/* 115int iwl3945_x2_queue_used(const struct iwl_queue *q, int i);
115 * Generic queue structure
116 *
117 * Contains common data for Rx and Tx queues
118 */
119struct iwl3945_queue {
120 int n_bd; /* number of BDs in this queue */
121 int write_ptr; /* 1-st empty entry (index) host_w*/
122 int read_ptr; /* last used entry (index) host_r*/
123 dma_addr_t dma_addr; /* physical addr for BD's */
124 int n_window; /* safe queue window */
125 u32 id;
126 int low_mark; /* low watermark, resume queue if free
127 * space more than this */
128 int high_mark; /* high watermark, stop queue if free
129 * space less than this */
130} __attribute__ ((packed));
131
132int iwl3945_queue_space(const struct iwl3945_queue *q);
133int iwl3945_x2_queue_used(const struct iwl3945_queue *q, int i);
134 116
135#define MAX_NUM_OF_TBS (20) 117#define MAX_NUM_OF_TBS (20)
136 118
@@ -152,7 +134,7 @@ struct iwl3945_tx_info {
152 * descriptors) and required locking structures. 134 * descriptors) and required locking structures.
153 */ 135 */
154struct iwl3945_tx_queue { 136struct iwl3945_tx_queue {
155 struct iwl3945_queue q; 137 struct iwl_queue q;
156 struct iwl3945_tfd_frame *bd; 138 struct iwl3945_tfd_frame *bd;
157 struct iwl3945_cmd *cmd; 139 struct iwl3945_cmd *cmd;
158 dma_addr_t dma_addr_cmd; 140 dma_addr_t dma_addr_cmd;
@@ -161,73 +143,6 @@ struct iwl3945_tx_queue {
161 int active; 143 int active;
162}; 144};
163 145
164#define IWL_NUM_SCAN_RATES (2)
165
166struct iwl3945_channel_tgd_info {
167 u8 type;
168 s8 max_power;
169};
170
171struct iwl3945_channel_tgh_info {
172 s64 last_radar_time;
173};
174
175/* current Tx power values to use, one for each rate for each channel.
176 * requested power is limited by:
177 * -- regulatory EEPROM limits for this channel
178 * -- hardware capabilities (clip-powers)
179 * -- spectrum management
180 * -- user preference (e.g. iwconfig)
181 * when requested power is set, base power index must also be set. */
182struct iwl3945_channel_power_info {
183 struct iwl3945_tx_power tpc; /* actual radio and DSP gain settings */
184 s8 power_table_index; /* actual (compenst'd) index into gain table */
185 s8 base_power_index; /* gain index for power at factory temp. */
186 s8 requested_power; /* power (dBm) requested for this chnl/rate */
187};
188
189/* current scan Tx power values to use, one for each scan rate for each
190 * channel. */
191struct iwl3945_scan_power_info {
192 struct iwl3945_tx_power tpc; /* actual radio and DSP gain settings */
193 s8 power_table_index; /* actual (compenst'd) index into gain table */
194 s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */
195};
196
197/*
198 * One for each channel, holds all channel setup data
199 * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
200 * with one another!
201 */
202#define IWL4965_MAX_RATE (33)
203
204struct iwl3945_channel_info {
205 struct iwl3945_channel_tgd_info tgd;
206 struct iwl3945_channel_tgh_info tgh;
207 struct iwl_eeprom_channel eeprom; /* EEPROM regulatory limit */
208 struct iwl_eeprom_channel fat_eeprom; /* EEPROM regulatory limit for
209 * FAT channel */
210
211 u8 channel; /* channel number */
212 u8 flags; /* flags copied from EEPROM */
213 s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
214 s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) */
215 s8 min_power; /* always 0 */
216 s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */
217
218 u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */
219 u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */
220 enum ieee80211_band band;
221
222 /* Radio/DSP gain settings for each "normal" data Tx rate.
223 * These include, in addition to RF and DSP gain, a few fields for
224 * remembering/modifying gain settings (indexes). */
225 struct iwl3945_channel_power_info power_info[IWL4965_MAX_RATE];
226
227 /* Radio/DSP gain settings for each scan rate, for directed scans. */
228 struct iwl3945_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES];
229};
230
231struct iwl3945_clip_group { 146struct iwl3945_clip_group {
232 /* maximum power level to prevent clipping for each rate, derived by 147 /* maximum power level to prevent clipping for each rate, derived by
233 * us from this band's saturation power in EEPROM */ 148 * us from this band's saturation power in EEPROM */
@@ -266,15 +181,6 @@ struct iwl3945_frame {
266#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) 181#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
267#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) 182#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
268 183
269enum {
270 /* CMD_SIZE_NORMAL = 0, */
271 CMD_SIZE_HUGE = (1 << 0),
272 /* CMD_SYNC = 0, */
273 CMD_ASYNC = (1 << 1),
274 /* CMD_NO_SKB = 0, */
275 CMD_WANT_SKB = (1 << 2),
276};
277
278struct iwl3945_cmd; 184struct iwl3945_cmd;
279struct iwl3945_priv; 185struct iwl3945_priv;
280 186
@@ -328,7 +234,7 @@ struct iwl3945_host_cmd {
328 const void *data; 234 const void *data;
329}; 235};
330 236
331#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl3945_cmd) - \ 237#define TFD39_MAX_PAYLOAD_SIZE (sizeof(struct iwl3945_cmd) - \
332 sizeof(struct iwl3945_cmd_meta)) 238 sizeof(struct iwl3945_cmd_meta))
333 239
334/* 240/*
@@ -453,13 +359,6 @@ struct iwl3945_station_entry {
453 struct iwl3945_hw_key keyinfo; 359 struct iwl3945_hw_key keyinfo;
454}; 360};
455 361
456/* one for each uCode image (inst/data, boot/init/runtime) */
457struct fw_desc {
458 void *v_addr; /* access by driver */
459 dma_addr_t p_addr; /* access by card's busmaster DMA */
460 u32 len; /* bytes */
461};
462
463/* uCode file layout */ 362/* uCode file layout */
464struct iwl3945_ucode { 363struct iwl3945_ucode {
465 __le32 ver; /* major/minor/API/serial */ 364 __le32 ver; /* major/minor/API/serial */
@@ -629,16 +528,6 @@ extern int iwl3945_txpower_set_from_eeprom(struct iwl3945_priv *priv);
629extern u8 iwl3945_sync_sta(struct iwl3945_priv *priv, int sta_id, 528extern u8 iwl3945_sync_sta(struct iwl3945_priv *priv, int sta_id,
630 u16 tx_rate, u8 flags); 529 u16 tx_rate, u8 flags);
631 530
632
633#ifdef CONFIG_IWL3945_SPECTRUM_MEASUREMENT
634
635enum {
636 MEASUREMENT_READY = (1 << 0),
637 MEASUREMENT_ACTIVE = (1 << 1),
638};
639
640#endif
641
642#ifdef CONFIG_IWL3945_RFKILL 531#ifdef CONFIG_IWL3945_RFKILL
643struct iwl3945_priv; 532struct iwl3945_priv;
644 533
@@ -682,7 +571,7 @@ struct iwl3945_priv {
682 571
683 /* we allocate array of iwl3945_channel_info for NIC's valid channels. 572 /* we allocate array of iwl3945_channel_info for NIC's valid channels.
684 * Access via channel # using indirect index array */ 573 * Access via channel # using indirect index array */
685 struct iwl3945_channel_info *channel_info; /* channel info array */ 574 struct iwl_channel_info *channel_info; /* channel info array */
686 u8 channel_count; /* # of channels */ 575 u8 channel_count; /* # of channels */
687 576
688 /* each calibration channel group in the EEPROM has a derived 577 /* each calibration channel group in the EEPROM has a derived
@@ -873,39 +762,7 @@ static inline int iwl3945_is_associated(struct iwl3945_priv *priv)
873 return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; 762 return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
874} 763}
875 764
876static inline int is_channel_valid(const struct iwl3945_channel_info *ch_info) 765extern const struct iwl_channel_info *iwl3945_get_channel_info(
877{
878 if (ch_info == NULL)
879 return 0;
880 return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
881}
882
883static inline int is_channel_radar(const struct iwl3945_channel_info *ch_info)
884{
885 return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
886}
887
888static inline u8 is_channel_a_band(const struct iwl3945_channel_info *ch_info)
889{
890 return ch_info->band == IEEE80211_BAND_5GHZ;
891}
892
893static inline u8 is_channel_bg_band(const struct iwl3945_channel_info *ch_info)
894{
895 return ch_info->band == IEEE80211_BAND_2GHZ;
896}
897
898static inline int is_channel_passive(const struct iwl3945_channel_info *ch)
899{
900 return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
901}
902
903static inline int is_channel_ibss(const struct iwl3945_channel_info *ch)
904{
905 return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
906}
907
908extern const struct iwl3945_channel_info *iwl3945_get_channel_info(
909 const struct iwl3945_priv *priv, enum ieee80211_band band, u16 channel); 766 const struct iwl3945_priv *priv, enum ieee80211_band band, u16 channel);
910 767
911extern int iwl3945_rs_next_rate(struct iwl3945_priv *priv, int rate); 768extern int iwl3945_rs_next_rate(struct iwl3945_priv *priv, int rate);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 73a0b6c53e18..f63209aaeaf6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -39,6 +39,7 @@
39#include "iwl-rfkill.h" 39#include "iwl-rfkill.h"
40#include "iwl-eeprom.h" 40#include "iwl-eeprom.h"
41#include "iwl-4965-hw.h" 41#include "iwl-4965-hw.h"
42#include "iwl-3945-hw.h"
42#include "iwl-csr.h" 43#include "iwl-csr.h"
43#include "iwl-prph.h" 44#include "iwl-prph.h"
44#include "iwl-debug.h" 45#include "iwl-debug.h"
@@ -153,6 +154,30 @@ struct iwl4965_channel_tgh_info {
153 s64 last_radar_time; 154 s64 last_radar_time;
154}; 155};
155 156
157#define IWL4965_MAX_RATE (33)
158
159/* current Tx power values to use, one for each rate for each channel.
160 * requested power is limited by:
161 * -- regulatory EEPROM limits for this channel
162 * -- hardware capabilities (clip-powers)
163 * -- spectrum management
164 * -- user preference (e.g. iwconfig)
165 * when requested power is set, base power index must also be set. */
166struct iwl3945_channel_power_info {
167 struct iwl3945_tx_power tpc; /* actual radio and DSP gain settings */
168 s8 power_table_index; /* actual (compenst'd) index into gain table */
169 s8 base_power_index; /* gain index for power at factory temp. */
170 s8 requested_power; /* power (dBm) requested for this chnl/rate */
171};
172
173/* current scan Tx power values to use, one for each scan rate for each
174 * channel. */
175struct iwl3945_scan_power_info {
176 struct iwl3945_tx_power tpc; /* actual radio and DSP gain settings */
177 s8 power_table_index; /* actual (compenst'd) index into gain table */
178 s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */
179};
180
156/* 181/*
157 * One for each channel, holds all channel setup data 182 * One for each channel, holds all channel setup data
158 * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant 183 * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
@@ -183,6 +208,14 @@ struct iwl_channel_info {
183 s8 fat_scan_power; /* (dBm) eeprom, direct scans, any rate */ 208 s8 fat_scan_power; /* (dBm) eeprom, direct scans, any rate */
184 u8 fat_flags; /* flags copied from EEPROM */ 209 u8 fat_flags; /* flags copied from EEPROM */
185 u8 fat_extension_channel; /* HT_IE_EXT_CHANNEL_* */ 210 u8 fat_extension_channel; /* HT_IE_EXT_CHANNEL_* */
211
212 /* Radio/DSP gain settings for each "normal" data Tx rate.
213 * These include, in addition to RF and DSP gain, a few fields for
214 * remembering/modifying gain settings (indexes). */
215 struct iwl3945_channel_power_info power_info[IWL4965_MAX_RATE];
216
217 /* Radio/DSP gain settings for each scan rate, for directed scans. */
218 struct iwl3945_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES];
186}; 219};
187 220
188 221
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index aac8825237f4..421c944b1877 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -53,6 +53,7 @@
53#include "iwl-3945.h" 53#include "iwl-3945.h"
54#include "iwl-3945-fh.h" 54#include "iwl-3945-fh.h"
55#include "iwl-helpers.h" 55#include "iwl-helpers.h"
56#include "iwl-dev.h"
56 57
57static int iwl3945_tx_queue_update_write_ptr(struct iwl3945_priv *priv, 58static int iwl3945_tx_queue_update_write_ptr(struct iwl3945_priv *priv,
58 struct iwl3945_tx_queue *txq); 59 struct iwl3945_tx_queue *txq);
@@ -132,44 +133,17 @@ static const struct ieee80211_supported_band *iwl3945_get_band(
132 * (#0-3) for data tx via EDCA. An additional 2 HCCA queues are unused. 133 * (#0-3) for data tx via EDCA. An additional 2 HCCA queues are unused.
133 ***************************************************/ 134 ***************************************************/
134 135
135int iwl3945_queue_space(const struct iwl3945_queue *q) 136int iwl3945_x2_queue_used(const struct iwl_queue *q, int i)
136{
137 int s = q->read_ptr - q->write_ptr;
138
139 if (q->read_ptr > q->write_ptr)
140 s -= q->n_bd;
141
142 if (s <= 0)
143 s += q->n_window;
144 /* keep some reserve to not confuse empty and full situations */
145 s -= 2;
146 if (s < 0)
147 s = 0;
148 return s;
149}
150
151int iwl3945_x2_queue_used(const struct iwl3945_queue *q, int i)
152{ 137{
153 return q->write_ptr > q->read_ptr ? 138 return q->write_ptr > q->read_ptr ?
154 (i >= q->read_ptr && i < q->write_ptr) : 139 (i >= q->read_ptr && i < q->write_ptr) :
155 !(i < q->read_ptr && i >= q->write_ptr); 140 !(i < q->read_ptr && i >= q->write_ptr);
156} 141}
157 142
158
159static inline u8 get_cmd_index(struct iwl3945_queue *q, u32 index, int is_huge)
160{
161 /* This is for scan command, the big buffer at end of command array */
162 if (is_huge)
163 return q->n_window; /* must be power of 2 */
164
165 /* Otherwise, use normal size buffers */
166 return index & (q->n_window - 1);
167}
168
169/** 143/**
170 * iwl3945_queue_init - Initialize queue's high/low-water and read/write indexes 144 * iwl3945_queue_init - Initialize queue's high/low-water and read/write indexes
171 */ 145 */
172static int iwl3945_queue_init(struct iwl3945_priv *priv, struct iwl3945_queue *q, 146static int iwl3945_queue_init(struct iwl3945_priv *priv, struct iwl_queue *q,
173 int count, int slots_num, u32 id) 147 int count, int slots_num, u32 id)
174{ 148{
175 q->n_bd = count; 149 q->n_bd = count;
@@ -297,7 +271,7 @@ int iwl3945_tx_queue_init(struct iwl3945_priv *priv,
297 */ 271 */
298void iwl3945_tx_queue_free(struct iwl3945_priv *priv, struct iwl3945_tx_queue *txq) 272void iwl3945_tx_queue_free(struct iwl3945_priv *priv, struct iwl3945_tx_queue *txq)
299{ 273{
300 struct iwl3945_queue *q = &txq->q; 274 struct iwl_queue *q = &txq->q;
301 struct pci_dev *dev = priv->pci_dev; 275 struct pci_dev *dev = priv->pci_dev;
302 int len; 276 int len;
303 277
@@ -581,7 +555,7 @@ static const char *get_cmd_string(u8 cmd)
581static int iwl3945_enqueue_hcmd(struct iwl3945_priv *priv, struct iwl3945_host_cmd *cmd) 555static int iwl3945_enqueue_hcmd(struct iwl3945_priv *priv, struct iwl3945_host_cmd *cmd)
582{ 556{
583 struct iwl3945_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM]; 557 struct iwl3945_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM];
584 struct iwl3945_queue *q = &txq->q; 558 struct iwl_queue *q = &txq->q;
585 struct iwl3945_tfd_frame *tfd; 559 struct iwl3945_tfd_frame *tfd;
586 u32 *control_flags; 560 u32 *control_flags;
587 struct iwl3945_cmd *out_cmd; 561 struct iwl3945_cmd *out_cmd;
@@ -596,7 +570,7 @@ static int iwl3945_enqueue_hcmd(struct iwl3945_priv *priv, struct iwl3945_host_c
596 /* If any of the command structures end up being larger than 570 /* If any of the command structures end up being larger than
597 * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then 571 * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then
598 * we will need to increase the size of the TFD entries */ 572 * we will need to increase the size of the TFD entries */
599 BUG_ON((fix_size > TFD_MAX_PAYLOAD_SIZE) && 573 BUG_ON((fix_size > TFD39_MAX_PAYLOAD_SIZE) &&
600 !(cmd->meta.flags & CMD_SIZE_HUGE)); 574 !(cmd->meta.flags & CMD_SIZE_HUGE));
601 575
602 576
@@ -605,7 +579,7 @@ static int iwl3945_enqueue_hcmd(struct iwl3945_priv *priv, struct iwl3945_host_c
605 return -EIO; 579 return -EIO;
606 } 580 }
607 581
608 if (iwl3945_queue_space(q) < ((cmd->meta.flags & CMD_ASYNC) ? 2 : 1)) { 582 if (iwl_queue_space(q) < ((cmd->meta.flags & CMD_ASYNC) ? 2 : 1)) {
609 IWL_ERROR("No space for Tx\n"); 583 IWL_ERROR("No space for Tx\n");
610 return -ENOSPC; 584 return -ENOSPC;
611 } 585 }
@@ -2171,7 +2145,7 @@ static void iwl3945_set_flags_for_phymode(struct iwl3945_priv *priv,
2171static void iwl3945_connection_init_rx_config(struct iwl3945_priv *priv, 2145static void iwl3945_connection_init_rx_config(struct iwl3945_priv *priv,
2172 int mode) 2146 int mode)
2173{ 2147{
2174 const struct iwl3945_channel_info *ch_info; 2148 const struct iwl_channel_info *ch_info;
2175 2149
2176 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon)); 2150 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon));
2177 2151
@@ -2241,7 +2215,7 @@ static void iwl3945_connection_init_rx_config(struct iwl3945_priv *priv,
2241static int iwl3945_set_mode(struct iwl3945_priv *priv, int mode) 2215static int iwl3945_set_mode(struct iwl3945_priv *priv, int mode)
2242{ 2216{
2243 if (mode == NL80211_IFTYPE_ADHOC) { 2217 if (mode == NL80211_IFTYPE_ADHOC) {
2244 const struct iwl3945_channel_info *ch_info; 2218 const struct iwl_channel_info *ch_info;
2245 2219
2246 ch_info = iwl3945_get_channel_info(priv, 2220 ch_info = iwl3945_get_channel_info(priv,
2247 priv->band, 2221 priv->band,
@@ -2457,7 +2431,7 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, struct sk_buff *skb)
2457 u32 *control_flags; 2431 u32 *control_flags;
2458 int txq_id = skb_get_queue_mapping(skb); 2432 int txq_id = skb_get_queue_mapping(skb);
2459 struct iwl3945_tx_queue *txq = NULL; 2433 struct iwl3945_tx_queue *txq = NULL;
2460 struct iwl3945_queue *q = NULL; 2434 struct iwl_queue *q = NULL;
2461 dma_addr_t phys_addr; 2435 dma_addr_t phys_addr;
2462 dma_addr_t txcmd_phys; 2436 dma_addr_t txcmd_phys;
2463 struct iwl3945_cmd *out_cmd = NULL; 2437 struct iwl3945_cmd *out_cmd = NULL;
@@ -2652,7 +2626,7 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, struct sk_buff *skb)
2652 if (rc) 2626 if (rc)
2653 return rc; 2627 return rc;
2654 2628
2655 if ((iwl3945_queue_space(q) < q->high_mark) 2629 if ((iwl_queue_space(q) < q->high_mark)
2656 && priv->mac80211_registered) { 2630 && priv->mac80211_registered) {
2657 if (wait_write_ptr) { 2631 if (wait_write_ptr) {
2658 spin_lock_irqsave(&priv->lock, flags); 2632 spin_lock_irqsave(&priv->lock, flags);
@@ -3305,7 +3279,7 @@ static void iwl3945_cmd_queue_reclaim(struct iwl3945_priv *priv,
3305 int txq_id, int index) 3279 int txq_id, int index)
3306{ 3280{
3307 struct iwl3945_tx_queue *txq = &priv->txq[txq_id]; 3281 struct iwl3945_tx_queue *txq = &priv->txq[txq_id];
3308 struct iwl3945_queue *q = &txq->q; 3282 struct iwl_queue *q = &txq->q;
3309 int nfreed = 0; 3283 int nfreed = 0;
3310 3284
3311 if ((index >= q->n_bd) || (iwl3945_x2_queue_used(q, index) == 0)) { 3285 if ((index >= q->n_bd) || (iwl3945_x2_queue_used(q, index) == 0)) {
@@ -4524,8 +4498,9 @@ static void iwl3945_init_band_reference(const struct iwl3945_priv *priv, int ban
4524 * 4498 *
4525 * Based on band and channel number. 4499 * Based on band and channel number.
4526 */ 4500 */
4527const struct iwl3945_channel_info *iwl3945_get_channel_info(const struct iwl3945_priv *priv, 4501const struct iwl_channel_info *
4528 enum ieee80211_band band, u16 channel) 4502iwl3945_get_channel_info(const struct iwl3945_priv *priv,
4503 enum ieee80211_band band, u16 channel)
4529{ 4504{
4530 int i; 4505 int i;
4531 4506
@@ -4560,7 +4535,7 @@ static int iwl3945_init_channel_map(struct iwl3945_priv *priv)
4560 const u8 *eeprom_ch_index = NULL; 4535 const u8 *eeprom_ch_index = NULL;
4561 const struct iwl_eeprom_channel *eeprom_ch_info = NULL; 4536 const struct iwl_eeprom_channel *eeprom_ch_info = NULL;
4562 int band, ch; 4537 int band, ch;
4563 struct iwl3945_channel_info *ch_info; 4538 struct iwl_channel_info *ch_info;
4564 4539
4565 if (priv->channel_count) { 4540 if (priv->channel_count) {
4566 IWL_DEBUG_INFO("Channel map already initialized.\n"); 4541 IWL_DEBUG_INFO("Channel map already initialized.\n");
@@ -4584,7 +4559,7 @@ static int iwl3945_init_channel_map(struct iwl3945_priv *priv)
4584 4559
4585 IWL_DEBUG_INFO("Parsing data for %d channels.\n", priv->channel_count); 4560 IWL_DEBUG_INFO("Parsing data for %d channels.\n", priv->channel_count);
4586 4561
4587 priv->channel_info = kzalloc(sizeof(struct iwl3945_channel_info) * 4562 priv->channel_info = kzalloc(sizeof(struct iwl_channel_info) *
4588 priv->channel_count, GFP_KERNEL); 4563 priv->channel_count, GFP_KERNEL);
4589 if (!priv->channel_info) { 4564 if (!priv->channel_info) {
4590 IWL_ERROR("Could not allocate channel_info\n"); 4565 IWL_ERROR("Could not allocate channel_info\n");
@@ -4746,7 +4721,7 @@ static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv,
4746{ 4721{
4747 const struct ieee80211_channel *channels = NULL; 4722 const struct ieee80211_channel *channels = NULL;
4748 const struct ieee80211_supported_band *sband; 4723 const struct ieee80211_supported_band *sband;
4749 const struct iwl3945_channel_info *ch_info; 4724 const struct iwl_channel_info *ch_info;
4750 u16 passive_dwell = 0; 4725 u16 passive_dwell = 0;
4751 u16 active_dwell = 0; 4726 u16 active_dwell = 0;
4752 int added, i; 4727 int added, i;
@@ -4858,7 +4833,7 @@ static void iwl3945_init_hw_rates(struct iwl3945_priv *priv,
4858 */ 4833 */
4859static int iwl3945_init_geos(struct iwl3945_priv *priv) 4834static int iwl3945_init_geos(struct iwl3945_priv *priv)
4860{ 4835{
4861 struct iwl3945_channel_info *ch; 4836 struct iwl_channel_info *ch;
4862 struct ieee80211_supported_band *sband; 4837 struct ieee80211_supported_band *sband;
4863 struct ieee80211_channel *channels; 4838 struct ieee80211_channel *channels;
4864 struct ieee80211_channel *geo_ch; 4839 struct ieee80211_channel *geo_ch;
@@ -6585,7 +6560,7 @@ static int iwl3945_mac_add_interface(struct ieee80211_hw *hw,
6585static int iwl3945_mac_config(struct ieee80211_hw *hw, u32 changed) 6560static int iwl3945_mac_config(struct ieee80211_hw *hw, u32 changed)
6586{ 6561{
6587 struct iwl3945_priv *priv = hw->priv; 6562 struct iwl3945_priv *priv = hw->priv;
6588 const struct iwl3945_channel_info *ch_info; 6563 const struct iwl_channel_info *ch_info;
6589 struct ieee80211_conf *conf = &hw->conf; 6564 struct ieee80211_conf *conf = &hw->conf;
6590 unsigned long flags; 6565 unsigned long flags;
6591 int ret = 0; 6566 int ret = 0;
@@ -7112,7 +7087,7 @@ static int iwl3945_mac_get_tx_stats(struct ieee80211_hw *hw,
7112 struct iwl3945_priv *priv = hw->priv; 7087 struct iwl3945_priv *priv = hw->priv;
7113 int i, avail; 7088 int i, avail;
7114 struct iwl3945_tx_queue *txq; 7089 struct iwl3945_tx_queue *txq;
7115 struct iwl3945_queue *q; 7090 struct iwl_queue *q;
7116 unsigned long flags; 7091 unsigned long flags;
7117 7092
7118 IWL_DEBUG_MAC80211("enter\n"); 7093 IWL_DEBUG_MAC80211("enter\n");
@@ -7127,7 +7102,7 @@ static int iwl3945_mac_get_tx_stats(struct ieee80211_hw *hw,
7127 for (i = 0; i < AC_NUM; i++) { 7102 for (i = 0; i < AC_NUM; i++) {
7128 txq = &priv->txq[i]; 7103 txq = &priv->txq[i];
7129 q = &txq->q; 7104 q = &txq->q;
7130 avail = iwl3945_queue_space(q); 7105 avail = iwl_queue_space(q);
7131 7106
7132 stats[i].len = q->n_window - avail; 7107 stats[i].len = q->n_window - avail;
7133 stats[i].limit = q->n_window - q->high_mark; 7108 stats[i].limit = q->n_window - q->high_mark;