Commit b869767b authored by Ivo van Doorn's avatar Ivo van Doorn Committed by John W. Linville

rt2x00: Don't kick TX queue after each frame

TX queues shouldn't be kicked after each frame that is put into the
queue.  This could cause problems during RTS and CTS-to-self as well
as with fragmentation. In all those cases you want all frames to be
send out in a single burst. Off course we shouldn't let the queue fill
up entirely, thus we introduce a 10% threshold which, when reached,
will force the frames to be send out regardless of the frame.

In addition we should prevent queues to become full in such a way
that the tx() handler can fail. Instead of stopping the queue when
it is full, we should stop it when it is below the threshold.
Signed-off-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 6db3786a
...@@ -1507,7 +1507,6 @@ static int rt2400pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) ...@@ -1507,7 +1507,6 @@ static int rt2400pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
*/ */
skbdesc = get_skb_frame_desc(skb); skbdesc = get_skb_frame_desc(skb);
memset(skbdesc, 0, sizeof(*skbdesc)); memset(skbdesc, 0, sizeof(*skbdesc));
skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED;
skbdesc->data = skb->data; skbdesc->data = skb->data;
skbdesc->data_len = skb->len; skbdesc->data_len = skb->len;
skbdesc->desc = entry_priv->desc; skbdesc->desc = entry_priv->desc;
......
...@@ -1823,7 +1823,6 @@ static int rt2500pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) ...@@ -1823,7 +1823,6 @@ static int rt2500pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
*/ */
skbdesc = get_skb_frame_desc(skb); skbdesc = get_skb_frame_desc(skb);
memset(skbdesc, 0, sizeof(*skbdesc)); memset(skbdesc, 0, sizeof(*skbdesc));
skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED;
skbdesc->data = skb->data; skbdesc->data = skb->data;
skbdesc->data_len = skb->len; skbdesc->data_len = skb->len;
skbdesc->desc = entry_priv->desc; skbdesc->desc = entry_priv->desc;
......
...@@ -1711,7 +1711,6 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) ...@@ -1711,7 +1711,6 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
*/ */
skbdesc = get_skb_frame_desc(skb); skbdesc = get_skb_frame_desc(skb);
memset(skbdesc, 0, sizeof(*skbdesc)); memset(skbdesc, 0, sizeof(*skbdesc));
skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED;
skbdesc->data = skb->data + intf->beacon->queue->desc_size; skbdesc->data = skb->data + intf->beacon->queue->desc_size;
skbdesc->data_len = skb->len - intf->beacon->queue->desc_size; skbdesc->data_len = skb->len - intf->beacon->queue->desc_size;
skbdesc->desc = skb->data; skbdesc->desc = skb->data;
......
...@@ -826,7 +826,7 @@ struct rt2x00_dev { ...@@ -826,7 +826,7 @@ struct rt2x00_dev {
* The Beacon array also contains the Atim queue * The Beacon array also contains the Atim queue
* if that is supported by the device. * if that is supported by the device.
*/ */
int data_queues; unsigned int data_queues;
struct data_queue *rx; struct data_queue *rx;
struct data_queue *tx; struct data_queue *tx;
struct data_queue *bcn; struct data_queue *bcn;
......
...@@ -34,7 +34,6 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev, ...@@ -34,7 +34,6 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev,
struct sk_buff *frag_skb) struct sk_buff *frag_skb)
{ {
struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(frag_skb); struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(frag_skb);
struct skb_frame_desc *skbdesc;
struct ieee80211_tx_info *rts_info; struct ieee80211_tx_info *rts_info;
struct sk_buff *skb; struct sk_buff *skb;
int size; int size;
...@@ -82,13 +81,6 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev, ...@@ -82,13 +81,6 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev,
frag_skb->data, size, tx_info, frag_skb->data, size, tx_info,
(struct ieee80211_rts *)(skb->data)); (struct ieee80211_rts *)(skb->data));
/*
* Initialize skb descriptor
*/
skbdesc = get_skb_frame_desc(skb);
memset(skbdesc, 0, sizeof(*skbdesc));
skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED;
if (rt2x00queue_write_tx_frame(queue, skb)) { if (rt2x00queue_write_tx_frame(queue, skb)) {
WARNING(rt2x00dev, "Failed to send RTS/CTS frame.\n"); WARNING(rt2x00dev, "Failed to send RTS/CTS frame.\n");
return NETDEV_TX_BUSY; return NETDEV_TX_BUSY;
...@@ -163,7 +155,7 @@ int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) ...@@ -163,7 +155,7 @@ int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
return NETDEV_TX_BUSY; return NETDEV_TX_BUSY;
} }
if (rt2x00queue_full(queue)) if (rt2x00queue_threshold(queue))
ieee80211_stop_queue(rt2x00dev->hw, qid); ieee80211_stop_queue(rt2x00dev->hw, qid);
return NETDEV_TX_OK; return NETDEV_TX_OK;
......
...@@ -170,11 +170,11 @@ void rt2x00pci_txdone(struct rt2x00_dev *rt2x00dev, struct queue_entry *entry, ...@@ -170,11 +170,11 @@ void rt2x00pci_txdone(struct rt2x00_dev *rt2x00dev, struct queue_entry *entry,
rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE); rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE);
/* /*
* If the data queue was full before the txdone handler * If the data queue was below the threshold before the txdone
* we must make sure the packet queue in the mac80211 stack * handler we must make sure the packet queue in the mac80211 stack
* is reenabled when the txdone handler has finished. * is reenabled when the txdone handler has finished.
*/ */
if (!rt2x00queue_full(entry->queue)) if (!rt2x00queue_threshold(entry->queue))
ieee80211_wake_queue(rt2x00dev->hw, qid); ieee80211_wake_queue(rt2x00dev->hw, qid);
} }
......
...@@ -163,8 +163,8 @@ EXPORT_SYMBOL_GPL(rt2x00queue_create_tx_descriptor); ...@@ -163,8 +163,8 @@ EXPORT_SYMBOL_GPL(rt2x00queue_create_tx_descriptor);
void rt2x00queue_write_tx_descriptor(struct queue_entry *entry, void rt2x00queue_write_tx_descriptor(struct queue_entry *entry,
struct txentry_desc *txdesc) struct txentry_desc *txdesc)
{ {
struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; struct data_queue *queue = entry->queue;
struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
rt2x00dev->ops->lib->write_tx_desc(rt2x00dev, entry->skb, txdesc); rt2x00dev->ops->lib->write_tx_desc(rt2x00dev, entry->skb, txdesc);
...@@ -175,16 +175,21 @@ void rt2x00queue_write_tx_descriptor(struct queue_entry *entry, ...@@ -175,16 +175,21 @@ void rt2x00queue_write_tx_descriptor(struct queue_entry *entry,
rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_TX, entry->skb); rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_TX, entry->skb);
/* /*
* We are done writing the frame to the queue entry, * Check if we need to kick the queue, there are however a few rules
* also kick the queue in case the correct flags are set, * 1) Don't kick beacon queue
* note that this will automatically filter beacons and * 2) Don't kick unless this is the last in frame in a burst.
* RTS/CTS frames since those frames don't have this flag * When the burst flag is set, this frame is always followed
* set. * by another frame which in some way are related to eachother.
* This is true for fragments, RTS or CTS-to-self frames.
* 3) Rule 2 can be broken when the available entries
* in the queue are less then a certain threshold.
*/ */
if (rt2x00dev->ops->lib->kick_tx_queue && if (entry->queue->qid == QID_BEACON)
!(skbdesc->flags & FRAME_DESC_DRIVER_GENERATED)) return;
rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev,
entry->queue->qid); if (rt2x00queue_threshold(queue) ||
!test_bit(ENTRY_TXD_BURST, &txdesc->flags))
rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, queue->qid);
} }
EXPORT_SYMBOL_GPL(rt2x00queue_write_tx_descriptor); EXPORT_SYMBOL_GPL(rt2x00queue_write_tx_descriptor);
...@@ -349,6 +354,7 @@ static int rt2x00queue_alloc_entries(struct data_queue *queue, ...@@ -349,6 +354,7 @@ static int rt2x00queue_alloc_entries(struct data_queue *queue,
rt2x00queue_reset(queue); rt2x00queue_reset(queue);
queue->limit = qdesc->entry_num; queue->limit = qdesc->entry_num;
queue->threshold = DIV_ROUND_UP(qdesc->entry_num, 10);
queue->data_size = qdesc->data_size; queue->data_size = qdesc->data_size;
queue->desc_size = qdesc->desc_size; queue->desc_size = qdesc->desc_size;
......
...@@ -82,12 +82,10 @@ enum data_queue_qid { ...@@ -82,12 +82,10 @@ enum data_queue_qid {
/** /**
* enum skb_frame_desc_flags: Flags for &struct skb_frame_desc * enum skb_frame_desc_flags: Flags for &struct skb_frame_desc
* *
* @FRAME_DESC_DRIVER_GENERATED: Frame was generated inside driver
* and should not be reported back to mac80211 during txdone.
*/ */
enum skb_frame_desc_flags { //enum skb_frame_desc_flags {
FRAME_DESC_DRIVER_GENERATED = 1 << 0, // TEMPORARILY EMPTY
}; //};
/** /**
* struct skb_frame_desc: Descriptor information for the skb buffer * struct skb_frame_desc: Descriptor information for the skb buffer
...@@ -325,6 +323,7 @@ enum queue_index { ...@@ -325,6 +323,7 @@ enum queue_index {
* index corruption due to concurrency. * index corruption due to concurrency.
* @count: Number of frames handled in the queue. * @count: Number of frames handled in the queue.
* @limit: Maximum number of entries in the queue. * @limit: Maximum number of entries in the queue.
* @threshold: Minimum number of free entries before queue is kicked by force.
* @length: Number of frames in queue. * @length: Number of frames in queue.
* @index: Index pointers to entry positions in the queue, * @index: Index pointers to entry positions in the queue,
* use &enum queue_index to get a specific index field. * use &enum queue_index to get a specific index field.
...@@ -343,6 +342,7 @@ struct data_queue { ...@@ -343,6 +342,7 @@ struct data_queue {
spinlock_t lock; spinlock_t lock;
unsigned int count; unsigned int count;
unsigned short limit; unsigned short limit;
unsigned short threshold;
unsigned short length; unsigned short length;
unsigned short index[Q_INDEX_MAX]; unsigned short index[Q_INDEX_MAX];
...@@ -466,6 +466,15 @@ static inline int rt2x00queue_available(struct data_queue *queue) ...@@ -466,6 +466,15 @@ static inline int rt2x00queue_available(struct data_queue *queue)
return queue->limit - queue->length; return queue->limit - queue->length;
} }
/**
* rt2x00queue_threshold - Check if the queue is below threshold
* @queue: Queue to check.
*/
static inline int rt2x00queue_threshold(struct data_queue *queue)
{
return rt2x00queue_available(queue) < queue->threshold;
}
/** /**
* rt2x00_desc_read - Read a word from the hardware descriptor. * rt2x00_desc_read - Read a word from the hardware descriptor.
* @desc: Base descriptor address * @desc: Base descriptor address
......
...@@ -165,11 +165,11 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb) ...@@ -165,11 +165,11 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb)
rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE); rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE);
/* /*
* If the data queue was full before the txdone handler * If the data queue was below the threshold before the txdone
* we must make sure the packet queue in the mac80211 stack * handler we must make sure the packet queue in the mac80211 stack
* is reenabled when the txdone handler has finished. * is reenabled when the txdone handler has finished.
*/ */
if (!rt2x00queue_full(entry->queue)) if (!rt2x00queue_threshold(entry->queue))
ieee80211_wake_queue(rt2x00dev->hw, qid); ieee80211_wake_queue(rt2x00dev->hw, qid);
} }
......
...@@ -2375,7 +2375,6 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) ...@@ -2375,7 +2375,6 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
*/ */
skbdesc = get_skb_frame_desc(skb); skbdesc = get_skb_frame_desc(skb);
memset(skbdesc, 0, sizeof(*skbdesc)); memset(skbdesc, 0, sizeof(*skbdesc));
skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED;
skbdesc->data = skb->data; skbdesc->data = skb->data;
skbdesc->data_len = skb->len; skbdesc->data_len = skb->len;
skbdesc->desc = entry_priv->desc; skbdesc->desc = entry_priv->desc;
......
...@@ -1980,7 +1980,6 @@ static int rt73usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) ...@@ -1980,7 +1980,6 @@ static int rt73usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
*/ */
skbdesc = get_skb_frame_desc(skb); skbdesc = get_skb_frame_desc(skb);
memset(skbdesc, 0, sizeof(*skbdesc)); memset(skbdesc, 0, sizeof(*skbdesc));
skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED;
skbdesc->data = skb->data + intf->beacon->queue->desc_size; skbdesc->data = skb->data + intf->beacon->queue->desc_size;
skbdesc->data_len = skb->len - intf->beacon->queue->desc_size; skbdesc->data_len = skb->len - intf->beacon->queue->desc_size;
skbdesc->desc = skb->data; skbdesc->desc = skb->data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment