* [PATCH 2/8][BNX2]: Restructure RX fast path handling.
@ 2007-12-12 18:58 Michael Chan
2007-12-12 19:17 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Michael Chan @ 2007-12-12 18:58 UTC (permalink / raw)
To: davem, netdev
[BNX2]: Restructure RX fast path handling.
Add a new function to handle new SKB allocation and to prepare the
completed SKB. This makes it easier to add support for non-linear
SKB.
Signed-off-by: Michael Chan <mchan@broadcom.com>
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index dfe50c2..14119fb 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -2379,6 +2379,27 @@ bnx2_reuse_rx_skb(struct bnx2 *bp, struct sk_buff *skb,
prod_bd->rx_bd_haddr_lo = cons_bd->rx_bd_haddr_lo;
}
+static int
+bnx2_rx_skb(struct bnx2 *bp, struct sk_buff *skb, unsigned int len,
+ dma_addr_t dma_addr, u32 ring_idx)
+{
+ int err;
+ u16 prod = ring_idx & 0xffff;
+
+ err = bnx2_alloc_rx_skb(bp, prod);
+ if (unlikely(err)) {
+ bnx2_reuse_rx_skb(bp, skb, (u16) (ring_idx >> 16), prod);
+ return err;
+ }
+
+ skb_reserve(skb, bp->rx_offset);
+ pci_unmap_single(bp->pdev, dma_addr, bp->rx_buf_use_size,
+ PCI_DMA_FROMDEVICE);
+
+ skb_put(skb, len);
+ return 0;
+}
+
static inline u16
bnx2_get_hw_rx_cons(struct bnx2 *bp)
{
@@ -2434,7 +2455,8 @@ bnx2_rx_int(struct bnx2 *bp, int budget)
L2_FHDR_ERRORS_TOO_SHORT |
L2_FHDR_ERRORS_GIANT_FRAME)) {
- goto reuse_rx;
+ bnx2_reuse_rx_skb(bp, skb, sw_ring_cons, sw_ring_prod);
+ goto next_rx;
}
/* Since we don't have a jumbo ring, copy small packets
@@ -2444,8 +2466,11 @@ bnx2_rx_int(struct bnx2 *bp, int budget)
struct sk_buff *new_skb;
new_skb = netdev_alloc_skb(bp->dev, len + 2);
- if (new_skb == NULL)
- goto reuse_rx;
+ if (new_skb == NULL) {
+ bnx2_reuse_rx_skb(bp, skb, sw_ring_cons,
+ sw_ring_prod);
+ goto next_rx;
+ }
/* aligned copy */
skb_copy_from_linear_data_offset(skb, bp->rx_offset - 2,
@@ -2457,20 +2482,9 @@ bnx2_rx_int(struct bnx2 *bp, int budget)
sw_ring_cons, sw_ring_prod);
skb = new_skb;
- }
- else if (bnx2_alloc_rx_skb(bp, sw_ring_prod) == 0) {
- pci_unmap_single(bp->pdev, dma_addr,
- bp->rx_buf_use_size, PCI_DMA_FROMDEVICE);
-
- skb_reserve(skb, bp->rx_offset);
- skb_put(skb, len);
- }
- else {
-reuse_rx:
- bnx2_reuse_rx_skb(bp, skb,
- sw_ring_cons, sw_ring_prod);
+ } else if (unlikely(bnx2_rx_skb(bp, skb, len, dma_addr,
+ (sw_ring_cons << 16) | sw_ring_prod)))
goto next_rx;
- }
skb->protocol = eth_type_trans(skb, bp->dev);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/8][BNX2]: Restructure RX fast path handling.
2007-12-12 18:58 [PATCH 2/8][BNX2]: Restructure RX fast path handling Michael Chan
@ 2007-12-12 19:17 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2007-12-12 19:17 UTC (permalink / raw)
To: mchan; +Cc: netdev
From: "Michael Chan" <mchan@broadcom.com>
Date: Wed, 12 Dec 2007 10:58:43 -0800
> [BNX2]: Restructure RX fast path handling.
>
> Add a new function to handle new SKB allocation and to prepare the
> completed SKB. This makes it easier to add support for non-linear
> SKB.
>
> Signed-off-by: Michael Chan <mchan@broadcom.com>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-12-12 19:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-12 18:58 [PATCH 2/8][BNX2]: Restructure RX fast path handling Michael Chan
2007-12-12 19:17 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).