083-solos-pci-Increase-headroom-on-received-packets.patch 2.2 KB

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