Re: [EXT] Re: [PATCH v2 1/1] net: fec: add initial XDP support

From: Andrew Lunn
Date: Mon Oct 31 2022 - 16:18:29 EST


> > > + cbd_base = rxq->bd.base;
> > > + if (bpf->prog)
> > > + rxq->bd.ring_size = XDP_RX_RING_SIZE;
> > > + else
> > > + rxq->bd.ring_size = RX_RING_SIZE;
> > > + size = dsize * rxq->bd.ring_size;
> > > + cbd_base = (struct bufdesc *)(((void *)cbd_base) + size);
> > > + rxq->bd.last = (struct bufdesc *)(((void
> > > + *)cbd_base) - dsize);
> >
> > This does not look safe. netif_tx_disable(dev) will stop new transmissions, but
> > the hardware can be busy receiving, DMAing frames, using the descriptors, etc.
> > Modifying rxq->bd.last in particular seems risky. I think you need to disable the
> > receiver, wait for it to indicate it really has stopped, and only then make these
> > modifications.
> >
>
> Sounds reasonable. How about moving the codes of updating ring size to the place
> right after the enet reset inside the fec_restart? This should clear those risky corner
> cases.

That sounds reasonable. But please add some comments. The driver has
RX_RING_SIZE elements allocated, but you are only using a subset. This
needs to be clear for when somebody implements the ethtool --rings
option.

And i still think it would be good to implement that code. As your
numbers show, the ring size does affect performance, and it is hard to
know if your hard coded XDP_RX_RING_SIZE is the right value, depending
on what the eBPF program is doing. If the ethtool option was provided,
it allows users to benchmark different ring sizes for their workload.

Andrew