Re: [PATCH V5 net-next 1/2] net: fec: add XDP_TX feature support

From: Jesper Dangaard Brouer
Date: Fri Aug 11 2023 - 11:09:05 EST




On 11/08/2023 03.26, Wei Fang wrote:
If you add below code comment you can add my ACK in V6:

Okay, I will add the annotation to the code in V6. Thanks.


Great, one adjustment to my suggested comment below.

Acked-by: Jesper Dangaard Brouer <hawk@xxxxxxxxxx>

@@ -1482,7 +1488,13 @@ fec_enet_tx_queue(struct net_device *ndev,
u16 queue_id, int budget)
/* 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_rx_napi(xdpf);
+ } else {
+ struct page *page = virt_to_head_page(xdpf->data);
+

I think this usage of page_pool_put_page() with dma_sync_size=0 requires a
comment, else we will forget why this okay...
I suggest:

/* PP dma_sync_size=0 as xmit already synced DMA for_device */


I update my suggestion to:

/* PP dma_sync_size=0 as XDP_TX already synced DMA for_device */

Reading code path there is an simple "else" to reach this spot, and it
will be good to hint to code-reader that this code path deals with
XDP_TX completion handling.

You are of-cause free to come up with a better comment yourself.

+ page_pool_put_page(page->pp, page, 0, true);
+ }

txq->tx_buf[index].xdp = NULL;
/* restore default tx buffer type: FEC_TXBUF_T_SKB */
@@ -1541,7


--Jesper