Commit 22e11703 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by Jeff Garzik

[PATCH] sky2: optimize receive restart

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: default avatarStephen Hemminger <shemminger@osdl.org>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent afa195da
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
#define RX_MAX_PENDING (RX_LE_SIZE/2 - 2) #define RX_MAX_PENDING (RX_LE_SIZE/2 - 2)
#define RX_DEF_PENDING RX_MAX_PENDING #define RX_DEF_PENDING RX_MAX_PENDING
#define RX_SKB_ALIGN 8 #define RX_SKB_ALIGN 8
#define RX_BUF_WRITE 16
#define TX_RING_SIZE 512 #define TX_RING_SIZE 512
#define TX_DEF_PENDING (TX_RING_SIZE - 1) #define TX_DEF_PENDING (TX_RING_SIZE - 1)
...@@ -1390,7 +1391,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) ...@@ -1390,7 +1391,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
} }
sky2->tx_cons = put; 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); netif_wake_queue(dev);
} }
...@@ -1889,9 +1890,6 @@ resubmit: ...@@ -1889,9 +1890,6 @@ resubmit:
re->skb->ip_summed = CHECKSUM_NONE; re->skb->ip_summed = CHECKSUM_NONE;
sky2_rx_add(sky2, re->mapaddr); sky2_rx_add(sky2, re->mapaddr);
/* Tell receiver about new buffers. */
sky2_put_idx(sky2->hw, rxqaddr[sky2->port], sky2->rx_put);
return skb; return skb;
oversize: oversize:
...@@ -1938,7 +1936,9 @@ static inline int sky2_more_work(const struct sky2_hw *hw) ...@@ -1938,7 +1936,9 @@ static inline int sky2_more_work(const struct sky2_hw *hw)
/* Process status response ring */ /* Process status response ring */
static int sky2_status_intr(struct sky2_hw *hw, int to_do) static int sky2_status_intr(struct sky2_hw *hw, int to_do)
{ {
struct sky2_port *sky2;
int work_done = 0; int work_done = 0;
unsigned buf_write[2] = { 0, 0 };
u16 hwidx = sky2_read16(hw, STAT_PUT_IDX); u16 hwidx = sky2_read16(hw, STAT_PUT_IDX);
rmb(); rmb();
...@@ -1946,7 +1946,6 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do) ...@@ -1946,7 +1946,6 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
while (hw->st_idx != hwidx) { while (hw->st_idx != hwidx) {
struct sky2_status_le *le = hw->st_le + hw->st_idx; struct sky2_status_le *le = hw->st_le + hw->st_idx;
struct net_device *dev; struct net_device *dev;
struct sky2_port *sky2;
struct sk_buff *skb; struct sk_buff *skb;
u32 status; u32 status;
u16 length; u16 length;
...@@ -1979,6 +1978,14 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do) ...@@ -1979,6 +1978,14 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
#endif #endif
netif_receive_skb(skb); 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) if (++work_done >= to_do)
goto exit_loop; goto exit_loop;
break; break;
...@@ -2017,6 +2024,16 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do) ...@@ -2017,6 +2024,16 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
} }
exit_loop: 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; return work_done;
} }
......
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