Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752913AbcLJUcw convert rfc822-to-8bit (ORCPT ); Sat, 10 Dec 2016 15:32:52 -0500 Received: from unicorn.mansr.com ([81.2.72.234]:51040 "EHLO unicorn.mansr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752725AbcLJUct (ORCPT ); Sat, 10 Dec 2016 15:32:49 -0500 From: =?iso-8859-1?Q?M=E5ns_Rullg=E5rd?= To: Felix Fietkau Cc: "Jason A. Donenfeld" , David Miller , Netdev , WireGuard mailing list , LKML , linux-mips@linux-mips.org Subject: Re: Misalignment, MIPS, and ip_hdr(skb)->version References: <20161207.135127.789629809982860453.davem@davemloft.net> <040bcdb2-2725-c8de-11d9-a4f77b75d9d8@nbd.name> <7f8ba817-73ef-e1e1-4fdf-b9178e922008@nbd.name> Date: Sat, 10 Dec 2016 20:32:44 +0000 In-Reply-To: <7f8ba817-73ef-e1e1-4fdf-b9178e922008@nbd.name> (Felix Fietkau's message of "Sat, 10 Dec 2016 21:09:57 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2247 Lines: 48 Felix Fietkau writes: > On 2016-12-10 14:25, M?ns Rullg?rd wrote: >> Felix Fietkau writes: >> >>> On 2016-12-07 19:54, Jason A. Donenfeld wrote: >>>> On Wed, Dec 7, 2016 at 7:51 PM, David Miller wrote: >>>>> It's so much better to analyze properly where the misalignment comes from >>>>> and address it at the source, as we have for various cases that trip up >>>>> Sparc too. >>>> >>>> That's sort of my attitude too, hence starting this thread. Any >>>> pointers you have about this would be most welcome, so as not to >>>> perpetuate what already seems like an issue in other parts of the >>>> stack. >>> Hi Jason, >>> >>> I'm the author of that hackish LEDE/OpenWrt patch that works around the >>> misalignment issues. Here's some context regarding that patch: >>> >>> I intentionally put it in the target specific patches for only one of >>> our MIPS targets. There are a few ar71xx devices where the misalignment >>> cannot be fixed, because the Ethernet MAC has a 4-byte DMA alignment >>> requirement, and does not support inserting 2 bytes of padding to >>> correct the IP header misalignment. >>> >>> With these limitations the choice was between this ugly network stack >>> patch or inserting a very expensive memmove in the data path (which is >>> better than taking the mis-alignment traps, but still hurts routing >>> performance significantly). >> >> I solved this problem in an Ethernet driver by copying the initial part >> of the packet to an aligned skb and appending the remainder using >> skb_add_rx_frag(). The kernel network stack only cares about the >> headers, so the alignment of the packet payload doesn't matter. > > I considered that as well, but it's bad for routing performance if the > ethernet MAC does not support scatter/gather for xmit. > Unfortunately that limitation is quite common on embedded hardware. Yes, I can see that being an issue. However, if you're doing zero-copy routing, the header part of the original buffer should still be there, unused, so you could presumably copy the header of the outgoing packet there and then do dma as usual. Maybe there's something in the network stack that makes this impossible though. -- M?ns Rullg?rd