wl12xx: fix tx_queue_count spurious increment
authorArik Nemtsov <arik@wizery.com>
Sun, 14 Aug 2011 10:17:39 +0000 (13:17 +0300)
committerLuciano Coelho <coelho@ti.com>
Mon, 22 Aug 2011 09:35:32 +0000 (12:35 +0300)
Only increment the queue count after actually queuing the skb. This
avoids a spurious increment is case of dropped packets.

Also move the Tx-watermark checking code after the packet is enqueued.
This makes the count more accurate - it includes the just-queued
packet.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
drivers/net/wireless/wl12xx/main.c

index b06ff0b25de15bfb107b64805c1ba64a18fb837d..82f4408e89ad278c575928d9266a5bb32305a044 100644 (file)
@@ -1485,18 +1485,6 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
 
        spin_lock_irqsave(&wl->wl_lock, flags);
 
-       wl->tx_queue_count[q]++;
-
-       /*
-        * The workqueue is slow to process the tx_queue and we need stop
-        * the queue here, otherwise the queue will get too long.
-        */
-       if (wl->tx_queue_count[q] >= WL1271_TX_QUEUE_HIGH_WATERMARK) {
-               wl1271_debug(DEBUG_TX, "op_tx: stopping queues for q %d", q);
-               ieee80211_stop_queue(wl->hw, mapping);
-               set_bit(q, &wl->stopped_queues_map);
-       }
-
        /* queue the packet */
        if (wl->bss_type == BSS_TYPE_AP_BSS) {
                if (!wl1271_is_active_sta(wl, hlid)) {
@@ -1512,6 +1500,18 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
                skb_queue_tail(&wl->tx_queue[q], skb);
        }
 
+       wl->tx_queue_count[q]++;
+
+       /*
+        * The workqueue is slow to process the tx_queue and we need stop
+        * the queue here, otherwise the queue will get too long.
+        */
+       if (wl->tx_queue_count[q] >= WL1271_TX_QUEUE_HIGH_WATERMARK) {
+               wl1271_debug(DEBUG_TX, "op_tx: stopping queues for q %d", q);
+               ieee80211_stop_queue(wl->hw, mapping);
+               set_bit(q, &wl->stopped_queues_map);
+       }
+
        /*
         * The chip specific setup must run before the first TX packet -
         * before that, the tx_work will not be initialized!