From: David Woodhouse <dwmw2@infradead.org>
To: netdev@vger.kernel.org
Cc: simon@fire.lp0.eu, guy@traverse.com.au,
linux-atm-general@lists.sourceforge.net
Subject: [PATCH] solos-pci: Increase headroom on received packets
Date: Wed, 16 Sep 2015 11:25:45 +0100 [thread overview]
Message-ID: <1442399145.131189.56.camel@infradead.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 2283 bytes --]
A comment in include/linux/skbuff.h says that:
* Various parts of the networking layer expect at least 32 bytes of
* headroom, you should not reduce this.
This was demonstrated by a panic when handling fragmented IPv6 packets:
http://marc.info/?l=linux-netdev&m=144236093519172&w=2
It's not entirely clear if that comment is still valid — and if it is,
perhaps netif_rx() ought to be enforcing it with a warning.
But either way, it is rather stupid from a performance point of view
for us to be receiving packets into a buffer which doesn't have enough
room to prepend an Ethernet header — it means that *every* incoming
packet is going to be need to be reallocated. So let's fix that.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
---
Tested in the DMA code path; I don't believe the DMA-capable devices
can still be used in MMIO mode. Simon, Guy, would you be able to test
the MMIO version?
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 74e18b0..be8225e 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -805,13 +805,13 @@ static void solos_bh(unsigned long card_arg)
continue;
}
- skb = alloc_skb(size + 1, GFP_ATOMIC);
+ skb = alloc_skb(size + NET_SKB_PAD + 1, GFP_ATOMIC);
if (!skb) {
if (net_ratelimit())
dev_warn(&card->dev->dev, "Failed to allocate sk_buff for RX\n");
continue;
}
-
+ skb_reserve(skb, NET_SKB_PAD);
memcpy_fromio(skb_put(skb, size),
RX_BUF(card, port) + sizeof(*header),
size);
@@ -869,8 +869,10 @@ static void solos_bh(unsigned long card_arg)
/* Allocate RX skbs for any ports which need them */
if (card->using_dma && card->atmdev[port] &&
!card->rx_skb[port]) {
- struct sk_buff *skb = alloc_skb(RX_DMA_SIZE, GFP_ATOMIC);
+ struct sk_buff *skb = alloc_skb(RX_DMA_SIZE + NET_SKB_PAD,
+ GFP_ATOMIC);
if (skb) {
+ skb_reserve(skb, NET_SKB_PAD);
SKB_CB(skb)->dma_addr =
dma_map_single(&card->dev->dev, skb->data,
RX_DMA_SIZE, DMA_FROM_DEVICE);
--
David Woodhouse Open Source Technology Centre
David.Woodhouse@intel.com Intel Corporation
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5691 bytes --]
next reply other threads:[~2015-09-16 10:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-16 10:25 David Woodhouse [this message]
2015-09-16 10:53 ` [PATCH] solos-pci: Increase headroom on received packets Eric Dumazet
2015-09-16 11:32 ` David Woodhouse
2015-09-16 11:35 ` [PATCH v2] " David Woodhouse
2015-09-16 13:26 ` Eric Dumazet
2015-09-18 4:29 ` David Miller
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=1442399145.131189.56.camel@infradead.org \
--to=dwmw2@infradead.org \
--cc=guy@traverse.com.au \
--cc=linux-atm-general@lists.sourceforge.net \
--cc=netdev@vger.kernel.org \
--cc=simon@fire.lp0.eu \
/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).