Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 150104
b: refs/heads/master
c: 7fd96ce
h: refs/heads/master
v: v3
  • Loading branch information
Lennert Buytenhek authored and David S. Miller committed May 6, 2009
1 parent 6c86656 commit af39df7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: becfad979d1875aca15ef2a1eda68782e7ac7769
refs/heads/master: 7fd96ce47ff83fc17ab78d465d8e067467a7f51e
21 changes: 13 additions & 8 deletions trunk/drivers/net/mv643xx_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ static char mv643xx_eth_driver_version[] = "1.4";
*/
#define DEFAULT_RX_QUEUE_SIZE 128
#define DEFAULT_TX_QUEUE_SIZE 256
#define SKB_DMA_REALIGN ((PAGE_SIZE - NET_SKB_PAD) % SMP_CACHE_BYTES)


/*
Expand Down Expand Up @@ -649,23 +650,20 @@ static int rxq_refill(struct rx_queue *rxq, int budget)
refilled = 0;
while (refilled < budget && rxq->rx_desc_count < rxq->rx_ring_size) {
struct sk_buff *skb;
int unaligned;
int rx;
struct rx_desc *rx_desc;

skb = __skb_dequeue(&mp->rx_recycle);
if (skb == NULL)
skb = dev_alloc_skb(mp->skb_size +
dma_get_cache_alignment() - 1);
skb = dev_alloc_skb(mp->skb_size);

if (skb == NULL) {
mp->oom = 1;
goto oom;
}

unaligned = (u32)skb->data & (dma_get_cache_alignment() - 1);
if (unaligned)
skb_reserve(skb, dma_get_cache_alignment() - unaligned);
if (SKB_DMA_REALIGN)
skb_reserve(skb, SKB_DMA_REALIGN);

refilled++;
rxq->rx_desc_count++;
Expand Down Expand Up @@ -964,8 +962,7 @@ static int txq_reclaim(struct tx_queue *txq, int budget, int force)
if (skb != NULL) {
if (skb_queue_len(&mp->rx_recycle) <
mp->rx_ring_size &&
skb_recycle_check(skb, mp->skb_size +
dma_get_cache_alignment() - 1))
skb_recycle_check(skb, mp->skb_size))
__skb_queue_head(&mp->rx_recycle, skb);
else
dev_kfree_skb(skb);
Expand Down Expand Up @@ -2336,6 +2333,14 @@ static void mv643xx_eth_recalc_skb_size(struct mv643xx_eth_private *mp)
* size field are ignored by the hardware.
*/
mp->skb_size = (skb_size + 7) & ~7;

/*
* If NET_SKB_PAD is smaller than a cache line,
* netdev_alloc_skb() will cause skb->data to be misaligned
* to a cache line boundary. If this is the case, include
* some extra space to allow re-aligning the data area.
*/
mp->skb_size += SKB_DMA_REALIGN;
}

static int mv643xx_eth_open(struct net_device *dev)
Expand Down

0 comments on commit af39df7

Please sign in to comment.