Hi, > -----Original Message----- > From: David Wei <dw@xxxxxxxxxxx> > Sent: Thursday, February 13, 2025 2:58 AM > To: io-uring@xxxxxxxxxxxxxxx; netdev@xxxxxxxxxxxxxxx > Cc: Jens Axboe <axboe@xxxxxxxxx>; Pavel Begunkov > <asml.silence@xxxxxxxxx>; Jakub Kicinski <kuba@xxxxxxxxxx>; Paolo Abeni > <pabeni@xxxxxxxxxx>; David S. Miller <davem@xxxxxxxxxxxxx>; Eric Dumazet > <edumazet@xxxxxxxxxx>; Jesper Dangaard Brouer <hawk@xxxxxxxxxx>; David > Ahern <dsahern@xxxxxxxxxx>; Mina Almasry <almasrymina@xxxxxxxxxx>; > Stanislav Fomichev <stfomichev@xxxxxxxxx>; Joe Damato > <jdamato@xxxxxxxxxx>; Pedro Tammela <pctammela@xxxxxxxxxxxx> > Subject: [PATCH net-next v13 11/11] io_uring/zcrx: add selftest > > Add a selftest for io_uring zero copy Rx. This test cannot run locally and > requires a remote host to be configured in net.config. The remote host must > have hardware support for zero copy Rx as listed in the documentation page. > The test will restore the NIC config back to before the test and is idempotent. > > liburing is required to compile the test and be installed on the remote host > running the test. > > Signed-off-by: David Wei <dw@xxxxxxxxxxx> > --- > .../selftests/drivers/net/hw/.gitignore | 2 + > .../testing/selftests/drivers/net/hw/Makefile | 5 + > .../selftests/drivers/net/hw/iou-zcrx.c | 426 ++++++++++++++++++ > .../selftests/drivers/net/hw/iou-zcrx.py | 64 +++ > 4 files changed, 497 insertions(+) > create mode 100644 tools/testing/selftests/drivers/net/hw/iou-zcrx.c > create mode 100755 tools/testing/selftests/drivers/net/hw/iou-zcrx.py > > diff --git a/tools/testing/selftests/drivers/net/hw/.gitignore > b/tools/testing/selftests/drivers/net/hw/.gitignore > index e9fe6ede681a..6942bf575497 100644 > --- a/tools/testing/selftests/drivers/net/hw/.gitignore > +++ b/tools/testing/selftests/drivers/net/hw/.gitignore > @@ -1 +1,3 @@ > +# SPDX-License-Identifier: GPL-2.0-only iou-zcrx > ncdevmem > diff --git a/tools/testing/selftests/drivers/net/hw/Makefile > b/tools/testing/selftests/drivers/net/hw/Makefile > index 21ba64ce1e34..7efc47c89463 100644 > --- a/tools/testing/selftests/drivers/net/hw/Makefile > +++ b/tools/testing/selftests/drivers/net/hw/Makefile > @@ -1,5 +1,7 @@ > # SPDX-License-Identifier: GPL-2.0+ OR MIT > > +TEST_GEN_FILES = iou-zcrx > + > TEST_PROGS = \ > csum.py \ > devlink_port_split.py \ > @@ -10,6 +12,7 @@ TEST_PROGS = \ > ethtool_rmon.sh \ > hw_stats_l3.sh \ > hw_stats_l3_gre.sh \ > + iou-zcrx.py \ > loopback.sh \ > nic_link_layer.py \ > nic_performance.py \ > @@ -38,3 +41,5 @@ include ../../../lib.mk # YNL build YNL_GENS := ethtool > netdev include ../../../net/ynl.mk > + > +$(OUTPUT)/iou-zcrx: LDLIBS += -luring > diff --git a/tools/testing/selftests/drivers/net/hw/iou-zcrx.c > b/tools/testing/selftests/drivers/net/hw/iou-zcrx.c > new file mode 100644 > index 000000000000..010c261d2132 > --- /dev/null > +++ b/tools/testing/selftests/drivers/net/hw/iou-zcrx.c > @@ -0,0 +1,426 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include <assert.h> > +#include <errno.h> > +#include <error.h> > +#include <fcntl.h> > +#include <limits.h> > +#include <stdbool.h> > +#include <stdint.h> > +#include <stdio.h> > +#include <stdlib.h> > +#include <string.h> > +#include <unistd.h> > + > +#include <arpa/inet.h> > +#include <linux/errqueue.h> > +#include <linux/if_packet.h> > +#include <linux/ipv6.h> > +#include <linux/socket.h> > +#include <linux/sockios.h> > +#include <net/ethernet.h> > +#include <net/if.h> > +#include <netinet/in.h> > +#include <netinet/ip.h> > +#include <netinet/ip6.h> > +#include <netinet/tcp.h> > +#include <netinet/udp.h> > +#include <sys/epoll.h> > +#include <sys/ioctl.h> > +#include <sys/mman.h> > +#include <sys/resource.h> > +#include <sys/socket.h> > +#include <sys/stat.h> > +#include <sys/time.h> > +#include <sys/types.h> > +#include <sys/un.h> > +#include <sys/wait.h> > + When I compiled this testcase, I got some errors: iou-zcrx.c:145:9: error: variable ‘region_reg’ has initializer but incomplete type iou-zcrx.c:148:12: error: ‘IORING_MEM_REGION_TYPE_USER’ undeclared (first use in this function) ... It seems that the linux/io_uring.h should be included here. Also, after include this header file, some errors still exist. iou-zcrx.c:(.text+0x5f0): undefined reference to `io_uring_register_ifq' It is caused because io_uring_register_ifq symbol was not exported in liburing. Finally some warnings should also be fixed: iou-zcrx.c:288:17: warning: passing argument 2 of ‘bind’ from incompatible pointer type iou-zcrx.c:326:18: warning: passing argument 2 of ‘connect’ from incompatible pointer type > +#include <liburing.h> --- Li Zetao