On Tue, Sep 9, 2025 at 12:04 AM Jerome Forissier <[email protected]> wrote: > > > > On 9/8/25 18:44, Tim Harvey wrote: > > On Mon, Sep 8, 2025 at 7:21 AM Jerome Forissier > > <[email protected]> wrote: > >> > >> Hi Tim, > >> > >> On 9/5/25 19:45, Tim Harvey wrote: > >>> Hi Jerome, > >>> > >>> I'm working with a board that has an IMX ENETC MAC on it > >>> drivers/net/fsl_enetc.c and when configured for LWIP it fails and > >>> warns about RX buffers not being 64B aligned: > >>> WARNING at drivers/net/fsl_enetc.c:776/enetc_setup_rx_bdr()! > >>> > >>> I tried changing MEM_ALIGNMENT to 64 in lib/lwip/u-boot/lwipopts.h but > >>> that did not align the buffers to 64B. Where are the lwip buffers > >>> created and do you have any suggestions for working around this? > >> > >> The LwIP RX buffers are created in net-lwip.c. See eth_init_rings(). > >> You might have PKTSIZE_ALIGN and/or PKTALIGN set wrongly. > >> > > > > Hi Jerome, > > > > Thanks for pointing me to eth_init_rings(). This function uses > > net_pkt_buf as the base for the net_rx_packets array which is a static > > global and not aligned. > > > > Looks like we need: > > diff --git a/net/lwip/net-lwip.c b/net/lwip/net-lwip.c > > index 660ceb10cbe..aec05d55de6 100644 > > --- a/net/lwip/net-lwip.c > > +++ b/net/lwip/net-lwip.c > > @@ -30,7 +30,7 @@ void (*push_packet)(void *, int len) = 0; > > static int net_try_count; > > static int net_restarted; > > int net_restart_wrap; > > -static uchar net_pkt_buf[(PKTBUFSRX) * PKTSIZE_ALIGN + PKTALIGN]; > > +static uchar net_pkt_buf[(PKTBUFSRX) * PKTSIZE_ALIGN + PKTALIGN] > > __attribute__((aligned(PKTALIGN))); > > uchar *net_rx_packets[PKTBUFSRX]; > > uchar *net_rx_packet; > > const u8 net_bcast_ethaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; > > > > If you agree I'll submit that. This does resolve the issue I see with > > the enetc driver using LwIP. > > Please do. But then I wonder how come the legacy NET works OK? Or does it? > net/net.c has the same initialization sequence. >
Hi Jerome, Sorry for the late reply here. I can't explain how legacy NET aligns Ok - just lucky I guess as net_pkt_buf does end up with the right alignment there but definitely does not with lwip. Best Regards, Tim

