From 73de130446da0c7854d06d2ca9bab3c40cd8b1ef Mon Sep 17 00:00:00 2001 From: Tomas Winkler Date: Mon, 20 Aug 2007 15:59:02 +0300 Subject: [PATCH 18/31] iwlwifi: simplifying reclaim flow This patch simplifies reclaim function. It kills unused 'used' variable and replaces return value with number of freed packets. The number of freed packets will be used for handling AGG queues statistics. Signed-off-by: Tomas Winkler Signed-off-by: Zhu Yi --- drivers/net/wireless/iwl-base.c | 29 +++++++++++------------------ 1 files changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/net/wireless/iwl-base.c b/drivers/net/wireless/iwl-base.c index 9b1ed16..17f121d 100644 --- a/drivers/net/wireless/iwl-base.c +++ b/drivers/net/wireless/iwl-base.c @@ -3543,25 +3543,27 @@ int iwl_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) { struct iwl_tx_queue *txq = &priv->txq[txq_id]; struct iwl_queue *q = &txq->q; - u8 hcmd_num = 0; - int used; - + int nfreed = 0; if ((index >= q->n_bd) || (x2_queue_used(q, index) == 0)) { IWL_ERROR("Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, index, q->n_bd, q->first_empty, q->last_used); return 0; } - index = iwl_queue_inc_wrap(index, q->n_bd); - for (; q->last_used != index; - q->last_used = iwl_queue_inc_wrap(q->last_used, q->n_bd)) { + for (index = iwl_queue_inc_wrap(index, q->n_bd); + q->last_used != index; + q->last_used = iwl_queue_inc_wrap(q->last_used, q->n_bd)) { if (txq_id != IWL_CMD_QUEUE_NUM) { iwl_txstatus_to_ieee(priv, &(txq->txb[txq->q.last_used])); iwl_hw_txq_free_tfd(priv, txq); - } else - hcmd_num++; + } else if (nfreed > 1) { + IWL_ERROR("HCMD skipped: index (%d) %d %d\n", index, + q->first_empty, q->last_used); + queue_work(priv->workqueue, &priv->restart); + } + nfreed++; } if (iwl_queue_space(q) > q->low_mark && (txq_id >= 0) && @@ -3569,17 +3571,8 @@ int iwl_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) priv->mac80211_registered) ieee80211_wake_queue(priv->hw, txq_id); - used = q->first_empty - q->last_used; - if (used < 0) - used += q->n_bd; - - if (hcmd_num > 1) { - IWL_ERROR("HCMD skipped: index (%d) %d %d\n", index, - q->first_empty, q->last_used); - queue_work(priv->workqueue, &priv->restart); - } - return used; + return nfreed; } static int iwl_is_tx_success(u32 status) -- 1.5.2