]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] sky2: optimize receive restart
authorStephen Hemminger <shemminger@osdl.org>
Wed, 12 Jul 2006 22:23:48 +0000 (15:23 -0700)
committerJeff Garzik <jeff@garzik.org>
Wed, 12 Jul 2006 22:39:22 +0000 (18:39 -0400)
When the driver handles multiple packets per NAPI poll, it is
better to reload the receive ring, then tell the hardware. Otherwise,
under packet storm with flow control, the driver/hardware will degrade
down to one packet getting through per pause-exchange.

Likewise on transmit, don't wakeup until a little more than minimum
ring space is available.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/sky2.c

index e65689ebe14749f6a568eaef32c680c69bcb00aa..d98f28c34e5cf1cdd23f6d6805ce430d8b5a72ae 100644 (file)
@@ -65,6 +65,7 @@
 #define RX_MAX_PENDING         (RX_LE_SIZE/2 - 2)
 #define RX_DEF_PENDING         RX_MAX_PENDING
 #define RX_SKB_ALIGN           8
+#define RX_BUF_WRITE           16
 
 #define TX_RING_SIZE           512
 #define TX_DEF_PENDING         (TX_RING_SIZE - 1)
@@ -1390,7 +1391,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
        }
 
        sky2->tx_cons = put;
-       if (tx_avail(sky2) > MAX_SKB_TX_LE)
+       if (tx_avail(sky2) > MAX_SKB_TX_LE + 4)
                netif_wake_queue(dev);
 }
 
@@ -1889,9 +1890,6 @@ resubmit:
        re->skb->ip_summed = CHECKSUM_NONE;
        sky2_rx_add(sky2, re->mapaddr);
 
-       /* Tell receiver about new buffers. */
-       sky2_put_idx(sky2->hw, rxqaddr[sky2->port], sky2->rx_put);
-
        return skb;
 
 oversize:
@@ -1938,7 +1936,9 @@ static inline int sky2_more_work(const struct sky2_hw *hw)
 /* Process status response ring */
 static int sky2_status_intr(struct sky2_hw *hw, int to_do)
 {
+       struct sky2_port *sky2;
        int work_done = 0;
+       unsigned buf_write[2] = { 0, 0 };
        u16 hwidx = sky2_read16(hw, STAT_PUT_IDX);
 
        rmb();
@@ -1946,7 +1946,6 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
        while (hw->st_idx != hwidx) {
                struct sky2_status_le *le  = hw->st_le + hw->st_idx;
                struct net_device *dev;
-               struct sky2_port *sky2;
                struct sk_buff *skb;
                u32 status;
                u16 length;
@@ -1979,6 +1978,14 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
 #endif
                                netif_receive_skb(skb);
 
+                       /* Update receiver after 16 frames */
+                       if (++buf_write[le->link] == RX_BUF_WRITE) {
+                               sky2_put_idx(hw, rxqaddr[le->link],
+                                            sky2->rx_put);
+                               buf_write[le->link] = 0;
+                       }
+
+                       /* Stop after net poll weight */
                        if (++work_done >= to_do)
                                goto exit_loop;
                        break;
@@ -2017,6 +2024,16 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
        }
 
 exit_loop:
+       if (buf_write[0]) {
+               sky2 = netdev_priv(hw->dev[0]);
+               sky2_put_idx(hw, Q_R1, sky2->rx_put);
+       }
+
+       if (buf_write[1]) {
+               sky2 = netdev_priv(hw->dev[1]);
+               sky2_put_idx(hw, Q_R2, sky2->rx_put);
+       }
+
        return work_done;
 }