diff options
author | Felix Fietkau <nbd@openwrt.org> | 2015-09-17 15:38:58 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2015-09-17 15:38:58 +0000 |
commit | 6c018c2f5e60c6354ce31768373f87422549880d (patch) | |
tree | f7eb33f2a2199bacc18383f6d1cfc1a24d428305 /target/linux/generic | |
parent | 312908ff4bba09fa6641420c9b7ea642087f8a50 (diff) | |
download | mtk-20170518-6c018c2f5e60c6354ce31768373f87422549880d.zip mtk-20170518-6c018c2f5e60c6354ce31768373f87422549880d.tar.gz mtk-20170518-6c018c2f5e60c6354ce31768373f87422549880d.tar.bz2 |
kernel: solos-pci: Increase headroom on received packets
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 46993
Diffstat (limited to 'target/linux/generic')
2 files changed, 108 insertions, 0 deletions
diff --git a/target/linux/generic/patches-3.18/083-solos-pci-Increase-headroom-on-received-packets.patch b/target/linux/generic/patches-3.18/083-solos-pci-Increase-headroom-on-received-packets.patch new file mode 100644 index 0000000..7f9f926 --- /dev/null +++ b/target/linux/generic/patches-3.18/083-solos-pci-Increase-headroom-on-received-packets.patch @@ -0,0 +1,54 @@ +From: David Woodhouse <dwmw2@infradead.org> +Date: Thu, 17 Sep 2015 11:19:53 +0100 +Subject: [PATCH] solos-pci: Increase headroom on received packets +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +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> +--- + +--- a/drivers/atm/solos-pci.c ++++ b/drivers/atm/solos-pci.c +@@ -805,7 +805,12 @@ static void solos_bh(unsigned long card_ + continue; + } + +- skb = alloc_skb(size + 1, GFP_ATOMIC); ++ /* Use netdev_alloc_skb() because it adds NET_SKB_PAD of ++ * headroom, and ensures we can route packets back out an ++ * Ethernet interface (for example) without having to ++ * reallocate. Adding NET_IP_ALIGN also ensures that both ++ * PPPoATM and PPPoEoBR2684 packets end up aligned. */ ++ skb = netdev_alloc_skb_ip_align(NULL, size + 1); + if (!skb) { + if (net_ratelimit()) + dev_warn(&card->dev->dev, "Failed to allocate sk_buff for RX\n"); +@@ -869,7 +874,10 @@ static void solos_bh(unsigned long card_ + /* 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); ++ /* Unlike the MMIO case (qv) we can't add NET_IP_ALIGN ++ * here; the FPGA can only DMA to addresses which are ++ * aligned to 4 bytes. */ ++ struct sk_buff *skb = dev_alloc_skb(RX_DMA_SIZE); + if (skb) { + SKB_CB(skb)->dma_addr = + pci_map_single(card->dev, skb->data, diff --git a/target/linux/generic/patches-4.1/081-solos-pci-Increase-headroom-on-received-packets.patch b/target/linux/generic/patches-4.1/081-solos-pci-Increase-headroom-on-received-packets.patch new file mode 100644 index 0000000..605f57a --- /dev/null +++ b/target/linux/generic/patches-4.1/081-solos-pci-Increase-headroom-on-received-packets.patch @@ -0,0 +1,54 @@ +From: David Woodhouse <dwmw2@infradead.org> +Date: Thu, 17 Sep 2015 11:19:53 +0100 +Subject: [PATCH] solos-pci: Increase headroom on received packets +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +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> +--- + +--- a/drivers/atm/solos-pci.c ++++ b/drivers/atm/solos-pci.c +@@ -805,7 +805,12 @@ static void solos_bh(unsigned long card_ + continue; + } + +- skb = alloc_skb(size + 1, GFP_ATOMIC); ++ /* Use netdev_alloc_skb() because it adds NET_SKB_PAD of ++ * headroom, and ensures we can route packets back out an ++ * Ethernet interface (for example) without having to ++ * reallocate. Adding NET_IP_ALIGN also ensures that both ++ * PPPoATM and PPPoEoBR2684 packets end up aligned. */ ++ skb = netdev_alloc_skb_ip_align(NULL, size + 1); + if (!skb) { + if (net_ratelimit()) + dev_warn(&card->dev->dev, "Failed to allocate sk_buff for RX\n"); +@@ -869,7 +874,10 @@ static void solos_bh(unsigned long card_ + /* 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); ++ /* Unlike the MMIO case (qv) we can't add NET_IP_ALIGN ++ * here; the FPGA can only DMA to addresses which are ++ * aligned to 4 bytes. */ ++ struct sk_buff *skb = dev_alloc_skb(RX_DMA_SIZE); + if (skb) { + SKB_CB(skb)->dma_addr = + dma_map_single(&card->dev->dev, skb->data, |