aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl4965-base.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl4965-base.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index eb2d7a555bbc..e0feca8acddb 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -208,9 +208,9 @@ static void iwl_print_hex_dump(int level, void *p, u32 len)
208 208
209static int iwl_queue_space(const struct iwl_queue *q) 209static int iwl_queue_space(const struct iwl_queue *q)
210{ 210{
211 int s = q->last_used - q->first_empty; 211 int s = q->read_ptr - q->write_ptr;
212 212
213 if (q->last_used > q->first_empty) 213 if (q->read_ptr > q->write_ptr)
214 s -= q->n_bd; 214 s -= q->n_bd;
215 215
216 if (s <= 0) 216 if (s <= 0)
@@ -236,9 +236,9 @@ static inline int iwl_queue_dec_wrap(int index, int n_bd)
236 236
237static inline int x2_queue_used(const struct iwl_queue *q, int i) 237static inline int x2_queue_used(const struct iwl_queue *q, int i)
238{ 238{
239 return q->first_empty > q->last_used ? 239 return q->write_ptr > q->read_ptr ?
240 (i >= q->last_used && i < q->first_empty) : 240 (i >= q->read_ptr && i < q->write_ptr) :
241 !(i < q->last_used && i >= q->first_empty); 241 !(i < q->read_ptr && i >= q->write_ptr);
242} 242}
243 243
244static inline u8 get_cmd_index(struct iwl_queue *q, u32 index, int is_huge) 244static inline u8 get_cmd_index(struct iwl_queue *q, u32 index, int is_huge)
@@ -272,7 +272,7 @@ static int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q,
272 if (q->high_mark < 2) 272 if (q->high_mark < 2)
273 q->high_mark = 2; 273 q->high_mark = 2;
274 274
275 q->first_empty = q->last_used = 0; 275 q->write_ptr = q->read_ptr = 0;
276 276
277 return 0; 277 return 0;
278} 278}
@@ -368,8 +368,8 @@ void iwl_tx_queue_free(struct iwl_priv *priv, struct iwl_tx_queue *txq)
368 return; 368 return;
369 369
370 /* first, empty all BD's */ 370 /* first, empty all BD's */
371 for (; q->first_empty != q->last_used; 371 for (; q->write_ptr != q->read_ptr;
372 q->last_used = iwl_queue_inc_wrap(q->last_used, q->n_bd)) 372 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd))
373 iwl_hw_txq_free_tfd(priv, txq); 373 iwl_hw_txq_free_tfd(priv, txq);
374 374
375 len = sizeof(struct iwl_cmd) * q->n_window; 375 len = sizeof(struct iwl_cmd) * q->n_window;
@@ -652,12 +652,12 @@ static int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
652 652
653 spin_lock_irqsave(&priv->hcmd_lock, flags); 653 spin_lock_irqsave(&priv->hcmd_lock, flags);
654 654
655 tfd = &txq->bd[q->first_empty]; 655 tfd = &txq->bd[q->write_ptr];
656 memset(tfd, 0, sizeof(*tfd)); 656 memset(tfd, 0, sizeof(*tfd));
657 657
658 control_flags = (u32 *) tfd; 658 control_flags = (u32 *) tfd;
659 659
660 idx = get_cmd_index(q, q->first_empty, cmd->meta.flags & CMD_SIZE_HUGE); 660 idx = get_cmd_index(q, q->write_ptr, cmd->meta.flags & CMD_SIZE_HUGE);
661 out_cmd = &txq->cmd[idx]; 661 out_cmd = &txq->cmd[idx];
662 662
663 out_cmd->hdr.cmd = cmd->id; 663 out_cmd->hdr.cmd = cmd->id;
@@ -669,7 +669,7 @@ static int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
669 669
670 out_cmd->hdr.flags = 0; 670 out_cmd->hdr.flags = 0;
671 out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(IWL_CMD_QUEUE_NUM) | 671 out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(IWL_CMD_QUEUE_NUM) |
672 INDEX_TO_SEQ(q->first_empty)); 672 INDEX_TO_SEQ(q->write_ptr));
673 if (out_cmd->meta.flags & CMD_SIZE_HUGE) 673 if (out_cmd->meta.flags & CMD_SIZE_HUGE)
674 out_cmd->hdr.sequence |= cpu_to_le16(SEQ_HUGE_FRAME); 674 out_cmd->hdr.sequence |= cpu_to_le16(SEQ_HUGE_FRAME);
675 675
@@ -681,11 +681,11 @@ static int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
681 "%d bytes at %d[%d]:%d\n", 681 "%d bytes at %d[%d]:%d\n",
682 get_cmd_string(out_cmd->hdr.cmd), 682 get_cmd_string(out_cmd->hdr.cmd),
683 out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence), 683 out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence),
684 fix_size, q->first_empty, idx, IWL_CMD_QUEUE_NUM); 684 fix_size, q->write_ptr, idx, IWL_CMD_QUEUE_NUM);
685 685
686 txq->need_update = 1; 686 txq->need_update = 1;
687 ret = iwl4965_tx_queue_update_wr_ptr(priv, txq, 0); 687 ret = iwl4965_tx_queue_update_wr_ptr(priv, txq, 0);
688 q->first_empty = iwl_queue_inc_wrap(q->first_empty, q->n_bd); 688 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
689 iwl_tx_queue_update_write_ptr(priv, txq); 689 iwl_tx_queue_update_write_ptr(priv, txq);
690 690
691 spin_unlock_irqrestore(&priv->hcmd_lock, flags); 691 spin_unlock_irqrestore(&priv->hcmd_lock, flags);
@@ -2889,21 +2889,21 @@ static int iwl_tx_skb(struct iwl_priv *priv,
2889 2889
2890 spin_lock_irqsave(&priv->lock, flags); 2890 spin_lock_irqsave(&priv->lock, flags);
2891 2891
2892 tfd = &txq->bd[q->first_empty]; 2892 tfd = &txq->bd[q->write_ptr];
2893 memset(tfd, 0, sizeof(*tfd)); 2893 memset(tfd, 0, sizeof(*tfd));
2894 control_flags = (u32 *) tfd; 2894 control_flags = (u32 *) tfd;
2895 idx = get_cmd_index(q, q->first_empty, 0); 2895 idx = get_cmd_index(q, q->write_ptr, 0);
2896 2896
2897 memset(&(txq->txb[q->first_empty]), 0, sizeof(struct iwl_tx_info)); 2897 memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info));
2898 txq->txb[q->first_empty].skb[0] = skb; 2898 txq->txb[q->write_ptr].skb[0] = skb;
2899 memcpy(&(txq->txb[q->first_empty].status.control), 2899 memcpy(&(txq->txb[q->write_ptr].status.control),
2900 ctl, sizeof(struct ieee80211_tx_control)); 2900 ctl, sizeof(struct ieee80211_tx_control));
2901 out_cmd = &txq->cmd[idx]; 2901 out_cmd = &txq->cmd[idx];
2902 memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); 2902 memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr));
2903 memset(&out_cmd->cmd.tx, 0, sizeof(out_cmd->cmd.tx)); 2903 memset(&out_cmd->cmd.tx, 0, sizeof(out_cmd->cmd.tx));
2904 out_cmd->hdr.cmd = REPLY_TX; 2904 out_cmd->hdr.cmd = REPLY_TX;
2905 out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | 2905 out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) |
2906 INDEX_TO_SEQ(q->first_empty))); 2906 INDEX_TO_SEQ(q->write_ptr)));
2907 /* copy frags header */ 2907 /* copy frags header */
2908 memcpy(out_cmd->cmd.tx.hdr, hdr, hdr_len); 2908 memcpy(out_cmd->cmd.tx.hdr, hdr, hdr_len);
2909 2909
@@ -2969,7 +2969,7 @@ static int iwl_tx_skb(struct iwl_priv *priv,
2969 2969
2970 iwl4965_tx_queue_update_wr_ptr(priv, txq, len); 2970 iwl4965_tx_queue_update_wr_ptr(priv, txq, len);
2971 2971
2972 q->first_empty = iwl_queue_inc_wrap(q->first_empty, q->n_bd); 2972 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
2973 rc = iwl_tx_queue_update_write_ptr(priv, txq); 2973 rc = iwl_tx_queue_update_write_ptr(priv, txq);
2974 spin_unlock_irqrestore(&priv->lock, flags); 2974 spin_unlock_irqrestore(&priv->lock, flags);
2975 2975
@@ -3463,20 +3463,20 @@ int iwl_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index)
3463 if ((index >= q->n_bd) || (x2_queue_used(q, index) == 0)) { 3463 if ((index >= q->n_bd) || (x2_queue_used(q, index) == 0)) {
3464 IWL_ERROR("Read index for DMA queue txq id (%d), index %d, " 3464 IWL_ERROR("Read index for DMA queue txq id (%d), index %d, "
3465 "is out of range [0-%d] %d %d.\n", txq_id, 3465 "is out of range [0-%d] %d %d.\n", txq_id,
3466 index, q->n_bd, q->first_empty, q->last_used); 3466 index, q->n_bd, q->write_ptr, q->read_ptr);
3467 return 0; 3467 return 0;
3468 } 3468 }
3469 3469
3470 for (index = iwl_queue_inc_wrap(index, q->n_bd); 3470 for (index = iwl_queue_inc_wrap(index, q->n_bd);
3471 q->last_used != index; 3471 q->read_ptr != index;
3472 q->last_used = iwl_queue_inc_wrap(q->last_used, q->n_bd)) { 3472 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
3473 if (txq_id != IWL_CMD_QUEUE_NUM) { 3473 if (txq_id != IWL_CMD_QUEUE_NUM) {
3474 iwl_txstatus_to_ieee(priv, 3474 iwl_txstatus_to_ieee(priv,
3475 &(txq->txb[txq->q.last_used])); 3475 &(txq->txb[txq->q.read_ptr]));
3476 iwl_hw_txq_free_tfd(priv, txq); 3476 iwl_hw_txq_free_tfd(priv, txq);
3477 } else if (nfreed > 1) { 3477 } else if (nfreed > 1) {
3478 IWL_ERROR("HCMD skipped: index (%d) %d %d\n", index, 3478 IWL_ERROR("HCMD skipped: index (%d) %d %d\n", index,
3479 q->first_empty, q->last_used); 3479 q->write_ptr, q->read_ptr);
3480 queue_work(priv->workqueue, &priv->restart); 3480 queue_work(priv->workqueue, &priv->restart);
3481 } 3481 }
3482 nfreed++; 3482 nfreed++;
@@ -3564,7 +3564,7 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
3564 IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d \n", 3564 IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d \n",
3565 agg->frame_count, agg->start_idx); 3565 agg->frame_count, agg->start_idx);
3566 3566
3567 tx_status = &(priv->txq[txq_id].txb[txq->q.last_used].status); 3567 tx_status = &(priv->txq[txq_id].txb[txq->q.read_ptr].status);
3568 tx_status->retry_count = tx_resp->failure_frame; 3568 tx_status->retry_count = tx_resp->failure_frame;
3569 tx_status->queue_number = status & 0xff; 3569 tx_status->queue_number = status & 0xff;
3570 tx_status->queue_length = tx_resp->bt_kill_count; 3570 tx_status->queue_length = tx_resp->bt_kill_count;
@@ -3669,8 +3669,8 @@ static void iwl_rx_reply_tx(struct iwl_priv *priv,
3669 if ((index >= txq->q.n_bd) || (x2_queue_used(&txq->q, index) == 0)) { 3669 if ((index >= txq->q.n_bd) || (x2_queue_used(&txq->q, index) == 0)) {
3670 IWL_ERROR("Read index for DMA queue txq_id (%d) index %d " 3670 IWL_ERROR("Read index for DMA queue txq_id (%d) index %d "
3671 "is out of range [0-%d] %d %d\n", txq_id, 3671 "is out of range [0-%d] %d %d\n", txq_id,
3672 index, txq->q.n_bd, txq->q.first_empty, 3672 index, txq->q.n_bd, txq->q.write_ptr,
3673 txq->q.last_used); 3673 txq->q.read_ptr);
3674 return; 3674 return;
3675 } 3675 }
3676 3676
@@ -3705,7 +3705,7 @@ static void iwl_rx_reply_tx(struct iwl_priv *priv,
3705 /* TODO: send BAR */ 3705 /* TODO: send BAR */
3706 } 3706 }
3707 3707
3708 if ((txq->q.last_used != (scd_ssn & 0xff))) { 3708 if ((txq->q.read_ptr != (scd_ssn & 0xff))) {
3709 index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); 3709 index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
3710 IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn " 3710 IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn "
3711 "%d index %d\n", scd_ssn , index); 3711 "%d index %d\n", scd_ssn , index);
@@ -3714,7 +3714,7 @@ static void iwl_rx_reply_tx(struct iwl_priv *priv,
3714 } else { 3714 } else {
3715#endif /* CONFIG_IWLWIFI_HT_AGG */ 3715#endif /* CONFIG_IWLWIFI_HT_AGG */
3716#endif /* CONFIG_IWLWIFI_HT */ 3716#endif /* CONFIG_IWLWIFI_HT */
3717 tx_status = &(txq->txb[txq->q.last_used].status); 3717 tx_status = &(txq->txb[txq->q.read_ptr].status);
3718 3718
3719 tx_status->retry_count = tx_resp->failure_frame; 3719 tx_status->retry_count = tx_resp->failure_frame;
3720 tx_status->queue_number = status; 3720 tx_status->queue_number = status;
@@ -4692,14 +4692,14 @@ int iwl_tx_queue_update_write_ptr(struct iwl_priv *priv,
4692 if (rc) 4692 if (rc)
4693 return rc; 4693 return rc;
4694 iwl_write_restricted(priv, HBUS_TARG_WRPTR, 4694 iwl_write_restricted(priv, HBUS_TARG_WRPTR,
4695 txq->q.first_empty | (txq_id << 8)); 4695 txq->q.write_ptr | (txq_id << 8));
4696 iwl_release_restricted_access(priv); 4696 iwl_release_restricted_access(priv);
4697 4697
4698 /* else not in power-save mode, uCode will never sleep when we're 4698 /* else not in power-save mode, uCode will never sleep when we're
4699 * trying to tx (during RFKILL, we're not trying to tx). */ 4699 * trying to tx (during RFKILL, we're not trying to tx). */
4700 } else 4700 } else
4701 iwl_write32(priv, HBUS_TARG_WRPTR, 4701 iwl_write32(priv, HBUS_TARG_WRPTR,
4702 txq->q.first_empty | (txq_id << 8)); 4702 txq->q.write_ptr | (txq_id << 8));
4703 4703
4704 txq->need_update = 0; 4704 txq->need_update = 0;
4705 4705