Re: [PATCH 1/6] net: stmmac: use correct DMA buffer size in the RX descriptor
From: Aaro Koskinen
Date: Fri Mar 29 2019 - 06:48:53 EST
Hi,
On Fri, Mar 29, 2019 at 10:02:20AM +0000, Jose Abreu wrote:
> On 3/27/2019 8:35 PM, Aaro Koskinen wrote:
> > From: Aaro Koskinen <aaro.koskinen@xxxxxxxxx>
> >
> > We always program the maximum DMA buffer size into the receive descriptor,
> > although the allocated size may be less. E.g. with the default MTU size
> > we allocate only 1536 bytes. If somebody sends us a bigger frame, then
> > memory may get corrupted.
> >
> > Fix by using exact buffer sizes.
> >
> > Signed-off-by: Aaro Koskinen <aaro.koskinen@xxxxxxxxx>
>
> So, I'm seeing that the maximum allowed buffer size that can be
> put in the descriptor changes between enhanced descriptors to
> normal descriptors (8KB vs. 2KB right ?).
There are two size fields, so it's 16KB vs 4 KB.
> Shouldn't stmmac_main know about this limit before trying to init
> descriptors ?
Yes, and that is not a problem.
> We do limit the MTU according to HW version but I would rather
> prefer not having to need to calculate min() values in the
> descriptor code and just use the value as is ...
I don't think the calculation can be avoided, as the passed value can
be bigger than a single field can hold, or less than the maximum.
A.