Commit b2c68833 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'selftests-drv-net-test-xdp-native-support'

Mohsin Bashir says:

====================
selftests: drv-net: Test XDP native support

This patch series add tests to validate XDP native support for PASS,
DROP, ABORT, and TX actions, as well as headroom and tailroom adjustment.
For adjustment tests, validate support for both the extension and
shrinking cases across various packet sizes and offset values.

The pass criteria for head/tail adjustment tests require that at-least
one adjustment value works for at-least one packet size. This ensure
that the variability in maximum supported head/tail adjustment offset
across different drivers is being incorporated.

The results reported in this series are based on netdevsim. However,
the series is tested against multiple other drivers including fbnic.

Note: The XDP support for fbnic will be added later.
====================

Link: https://patch.msgid.link/20250719083059.3209169-1-mohsin.bashr@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 391daec3 d6444ebc
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -387,15 +387,34 @@ static int nsim_get_iflink(const struct net_device *dev)
static int nsim_rcv(struct nsim_rq *rq, int budget)
{
	struct net_device *dev = rq->napi.dev;
	struct bpf_prog *xdp_prog;
	struct netdevsim *ns;
	struct sk_buff *skb;
	unsigned int skblen;
	int i, ret;

	ns = netdev_priv(dev);
	xdp_prog = READ_ONCE(ns->xdp.prog);

	for (i = 0; i < budget; i++) {
		if (skb_queue_empty(&rq->skb_queue))
			break;

		skb = skb_dequeue(&rq->skb_queue);

		if (xdp_prog) {
			/* skb might be freed directly by XDP, save the len */
			skblen = skb->len;

			if (skb->ip_summed == CHECKSUM_PARTIAL)
				skb_checksum_help(skb);
			ret = do_xdp_generic(xdp_prog, &skb);
			if (ret != XDP_PASS) {
				dev_dstats_rx_add(dev, skblen);
				continue;
			}
		}

		/* skb might be discard at netif_receive_skb, save the len */
		skblen = skb->len;
		skb_mark_napi_id(skb, &rq->napi);
@@ -936,7 +955,7 @@ static void nsim_setup(struct net_device *dev)
			    NETIF_F_TSO;
	dev->pcpu_stat_type = NETDEV_PCPU_STAT_DSTATS;
	dev->max_mtu = ETH_MAX_MTU;
	dev->xdp_features = NETDEV_XDP_ACT_HW_OFFLOAD;
	dev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_HW_OFFLOAD;
}

static int nsim_queue_init(struct netdevsim *ns)
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ TEST_PROGS := \
	stats.py \
	shaper.py \
	hds.py \
	xdp.py \
# end of TEST_PROGS

include ../../lib.mk
+656 −0

File added.

Preview size limit exceeded, changes collapsed.

+621 −0

File added.

Preview size limit exceeded, changes collapsed.