kernel: update kernel 3.18 to version 3.18.23
[openwrt/staging/chunkeey.git] / target / linux / generic / patches-3.18 / 083-solos-pci-Increase-headroom-on-received-packets.patch
1 From: David Woodhouse <dwmw2@infradead.org>
2 Date: Thu, 17 Sep 2015 11:19:53 +0100
3 Subject: [PATCH] solos-pci: Increase headroom on received packets
4 MIME-Version: 1.0
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
7
8 A comment in include/linux/skbuff.h says that:
9
10 * Various parts of the networking layer expect at least 32 bytes of
11 * headroom, you should not reduce this.
12
13 This was demonstrated by a panic when handling fragmented IPv6 packets:
14 http://marc.info/?l=linux-netdev&m=144236093519172&w=2
15
16 It's not entirely clear if that comment is still valid — and if it is,
17 perhaps netif_rx() ought to be enforcing it with a warning.
18
19 But either way, it is rather stupid from a performance point of view
20 for us to be receiving packets into a buffer which doesn't have enough
21 room to prepend an Ethernet header — it means that *every* incoming
22 packet is going to be need to be reallocated. So let's fix that.
23
24 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
25 ---
26
27 --- a/drivers/atm/solos-pci.c
28 +++ b/drivers/atm/solos-pci.c
29 @@ -805,7 +805,12 @@ static void solos_bh(unsigned long card_
30 continue;
31 }
32
33 - skb = alloc_skb(size + 1, GFP_ATOMIC);
34 + /* Use netdev_alloc_skb() because it adds NET_SKB_PAD of
35 + * headroom, and ensures we can route packets back out an
36 + * Ethernet interface (for example) without having to
37 + * reallocate. Adding NET_IP_ALIGN also ensures that both
38 + * PPPoATM and PPPoEoBR2684 packets end up aligned. */
39 + skb = netdev_alloc_skb_ip_align(NULL, size + 1);
40 if (!skb) {
41 if (net_ratelimit())
42 dev_warn(&card->dev->dev, "Failed to allocate sk_buff for RX\n");
43 @@ -869,7 +874,10 @@ static void solos_bh(unsigned long card_
44 /* Allocate RX skbs for any ports which need them */
45 if (card->using_dma && card->atmdev[port] &&
46 !card->rx_skb[port]) {
47 - struct sk_buff *skb = alloc_skb(RX_DMA_SIZE, GFP_ATOMIC);
48 + /* Unlike the MMIO case (qv) we can't add NET_IP_ALIGN
49 + * here; the FPGA can only DMA to addresses which are
50 + * aligned to 4 bytes. */
51 + struct sk_buff *skb = dev_alloc_skb(RX_DMA_SIZE);
52 if (skb) {
53 SKB_CB(skb)->dma_addr =
54 pci_map_single(card->dev, skb->data,