From: "Nathaniel J. Smith" <njs@pobox.com>
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org, wey-yi.w.guy@intel.com,
ilw@linux.intel.com, "Nathaniel J. Smith" <njs@pobox.com>
Subject: [PATCH 3/5] iwlwifi: Invert the sense of the queue high_mark
Date: Sun, 13 Feb 2011 09:56:40 -0800 [thread overview]
Message-ID: <1297619803-2832-4-git-send-email-njs@pobox.com> (raw)
In-Reply-To: <1297619803-2832-1-git-send-email-njs@pobox.com>
Before, the high_mark was the minimum amount of free space allowed in a
queue. Now, it's the maximum number of packets which are allowed to be
in the queue.
No behavioral changes, but this makes the high_mark much easier to reason
about. (You might think it wouldn't make a difference, but in fact the
relationship between the number of packets enqueued and the queue free
space is complicated by the need to distinguish the queue full and queue
empty conditions. Removing this complication makes the next patches
simpler.)
Signed-off-by: Nathaniel J. Smith <njs@pobox.com>
---
drivers/net/wireless/iwlwifi/iwl-3945.c | 3 ++-
drivers/net/wireless/iwlwifi/iwl-4965.c | 4 ++--
drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 4 ++--
drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 6 +++---
drivers/net/wireless/iwlwifi/iwl-dev.h | 6 +++---
drivers/net/wireless/iwlwifi/iwl-tx.c | 19 +++++++++++++------
drivers/net/wireless/iwlwifi/iwl3945-base.c | 4 ++--
7 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 63999ae..f2e9e59 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -294,7 +294,8 @@ static void iwl3945_tx_queue_reclaim(struct iwl_priv *priv,
priv->cfg->ops->lib->txq_free_tfd(priv, txq);
}
- if (iwl_queue_space(q) > atomic_read(&q->high_mark) && (txq_id >= 0) &&
+ if (iwl_queue_space_used(q) < atomic_read(&q->high_mark) &&
+ (txq_id >= 0) &&
(txq_id != IWL39_CMD_QUEUE_NUM) &&
priv->mac80211_registered)
iwl_wake_queue(priv, txq);
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 548cbe9..6203c45 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -2230,7 +2230,7 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
tid, freed);
if (priv->mac80211_registered &&
- (iwl_queue_space(&txq->q) > atomic_read(&txq->q.high_mark)) &&
+ (iwl_queue_space_used(&txq->q) < atomic_read(&txq->q.high_mark)) &&
(agg->state != IWL_EMPTYING_HW_QUEUE_DELBA))
iwl_wake_queue(priv, txq);
}
@@ -2255,7 +2255,7 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
IWL_DEBUG_TX_REPLY(priv, "Station not known\n");
if (priv->mac80211_registered &&
- (iwl_queue_space(&txq->q) > atomic_read(&txq->q.high_mark)))
+ (iwl_queue_space_used(&txq->q) < atomic_read(&txq->q.high_mark)))
iwl_wake_queue(priv, txq);
}
if (qc && likely(sta_id != IWL_INVALID_STATION))
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index b2b841f..a84b4a7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -445,7 +445,7 @@ static void iwlagn_rx_reply_tx(struct iwl_priv *priv,
iwl_free_tfds_in_queue(priv, sta_id, tid, freed);
if (priv->mac80211_registered &&
- (iwl_queue_space(&txq->q) > atomic_read(&txq->q.high_mark)) &&
+ (iwl_queue_space_used(&txq->q) < atomic_read(&txq->q.high_mark)) &&
(agg->state != IWL_EMPTYING_HW_QUEUE_DELBA))
iwl_wake_queue(priv, txq);
}
@@ -455,7 +455,7 @@ static void iwlagn_rx_reply_tx(struct iwl_priv *priv,
iwl_free_tfds_in_queue(priv, sta_id, tid, freed);
if (priv->mac80211_registered &&
- (iwl_queue_space(&txq->q) > atomic_read(&txq->q.high_mark)))
+ (iwl_queue_space_used(&txq->q) < atomic_read(&txq->q.high_mark)))
iwl_wake_queue(priv, txq);
}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
index 0c808f0..921876d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
@@ -638,7 +638,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
txq = &priv->txq[txq_id];
q = &txq->q;
- if (unlikely(iwl_queue_space(q) <= atomic_read(&q->high_mark))) {
+ if (unlikely(iwl_queue_space_used(q) >= atomic_read(&q->high_mark))) {
spin_unlock(&priv->sta_lock);
goto drop_unlock;
}
@@ -789,7 +789,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
if (sta_priv && sta_priv->client && !is_agg)
atomic_inc(&sta_priv->pending_frames);
- if ((iwl_queue_space(q) <= atomic_read(&q->high_mark))
+ if ((iwl_queue_space_used(q) >= atomic_read(&q->high_mark))
&& priv->mac80211_registered) {
if (wait_write_ptr) {
spin_lock_irqsave(&priv->lock, flags);
@@ -1433,7 +1433,7 @@ void iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
int freed = iwlagn_tx_queue_reclaim(priv, scd_flow, index);
iwl_free_tfds_in_queue(priv, sta_id, tid, freed);
- if ((iwl_queue_space(&txq->q) > atomic_read(&txq->q.high_mark)) &&
+ if ((iwl_queue_space_used(&txq->q) < atomic_read(&txq->q.high_mark)) &&
priv->mac80211_registered &&
(agg->state != IWL_EMPTYING_HW_QUEUE_DELBA))
iwl_wake_queue(priv, txq);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index cf9807c..dc6dd5f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -135,8 +135,8 @@ struct iwl_queue {
dma_addr_t dma_addr; /* physical addr for BD's */
int n_window; /* safe queue window */
u32 id;
- atomic_t high_mark; /* high watermark, stop queue if free
- * space less than or equal to this */
+ atomic_t high_mark; /* high watermark -- don't queue more than this
+ * many entries */
};
/* One for each TFD */
@@ -729,7 +729,7 @@ extern void iwl_update_chain_flags(struct iwl_priv *priv);
extern const u8 iwl_bcast_addr[ETH_ALEN];
extern int iwl_rxq_stop(struct iwl_priv *priv);
extern void iwl_txq_ctx_stop(struct iwl_priv *priv);
-extern int iwl_queue_space(const struct iwl_queue *q);
+extern int iwl_queue_space_used(const struct iwl_queue *q);
static inline int iwl_queue_used(const struct iwl_queue *q, int i)
{
return q->write_ptr >= q->read_ptr ?
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 1867f99..ce62981 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -219,7 +219,7 @@ EXPORT_SYMBOL(iwl_cmd_queue_free);
* See more detailed info in iwl-4965-hw.h.
***************************************************/
-int iwl_queue_space(const struct iwl_queue *q)
+static int iwl_queue_space_free(const struct iwl_queue *q)
{
int s = q->read_ptr - q->write_ptr;
@@ -234,8 +234,15 @@ int iwl_queue_space(const struct iwl_queue *q)
s = 0;
return s;
}
-EXPORT_SYMBOL(iwl_queue_space);
+int iwl_queue_space_used(const struct iwl_queue *q)
+{
+ int s = q->write_ptr - q->read_ptr;
+ if (s < 0)
+ s += q->n_bd;
+ return s;
+}
+EXPORT_SYMBOL(iwl_queue_space_used);
/**
* iwl_queue_init - Initialize queue's high-water and read/write indexes
@@ -255,9 +262,9 @@ static int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q,
* get_cmd_index is broken. */
BUG_ON(!is_power_of_2(slots_num));
- atomic_set(&q->high_mark, q->n_window / 8);
- if (atomic_read(&q->high_mark) < 2)
- atomic_set(&q->high_mark, 2);
+ atomic_set(&q->high_mark, q->n_window - q->n_window / 8);
+ if (q->n_window - atomic_read(&q->high_mark) < 2)
+ atomic_set(&q->high_mark, q->n_window - 2);
q->write_ptr = q->read_ptr = 0;
@@ -445,7 +452,7 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
return -EIO;
}
- if (iwl_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) {
+ if (iwl_queue_space_free(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) {
IWL_ERR(priv, "No space in command queue\n");
if (priv->cfg->ops->lib->tt_ops.ct_kill_check) {
is_ct_kill =
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index b3f8f3e..d0aa01c 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -537,7 +537,7 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
txq = &priv->txq[txq_id];
q = &txq->q;
- if ((iwl_queue_space(q) <= atomic_read(&q->high_mark)))
+ if ((iwl_queue_space_used(q) >= atomic_read(&q->high_mark)))
goto drop;
spin_lock_irqsave(&priv->lock, flags);
@@ -647,7 +647,7 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
iwl_txq_update_write_ptr(priv, txq);
spin_unlock_irqrestore(&priv->lock, flags);
- if ((iwl_queue_space(q) <= atomic_read(&q->high_mark))
+ if ((iwl_queue_space_used(q) >= atomic_read(&q->high_mark))
&& priv->mac80211_registered) {
if (wait_write_ptr) {
spin_lock_irqsave(&priv->lock, flags);
--
1.7.1
next prev parent reply other threads:[~2011-02-13 17:57 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-13 17:56 [PATCH 0/5] iwlwifi: Auto-tune tx queue size to maintain latency under load Nathaniel J. Smith
2011-02-13 17:56 ` [PATCH 1/5] iwlwifi: Simplify tx queue management Nathaniel J. Smith
2011-02-14 9:57 ` Johannes Berg
2011-02-14 22:17 ` Nathaniel Smith
2011-02-14 22:45 ` wwguy
2011-02-15 0:15 ` Dave Täht
2011-02-16 9:16 ` Stanislaw Gruszka
2011-02-16 14:41 ` John W. Linville
2011-02-16 15:13 ` wwguy
2011-02-15 12:11 ` Johannes Berg
2011-02-14 15:33 ` wwguy
2011-02-13 17:56 ` [PATCH 2/5] iwlwifi: Convert the tx queue high_mark to an atomic_t Nathaniel J. Smith
2011-02-14 12:16 ` Johannes Berg
2011-02-14 22:35 ` Nathaniel Smith
2011-02-15 12:08 ` Johannes Berg
2011-02-15 17:37 ` Nathaniel Smith
2011-02-13 17:56 ` Nathaniel J. Smith [this message]
2011-02-13 17:56 ` [PATCH 4/5] iwlwifi: auto-tune tx queue size to minimize latency Nathaniel J. Smith
2011-02-14 12:17 ` Johannes Berg
2011-02-14 21:58 ` Nathaniel Smith
2011-02-15 12:13 ` Johannes Berg
2011-02-15 15:03 ` John W. Linville
2011-02-16 8:59 ` Johannes Berg
2011-02-15 17:31 ` Nathaniel Smith
2011-02-14 15:46 ` wwguy
2011-02-13 17:56 ` [PATCH 5/5] iwlwifi: make current tx queue sizes visible in debugfs Nathaniel J. Smith
2011-02-14 0:32 ` [PATCH 0/5] iwlwifi: Auto-tune tx queue size to maintain latency under load Julian Calaby
2011-02-14 3:28 ` Nathaniel Smith
2011-02-16 15:50 ` John W. Linville
2011-02-16 23:08 ` Nathaniel Smith
2011-02-16 23:42 ` wwguy
2011-02-17 1:49 ` [RFC] mac80211: implement eBDP algorithm to fight bufferbloat John W. Linville
2011-02-17 3:31 ` Ben Greear
2011-02-17 4:26 ` Nathaniel Smith
2011-02-17 8:31 ` Johannes Berg
2011-02-18 21:21 ` [RFC v2] " John W. Linville
2011-02-19 3:44 ` Nathaniel Smith
2011-02-21 18:47 ` John W. Linville
2011-02-21 23:26 ` Nathaniel Smith
2011-02-23 22:28 ` John W. Linville
2011-02-25 18:21 ` Nathaniel Smith
2011-02-25 18:27 ` Nathaniel Smith
2011-02-20 0:37 ` Nathaniel Smith
2011-02-21 18:52 ` John W. Linville
2011-02-21 15:28 ` Johannes Berg
2011-02-21 19:06 ` John W. Linville
2011-02-21 20:26 ` Tianji Li
2011-02-28 13:07 ` Johannes Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1297619803-2832-4-git-send-email-njs@pobox.com \
--to=njs@pobox.com \
--cc=ilw@linux.intel.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=wey-yi.w.guy@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).