Commit 0d63fb32 authored by Ayaz Abdulla's avatar Ayaz Abdulla Committed by Jeff Garzik

forcedeth: rx skb recycle

This patch removes the code that recycled the skb on error. This will
help in reducing the branches in the main data paths.
Signed-Off-By: default avatarAyaz Abdulla <aabdulla@nvidia.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 164a86e4
...@@ -1330,17 +1330,10 @@ static int nv_alloc_rx(struct net_device *dev) ...@@ -1330,17 +1330,10 @@ static int nv_alloc_rx(struct net_device *dev)
break; break;
} }
if (np->put_rx_ctx->skb == NULL) {
skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD); skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
if (!skb) if (skb) {
return 1;
skb->dev = dev; skb->dev = dev;
np->put_rx_ctx->skb = skb; np->put_rx_ctx->skb = skb;
} else {
skb = np->put_rx_ctx->skb;
}
np->put_rx_ctx->dma = pci_map_single(np->pci_dev, skb->data, np->put_rx_ctx->dma = pci_map_single(np->pci_dev, skb->data,
skb->end-skb->data, PCI_DMA_FROMDEVICE); skb->end-skb->data, PCI_DMA_FROMDEVICE);
np->put_rx_ctx->dma_len = skb->end-skb->data; np->put_rx_ctx->dma_len = skb->end-skb->data;
...@@ -1360,6 +1353,9 @@ static int nv_alloc_rx(struct net_device *dev) ...@@ -1360,6 +1353,9 @@ static int nv_alloc_rx(struct net_device *dev)
} }
if (np->put_rx_ctx++ == np->last_rx_ctx) if (np->put_rx_ctx++ == np->last_rx_ctx)
np->put_rx_ctx = np->first_rx_ctx; np->put_rx_ctx = np->first_rx_ctx;
} else {
return 1;
}
} }
return 0; return 0;
} }
...@@ -1948,6 +1944,8 @@ static int nv_rx_process(struct net_device *dev, int limit) ...@@ -1948,6 +1944,8 @@ static int nv_rx_process(struct net_device *dev, int limit)
pci_unmap_single(np->pci_dev, np->get_rx_ctx->dma, pci_unmap_single(np->pci_dev, np->get_rx_ctx->dma,
np->get_rx_ctx->dma_len, np->get_rx_ctx->dma_len,
PCI_DMA_FROMDEVICE); PCI_DMA_FROMDEVICE);
skb = np->get_rx_ctx->skb;
np->get_rx_ctx->skb = NULL;
{ {
int j; int j;
...@@ -1955,39 +1953,46 @@ static int nv_rx_process(struct net_device *dev, int limit) ...@@ -1955,39 +1953,46 @@ static int nv_rx_process(struct net_device *dev, int limit)
for (j=0; j<64; j++) { for (j=0; j<64; j++) {
if ((j%16) == 0) if ((j%16) == 0)
dprintk("\n%03x:", j); dprintk("\n%03x:", j);
dprintk(" %02x", ((unsigned char*)np->get_rx_ctx->skb->data)[j]); dprintk(" %02x", ((unsigned char*)skb->data)[j]);
} }
dprintk("\n"); dprintk("\n");
} }
/* look at what we actually got: */ /* look at what we actually got: */
if (np->desc_ver == DESC_VER_1) { if (np->desc_ver == DESC_VER_1) {
if (!(flags & NV_RX_DESCRIPTORVALID)) if (!(flags & NV_RX_DESCRIPTORVALID)) {
dev_kfree_skb(skb);
goto next_pkt; goto next_pkt;
}
if (flags & NV_RX_ERROR) { if (flags & NV_RX_ERROR) {
if (flags & NV_RX_MISSEDFRAME) { if (flags & NV_RX_MISSEDFRAME) {
np->stats.rx_missed_errors++; np->stats.rx_missed_errors++;
np->stats.rx_errors++; np->stats.rx_errors++;
dev_kfree_skb(skb);
goto next_pkt; goto next_pkt;
} }
if (flags & (NV_RX_ERROR1|NV_RX_ERROR2|NV_RX_ERROR3)) { if (flags & (NV_RX_ERROR1|NV_RX_ERROR2|NV_RX_ERROR3)) {
np->stats.rx_errors++; np->stats.rx_errors++;
dev_kfree_skb(skb);
goto next_pkt; goto next_pkt;
} }
if (flags & NV_RX_CRCERR) { if (flags & NV_RX_CRCERR) {
np->stats.rx_crc_errors++; np->stats.rx_crc_errors++;
np->stats.rx_errors++; np->stats.rx_errors++;
dev_kfree_skb(skb);
goto next_pkt; goto next_pkt;
} }
if (flags & NV_RX_OVERFLOW) { if (flags & NV_RX_OVERFLOW) {
np->stats.rx_over_errors++; np->stats.rx_over_errors++;
np->stats.rx_errors++; np->stats.rx_errors++;
dev_kfree_skb(skb);
goto next_pkt; goto next_pkt;
} }
if (flags & NV_RX_ERROR4) { if (flags & NV_RX_ERROR4) {
len = nv_getlen(dev, np->get_rx_ctx->skb->data, len); len = nv_getlen(dev, skb->data, len);
if (len < 0) { if (len < 0) {
np->stats.rx_errors++; np->stats.rx_errors++;
dev_kfree_skb(skb);
goto next_pkt; goto next_pkt;
} }
} }
...@@ -1999,28 +2004,34 @@ static int nv_rx_process(struct net_device *dev, int limit) ...@@ -1999,28 +2004,34 @@ static int nv_rx_process(struct net_device *dev, int limit)
} }
} }
} else { } else {
if (!(flags & NV_RX2_DESCRIPTORVALID)) if (!(flags & NV_RX2_DESCRIPTORVALID)) {
dev_kfree_skb(skb);
goto next_pkt; goto next_pkt;
}
if (flags & NV_RX2_ERROR) { if (flags & NV_RX2_ERROR) {
if (flags & (NV_RX2_ERROR1|NV_RX2_ERROR2|NV_RX2_ERROR3)) { if (flags & (NV_RX2_ERROR1|NV_RX2_ERROR2|NV_RX2_ERROR3)) {
np->stats.rx_errors++; np->stats.rx_errors++;
dev_kfree_skb(skb);
goto next_pkt; goto next_pkt;
} }
if (flags & NV_RX2_CRCERR) { if (flags & NV_RX2_CRCERR) {
np->stats.rx_crc_errors++; np->stats.rx_crc_errors++;
np->stats.rx_errors++; np->stats.rx_errors++;
dev_kfree_skb(skb);
goto next_pkt; goto next_pkt;
} }
if (flags & NV_RX2_OVERFLOW) { if (flags & NV_RX2_OVERFLOW) {
np->stats.rx_over_errors++; np->stats.rx_over_errors++;
np->stats.rx_errors++; np->stats.rx_errors++;
dev_kfree_skb(skb);
goto next_pkt; goto next_pkt;
} }
if (flags & NV_RX2_ERROR4) { if (flags & NV_RX2_ERROR4) {
len = nv_getlen(dev, np->get_rx_ctx->skb->data, len); len = nv_getlen(dev, skb->data, len);
if (len < 0) { if (len < 0) {
np->stats.rx_errors++; np->stats.rx_errors++;
dev_kfree_skb(skb);
goto next_pkt; goto next_pkt;
} }
} }
...@@ -2037,16 +2048,13 @@ static int nv_rx_process(struct net_device *dev, int limit) ...@@ -2037,16 +2048,13 @@ static int nv_rx_process(struct net_device *dev, int limit)
flags == NV_RX2_CHECKSUMOK2 || flags == NV_RX2_CHECKSUMOK2 ||
flags == NV_RX2_CHECKSUMOK3) { flags == NV_RX2_CHECKSUMOK3) {
dprintk(KERN_DEBUG "%s: hw checksum hit!.\n", dev->name); dprintk(KERN_DEBUG "%s: hw checksum hit!.\n", dev->name);
np->get_rx_ctx->skb->ip_summed = CHECKSUM_UNNECESSARY; skb->ip_summed = CHECKSUM_UNNECESSARY;
} else { } else {
dprintk(KERN_DEBUG "%s: hwchecksum miss!.\n", dev->name); dprintk(KERN_DEBUG "%s: hwchecksum miss!.\n", dev->name);
} }
} }
} }
/* got a valid packet - forward it to the network core */ /* got a valid packet - forward it to the network core */
skb = np->get_rx_ctx->skb;
np->get_rx_ctx->skb = NULL;
skb_put(skb, len); skb_put(skb, len);
skb->protocol = eth_type_trans(skb, dev); skb->protocol = eth_type_trans(skb, dev);
dprintk(KERN_DEBUG "%s: nv_rx_process: %d bytes, proto %d accepted.\n", dprintk(KERN_DEBUG "%s: nv_rx_process: %d bytes, proto %d accepted.\n",
......
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