aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl3945-base.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl3945-base.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c69
1 files changed, 22 insertions, 47 deletions
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;