RE: [PATCH V2 net-next] net: fec: add XDP_TX feature support

From: Wei Fang
Date: Mon Jul 24 2023 - 21:59:11 EST


> On Fri, 21 Jul 2023 14:21:53 +0800 Wei Fang wrote:
> > + /* Tx processing cannot call any XDP (or page pool) APIs if
> > + * the "budget" is 0. Because NAPI is called with budget of
> > + * 0 (such as netpoll) indicates we may be in an IRQ context,
> > + * however, we can't use the page pool from IRQ context.
> > + */
> > + if (unlikely(!budget))
> > + break;
> > +
> > xdpf = txq->tx_buf[index].xdp;
> > - if (bdp->cbd_bufaddr)
> > + if (bdp->cbd_bufaddr &&
> > + txq->tx_buf[index].type == FEC_TXBUF_T_XDP_NDO)
> > dma_unmap_single(&fep->pdev->dev,
> > fec32_to_cpu(bdp->cbd_bufaddr),
> > fec16_to_cpu(bdp->cbd_datlen), @@ -1474,7
> +1486,10 @@
> > fec_enet_tx_queue(struct net_device *ndev, u16 queue_id)
> > /* Free the sk buffer associated with this last transmit */
> > dev_kfree_skb_any(skb);
> > } else {
> > - xdp_return_frame(xdpf);
> > + if (txq->tx_buf[index].type == FEC_TXBUF_T_XDP_NDO)
> > + xdp_return_frame(xdpf);
> > + else
> > + xdp_return_frame_rx_napi(xdpf);
>
> I think that you need to also break if (!budget) here,
I think there is no need to break again here, because if the "budget" is 0, the code logic
will no jump here.

> xdp_return_frame() may call page pool APIs to return the frame to a page pool
> owned by another driver. And that needs to be fixed in net/main already?
Yes, you are right, I should fixed it in net tree first, and when the fix is merged
into net-next tree, I will send a 3rd version of this patch.