linux/drivers/net
Wei Fang 25eb3058eb net: fec: add AF_XDP zero-copy support
This patch adds AF_XDP zero-copy support for both TX and RX on the FEC
driver. It introduces new functions for XSK buffer allocation, RX/TX
queue processing in zero-copy mode, and XSK pool setup/teardown.

For RX, fec_alloc_rxq_buffers_zc() is added to allocate RX buffers from
XSK pool. And fec_enet_rx_queue_xsk() is used to process the frames from
the RX queue which is bound to the AF_XDP socket. Similar to the copy
mode, the zero-copy mode also supports XDP_TX, XDP_PASS, XDP_DROP and
XDP_REDIRECT actions. In addition, fec_enet_xsk_tx_xmit() is similar to
fec_enet_xdp_tx_xmit() and is used to handle XDP_TX action in zero-copy
mode.

For TX, there are two cases, one is the frames from the AF_XDP socket,
so fec_enet_xsk_xmit() is added to directly transmit the frames from
the socket and the buffer type is marked as FEC_TXBUF_T_XSK_XMIT. The
other one is the frames from the RX queue (XDP_TX action), the buffer
type is marked as FEC_TXBUF_T_XSK_TX. Therefore, fec_enet_tx_queue()
could correctly clean the TX queue base on the buffer type.

Also, some tests have been done on the i.MX93-EVK board with the xdpsock
tool, the following are the results.

Env: i.MX93 connects to a packet generator, the link speed is 1Gbps, and
flow-control is off. The RX packet size is 64 bytes including FCS. Only
one RX queue (CPU) is used to receive frames.

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

Signed-off-by: Wei Fang <wei.fang@nxp.com>
Link: https://patch.msgid.link/20260205085742.2685134-16-wei.fang@nxp.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-02-10 10:58:20 +01:00
..
arcnet net: arcnet: com20020-pci: use module_pci_driver 2026-02-10 10:16:33 +01:00
bonding Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-01-29 17:28:54 -08:00
caif
can can: gw: use can_gw_hops instead of sk_buff::csum_start 2026-02-05 11:58:40 +01:00
dsa net: dsa: mxl-gsw1xx: validate chip ID 2026-02-10 09:09:27 +01:00
ethernet net: fec: add AF_XDP zero-copy support 2026-02-10 10:58:20 +01:00
fddi
fjes fjes: Add missing iounmap in fjes_hw_init() 2025-12-22 12:11:32 +01:00
hamradio net: remove unnecessary module_init/exit functions 2026-02-02 17:25:23 -08:00
hyperv net: hv_netvsc: reject RSS hash key programming without RX indirection table 2026-01-13 19:07:31 -08:00
ieee802154
ipa
ipvlan ipvlan: remove ipvlan_ht_addr_lookup() 2026-01-25 14:35:19 -08:00
mctp mctp i2c: initialise event handler read bytes 2026-01-17 15:14:18 -08:00
mdio net: mdio: rtl9300: use scoped for loops 2025-12-28 08:55:48 +01:00
netdevsim netdevsim: use u64_stats_t with u64_stats_sync properly 2026-01-26 19:53:36 -08:00
ovpn ovpn: Replace use of system_wq with system_percpu_wq 2026-02-04 20:41:38 -08:00
pcs Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-01-22 20:14:36 -08:00
phy Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-02-05 09:54:08 -08:00
plip
ppp ppp: enable TX scatter-gather 2026-02-05 10:06:27 +01:00
pse-pd
slip
team team: fix check for port enabled in team_queue_override_port_prio_changed() 2025-12-23 09:07:48 +01:00
thunderbolt net: thunderbolt: Allow reading link settings 2026-01-19 12:09:58 -08:00
usb Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-02-05 09:54:08 -08:00
vmxnet3
vxlan vxlan: vnifilter: fix memcpy with u64_stats 2026-01-25 13:14:11 -08:00
wan net: wan: framer: Discard pm_runtime_put() return values 2026-01-08 08:15:03 -08:00
wireguard
wireless Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-02-05 09:54:08 -08:00
wwan net: wwan: mhi_wwan_ctrl: Add NMEA channel support 2026-01-30 18:27:00 -08:00
xen-netback net/xen-netback: Fix mispelling of "Software" as "Softare" 2026-01-20 19:00:46 -08:00
Kconfig net: remove HIPPI support and RoadRunner HIPPI driver 2026-01-20 19:12:06 -08:00
LICENSE.SRC
Makefile net: remove HIPPI support and RoadRunner HIPPI driver 2026-01-20 19:12:06 -08:00
Space.c
amt.c
bareudp.c
dummy.c
eql.c
geneve.c geneve: use GRO hint option in the RX path 2026-01-23 11:31:14 -08:00
gtp.c
ifb.c net: ifb: use u64_stats_t with u64_stats_sync properly 2026-01-22 13:00:36 +01:00
loopback.c
macsec.c macsec: fix memcpy with u64_stats 2026-01-25 13:14:11 -08:00
macvlan.c macvlan: fix error recovery in macvlan_common_newlink() 2026-01-30 17:37:11 -08:00
macvtap.c
mdio.c
mhi_net.c
mii.c
net_failover.c net: remove unnecessary module_init/exit functions 2026-02-02 17:25:23 -08:00
netconsole.c netconsole: resume previously deactivated target 2026-01-21 19:09:11 -08:00
netkit.c Revert "Merge branch 'netkit-support-for-io_uring-zero-copy-and-af_xdp'" 2026-01-20 18:06:01 -08:00
nlmon.c
ntb_netdev.c
pfcp.c
rionet.c
sungem_phy.c
tap.c
tun.c
tun_vnet.h
veth.c veth: fix data race in veth_get_ethtool_stats 2026-01-17 16:22:18 -08:00
virtio_net.c virtio_net: Fix misalignment bug in struct virtnet_info 2026-01-15 10:18:42 +01:00
vrf.c
vsockmon.c
xen-netfront.c xen/netfront: Use u64_stats_t with u64_stats_sync properly 2026-01-22 13:00:49 +01:00