From: olof@lixom.net (Olof Johansson)
To: jgarzik@pobox.com
Cc: netdev@vger.kernel.org
Subject: [PATCH v3] [5/10] pasemi_mac: Add SKB reuse / copy-break
Date: Sat, 28 Apr 2007 15:37:28 -0500 [thread overview]
Message-ID: <20070428203728.GF4331@lixom.net> (raw)
In-Reply-To: <20070428203624.GA4331@lixom.net>
Add a copy-break and recycle the SKB in the driver for small packets.
Signed-off-by: Olof Johansson <olof@lixom.net>
Index: netdev-2.6/drivers/net/pasemi_mac.c
===================================================================
--- netdev-2.6.orig/drivers/net/pasemi_mac.c
+++ netdev-2.6/drivers/net/pasemi_mac.c
@@ -279,8 +279,8 @@ static void pasemi_mac_free_rx_resources
for (i = 0; i < RX_RING_SIZE; i++) {
info = &RX_DESC_INFO(mac, i);
dp = &RX_DESC(mac, i);
- if (info->dma) {
- if (info->skb) {
+ if (info->skb) {
+ if (info->dma) {
pci_unmap_single(mac->dma_pdev,
info->dma,
info->skb->len,
@@ -329,12 +329,14 @@ static void pasemi_mac_replenish_rx_ring
struct sk_buff *skb;
dma_addr_t dma;
- skb = dev_alloc_skb(BUF_SIZE);
+ /* skb might still be in there for recycle on short receives */
+ if (info->skb)
+ skb = info->skb;
+ else
+ skb = dev_alloc_skb(BUF_SIZE);
- if (!skb) {
- count = i - start;
+ if (unlikely(!skb))
break;
- }
dma = pci_map_single(mac->dma_pdev, skb->data, skb->len,
PCI_DMA_FROMDEVICE);
@@ -442,13 +444,28 @@ static int pasemi_mac_clean_rx(struct pa
BUG_ON(!info);
BUG_ON(info->dma != dma);
+ skb = info->skb;
pci_unmap_single(mac->dma_pdev, info->dma, info->skb->len,
PCI_DMA_FROMDEVICE);
+ info->dma = 0;
- skb = info->skb;
len = (dp->macrx & XCT_MACRX_LLEN_M) >> XCT_MACRX_LLEN_S;
+ if (len < 256) {
+ struct sk_buff *new_skb =
+ netdev_alloc_skb(mac->netdev, len + NET_IP_ALIGN);
+ if (new_skb) {
+ skb_reserve(new_skb, NET_IP_ALIGN);
+ memcpy(new_skb->data - NET_IP_ALIGN,
+ skb->data - NET_IP_ALIGN,
+ len + NET_IP_ALIGN);
+ /* save the skb in buffer_info as good */
+ skb = new_skb;
+ }
+ /* else just continue with the old one */
+ } else
+ info->skb = NULL;
skb_put(skb, len);
next prev parent reply other threads:[~2007-04-28 20:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-28 20:36 [PATCH v3] [0/10] pasemi_mac: fixes and enhancements Olof Johansson
2007-04-28 20:36 ` [PATCH v3] [1/10] pasemi_mac: A couple of minor bugfixes Olof Johansson
2007-05-08 5:02 ` Jeff Garzik
2007-04-28 20:36 ` [PATCH v3] [2/10] pasemi_mac: Move the IRQ mapping from the PCI layer to the driver Olof Johansson
2007-04-28 20:57 ` [PATCH v3] [2/10] [REAL 2/10] " Olof Johansson
2007-05-08 5:02 ` Jeff Garzik
2007-05-08 5:32 ` Olof Johansson
2007-04-28 20:37 ` [PATCH v3] [3/10] pasemi_mac: Abstract and fix up interrupt restart routines Olof Johansson
2007-04-28 20:37 ` [PATCH v3] [4/10] pasemi_mac: Timer and interrupt fixes Olof Johansson
2007-04-28 20:37 ` Olof Johansson [this message]
2007-04-28 20:37 ` [PATCH v3] [6/10] pasemi_mac: Minor cleanup / define fixes Olof Johansson
2007-04-28 20:37 ` [PATCH v3] [2/10] pasemi_mac: Move the IRQ mapping from the PCI layer to the driver[PATCH v3] [7/10] pasemi_mac: Logic cleanup / rx performance improvements Olof Johansson
2007-04-28 20:38 ` [PATCH v3] [8/10] pasemi_mac: Add msglevel support and "pasemi_mac_debug" module param Olof Johansson
2007-05-08 5:03 ` Jeff Garzik
2007-05-08 5:33 ` Olof Johansson
2007-04-28 20:38 ` [PATCH v3] [9/10] pasemi_mac: PHY support Olof Johansson
2007-05-08 5:03 ` Jeff Garzik
2007-04-28 20:38 ` [PATCH v3] [10/10] pasemi_mac: Use local-mac-address instead of mac-address if available Olof Johansson
2007-04-28 20:58 ` [PATCH v3] [7/10] pasemi_mac: Logic cleanup / rx performance improvements Olof Johansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070428203728.GF4331@lixom.net \
--to=olof@lixom.net \
--cc=jgarzik@pobox.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).