From 09201b7190726c270fb38910811c2923e71efe78 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Fri, 12 Feb 2010 06:58:02 +0000 Subject: [PATCH] --- yaml --- r: 184035 b: refs/heads/master c: 39ef110ba859f44efeb9a88d0e85316cd1bbecda h: refs/heads/master i: 184033: e28a1adcd895b9b2ebd79a6763bb7cdf4994d6a1 184031: 7a0dece87ead925880f6e90ef76772951f998c9e v: v3 --- [refs] | 2 +- trunk/drivers/net/sky2.c | 57 ++++++++++++++++++++++++++-------------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/[refs] b/[refs] index 88541cb653da..2119ea4c2c84 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 44dde56d37787cbad2e867a41fe87d6b0aa37fc8 +refs/heads/master: 39ef110ba859f44efeb9a88d0e85316cd1bbecda diff --git a/trunk/drivers/net/sky2.c b/trunk/drivers/net/sky2.c index 8a87e16e732f..c5de65c6f6e1 100644 --- a/trunk/drivers/net/sky2.c +++ b/trunk/drivers/net/sky2.c @@ -1049,6 +1049,40 @@ static inline struct sky2_rx_le *sky2_next_rx(struct sky2_port *sky2) return le; } +static unsigned sky2_get_rx_threshold(struct sky2_port* sky2) +{ + unsigned size; + + /* Space needed for frame data + headers rounded up */ + size = roundup(sky2->netdev->mtu + ETH_HLEN + VLAN_HLEN, 8); + + /* Stopping point for hardware truncation */ + return (size - 8) / sizeof(u32); +} + +static unsigned sky2_get_rx_data_size(struct sky2_port* sky2) +{ + struct rx_ring_info *re; + unsigned size; + + /* Space needed for frame data + headers rounded up */ + size = roundup(sky2->netdev->mtu + ETH_HLEN + VLAN_HLEN, 8); + + sky2->rx_nfrags = size >> PAGE_SHIFT; + BUG_ON(sky2->rx_nfrags > ARRAY_SIZE(re->frag_addr)); + + /* Compute residue after pages */ + size -= sky2->rx_nfrags << PAGE_SHIFT; + + /* Optimize to handle small packets and headers */ + if (size < copybreak) + size = copybreak; + if (size < ETH_HLEN) + size = ETH_HLEN; + + return size; +} + /* Build description to hardware for one receive segment */ static void sky2_rx_add(struct sky2_port *sky2, u8 op, dma_addr_t map, unsigned len) @@ -1343,7 +1377,7 @@ static int sky2_rx_start(struct sky2_port *sky2) struct sky2_hw *hw = sky2->hw; struct rx_ring_info *re; unsigned rxq = rxqaddr[sky2->port]; - unsigned i, size, thresh; + unsigned i, thresh; sky2->rx_put = sky2->rx_next = 0; sky2_qset(hw, rxq); @@ -1364,25 +1398,7 @@ static int sky2_rx_start(struct sky2_port *sky2) if (!(hw->flags & SKY2_HW_NEW_LE)) rx_set_checksum(sky2); - /* Space needed for frame data + headers rounded up */ - size = roundup(sky2->netdev->mtu + ETH_HLEN + VLAN_HLEN, 8); - - /* Stopping point for hardware truncation */ - thresh = (size - 8) / sizeof(u32); - - sky2->rx_nfrags = size >> PAGE_SHIFT; - BUG_ON(sky2->rx_nfrags > ARRAY_SIZE(re->frag_addr)); - - /* Compute residue after pages */ - size -= sky2->rx_nfrags << PAGE_SHIFT; - - /* Optimize to handle small packets and headers */ - if (size < copybreak) - size = copybreak; - if (size < ETH_HLEN) - size = ETH_HLEN; - - sky2->rx_data_size = size; + sky2->rx_data_size = sky2_get_rx_data_size(sky2); /* Fill Rx ring */ for (i = 0; i < sky2->rx_pending; i++) { @@ -1407,6 +1423,7 @@ static int sky2_rx_start(struct sky2_port *sky2) * the register is limited to 9 bits, so if you do frames > 2052 * you better get the MTU right! */ + thresh = sky2_get_rx_threshold(sky2); if (thresh > 0x1ff) sky2_write32(hw, SK_REG(sky2->port, RX_GMF_CTRL_T), RX_TRUNC_OFF); else {