aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2008-03-06 20:36:53 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-03-07 16:03:01 -0500
commitc54b679ddcd91604fd0d144cd793a0ddbd0ae03d (patch)
tree3ebbedc13d2a64a1c6491ac29c5c3a18e934bc6b
parent34cf6ff6dd42cbc61fd652f893dcf71eed6052a5 (diff)
iwlwifi: queue functions cleanup
This patch moves 1. iwl_queue_inc_wrap and int iwl_queue_dec_wrap into iwl-helpers.h these two functions are identical to common for both iwl3956 and iwl4965 2. renames x2_queue_used to iwl3945_x2_queue_used 3. exports iwl3945_queue_space out of iwl3964-base.c Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-helpers.h20
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c45
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c37
4 files changed, 45 insertions, 60 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index a238e833251f..0ab22d366d93 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -116,6 +116,9 @@ struct iwl3945_queue {
116 * space less than this */ 116 * space less than this */
117} __attribute__ ((packed)); 117} __attribute__ ((packed));
118 118
119int iwl3945_queue_space(const struct iwl3945_queue *q);
120int iwl3945_x2_queue_used(const struct iwl3945_queue *q, int i);
121
119#define MAX_NUM_OF_TBS (20) 122#define MAX_NUM_OF_TBS (20)
120 123
121/* One for each TFD */ 124/* One for each TFD */
diff --git a/drivers/net/wireless/iwlwifi/iwl-helpers.h b/drivers/net/wireless/iwlwifi/iwl-helpers.h
index 8993cca81b40..736b88881b03 100644
--- a/drivers/net/wireless/iwlwifi/iwl-helpers.h
+++ b/drivers/net/wireless/iwlwifi/iwl-helpers.h
@@ -254,6 +254,26 @@ static inline u8 iwl_get_dma_hi_address(dma_addr_t addr)
254 return sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0; 254 return sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0;
255} 255}
256 256
257/**
258 * iwl_queue_inc_wrap - increment queue index, wrap back to beginning
259 * @index -- current index
260 * @n_bd -- total number of entries in queue (must be power of 2)
261 */
262static inline int iwl_queue_inc_wrap(int index, int n_bd)
263{
264 return ++index & (n_bd - 1);
265}
266
267/**
268 * iwl_queue_dec_wrap - decrement queue index, wrap back to end
269 * @index -- current index
270 * @n_bd -- total number of entries in queue (must be power of 2)
271 */
272static inline int iwl_queue_dec_wrap(int index, int n_bd)
273{
274 return --index & (n_bd - 1);
275}
276
257/* TODO: Move fw_desc functions to iwl-pci.ko */ 277/* TODO: Move fw_desc functions to iwl-pci.ko */
258static inline void iwl_free_fw_desc(struct pci_dev *pci_dev, 278static inline void iwl_free_fw_desc(struct pci_dev *pci_dev,
259 struct fw_desc *desc) 279 struct fw_desc *desc)
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 4aaced0b9f26..39fd5440a248 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -183,7 +183,7 @@ static const char *iwl3945_escape_essid(const char *essid, u8 essid_len)
183 * (#0-3) for data tx via EDCA. An additional 2 HCCA queues are unused. 183 * (#0-3) for data tx via EDCA. An additional 2 HCCA queues are unused.
184 ***************************************************/ 184 ***************************************************/
185 185
186static int iwl3945_queue_space(const struct iwl3945_queue *q) 186int iwl3945_queue_space(const struct iwl3945_queue *q)
187{ 187{
188 int s = q->read_ptr - q->write_ptr; 188 int s = q->read_ptr - q->write_ptr;
189 189
@@ -199,33 +199,14 @@ static int iwl3945_queue_space(const struct iwl3945_queue *q)
199 return s; 199 return s;
200} 200}
201 201
202/** 202int iwl3945_x2_queue_used(const struct iwl3945_queue *q, int i)
203 * iwl3945_queue_inc_wrap - increment queue index, wrap back to beginning
204 * @index -- current index
205 * @n_bd -- total number of entries in queue (must be power of 2)
206 */
207static inline int iwl3945_queue_inc_wrap(int index, int n_bd)
208{
209 return ++index & (n_bd - 1);
210}
211
212/**
213 * iwl3945_queue_dec_wrap - increment queue index, wrap back to end
214 * @index -- current index
215 * @n_bd -- total number of entries in queue (must be power of 2)
216 */
217static inline int iwl3945_queue_dec_wrap(int index, int n_bd)
218{
219 return --index & (n_bd - 1);
220}
221
222static inline int x2_queue_used(const struct iwl3945_queue *q, int i)
223{ 203{
224 return q->write_ptr > q->read_ptr ? 204 return q->write_ptr > q->read_ptr ?
225 (i >= q->read_ptr && i < q->write_ptr) : 205 (i >= q->read_ptr && i < q->write_ptr) :
226 !(i < q->read_ptr && i >= q->write_ptr); 206 !(i < q->read_ptr && i >= q->write_ptr);
227} 207}
228 208
209
229static inline u8 get_cmd_index(struct iwl3945_queue *q, u32 index, int is_huge) 210static inline u8 get_cmd_index(struct iwl3945_queue *q, u32 index, int is_huge)
230{ 211{
231 /* This is for scan command, the big buffer at end of command array */ 212 /* This is for scan command, the big buffer at end of command array */
@@ -246,8 +227,8 @@ static int iwl3945_queue_init(struct iwl3945_priv *priv, struct iwl3945_queue *q
246 q->n_window = slots_num; 227 q->n_window = slots_num;
247 q->id = id; 228 q->id = id;
248 229
249 /* count must be power-of-two size, otherwise iwl3945_queue_inc_wrap 230 /* count must be power-of-two size, otherwise iwl_queue_inc_wrap
250 * and iwl3945_queue_dec_wrap are broken. */ 231 * and iwl_queue_dec_wrap are broken. */
251 BUG_ON(!is_power_of_2(count)); 232 BUG_ON(!is_power_of_2(count));
252 233
253 /* slots_num must be power-of-two size, otherwise 234 /* slots_num must be power-of-two size, otherwise
@@ -347,7 +328,7 @@ int iwl3945_tx_queue_init(struct iwl3945_priv *priv,
347 txq->need_update = 0; 328 txq->need_update = 0;
348 329
349 /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise 330 /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise
350 * iwl3945_queue_inc_wrap and iwl3945_queue_dec_wrap are broken. */ 331 * iwl_queue_inc_wrap and iwl_queue_dec_wrap are broken. */
351 BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); 332 BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1));
352 333
353 /* Initialize queue high/low-water, head/tail indexes */ 334 /* Initialize queue high/low-water, head/tail indexes */
@@ -378,7 +359,7 @@ void iwl3945_tx_queue_free(struct iwl3945_priv *priv, struct iwl3945_tx_queue *t
378 359
379 /* first, empty all BD's */ 360 /* first, empty all BD's */
380 for (; q->write_ptr != q->read_ptr; 361 for (; q->write_ptr != q->read_ptr;
381 q->read_ptr = iwl3945_queue_inc_wrap(q->read_ptr, q->n_bd)) 362 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd))
382 iwl3945_hw_txq_free_tfd(priv, txq); 363 iwl3945_hw_txq_free_tfd(priv, txq);
383 364
384 len = sizeof(struct iwl3945_cmd) * q->n_window; 365 len = sizeof(struct iwl3945_cmd) * q->n_window;
@@ -717,7 +698,7 @@ static int iwl3945_enqueue_hcmd(struct iwl3945_priv *priv, struct iwl3945_host_c
717 txq->need_update = 1; 698 txq->need_update = 1;
718 699
719 /* Increment and update queue's write index */ 700 /* Increment and update queue's write index */
720 q->write_ptr = iwl3945_queue_inc_wrap(q->write_ptr, q->n_bd); 701 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
721 ret = iwl3945_tx_queue_update_write_ptr(priv, txq); 702 ret = iwl3945_tx_queue_update_write_ptr(priv, txq);
722 703
723 spin_unlock_irqrestore(&priv->hcmd_lock, flags); 704 spin_unlock_irqrestore(&priv->hcmd_lock, flags);
@@ -2797,7 +2778,7 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv,
2797 ieee80211_get_hdrlen(fc)); 2778 ieee80211_get_hdrlen(fc));
2798 2779
2799 /* Tell device the write index *just past* this latest filled TFD */ 2780 /* Tell device the write index *just past* this latest filled TFD */
2800 q->write_ptr = iwl3945_queue_inc_wrap(q->write_ptr, q->n_bd); 2781 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
2801 rc = iwl3945_tx_queue_update_write_ptr(priv, txq); 2782 rc = iwl3945_tx_queue_update_write_ptr(priv, txq);
2802 spin_unlock_irqrestore(&priv->lock, flags); 2783 spin_unlock_irqrestore(&priv->lock, flags);
2803 2784
@@ -3189,16 +3170,16 @@ static int iwl3945_tx_queue_reclaim(struct iwl3945_priv *priv, int txq_id, int i
3189 struct iwl3945_queue *q = &txq->q; 3170 struct iwl3945_queue *q = &txq->q;
3190 int nfreed = 0; 3171 int nfreed = 0;
3191 3172
3192 if ((index >= q->n_bd) || (x2_queue_used(q, index) == 0)) { 3173 if ((index >= q->n_bd) || (iwl3945_x2_queue_used(q, index) == 0)) {
3193 IWL_ERROR("Read index for DMA queue txq id (%d), index %d, " 3174 IWL_ERROR("Read index for DMA queue txq id (%d), index %d, "
3194 "is out of range [0-%d] %d %d.\n", txq_id, 3175 "is out of range [0-%d] %d %d.\n", txq_id,
3195 index, q->n_bd, q->write_ptr, q->read_ptr); 3176 index, q->n_bd, q->write_ptr, q->read_ptr);
3196 return 0; 3177 return 0;
3197 } 3178 }
3198 3179
3199 for (index = iwl3945_queue_inc_wrap(index, q->n_bd); 3180 for (index = iwl_queue_inc_wrap(index, q->n_bd);
3200 q->read_ptr != index; 3181 q->read_ptr != index;
3201 q->read_ptr = iwl3945_queue_inc_wrap(q->read_ptr, q->n_bd)) { 3182 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
3202 if (txq_id != IWL_CMD_QUEUE_NUM) { 3183 if (txq_id != IWL_CMD_QUEUE_NUM) {
3203 iwl3945_txstatus_to_ieee(priv, 3184 iwl3945_txstatus_to_ieee(priv,
3204 &(txq->txb[txq->q.read_ptr])); 3185 &(txq->txb[txq->q.read_ptr]));
@@ -3245,7 +3226,7 @@ static void iwl3945_rx_reply_tx(struct iwl3945_priv *priv,
3245 struct iwl3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; 3226 struct iwl3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
3246 u32 status = le32_to_cpu(tx_resp->status); 3227 u32 status = le32_to_cpu(tx_resp->status);
3247 3228
3248 if ((index >= txq->q.n_bd) || (x2_queue_used(&txq->q, index) == 0)) { 3229 if ((index >= txq->q.n_bd) || (iwl3945_x2_queue_used(&txq->q, index) == 0)) {
3249 IWL_ERROR("Read index for DMA queue txq_id (%d) index %d " 3230 IWL_ERROR("Read index for DMA queue txq_id (%d) index %d "
3250 "is out of range [0-%d] %d %d\n", txq_id, 3231 "is out of range [0-%d] %d %d\n", txq_id,
3251 index, txq->q.n_bd, txq->q.write_ptr, 3232 index, txq->q.n_bd, txq->q.write_ptr,
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index af95626a6112..28c64c39ef02 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -194,25 +194,6 @@ int iwl4965_queue_space(const struct iwl4965_queue *q)
194 return s; 194 return s;
195} 195}
196 196
197/**
198 * iwl4965_queue_inc_wrap - increment queue index, wrap back to beginning
199 * @index -- current index
200 * @n_bd -- total number of entries in queue (must be power of 2)
201 */
202static inline int iwl4965_queue_inc_wrap(int index, int n_bd)
203{
204 return ++index & (n_bd - 1);
205}
206
207/**
208 * iwl4965_queue_dec_wrap - decrement queue index, wrap back to end
209 * @index -- current index
210 * @n_bd -- total number of entries in queue (must be power of 2)
211 */
212static inline int iwl4965_queue_dec_wrap(int index, int n_bd)
213{
214 return --index & (n_bd - 1);
215}
216 197
217static inline int x2_queue_used(const struct iwl4965_queue *q, int i) 198static inline int x2_queue_used(const struct iwl4965_queue *q, int i)
218{ 199{
@@ -241,8 +222,8 @@ static int iwl4965_queue_init(struct iwl4965_priv *priv, struct iwl4965_queue *q
241 q->n_window = slots_num; 222 q->n_window = slots_num;
242 q->id = id; 223 q->id = id;
243 224
244 /* count must be power-of-two size, otherwise iwl4965_queue_inc_wrap 225 /* count must be power-of-two size, otherwise iwl_queue_inc_wrap
245 * and iwl4965_queue_dec_wrap are broken. */ 226 * and iwl_queue_dec_wrap are broken. */
246 BUG_ON(!is_power_of_2(count)); 227 BUG_ON(!is_power_of_2(count));
247 228
248 /* slots_num must be power-of-two size, otherwise 229 /* slots_num must be power-of-two size, otherwise
@@ -342,7 +323,7 @@ int iwl4965_tx_queue_init(struct iwl4965_priv *priv,
342 txq->need_update = 0; 323 txq->need_update = 0;
343 324
344 /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise 325 /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise
345 * iwl4965_queue_inc_wrap and iwl4965_queue_dec_wrap are broken. */ 326 * iwl_queue_inc_wrap and iwl_queue_dec_wrap are broken. */
346 BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); 327 BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1));
347 328
348 /* Initialize queue's high/low-water marks, and head/tail indexes */ 329 /* Initialize queue's high/low-water marks, and head/tail indexes */
@@ -373,7 +354,7 @@ void iwl4965_tx_queue_free(struct iwl4965_priv *priv, struct iwl4965_tx_queue *t
373 354
374 /* first, empty all BD's */ 355 /* first, empty all BD's */
375 for (; q->write_ptr != q->read_ptr; 356 for (; q->write_ptr != q->read_ptr;
376 q->read_ptr = iwl4965_queue_inc_wrap(q->read_ptr, q->n_bd)) 357 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd))
377 iwl4965_hw_txq_free_tfd(priv, txq); 358 iwl4965_hw_txq_free_tfd(priv, txq);
378 359
379 len = sizeof(struct iwl4965_cmd) * q->n_window; 360 len = sizeof(struct iwl4965_cmd) * q->n_window;
@@ -714,7 +695,7 @@ static int iwl4965_enqueue_hcmd(struct iwl4965_priv *priv, struct iwl4965_host_c
714 ret = iwl4965_tx_queue_update_wr_ptr(priv, txq, 0); 695 ret = iwl4965_tx_queue_update_wr_ptr(priv, txq, 0);
715 696
716 /* Increment and update queue's write index */ 697 /* Increment and update queue's write index */
717 q->write_ptr = iwl4965_queue_inc_wrap(q->write_ptr, q->n_bd); 698 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
718 iwl4965_tx_queue_update_write_ptr(priv, txq); 699 iwl4965_tx_queue_update_write_ptr(priv, txq);
719 700
720 spin_unlock_irqrestore(&priv->hcmd_lock, flags); 701 spin_unlock_irqrestore(&priv->hcmd_lock, flags);
@@ -2897,7 +2878,7 @@ static int iwl4965_tx_skb(struct iwl4965_priv *priv,
2897 iwl4965_tx_queue_update_wr_ptr(priv, txq, len); 2878 iwl4965_tx_queue_update_wr_ptr(priv, txq, len);
2898 2879
2899 /* Tell device the write index *just past* this latest filled TFD */ 2880 /* Tell device the write index *just past* this latest filled TFD */
2900 q->write_ptr = iwl4965_queue_inc_wrap(q->write_ptr, q->n_bd); 2881 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
2901 rc = iwl4965_tx_queue_update_write_ptr(priv, txq); 2882 rc = iwl4965_tx_queue_update_write_ptr(priv, txq);
2902 spin_unlock_irqrestore(&priv->lock, flags); 2883 spin_unlock_irqrestore(&priv->lock, flags);
2903 2884
@@ -3291,9 +3272,9 @@ int iwl4965_tx_queue_reclaim(struct iwl4965_priv *priv, int txq_id, int index)
3291 return 0; 3272 return 0;
3292 } 3273 }
3293 3274
3294 for (index = iwl4965_queue_inc_wrap(index, q->n_bd); 3275 for (index = iwl_queue_inc_wrap(index, q->n_bd);
3295 q->read_ptr != index; 3276 q->read_ptr != index;
3296 q->read_ptr = iwl4965_queue_inc_wrap(q->read_ptr, q->n_bd)) { 3277 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
3297 if (txq_id != IWL_CMD_QUEUE_NUM) { 3278 if (txq_id != IWL_CMD_QUEUE_NUM) {
3298 iwl4965_txstatus_to_ieee(priv, 3279 iwl4965_txstatus_to_ieee(priv,
3299 &(txq->txb[txq->q.read_ptr])); 3280 &(txq->txb[txq->q.read_ptr]));
@@ -3538,7 +3519,7 @@ static void iwl4965_rx_reply_tx(struct iwl4965_priv *priv,
3538 3519
3539 if (txq->q.read_ptr != (scd_ssn & 0xff)) { 3520 if (txq->q.read_ptr != (scd_ssn & 0xff)) {
3540 int freed; 3521 int freed;
3541 index = iwl4965_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); 3522 index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
3542 IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn " 3523 IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn "
3543 "%d index %d\n", scd_ssn , index); 3524 "%d index %d\n", scd_ssn , index);
3544 freed = iwl4965_tx_queue_reclaim(priv, txq_id, index); 3525 freed = iwl4965_tx_queue_reclaim(priv, txq_id, index);