From patchwork Thu Feb 20 08:41:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Vyavahare X-Patchwork-Id: 13983520 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9218C1EE02A; Thu, 20 Feb 2025 09:10:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740042606; cv=none; b=BDRvOFs79O6tLP1NM51xR7qsAVijW5+WMNSL8/MEkaw+FKhmwmM8bmPfFf1OCH7GC/oG9oD92aGg16odIjlSSuB5tR9Cyojw3pvJZmu6xIqGuXdpJhdfha7JB5+SfjoWWf65DrNg44uIEGlfLZ5S/dFTNUnlmEeAU3FBlift+80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740042606; c=relaxed/simple; bh=E1UXRj+rYj5wimRyBVLFjJd4blMvr+lEmcvsqaP+p3I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EroVCXWkzQxTI2kYk87oa+LQai9NN9R3tYJtS+w1BvfCPrLqBari8WCUarWdiw1Mbe6QmYZCLBzWeqC+gLiHjRV4Y0rCyYjtznNmVHw8Kkh6Nn6i35nxOziyPqvj7spQrofqxJSHHVoLCIzX+hVJK6FxEltoTTQMgtjmtnmCGEI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=g2GnKu5e; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="g2GnKu5e" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740042605; x=1771578605; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=E1UXRj+rYj5wimRyBVLFjJd4blMvr+lEmcvsqaP+p3I=; b=g2GnKu5e1TOG95EkB8C0wTLrEkj+NGSSJQrQjWUiLU4tBTTynt651URv 3CaJjFbuENJtHCH2dzuArXPVwdcBG5oTfim5Kk4Ueiyju4I8pILMp44MX CGJuvMHxiv2uN158oygexpZwnKHhjjW7M5SJiM1blymkIBDWzDZ3dhDmE E2kh2GIrPKxKAlEchUl3v9eEvmEMC1R3w+y4cqSsAwEmyfI0OXDopMRXm ZzvNOBCQFqTHuj8vBtttzPJ8zGTy/GR+tS3CAcT8B+5Rb81pN3XUDMkgH UM1wdk6L7LKLMlN+aTYS2x7hKH+m1g3cDJaAo+vKJaBdkXAekvRk2Jf9Z g==; X-CSE-ConnectionGUID: +s+YmJ3ITtWpkYqQ99N3wA== X-CSE-MsgGUID: vvGMl6q3Sd6KQ2+kvg+WeQ== X-IronPort-AV: E=McAfee;i="6700,10204,11350"; a="40733477" X-IronPort-AV: E=Sophos;i="6.13,301,1732608000"; d="scan'208";a="40733477" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2025 01:10:05 -0800 X-CSE-ConnectionGUID: GCbbDO9LSza61hfQ/ahtxw== X-CSE-MsgGUID: sxgqp6rPQPCjV5Xio1a0bQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,301,1732608000"; d="scan'208";a="120084549" Received: from brc05.iind.intel.com (HELO brc05..) ([10.190.162.156]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2025 01:10:01 -0800 From: Tushar Vyavahare To: bpf@vger.kernel.org Cc: netdev@vger.kernel.org, bjorn@kernel.org, magnus.karlsson@intel.com, maciej.fijalkowski@intel.com, jonathan.lemon@gmail.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net, tushar.vyavahare@intel.com Subject: [PATCH bpf-next 1/6] selftests/xsk: Add packet stream replacement functions Date: Thu, 20 Feb 2025 08:41:42 +0000 Message-Id: <20250220084147.94494-2-tushar.vyavahare@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250220084147.94494-1-tushar.vyavahare@intel.com> References: <20250220084147.94494-1-tushar.vyavahare@intel.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Add pkt_stream_replace function to replace the packet stream for a given ifobject. Add pkt_stream_replace_both function to replace the packet streams for both transmit and receive ifobject in test_spec. Enhance test framework to handle packet stream replacements efficiently. Signed-off-by: Tushar Vyavahare --- tools/testing/selftests/bpf/xskxceiver.c | 29 +++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index 11f047b8af75..1d9b03666ee6 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -757,14 +757,15 @@ static struct pkt_stream *pkt_stream_clone(struct pkt_stream *pkt_stream) return pkt_stream_generate(pkt_stream->nb_pkts, pkt_stream->pkts[0].len); } -static void pkt_stream_replace(struct test_spec *test, u32 nb_pkts, u32 pkt_len) +static void pkt_stream_replace(struct ifobject *ifobj, u32 nb_pkts, u32 pkt_len) { - struct pkt_stream *pkt_stream; + ifobj->xsk->pkt_stream = pkt_stream_generate(nb_pkts, pkt_len); +} - pkt_stream = pkt_stream_generate(nb_pkts, pkt_len); - test->ifobj_tx->xsk->pkt_stream = pkt_stream; - pkt_stream = pkt_stream_generate(nb_pkts, pkt_len); - test->ifobj_rx->xsk->pkt_stream = pkt_stream; +static void pkt_stream_replace_both(struct test_spec *test, u32 nb_pkts, u32 pkt_len) +{ + pkt_stream_replace(test->ifobj_tx, nb_pkts, pkt_len); + pkt_stream_replace(test->ifobj_rx, nb_pkts, pkt_len); } static void __pkt_stream_replace_half(struct ifobject *ifobj, u32 pkt_len, @@ -2052,7 +2053,8 @@ static int testapp_stats_tx_invalid_descs(struct test_spec *test) static int testapp_stats_rx_full(struct test_spec *test) { - pkt_stream_replace(test, DEFAULT_UMEM_BUFFERS + DEFAULT_UMEM_BUFFERS / 2, MIN_PKT_SIZE); + pkt_stream_replace_both(test, DEFAULT_UMEM_BUFFERS + DEFAULT_UMEM_BUFFERS / 2, + MIN_PKT_SIZE); test->ifobj_rx->xsk->pkt_stream = pkt_stream_generate(DEFAULT_UMEM_BUFFERS, MIN_PKT_SIZE); test->ifobj_rx->xsk->rxqsize = DEFAULT_UMEM_BUFFERS; @@ -2063,7 +2065,8 @@ static int testapp_stats_rx_full(struct test_spec *test) static int testapp_stats_fill_empty(struct test_spec *test) { - pkt_stream_replace(test, DEFAULT_UMEM_BUFFERS + DEFAULT_UMEM_BUFFERS / 2, MIN_PKT_SIZE); + pkt_stream_replace_both(test, DEFAULT_UMEM_BUFFERS + DEFAULT_UMEM_BUFFERS / 2, + MIN_PKT_SIZE); test->ifobj_rx->xsk->pkt_stream = pkt_stream_generate(DEFAULT_UMEM_BUFFERS, MIN_PKT_SIZE); test->ifobj_rx->use_fill_ring = false; @@ -2086,7 +2089,7 @@ static int testapp_send_receive_unaligned_mb(struct test_spec *test) test->mtu = MAX_ETH_JUMBO_SIZE; test->ifobj_tx->umem->unaligned_mode = true; test->ifobj_rx->umem->unaligned_mode = true; - pkt_stream_replace(test, DEFAULT_PKT_CNT, MAX_ETH_JUMBO_SIZE); + pkt_stream_replace_both(test, DEFAULT_PKT_CNT, MAX_ETH_JUMBO_SIZE); return testapp_validate_traffic(test); } @@ -2101,7 +2104,7 @@ static int testapp_single_pkt(struct test_spec *test) static int testapp_send_receive_mb(struct test_spec *test) { test->mtu = MAX_ETH_JUMBO_SIZE; - pkt_stream_replace(test, DEFAULT_PKT_CNT, MAX_ETH_JUMBO_SIZE); + pkt_stream_replace_both(test, DEFAULT_PKT_CNT, MAX_ETH_JUMBO_SIZE); return testapp_validate_traffic(test); } @@ -2252,7 +2255,7 @@ static int testapp_poll_txq_tmout(struct test_spec *test) test->ifobj_tx->use_poll = true; /* create invalid frame by set umem frame_size and pkt length equal to 2048 */ test->ifobj_tx->umem->frame_size = 2048; - pkt_stream_replace(test, 2 * DEFAULT_PKT_CNT, 2048); + pkt_stream_replace_both(test, 2 * DEFAULT_PKT_CNT, 2048); return testapp_validate_traffic_single_thread(test, test->ifobj_tx); } @@ -2389,7 +2392,7 @@ static int testapp_send_receive_2k_frame(struct test_spec *test) { test->ifobj_tx->umem->frame_size = 2048; test->ifobj_rx->umem->frame_size = 2048; - pkt_stream_replace(test, DEFAULT_PKT_CNT, MIN_PKT_SIZE); + pkt_stream_replace_both(test, DEFAULT_PKT_CNT, MIN_PKT_SIZE); return testapp_validate_traffic(test); } @@ -2511,7 +2514,7 @@ static int testapp_hw_sw_max_ring_size(struct test_spec *test) */ test->ifobj_tx->xsk->batch_size = test->ifobj_tx->ring.tx_max_pending - 8; test->ifobj_rx->xsk->batch_size = test->ifobj_tx->ring.tx_max_pending - 8; - pkt_stream_replace(test, max_descs, MIN_PKT_SIZE); + pkt_stream_replace_both(test, max_descs, MIN_PKT_SIZE); return testapp_validate_traffic(test); } From patchwork Thu Feb 20 08:41:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Vyavahare X-Patchwork-Id: 13983521 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31A471EEA57; Thu, 20 Feb 2025 09:10:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740042610; cv=none; b=ciYyIIXz9KWHbGqpPfAQozXHJNtS667Qin8A3rGwjhBLihrcL8R7G7frYkyzFxKSpSMZAfttL8a6As7fNIp0SOPi5/oAaXHlkxOo9h6Fhyc1vN08soEwvV2HdRe5jdlLb0BwD6N7BxKGnL/3G22HU0vYOlut+FQhlYHrssDXNNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740042610; c=relaxed/simple; bh=lum8LUwQY8cn20WEhhkEiPaz8vRPQuWHKH2mHyC2354=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gLl7+Rncljgu/f+IL/r9MX68v5RCc6GMApdj+jaF+hwnObedPhepXtZFnsZn2ZgjAZmY3WJAdlSp4BQFkAyOPJv6P1alQwDuabwAWzDPV3aQfyaNn+NZisr2pPFVobIpVThcduWcy1ec4FbSTqgE0Wd1pKhW7WDFJz2DtpIuZSg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AvRTnhTa; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AvRTnhTa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740042609; x=1771578609; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lum8LUwQY8cn20WEhhkEiPaz8vRPQuWHKH2mHyC2354=; b=AvRTnhTamsHk4kNyvjjLLh/rVoKZtswiwObm4mAZOu5nKy1u+4OBHGUk 9Gk1ZPTXvaElZVJJJ9p2yIUszzmNcD84m6IVAhW5RqyrENqg4X+1ghJKk olPEr3RMryD5fOi44cKBuyqcIG4x4vczWvyTZFZpVzQZNq3b4R/RCpaPx mKY2N+yfRs8u+cRN8zSH2JXVqkGYmeiBG/+jnD/9JDuHp7t82Vruqm/sv i7PFYxYCx5b662eJCwPWmDADV761tDbFMrxAwRpMpUrouIpDx0MyTipeQ iJBvb8fC9SKH4bxRc9vtGLLi/TXLlIBns1UVypNR08p2sTiun2OZkFFJ+ A==; X-CSE-ConnectionGUID: sLTtBWd7S6Wg2G2T2XOKWA== X-CSE-MsgGUID: 19s7sW6TTMq/lHoA4JB3Kw== X-IronPort-AV: E=McAfee;i="6700,10204,11350"; a="40733491" X-IronPort-AV: E=Sophos;i="6.13,301,1732608000"; d="scan'208";a="40733491" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2025 01:10:08 -0800 X-CSE-ConnectionGUID: UsZkltYqRACt6a15BunG6w== X-CSE-MsgGUID: +jFibForRq+CwCHc67c3Mw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,301,1732608000"; d="scan'208";a="120084560" Received: from brc05.iind.intel.com (HELO brc05..) ([10.190.162.156]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2025 01:10:04 -0800 From: Tushar Vyavahare To: bpf@vger.kernel.org Cc: netdev@vger.kernel.org, bjorn@kernel.org, magnus.karlsson@intel.com, maciej.fijalkowski@intel.com, jonathan.lemon@gmail.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net, tushar.vyavahare@intel.com Subject: [PATCH bpf-next 2/6] selftests/xsk: Add tail adjustment functionality to XDP Date: Thu, 20 Feb 2025 08:41:43 +0000 Message-Id: <20250220084147.94494-3-tushar.vyavahare@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250220084147.94494-1-tushar.vyavahare@intel.com> References: <20250220084147.94494-1-tushar.vyavahare@intel.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Introduce a new function, xsk_xdp_adjust_tail, within the XDP program to adjust the tail of packets. This function utilizes bpf_xdp_adjust_tail to modify the packet size dynamically based on the 'count' variable. If the adjustment fails, the packet is dropped using XDP_DROP to ensure processing of only correctly modified packets. Signed-off-by: Tushar Vyavahare --- .../selftests/bpf/progs/xsk_xdp_progs.c | 48 +++++++++++++++++++ tools/testing/selftests/bpf/xsk_xdp_common.h | 1 + 2 files changed, 49 insertions(+) diff --git a/tools/testing/selftests/bpf/progs/xsk_xdp_progs.c b/tools/testing/selftests/bpf/progs/xsk_xdp_progs.c index ccde6a4c6319..2e8e2faf17e0 100644 --- a/tools/testing/selftests/bpf/progs/xsk_xdp_progs.c +++ b/tools/testing/selftests/bpf/progs/xsk_xdp_progs.c @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include "xsk_xdp_common.h" struct { @@ -70,4 +72,50 @@ SEC("xdp") int xsk_xdp_shared_umem(struct xdp_md *xdp) return bpf_redirect_map(&xsk, idx, XDP_DROP); } +SEC("xdp.frags") int xsk_xdp_adjust_tail(struct xdp_md *xdp) +{ + __u32 buff_len, curr_buff_len; + int ret; + + buff_len = bpf_xdp_get_buff_len(xdp); + if (buff_len == 0) + return XDP_DROP; + + ret = bpf_xdp_adjust_tail(xdp, count); + if (ret < 0) { + /* Handle unsupported cases */ + if (ret == -EOPNOTSUPP) { + /* Set count to -EOPNOTSUPP to indicate to userspace that this case is + * unsupported + */ + count = -EOPNOTSUPP; + return bpf_redirect_map(&xsk, 0, XDP_DROP); + } + + return XDP_DROP; + } + + curr_buff_len = bpf_xdp_get_buff_len(xdp); + if (curr_buff_len != buff_len + count) + return XDP_DROP; + + if (curr_buff_len > buff_len) { + __u32 *pkt_data = (void *)(long)xdp->data; + __u32 len, words_to_end, seq_num; + + len = curr_buff_len - PKT_HDR_ALIGN; + words_to_end = len / sizeof(*pkt_data) - 1; + seq_num = words_to_end; + + /* Convert sequence number to network byte order. Store this in the last 4 bytes of + * the packet. Use 'count' to determine the position at the end of the packet for + * storing the sequence number. + */ + seq_num = __constant_htonl(words_to_end); + bpf_xdp_store_bytes(xdp, curr_buff_len - count, &seq_num, sizeof(seq_num)); + } + + return bpf_redirect_map(&xsk, 0, XDP_DROP); +} + char _license[] SEC("license") = "GPL"; diff --git a/tools/testing/selftests/bpf/xsk_xdp_common.h b/tools/testing/selftests/bpf/xsk_xdp_common.h index 5a6f36f07383..45810ff552da 100644 --- a/tools/testing/selftests/bpf/xsk_xdp_common.h +++ b/tools/testing/selftests/bpf/xsk_xdp_common.h @@ -4,6 +4,7 @@ #define XSK_XDP_COMMON_H_ #define MAX_SOCKETS 2 +#define PKT_HDR_ALIGN (sizeof(struct ethhdr) + 2) /* Just to align the data in the packet */ struct xdp_info { __u64 count; From patchwork Thu Feb 20 08:41:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Vyavahare X-Patchwork-Id: 13983522 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F7901EE7C4; Thu, 20 Feb 2025 09:10:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740042613; cv=none; b=Ki7hCI/EUIwwzi5tBnYaxN0RCWvddpAqMXlRgrO8uTaFP/OKM/zQFBL9pdb0ouSAeoL7P0szMqVWjvq1Hhj1XKkcK98l9rw2t0GvOZE5IG6a/utoPdwrXYyvyCNm1lWV6+CUEAEdlJwkvl2e3UXUxjMD4horaTMy5FoARZVFOLI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740042613; c=relaxed/simple; bh=ap06RU9lK+93Lg6AqAUmYtxQbCvi2WxR1WXqtk+05uc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tNOoz1o2xAp1f3x1pH75+EBfp8W3dQyENXnT9nXg3xej8A5pW++2XDQm+W8OQKud5moCK7CBAXZ5n8vUKO4Nv4OZZKGRadCDjphb1Vm+8VD7SUcRw+fO3+8QgUVm98pXybhDsnwXrQMB5vp1HQGIV6wUJ4LqHKVx+p2gZYO0WlM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fp5i5WSN; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fp5i5WSN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740042612; x=1771578612; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ap06RU9lK+93Lg6AqAUmYtxQbCvi2WxR1WXqtk+05uc=; b=fp5i5WSNM61f11f/nPVwqJAQ74IKg9gcxJTa8Z65bztuhCUiz/b94pvh 9Qsbf/JuCvyj75kV2wz7uDxxGO8lyTtNm8zzI3hx6HyLN8I6JQ8ba769V Zo07o4VV+oMLUGuCjln6cLV9z6CjcqUGl8mtIQHdmVUAg3hJw2xIrt0GT VQVqcXk3MkU8xtX8pIYHKeSwYYy62P8nI+xlRIAN/NcLzM5GS+s0L74Bb ORfezw0/I0rISFVyVSPTLm/eP66Jm5bBVUUxyKrXIuWrzIcHrEEZQZW+T ufxoBXXytwiHQvqulJ16uYesV7yP2WcNKckKZPODozZhJgIe1Tj7B8V4J Q==; X-CSE-ConnectionGUID: /VvubdtVRp6DPz2rb4VAEg== X-CSE-MsgGUID: 38JcGGoZQXmbFeUwEvEaBQ== X-IronPort-AV: E=McAfee;i="6700,10204,11350"; a="40733518" X-IronPort-AV: E=Sophos;i="6.13,301,1732608000"; d="scan'208";a="40733518" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2025 01:10:12 -0800 X-CSE-ConnectionGUID: LZK3BoBqRy2EHG8UiAlviA== X-CSE-MsgGUID: gjLrkeyTRreDuiUtlW6hYQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,301,1732608000"; d="scan'208";a="120084570" Received: from brc05.iind.intel.com (HELO brc05..) ([10.190.162.156]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2025 01:10:08 -0800 From: Tushar Vyavahare To: bpf@vger.kernel.org Cc: netdev@vger.kernel.org, bjorn@kernel.org, magnus.karlsson@intel.com, maciej.fijalkowski@intel.com, jonathan.lemon@gmail.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net, tushar.vyavahare@intel.com Subject: [PATCH bpf-next 3/6] selftests/xsk: Add testapp_xdp_adjust_tail function to userspace for packet tail adjustment Date: Thu, 20 Feb 2025 08:41:44 +0000 Message-Id: <20250220084147.94494-4-tushar.vyavahare@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250220084147.94494-1-tushar.vyavahare@intel.com> References: <20250220084147.94494-1-tushar.vyavahare@intel.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net This commit adds the testapp_xdp_adjust_tail function in the userspace code. The function is responsible for adjusting the tail of packets using the xsk_xdp_adjust_tail XDP program. The function performs the following tasks: 1. Retrieves the XDP program objects (skel_rx and skel_tx) from the test_spec structure. 2. Finds the bpf_map for the XDP program's bss section. 3. Updates the 'count' variable in the XDP program's bss section with the provided adjust_value. 4. Sets the XDP program (xsk_xdp_adjust_tail) for both RX and TX interfaces using test_spec_set_xdp_prog. 5. Calls testapp_validate_traffic to validate the traffic after adjusting the packet tail. This function allows testing and validating the XDP program's behavior when adjusting the packet tail using the bpf_xdp_adjust_tail helper function. Signed-off-by: Tushar Vyavahare --- tools/testing/selftests/bpf/xskxceiver.c | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index 1d9b03666ee6..ff3316f6174e 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -2518,6 +2518,31 @@ static int testapp_hw_sw_max_ring_size(struct test_spec *test) return testapp_validate_traffic(test); } +static int testapp_xdp_adjust_tail(struct test_spec *test, int count) +{ + struct xsk_xdp_progs *skel_rx = test->ifobj_rx->xdp_progs; + struct xsk_xdp_progs *skel_tx = test->ifobj_tx->xdp_progs; + struct bpf_map *data_map; + int key = 0; + + test_spec_set_xdp_prog(test, skel_rx->progs.xsk_xdp_adjust_tail, + skel_tx->progs.xsk_xdp_adjust_tail, + skel_rx->maps.xsk, skel_tx->maps.xsk); + + data_map = bpf_object__find_map_by_name(skel_rx->obj, "xsk_xdp_.bss"); + if (!data_map || !bpf_map__is_internal(data_map)) { + ksft_print_msg("Error: could not find bss section of XDP program\n"); + return TEST_FAILURE; + } + + if (bpf_map_update_elem(bpf_map__fd(data_map), &key, &count, BPF_ANY)) { + ksft_print_msg("Error: could not update count element\n"); + return TEST_FAILURE; + } + + return testapp_validate_traffic(test); +} + static void run_pkt_test(struct test_spec *test) { int ret; From patchwork Thu Feb 20 08:41:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Vyavahare X-Patchwork-Id: 13983523 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FF6F1E9B30; Thu, 20 Feb 2025 09:10:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740042616; cv=none; b=gV28A1kJFOvU1N/jZc1fPiGuwPPsl7qzrjeqTALq5o2CPQoSrV7JrSGdBYLnpxFOeK9TgaYQaPMhIx+QKCiOaf0Dk4VJGPI96a6nWg26BiXtq8x4p1yk7oB5FwpbcHHyL0D5lS9NrWan9LZRtsLJ4ExrqJAn3xnBp1b1LfSqses= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740042616; c=relaxed/simple; bh=vTo4jqO2u9FWy+M1kTIwSjNDnk6sQfDFNVfziDDlhYQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JRI9WG0g9kQrHjR4Pp3DczFKJzDLS56CZaLDofacMlRBYX4+lZACZTRTmAhIJhgQf/HVcchpUB95pDAlsYrZ3v4Su1Gr5E5/+XzqCvkGo2R2MO0tQVC5RKwA9DWtsSJZ36Iw7blF8JXOa5cW/40382yOeU50szD9UT28FJ7q4pY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Zp9pW3s/; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Zp9pW3s/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740042616; x=1771578616; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vTo4jqO2u9FWy+M1kTIwSjNDnk6sQfDFNVfziDDlhYQ=; b=Zp9pW3s/Kxa/EQbhFAPwqPNA43eH993gfD78+i+rP7ESqiZrokNZg1Xm fb+WvyF1OAmdI+lJDUo05QBu49qKQ27y39TZwQNNGTUgtrGfuy8dGSCnw tRo7Ru8k3FvZp0cgEvzraj32qf2jovyNH8uDjzGKgxiQ5iQKRLY5qNVH6 HjvWwlo+8wQ6A7nQyqbsaUfFdIZkDNLdqgCxdzxFnrDN+9GDNaPOkFECd U1Wwt+v8GqrMMs+n6MetqvswWquLbm3JZPq4PgA6N/86DY99jjgQjaIBx SJsXbbKNRN/NzlH4mqpQrJygUi5XMMX/40AQ7zDjZk0nLPghx5xXsmdXn g==; X-CSE-ConnectionGUID: vJOOSb6KR6y/H6l6CH4VDQ== X-CSE-MsgGUID: j1NBPoeGT0KcfK1yyyyelA== X-IronPort-AV: E=McAfee;i="6700,10204,11350"; a="40733532" X-IronPort-AV: E=Sophos;i="6.13,301,1732608000"; d="scan'208";a="40733532" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2025 01:10:15 -0800 X-CSE-ConnectionGUID: /okReAK9TAyqzp89tPoY3g== X-CSE-MsgGUID: Cngx8xvRQ0+17tL4INnGdQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,301,1732608000"; d="scan'208";a="120084575" Received: from brc05.iind.intel.com (HELO brc05..) ([10.190.162.156]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2025 01:10:11 -0800 From: Tushar Vyavahare To: bpf@vger.kernel.org Cc: netdev@vger.kernel.org, bjorn@kernel.org, magnus.karlsson@intel.com, maciej.fijalkowski@intel.com, jonathan.lemon@gmail.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net, tushar.vyavahare@intel.com Subject: [PATCH bpf-next 4/6] selftests/xsk: Add support check for bpf_xdp_adjust_tail() helper in xskxceiver Date: Thu, 20 Feb 2025 08:41:45 +0000 Message-Id: <20250220084147.94494-5-tushar.vyavahare@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250220084147.94494-1-tushar.vyavahare@intel.com> References: <20250220084147.94494-1-tushar.vyavahare@intel.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Add is_adjust_tail_supported function to check if the bpf_xdp_adjust_tail() helper is supported when 'adjust_tail' is set in the test. Look up a specific key in the bss section of the XDP program. If the key is not found or its value is -EOPNOTSUPP, return false, indicating that the helper is not supported. Signed-off-by: Tushar Vyavahare --- tools/testing/selftests/bpf/xskxceiver.c | 36 ++++++++++++++++++++++-- tools/testing/selftests/bpf/xskxceiver.h | 2 ++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index ff3316f6174e..ccf35b73418b 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -524,6 +524,8 @@ static void __test_spec_init(struct test_spec *test, struct ifobject *ifobj_tx, test->nb_sockets = 1; test->fail = false; test->set_ring = false; + test->adjust_tail = false; + test->adjust_tail_support = false; test->mtu = MAX_ETH_PKT_SIZE; test->xdp_prog_rx = ifobj_rx->xdp_progs->progs.xsk_def_prog; test->xskmap_rx = ifobj_rx->xdp_progs->maps.xsk; @@ -992,6 +994,31 @@ static bool is_metadata_correct(struct pkt *pkt, void *buffer, u64 addr) return true; } +static bool is_adjust_tail_supported(struct xsk_xdp_progs *skel_rx) +{ + struct bpf_map *data_map; + int value = 0; + int key = 0; + int ret; + + data_map = bpf_object__find_map_by_name(skel_rx->obj, "xsk_xdp_.bss"); + if (!data_map || !bpf_map__is_internal(data_map)) { + ksft_print_msg("Error: could not find bss section of XDP program\n"); + exit_with_error(errno); + } + + ret = bpf_map_lookup_elem(bpf_map__fd(data_map), &key, &value); + if (ret) { + ksft_print_msg("Error: bpf_map_lookup_elem failed with error %d\n", ret); + return false; + } + + /* Set the 'count' variable to -EOPNOTSUPP in the XDP program if the adjust_tail helper is + * not supported. Skip the adjust_tail test case in this scenario. + */ + return value != -EOPNOTSUPP; +} + static bool is_frag_valid(struct xsk_umem_info *umem, u64 addr, u32 len, u32 expected_pkt_nb, u32 bytes_processed) { @@ -1768,8 +1795,13 @@ static void *worker_testapp_validate_rx(void *arg) if (!err && ifobject->validation_func) err = ifobject->validation_func(ifobject); - if (err) - report_failure(test); + + if (err) { + if (test->adjust_tail && !is_adjust_tail_supported(ifobject->xdp_progs)) + test->adjust_tail_support = false; + else + report_failure(test); + } pthread_exit(NULL); } diff --git a/tools/testing/selftests/bpf/xskxceiver.h b/tools/testing/selftests/bpf/xskxceiver.h index e46e823f6a1a..67fc44b2813b 100644 --- a/tools/testing/selftests/bpf/xskxceiver.h +++ b/tools/testing/selftests/bpf/xskxceiver.h @@ -173,6 +173,8 @@ struct test_spec { u16 nb_sockets; bool fail; bool set_ring; + bool adjust_tail; + bool adjust_tail_support; enum test_mode mode; char name[MAX_TEST_NAME_SIZE]; }; From patchwork Thu Feb 20 08:41:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Vyavahare X-Patchwork-Id: 13983524 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEA501F03C7; Thu, 20 Feb 2025 09:10:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740042620; cv=none; b=Mw3leyzT8jj/LevjdZNKa2DN8ZaavKZBt61aEybney8uLV/rhFMF+BOpHevcm5vlkm0yafE/aal8Ar2T+yT6q9s2umlko/R6fWJF0u+/61m++WdI03+AwtYsvzhAWN8Lg+KJXtbtFoTM0MTMfLbdPTJlQyX/VXuiHB+OU9uAWLU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740042620; c=relaxed/simple; bh=oaNG+MnBFlX2IjQboZYU9Xa0t64UQTXamM3hMilbGLk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jOb8ykQ4z/AhkY8rFjjHDe1dP6zie+ODu3w3/wfqgpTfkGcj1QSNUCymmj3FT/ipXw7GlzA7wE53dtA8cQtY8kyVuIXqm3gRFpF8fhKwpbVdT8/4MaMOebVshOmaAHMo9p+jIRn/Q4J+8qid6fwjgf+ddaBMUqxfubr2ZuThVgc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=bTYUWDJh; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bTYUWDJh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740042619; x=1771578619; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oaNG+MnBFlX2IjQboZYU9Xa0t64UQTXamM3hMilbGLk=; b=bTYUWDJhdG4+65oQAwCVwvY7p/bVg2BbIKV0s4skDlOZbCgTmZti5uhA 1B7+E/5z9AAs/DikDS4sxs1c0HUWcGHW8tuK5TKphJ2q3qJGtGzzo4kSK +Z1s8IYjSMKLSwL3lx0bE50zEdcOij38mn0ZV4av20+NRhtMFty1Klz4b AJfnbtcxGpNaaTAhujleSWOVSz/K3tunw77FwKPJD5Bg6+90z1S7huUgN FVrBZnm8ZvlagNs198MCpvmOSE7MJIC3yWgtha82uIIMgUW62YpjeIetd KbfVCx8ZxV20MoqVm0k2FKnmL6NSUiZN8db6CFYAUTcGy8VnKuE+0uV+v A==; X-CSE-ConnectionGUID: yqWhADG5T0aOiB5OfvtbPw== X-CSE-MsgGUID: aB1VxxrLRvOdRP1GAtm1zw== X-IronPort-AV: E=McAfee;i="6700,10204,11350"; a="40733542" X-IronPort-AV: E=Sophos;i="6.13,301,1732608000"; d="scan'208";a="40733542" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2025 01:10:19 -0800 X-CSE-ConnectionGUID: q8yh1Ze4QIarKmC02uCY0g== X-CSE-MsgGUID: 1nXxnU0wQH2IdiMhbEl8IQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,301,1732608000"; d="scan'208";a="120084581" Received: from brc05.iind.intel.com (HELO brc05..) ([10.190.162.156]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2025 01:10:15 -0800 From: Tushar Vyavahare To: bpf@vger.kernel.org Cc: netdev@vger.kernel.org, bjorn@kernel.org, magnus.karlsson@intel.com, maciej.fijalkowski@intel.com, jonathan.lemon@gmail.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net, tushar.vyavahare@intel.com Subject: [PATCH bpf-next 5/6] selftests/xsk: Implement packet resizing test with bpf_xdp_adjust_tail Date: Thu, 20 Feb 2025 08:41:46 +0000 Message-Id: <20250220084147.94494-6-tushar.vyavahare@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250220084147.94494-1-tushar.vyavahare@intel.com> References: <20250220084147.94494-1-tushar.vyavahare@intel.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Implement a packet resizing test using the bpf_xdp_adjust_tail() function. Add the testapp_adjust_tail function to test packet resizing capabilities. Replace packet streams for both transmit and receive with adjusted lengths. Include logic to skip the test if bpf_xdp_adjust_tail is not supported. Update the test framework to handle various packet resizing scenarios. Signed-off-by: Tushar Vyavahare --- tools/testing/selftests/bpf/xskxceiver.c | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index ccf35b73418b..52ce0217d3d5 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -2575,6 +2575,31 @@ static int testapp_xdp_adjust_tail(struct test_spec *test, int count) return testapp_validate_traffic(test); } +static int testapp_adjust_tail(struct test_spec *test, u32 value, u32 pkt_len) +{ + u32 pkt_cnt = DEFAULT_BATCH_SIZE; + int ret; + + test->adjust_tail_support = true; + test->adjust_tail = true; + test->total_steps = 1; + + pkt_stream_replace(test->ifobj_tx, pkt_cnt, pkt_len); + pkt_stream_replace(test->ifobj_rx, pkt_cnt, pkt_len + value); + + ret = testapp_xdp_adjust_tail(test, value); + if (ret) + return ret; + + if (!test->adjust_tail_support) { + ksft_test_result_skip("%s %sResize pkt with bpf_xdp_adjust_tail() not supported\n", + mode_string(test), busy_poll_string(test)); + return TEST_SKIP; + } + + return 0; +} + static void run_pkt_test(struct test_spec *test) { int ret; From patchwork Thu Feb 20 08:41:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Vyavahare X-Patchwork-Id: 13983525 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 631571EA7EA; Thu, 20 Feb 2025 09:10:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740042623; cv=none; b=F3VnsoRWcDQo6pKrg8aHEtM52T//puHSPXfJL3qV6zKZVR4BFsG5CWd35qKnH7V5wT2pU3ridciVwLj/tjaj38K5LhcjQChcP99quu+Dtdmua1MIu8rEOamOu07snCtiCZkhcUk86KaOpQlQX5dd1s4KwAat1gXffkkWB/OUnwQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740042623; c=relaxed/simple; bh=KXJG1gcD6dEpOZizSd+f6lNxkAX7x7A5ASaYgh4OlhY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C6k/YOzzbPRv31Te7xhglrZoqFT68krsyvzDXqOBRE6wHxKp64PwgsWyDd9ASeTfnhIe4uf0dlfbqGEsRNq3+hb9DMmKKvC+sWfEAmuKDS1W2KWsxaLAPEbEE/ER3DhduAf6iA696xPOEGR5+N9o55vyQVTqqcrUvFT/ZX+Euh8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FoMCbTxk; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FoMCbTxk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740042623; x=1771578623; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KXJG1gcD6dEpOZizSd+f6lNxkAX7x7A5ASaYgh4OlhY=; b=FoMCbTxkmmD4fgUhRBFamQV2NZ0UMTpiAyRWoPuUi5AUVlEQSfACucxO Cwxyx329vIHNzmgPipvISTRzLNu1mZz4QkTqJvSFjjz6ZqIf+9u0PYbYB h4wAJxeWRYpLsgBSS1GPKloimcgmY5oNa2+MNTUUGVbOPeSKkpu9ugHU3 MUE1wXV3E/pNY9dkyHq5OYHcDhxMVxI5phutbE82hlbDhus/D4yajy0q1 xxT6TvLI3+MY8h8B2X1oqo4LlpUPzcFlLv+2zhkXn8AM6aOGKb7K0FujY gAowqWEONJeg+THYGuRlgnbAZozC/kYZu/JPzRvwWDsC4c8SGLlSymNNV Q==; X-CSE-ConnectionGUID: r7yc3/wOTK+DzOx/mZNZSw== X-CSE-MsgGUID: 5Ex332JoQf+AUo98e3q8iw== X-IronPort-AV: E=McAfee;i="6700,10204,11350"; a="40733549" X-IronPort-AV: E=Sophos;i="6.13,301,1732608000"; d="scan'208";a="40733549" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2025 01:10:23 -0800 X-CSE-ConnectionGUID: EV+HLZuAS1irpmB2g6ibSQ== X-CSE-MsgGUID: ksRbIP7kQv65pRKpPBt9fw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,301,1732608000"; d="scan'208";a="120084585" Received: from brc05.iind.intel.com (HELO brc05..) ([10.190.162.156]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2025 01:10:19 -0800 From: Tushar Vyavahare To: bpf@vger.kernel.org Cc: netdev@vger.kernel.org, bjorn@kernel.org, magnus.karlsson@intel.com, maciej.fijalkowski@intel.com, jonathan.lemon@gmail.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net, tushar.vyavahare@intel.com Subject: [PATCH bpf-next 6/6] selftests/xsk: Add packet resizing tests with bpf_xdp_adjust_tail for AF_XDP Date: Thu, 20 Feb 2025 08:41:47 +0000 Message-Id: <20250220084147.94494-7-tushar.vyavahare@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250220084147.94494-1-tushar.vyavahare@intel.com> References: <20250220084147.94494-1-tushar.vyavahare@intel.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Add packet resizing tests using the bpf_xdp_adjust_tail()function within the AF_XDP framework. Implement testapp_adjust_tail_common() to handle common logic for packet resizing tests, streamlining the testing process. Allow setting MTU to MAX_ETH_JUMBO_SIZE for specific tests. Implement testapp_adjust_tail_shrink() and testapp_adjust_tail_shrink_mb() to test shrinking packets, including multi-buffer scenarios, under AF_XDP. Implement testapp_adjust_tail_grow() and testapp_adjust_tail_grow_mb() to test growing packets within the AF_XDP context, utilizing the common logic function for consistency and efficiency. Signed-off-by: Tushar Vyavahare --- tools/testing/selftests/bpf/xskxceiver.c | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index 52ce0217d3d5..36f32b7ef31d 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -2600,6 +2600,34 @@ static int testapp_adjust_tail(struct test_spec *test, u32 value, u32 pkt_len) return 0; } +static int testapp_adjust_tail_common(struct test_spec *test, int adjust_value, u32 len, + bool set_mtu) +{ + if (set_mtu) + test->mtu = MAX_ETH_JUMBO_SIZE; + return testapp_adjust_tail(test, adjust_value, len); +} + +static int testapp_adjust_tail_shrink(struct test_spec *test) +{ + return testapp_adjust_tail_common(test, -4, MIN_PKT_SIZE, false); +} + +static int testapp_adjust_tail_shrink_mb(struct test_spec *test) +{ + return testapp_adjust_tail_common(test, -4, XSK_RING_PROD__DEFAULT_NUM_DESCS * 3, true); +} + +static int testapp_adjust_tail_grow(struct test_spec *test) +{ + return testapp_adjust_tail_common(test, 4, MIN_PKT_SIZE, false); +} + +static int testapp_adjust_tail_grow_mb(struct test_spec *test) +{ + return testapp_adjust_tail_common(test, 4, XSK_RING_PROD__DEFAULT_NUM_DESCS * 3, true); +} + static void run_pkt_test(struct test_spec *test) { int ret; @@ -2706,6 +2734,10 @@ static const struct test_spec tests[] = { {.name = "TOO_MANY_FRAGS", .test_func = testapp_too_many_frags}, {.name = "HW_SW_MIN_RING_SIZE", .test_func = testapp_hw_sw_min_ring_size}, {.name = "HW_SW_MAX_RING_SIZE", .test_func = testapp_hw_sw_max_ring_size}, + {.name = "XDP_ADJUST_TAIL_SHRINK", .test_func = testapp_adjust_tail_shrink}, + {.name = "XDP_ADJUST_TAIL_SHRINK_MULTI_BUFF", .test_func = testapp_adjust_tail_shrink_mb}, + {.name = "XDP_ADJUST_TAIL_GROW", .test_func = testapp_adjust_tail_grow}, + {.name = "XDP_ADJUST_TAIL_GROW_MULTI_BUFF", .test_func = testapp_adjust_tail_grow_mb}, }; static void print_tests(void)