Skip to content

Commit 310d80b

Browse files
author
Paolo Abeni
committed
Merge branch 'net-fec-improve-xdp-copy-mode-and-add-af_xdp-zero-copy-support'
Wei Fang says: ==================== net: fec: improve XDP copy mode and add AF_XDP zero-copy support This patch set optimizes the XDP copy mode logic as follows. 1. Separate the processing of RX XDP frames from fec_enet_rx_queue(), and adds a separate function fec_enet_rx_queue_xdp() for handling XDP frames. 2. For TX XDP packets, using the batch sending method to avoid frequent MMIO writes. 3. Use the switch statement to check the tx_buf type instead of the if...else... statement, making the cleanup logic of TX BD ring cleared and more efficient. We compared the performance of XDP copy mode before and after applying this patch set, and the results show that the performance has improved. Before applying this patch set. root@imx93evk:~# ./xdp-bench tx eth0 Summary 396,868 rx/s 0 err,drop/s Summary 396,024 rx/s 0 err,drop/s root@imx93evk:~# ./xdp-bench drop eth0 Summary 684,781 rx/s 0 err/s Summary 675,746 rx/s 0 err/s root@imx93evk:~# ./xdp-bench pass eth0 Summary 208,552 rx/s 0 err,drop/s Summary 208,654 rx/s 0 err,drop/s root@imx93evk:~# ./xdp-bench redirect eth0 eth0 eth0->eth0 311,210 rx/s 0 err,drop/s 311,208 xmit/s eth0->eth0 310,808 rx/s 0 err,drop/s 310,809 xmit/s After applying this patch set. root@imx93evk:~# ./xdp-bench tx eth0 Summary 425,778 rx/s 0 err,drop/s Summary 426,042 rx/s 0 err,drop/s root@imx93evk:~# ./xdp-bench drop eth0 Summary 698,351 rx/s 0 err/s Summary 701,882 rx/s 0 err/s root@imx93evk:~# ./xdp-bench pass eth0 Summary 210,348 rx/s 0 err,drop/s Summary 210,016 rx/s 0 err,drop/s root@imx93evk:~# ./xdp-bench redirect eth0 eth0 eth0->eth0 354,407 rx/s 0 err,drop/s 354,401 xmit/s eth0->eth0 350,381 rx/s 0 err,drop/s 350,389 xmit/s This patch set also addes the AF_XDP zero-copy support, and we tested the performance on i.MX93 platform with xdpsock tool. The following is the performance comparison of copy mode and zero-copy mode. It can be seen that the performance of zero-copy mode is better than that of copy mode. 1. MAC swap L2 forwarding 1.1 Zero-copy mode root@imx93evk:~# ./xdpsock -i eth0 -l -z sock0@eth0:0 l2fwd xdp-drv pps pkts 1.00 rx 414715 415455 tx 414715 415455 1.2 Copy mode root@imx93evk:~# ./xdpsock -i eth0 -l -c sock0@eth0:0 l2fwd xdp-drv pps pkts 1.00 rx 356396 356609 tx 356396 356609 2. TX only 2.1 Zero-copy mode root@imx93evk:~# ./xdpsock -i eth0 -t -s 64 -z sock0@eth0:0 txonly xdp-drv pps pkts 1.00 rx 0 0 tx 1119573 1126720 2.2 Copy mode root@imx93evk:~# ./xdpsock -i eth0 -t -s 64 -c sock0@eth0:0 txonly xdp-drv pps pkts 1.00 rx 0 0 tx 406864 407616 ==================== Link: https://patch.msgid.link/20260205085742.2685134-1-wei.fang@nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2 parents d82cb7b + 25eb305 commit 310d80b

2 files changed

Lines changed: 1258 additions & 403 deletions

File tree

drivers/net/ethernet/freescale/fec.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ struct bufdesc_ex {
340340
#define FEC_ENET_TX_FRPPG (PAGE_SIZE / FEC_ENET_TX_FRSIZE)
341341
#define TX_RING_SIZE 1024 /* Must be power of two */
342342
#define TX_RING_MOD_MASK 511 /* for this to work */
343+
#define FEC_XSK_TX_BUDGET_MAX 256
343344

344345
#define BD_ENET_RX_INT 0x00800000
345346
#define BD_ENET_RX_PTP ((ushort)0x0400)
@@ -528,6 +529,8 @@ enum fec_txbuf_type {
528529
FEC_TXBUF_T_SKB,
529530
FEC_TXBUF_T_XDP_NDO,
530531
FEC_TXBUF_T_XDP_TX,
532+
FEC_TXBUF_T_XSK_XMIT,
533+
FEC_TXBUF_T_XSK_TX,
531534
};
532535

533536
struct fec_tx_buffer {
@@ -539,6 +542,7 @@ struct fec_enet_priv_tx_q {
539542
struct bufdesc_prop bd;
540543
unsigned char *tx_bounce[TX_RING_SIZE];
541544
struct fec_tx_buffer tx_buf[TX_RING_SIZE];
545+
struct xsk_buff_pool *xsk_pool;
542546

543547
unsigned short tx_stop_threshold;
544548
unsigned short tx_wake_threshold;
@@ -548,9 +552,16 @@ struct fec_enet_priv_tx_q {
548552
dma_addr_t tso_hdrs_dma;
549553
};
550554

555+
union fec_rx_buffer {
556+
void *buf_p;
557+
struct page *page;
558+
struct xdp_buff *xdp;
559+
};
560+
551561
struct fec_enet_priv_rx_q {
552562
struct bufdesc_prop bd;
553-
struct page *rx_buf[RX_RING_SIZE];
563+
union fec_rx_buffer rx_buf[RX_RING_SIZE];
564+
struct xsk_buff_pool *xsk_pool;
554565

555566
/* page_pool */
556567
struct page_pool *page_pool;
@@ -643,6 +654,7 @@ struct fec_enet_private {
643654
struct pm_qos_request pm_qos_req;
644655

645656
unsigned int tx_align;
657+
unsigned int rx_shift;
646658

647659
/* hw interrupt coalesce */
648660
unsigned int rx_pkts_itr;

0 commit comments

Comments
 (0)