Re: [PATCH net v1] lan743x: fix ethernet frame cutoff issue

From: Julian Wiedmann
Date: Wed Apr 14 2021 - 09:34:27 EST


On 14.04.21 15:19, Sven Van Asbroeck wrote:
> Hi Julian,
>
> On Wed, Apr 14, 2021 at 8:53 AM Julian Wiedmann <jwi@xxxxxxxxxxxxx> wrote:
>>
>> On a cursory glance, using __netdev_alloc_skb_ip_align() here should
>> allow you to get rid of all the RX_HEAD_PADDING gymnastics.
>>
>> And also avoid the need for setting RX_CFG_B_RX_PAD_2_, as the
>> NET_IP_ALIGN part would no longer get dma-mapped.
>
> That's an excellent suggestion, and I'll definitely keep that in mind
> for the future.
>
> In this case, I'm not sure if it could work. This NIC has multi-buffer
> frames. The dma-ed skbs represent frame fragments. A flag in the
> descriptor ring indicates if an skb is "first". If first, we can
> reserve the padding. Otherwise, we cannot. because that would corrupt
> a fragment in the middle. At the time of skb allocation, we do not
> know whether that skb will be "first".
>

__netdev_alloc_skb_ip_align() already reserves the NET_IP_ALIGN part.
So when the NIC stores into the dma-mapped skb->data parts, each
fragment will automatically have the required alignment - even when
you only care about the first fragment's alignment.

> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/microchip/lan743x_main.c?h=v5.12-rc7#n2125
>
> Maybe I'm missing a trick here? Feel free to suggest improvements,
> it's always much appreciated.
>
> Sven
>