From patchwork Fri Mar 15 14:07:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Vyavahare X-Patchwork-Id: 13593509 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 175B8376FD; Fri, 15 Mar 2024 14:23:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710512609; cv=none; b=DOBRaK9rkQa2cE/OfV8mF67HVeJdz04bSP5VIQlaWpuQoSCXaWBBQogaKZJ0gWSR3Vxq4XbYGIWYeZCVJdx81HWG1tfMLvL3049T08JCe0flHXRctICpMppMmZlwmImJAZhu/u756Szc9V5Gxt4ihHRYR/OK8KUB6lT6I97qLiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710512609; c=relaxed/simple; bh=40Hxx4syLLyCO8G2kvw405E+QkvnKe9kxiKCITRd31s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CybmM+58xP3XSkNvRVXSiVUd1FMtjaC4HKtuWnlM9nSGtIXgeX4lu3BVtqm7ynhn6aXDhE4Vnd4iJJPZOLJbq3EB5EMpgR0JAU6skCUhRsNTvvzB+9YEOhpWxWlV1n/ADPd+m6O8xljxXykC+/FiRJr2GfqcfjqcjebmGNgRFkM= 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=Vr41/Am5; arc=none smtp.client-ip=198.175.65.19 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="Vr41/Am5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710512608; x=1742048608; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=40Hxx4syLLyCO8G2kvw405E+QkvnKe9kxiKCITRd31s=; b=Vr41/Am5GMPiDQdwFtytLEaFlllfLL4zd4+J7iV4zSrAp5fwj5U4IyiU xViHX08vdyXeJO31vXWbSHxyqcDgAHrYTprALxMF9Dzq/AsLZm/jOHs5k 8bKqLB6lfSaaaiY6pYIBA11K+CWoyMD147SiA+zCgIn8kH722UczZmUtg wZsvv++Gphsqew6VM9Z6AaTylEwzLfN4LCn6RONeWkEcwp7xHI10Rl3oI 6Gm3U0riAKzBmBkNkuH1scM/WsxWHsuPSGLWOXXQKpRf62Ic6dQESEWrC OXz8CQ7hjN3neNelww8vLWsKPSBQwEihva07yVTwkFi5w5RbpobfG5Mrn w==; X-IronPort-AV: E=McAfee;i="6600,9927,11013"; a="5250015" X-IronPort-AV: E=Sophos;i="6.07,128,1708416000"; d="scan'208";a="5250015" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2024 07:23:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,128,1708416000"; d="scan'208";a="17140742" Received: from intel.iind.intel.com (HELO brc5..) ([10.190.162.156]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2024 07:23:24 -0700 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, tirthendu.sarkar@intel.com, tushar.vyavahare@intel.com Subject: [PATCH bpf-next 1/6] tools/include: add ethtool_ringparam definition to UAPI header Date: Fri, 15 Mar 2024 14:07:21 +0000 Message-Id: <20240315140726.22291-2-tushar.vyavahare@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240315140726.22291-1-tushar.vyavahare@intel.com> References: <20240315140726.22291-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 the definition for ethtool_ringparam in the UAPI header located in the include directory. This is needed by the next patches as they run tests with various ring sizes. Signed-off-by: Tushar Vyavahare --- tools/include/uapi/linux/ethtool.h | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tools/include/uapi/linux/ethtool.h b/tools/include/uapi/linux/ethtool.h index 47afae3895ec..570afcd15bca 100644 --- a/tools/include/uapi/linux/ethtool.h +++ b/tools/include/uapi/linux/ethtool.h @@ -101,4 +101,45 @@ struct ethtool_drvinfo { #define ETHTOOL_GDRVINFO 0x00000003 +/** + * struct ethtool_ringparam - RX/TX ring parameters + * @cmd: Command number = %ETHTOOL_GRINGPARAM or %ETHTOOL_SRINGPARAM + * @rx_max_pending: Maximum supported number of pending entries per + * RX ring. Read-only. + * @rx_mini_max_pending: Maximum supported number of pending entries + * per RX mini ring. Read-only. + * @rx_jumbo_max_pending: Maximum supported number of pending entries + * per RX jumbo ring. Read-only. + * @tx_max_pending: Maximum supported number of pending entries per + * TX ring. Read-only. + * @rx_pending: Current maximum number of pending entries per RX ring + * @rx_mini_pending: Current maximum number of pending entries per RX + * mini ring + * @rx_jumbo_pending: Current maximum number of pending entries per RX + * jumbo ring + * @tx_pending: Current maximum supported number of pending entries + * per TX ring + * + * If the interface does not have separate RX mini and/or jumbo rings, + * @rx_mini_max_pending and/or @rx_jumbo_max_pending will be 0. + * + * There may also be driver-dependent minimum values for the number + * of entries per ring. + */ + +struct ethtool_ringparam { + __u32 cmd; + __u32 rx_max_pending; + __u32 rx_mini_max_pending; + __u32 rx_jumbo_max_pending; + __u32 tx_max_pending; + __u32 rx_pending; + __u32 rx_mini_pending; + __u32 rx_jumbo_pending; + __u32 tx_pending; +}; + +#define ETHTOOL_GRINGPARAM 0x00000010 /* Get ring parameters. */ +#define ETHTOOL_SRINGPARAM 0x00000011 /* Set ring parameters. */ + #endif /* _UAPI_LINUX_ETHTOOL_H */ From patchwork Fri Mar 15 14:07:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Vyavahare X-Patchwork-Id: 13593510 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 C759739875; Fri, 15 Mar 2024 14:23:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710512615; cv=none; b=Zrv6KDCCtpscZanQ6UAV3ZwavieYje98dNFhd7N2A1IrzGSHRIS0KKYZ+n8Q/BeUFgB/Z1lXHGSv9BhaS/7ZBlTjJFQ8RWbHLek8mfGdsYp8jQYUYaXtBsZvwOptaz5hUqAFYcH92o/ft/yUObvT4xo/9iv8kpX3nAo4VUep7eY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710512615; c=relaxed/simple; bh=hBmhM4yNE9bIwRPkbyIQxY1VuKDep4BXHxhqAzHSN3c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Hi2BrsL5XNDJZ0zu7HsmqsdshPEC73ldslkhWcw/qVIXpLCrMoDPPQ9Q3TKXg0il4QFlNzdpZ2ODRbuIIGCOj29ogQR+CSthmptn8vFjBzp3k/+wXmc1QePy6Yo822bizKBLxbm80B5hcn110t6VvrRjHXer4skVP3FWmc1aDqY= 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=VWKuwvN8; arc=none smtp.client-ip=198.175.65.19 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="VWKuwvN8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710512613; x=1742048613; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hBmhM4yNE9bIwRPkbyIQxY1VuKDep4BXHxhqAzHSN3c=; b=VWKuwvN8UeJJHN1naRQqrBxr+xaLX0NtJL69n24VuDUBaZ2GAIB0lQen L+PeiXTmk8YnK5PUBy9ZV5lZ1cR0awFeAjixC0Ee3XdBVXUChbM4ZPM+/ slfvt3EJvi/90GnMW+OByIEGUpJF5IlN/pYFktLPyj6fCZU+geSRuGWvD 0WT5qnSUCzuDsGtq4eWl4/PkeBQi1RP/jPB/Lnu65neJuBxBUqa8QXonf KrRdDMJLMgT7XY0rVljvJUQGWOUva/rPN2nwldLl4qThLga/ybjFz/sKR RSbRz+eBGjpoGc7R6HfLDQn7GpwZJW0kLjGzVsaweRG0qknF1buCNxtyv g==; X-IronPort-AV: E=McAfee;i="6600,9927,11013"; a="5250030" X-IronPort-AV: E=Sophos;i="6.07,128,1708416000"; d="scan'208";a="5250030" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2024 07:23:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,128,1708416000"; d="scan'208";a="17140746" Received: from intel.iind.intel.com (HELO brc5..) ([10.190.162.156]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2024 07:23:28 -0700 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, tirthendu.sarkar@intel.com, tushar.vyavahare@intel.com Subject: [PATCH bpf-next 2/6] selftests/xsk: make batch size variable Date: Fri, 15 Mar 2024 14:07:22 +0000 Message-Id: <20240315140726.22291-3-tushar.vyavahare@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240315140726.22291-1-tushar.vyavahare@intel.com> References: <20240315140726.22291-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 Convert the constant BATCH_SIZE into a variable named batch_size to allow dynamic modification at runtime. This is required for the forthcoming changes to support testing different hardware ring sizes. While running these tests, a bug [1] was identified when the batch size is roughly the same as the NIC ring size. This has now been addressed by Maciej's fix. [1] https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=913eda2b08cc49d31f382579e2be34c2709eb789 Signed-off-by: Tushar Vyavahare --- tools/testing/selftests/bpf/xskxceiver.c | 20 +++++++++++--------- tools/testing/selftests/bpf/xskxceiver.h | 3 ++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index b1102ee13faa..eaa102c8098b 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -239,7 +239,7 @@ static void enable_busy_poll(struct xsk_socket_info *xsk) (void *)&sock_opt, sizeof(sock_opt)) < 0) exit_with_error(errno); - sock_opt = BATCH_SIZE; + sock_opt = xsk->batch_size; if (setsockopt(xsk_socket__fd(xsk->xsk), SOL_SOCKET, SO_BUSY_POLL_BUDGET, (void *)&sock_opt, sizeof(sock_opt)) < 0) exit_with_error(errno); @@ -439,6 +439,7 @@ static void __test_spec_init(struct test_spec *test, struct ifobject *ifobj_tx, for (j = 0; j < MAX_SOCKETS; j++) { memset(&ifobj->xsk_arr[j], 0, sizeof(ifobj->xsk_arr[j])); ifobj->xsk_arr[j].rxqsize = XSK_RING_CONS__DEFAULT_NUM_DESCS; + ifobj->xsk_arr[j].batch_size = DEFAULT_BATCH_SIZE; if (i == 0) ifobj->xsk_arr[j].pkt_stream = test->tx_pkt_stream_default; else @@ -1087,7 +1088,7 @@ static int __receive_pkts(struct test_spec *test, struct xsk_socket_info *xsk) return TEST_CONTINUE; } - rcvd = xsk_ring_cons__peek(&xsk->rx, BATCH_SIZE, &idx_rx); + rcvd = xsk_ring_cons__peek(&xsk->rx, xsk->batch_size, &idx_rx); if (!rcvd) return TEST_CONTINUE; @@ -1239,7 +1240,8 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk, b buffer_len = pkt_get_buffer_len(umem, pkt_stream->max_pkt_len); /* pkts_in_flight might be negative if many invalid packets are sent */ - if (pkts_in_flight >= (int)((umem_size(umem) - BATCH_SIZE * buffer_len) / buffer_len)) { + if (pkts_in_flight >= (int)((umem_size(umem) - xsk->batch_size * buffer_len) / + buffer_len)) { ret = kick_tx(xsk); if (ret) return TEST_FAILURE; @@ -1249,7 +1251,7 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk, b fds.fd = xsk_socket__fd(xsk->xsk); fds.events = POLLOUT; - while (xsk_ring_prod__reserve(&xsk->tx, BATCH_SIZE, &idx) < BATCH_SIZE) { + while (xsk_ring_prod__reserve(&xsk->tx, xsk->batch_size, &idx) < xsk->batch_size) { if (use_poll) { ret = poll(&fds, 1, POLL_TMOUT); if (timeout) { @@ -1269,10 +1271,10 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk, b } } - complete_pkts(xsk, BATCH_SIZE); + complete_pkts(xsk, xsk->batch_size); } - for (i = 0; i < BATCH_SIZE; i++) { + for (i = 0; i < xsk->batch_size; i++) { struct pkt *pkt = pkt_stream_get_next_tx_pkt(pkt_stream); u32 nb_frags_left, nb_frags, bytes_written = 0; @@ -1280,9 +1282,9 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk, b break; nb_frags = pkt_nb_frags(umem->frame_size, pkt_stream, pkt); - if (nb_frags > BATCH_SIZE - i) { + if (nb_frags > xsk->batch_size - i) { pkt_stream_cancel(pkt_stream); - xsk_ring_prod__cancel(&xsk->tx, BATCH_SIZE - i); + xsk_ring_prod__cancel(&xsk->tx, xsk->batch_size - i); break; } nb_frags_left = nb_frags; @@ -1370,7 +1372,7 @@ static int wait_for_tx_completion(struct xsk_socket_info *xsk) return TEST_FAILURE; } - complete_pkts(xsk, BATCH_SIZE); + complete_pkts(xsk, xsk->batch_size); } return TEST_PASS; diff --git a/tools/testing/selftests/bpf/xskxceiver.h b/tools/testing/selftests/bpf/xskxceiver.h index f174df2d693f..425304e52f35 100644 --- a/tools/testing/selftests/bpf/xskxceiver.h +++ b/tools/testing/selftests/bpf/xskxceiver.h @@ -44,7 +44,7 @@ #define MAX_ETH_JUMBO_SIZE 9000 #define USLEEP_MAX 10000 #define SOCK_RECONF_CTR 10 -#define BATCH_SIZE 64 +#define DEFAULT_BATCH_SIZE 64 #define POLL_TMOUT 1000 #define THREAD_TMOUT 3 #define DEFAULT_PKT_CNT (4 * 1024) @@ -91,6 +91,7 @@ struct xsk_socket_info { struct pkt_stream *pkt_stream; u32 outstanding_tx; u32 rxqsize; + u32 batch_size; u8 dst_mac[ETH_ALEN]; u8 src_mac[ETH_ALEN]; }; From patchwork Fri Mar 15 14:07:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Vyavahare X-Patchwork-Id: 13593511 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 5ED633A1B2; Fri, 15 Mar 2024 14:23:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710512619; cv=none; b=SW34x/G8XeWxwJQwergVycrafPrYLaJsmD2QdvlwwImX/884eBorlAfdw/+oH506lw97xNJMqQHZylBf21IE6D0cZ1JhmdXSkY3v/IhQ4I+gBkWZloN6TZTO29snaL5KEzKoxGNFDABoPklSuV6v5eBNwGd9JedsHKts4dkzXUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710512619; c=relaxed/simple; bh=RYogotB+lCiNsjmLNbwWGJ5R2aXrQ3ASR296p4smeus=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=e0fpPCTSi7ywRXsU2hZ0igZCpYIztt9f8jIzy6ZWQklsphtAwo8KzxDAOkhvp3KoJGUC5W0Lm79tiIQpCQtuWHLdlALQ5uOVWSA3A3BoJT04tzQ/YdKbjlNdDmKWbKprzPbqtGV8yvh62np6uIMFGMGnBg5FsA8Mlbzu0g0Jhqs= 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=dh+V/PaY; arc=none smtp.client-ip=198.175.65.19 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="dh+V/PaY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710512618; x=1742048618; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RYogotB+lCiNsjmLNbwWGJ5R2aXrQ3ASR296p4smeus=; b=dh+V/PaY1gBhjctIQTXGpdfD6vSBbsx7FHlohESOBHIxEZwGL3SlGWiw gwYPqglNVKTGwqPR/GucKdXG73d/o1oQYy4Vi9LgF2zrACXjXAWhAROJk E46teXAaEQI0GyAIsRMhe4h5YjEONRCE8TOFeynfOHiCjvju+IB96k+1p Fvk3bFdwnvN4kAhvUZ9p8i1AzmJvjd8fv/vcyhfXBpTOxTzocLV5sABM3 B52bWOqKWxJpaWTl5zKkUmE659HcYA9XeChQoZiTR9fdhw247P+2rECop Aa7Jr7A1RH/kb624gT++fv/+d6HffzC3isPMIi9KYA3+lnS6VDzrM0BiG g==; X-IronPort-AV: E=McAfee;i="6600,9927,11013"; a="5250054" X-IronPort-AV: E=Sophos;i="6.07,128,1708416000"; d="scan'208";a="5250054" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2024 07:23:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,128,1708416000"; d="scan'208";a="17140749" Received: from intel.iind.intel.com (HELO brc5..) ([10.190.162.156]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2024 07:23:33 -0700 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, tirthendu.sarkar@intel.com, tushar.vyavahare@intel.com Subject: [PATCH bpf-next 3/6] selftests/xsk: implement get_hw_ring_size function to retrieve current and max interface size Date: Fri, 15 Mar 2024 14:07:23 +0000 Message-Id: <20240315140726.22291-4-tushar.vyavahare@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240315140726.22291-1-tushar.vyavahare@intel.com> References: <20240315140726.22291-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 called get_hw_size that retrieves both the current and maximum size of the interface and stores this information in the 'hw_ring' structure. Signed-off-by: Tushar Vyavahare --- tools/testing/selftests/bpf/xskxceiver.c | 32 ++++++++++++++++++++++++ tools/testing/selftests/bpf/xskxceiver.h | 8 ++++++ 2 files changed, 40 insertions(+) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index eaa102c8098b..32005bfb9c9f 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -81,6 +81,8 @@ #include #include #include +#include +#include #include #include #include @@ -95,6 +97,7 @@ #include #include #include +#include #include #include "xsk_xdp_progs.skel.h" @@ -409,6 +412,35 @@ static void parse_command_line(struct ifobject *ifobj_tx, struct ifobject *ifobj } } +static int get_hw_ring_size(struct ifobject *ifobj) +{ + struct ethtool_ringparam ring_param = {0}; + struct ifreq ifr = {0}; + int sockfd; + + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd < 0) + return errno; + + memcpy(ifr.ifr_name, ifobj->ifname, sizeof(ifr.ifr_name)); + + ring_param.cmd = ETHTOOL_GRINGPARAM; + ifr.ifr_data = (char *)&ring_param; + + if (ioctl(sockfd, SIOCETHTOOL, &ifr) < 0) { + close(sockfd); + return errno; + } + + ifobj->ring.default_tx = ring_param.tx_pending; + ifobj->ring.default_rx = ring_param.rx_pending; + ifobj->ring.max_tx = ring_param.tx_max_pending; + ifobj->ring.max_rx = ring_param.rx_max_pending; + + close(sockfd); + return 0; +} + static void __test_spec_init(struct test_spec *test, struct ifobject *ifobj_tx, struct ifobject *ifobj_rx) { diff --git a/tools/testing/selftests/bpf/xskxceiver.h b/tools/testing/selftests/bpf/xskxceiver.h index 425304e52f35..4f58b70fa781 100644 --- a/tools/testing/selftests/bpf/xskxceiver.h +++ b/tools/testing/selftests/bpf/xskxceiver.h @@ -114,6 +114,13 @@ struct pkt_stream { bool verbatim; }; +struct hw_ring { + u32 default_tx; + u32 default_rx; + u32 max_tx; + u32 max_rx; +}; + struct ifobject; struct test_spec; typedef int (*validation_func_t)(struct ifobject *ifobj); @@ -130,6 +137,7 @@ struct ifobject { struct xsk_xdp_progs *xdp_progs; struct bpf_map *xskmap; struct bpf_program *xdp_prog; + struct hw_ring ring; enum test_mode mode; int ifindex; int mtu; From patchwork Fri Mar 15 14:07:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Vyavahare X-Patchwork-Id: 13593512 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 0004F3A28E; Fri, 15 Mar 2024 14:23:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710512623; cv=none; b=pSMRPlsOjIC5HADC0arANeBVTQoMYW8MVtzmCfFWquz9dgHilYAAq8OpPafmXWMliIVCupPo1VdMHpP5KJPIbgBT+/qSfrPjTx3cH3o446AzT91OnkmvpkvnYBN5kAnUuH5nzJxPHQ8R0qd2SqTKm88d54vasDPLaN77fqbRiEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710512623; c=relaxed/simple; bh=jg2PdJKQGB4u9Cr0VqX6IloO14S4i9A1AIMZyfPu+QI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BhWz3GgNVMamHNCidSt/mFTBeR2vsjL1ZYlxWC3wNy1+ys1su0GkZgWKIqVJrGDYPPVEIrojGmFcnG7MkVgbNa6bHoZlaVnqWouHNgCM7+GQ/5ZsqlIAbgvFuMwpoUoJOxy/faA04he8mSKnLHoqFQ8G7YLK9PTXkPgXCYQiUuk= 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=l8cjTbQD; arc=none smtp.client-ip=198.175.65.19 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="l8cjTbQD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710512622; x=1742048622; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jg2PdJKQGB4u9Cr0VqX6IloO14S4i9A1AIMZyfPu+QI=; b=l8cjTbQDcpjyrCjZsZukTMEjVQHMNRSHsfi94CZzLxne8sH+R/NSz88e zuhEUBV65+93WgJJuG/x/+Ou8M55+RYvYffSiKfH8B13qQsnO9FlyrahF vkCHyeCqaofdOx1SN4ES7a/v60seP3j+P4C4T7NXYCJb3rwPMDMuVYjOr /1USCfrl77ArEGBToxpmhEeLGmDJ+FO08GLuPpMgJ8rTdh7l78EcZUQiF I+dXZ2i190hTSkhjssSleW3GAlukr7ZLZshQOZ/CGuUcFuq7og0bStR99 UmvKmEDykFJmHH0RKfuCNfJatcArnzRXxC1AyDQBaF9NbQyB/Zomt83qX w==; X-IronPort-AV: E=McAfee;i="6600,9927,11013"; a="5250069" X-IronPort-AV: E=Sophos;i="6.07,128,1708416000"; d="scan'208";a="5250069" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2024 07:23:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,128,1708416000"; d="scan'208";a="17140754" Received: from intel.iind.intel.com (HELO brc5..) ([10.190.162.156]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2024 07:23:38 -0700 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, tirthendu.sarkar@intel.com, tushar.vyavahare@intel.com Subject: [PATCH bpf-next 4/6] selftests/xsk: implement set_hw_ring_size function to configure interface ring size Date: Fri, 15 Mar 2024 14:07:24 +0000 Message-Id: <20240315140726.22291-5-tushar.vyavahare@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240315140726.22291-1-tushar.vyavahare@intel.com> References: <20240315140726.22291-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 called set_hw_ring_size that allows for the dynamic configuration of the ring size within the interface. Signed-off-by: Tushar Vyavahare --- tools/testing/selftests/bpf/xskxceiver.c | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index 32005bfb9c9f..aafa78307586 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -441,6 +441,41 @@ static int get_hw_ring_size(struct ifobject *ifobj) return 0; } +static int set_hw_ring_size(struct ifobject *ifobj, u32 tx, u32 rx) +{ + struct ethtool_ringparam ring_param = {0}; + struct ifreq ifr = {0}; + int sockfd, ret; + u32 ctr = 0; + + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd < 0) + return errno; + + memcpy(ifr.ifr_name, ifobj->ifname, sizeof(ifr.ifr_name)); + + ring_param.tx_pending = tx; + ring_param.rx_pending = rx; + + ring_param.cmd = ETHTOOL_SRINGPARAM; + ifr.ifr_data = (char *)&ring_param; + + while (ctr++ < SOCK_RECONF_CTR) { + ret = ioctl(sockfd, SIOCETHTOOL, &ifr); + if (!ret) + break; + /* Retry if it fails */ + if (ctr >= SOCK_RECONF_CTR) { + close(sockfd); + return errno; + } + usleep(USLEEP_MAX); + } + + close(sockfd); + return 0; +} + static void __test_spec_init(struct test_spec *test, struct ifobject *ifobj_tx, struct ifobject *ifobj_rx) { From patchwork Fri Mar 15 14:07:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Vyavahare X-Patchwork-Id: 13593513 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 6D0183D575; Fri, 15 Mar 2024 14:23:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710512628; cv=none; b=f9uTMhiSmef9umZxFKS5MrbCzq/npTH3OfoMHGzmYNY/fwYoEe26d60kWE8Kq7jwB6xXpcWr0lbDK0jE0AK9Gr0FjYahvgZz4uDly5gwvCloUKygmBPk4CdbhZVPlxXeNt9gGvwE57ucsacSDc29YGcO54G7evsfuFCDMvk32zI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710512628; c=relaxed/simple; bh=IgxxG8teAX2Wi5yKO8lrW9VDFBr+MNwOs9XcX07ZWcA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WT7lt9G3Ica3ejL+LEpGCcrkFcI4hKbjFI3Nd420rhBsZTXb4z3YYgGu6xpldaddC/oQOGsBEwp/28fPMM0yiBhAf8pXRv/Iv4mUKogtsjOWCimmOcDy9OJSz7DX1L9Uus8Zl/lx2T/GQ2Xv6H/M1nsC/gaagEhME2mWfOvMCfw= 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=gyi1Nxnj; arc=none smtp.client-ip=198.175.65.19 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="gyi1Nxnj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710512627; x=1742048627; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IgxxG8teAX2Wi5yKO8lrW9VDFBr+MNwOs9XcX07ZWcA=; b=gyi1NxnjhN/ZU9B/8OJw1mVx3pFBfXpgdJaoXysAZo2J/dufiZlBLt0F xLepLTFuwoXXjg+ikkaOX5UCqPM/4NEU6RiEUb8y78CcQFyW98xkKb7/w 3/Aig3SCBLlNRbpOgfSojAWNwrgswVT9jh5xS8R2T52A9YbtxzvAWKctQ 8UaYkisLNEF/3NfmEMVCvNni758xnXSP8+N9yRIn/lhpHscfnB8sQFqL/ 5J4D4IJhgMs+kLwzDyWIwsbFxCmq9ZMztE8xRlQHf4bv/0tTG8aLZkdv4 XlYMZrdybxam2lskimqeYV+VHXIeDODdV+jm4AJl7LR2I4qRM+I7RgJgv g==; X-IronPort-AV: E=McAfee;i="6600,9927,11013"; a="5250092" X-IronPort-AV: E=Sophos;i="6.07,128,1708416000"; d="scan'208";a="5250092" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2024 07:23:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,128,1708416000"; d="scan'208";a="17140757" Received: from intel.iind.intel.com (HELO brc5..) ([10.190.162.156]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2024 07:23:42 -0700 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, tirthendu.sarkar@intel.com, tushar.vyavahare@intel.com Subject: [PATCH bpf-next 5/6] selftests/xsk: test AF_XDP functionality under minimal ring configurations Date: Fri, 15 Mar 2024 14:07:25 +0000 Message-Id: <20240315140726.22291-6-tushar.vyavahare@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240315140726.22291-1-tushar.vyavahare@intel.com> References: <20240315140726.22291-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 a new test case that stresses AF_XDP and the driver by configuring small hardware and software ring sizes. This verifies that AF_XDP continues to function properly even with insufficient ring space that could lead to frequent producer/consumer throttling. The test procedure involves: 1. Set the minimum possible ring configuration(tx 64 and rx 64). 2. Run tests with various batch sizes(1 and 63) to validate the system's behavior under different configurations. Signed-off-by: Tushar Vyavahare --- tools/testing/selftests/bpf/xskxceiver.c | 47 ++++++++++++++++++++++++ tools/testing/selftests/bpf/xskxceiver.h | 3 ++ 2 files changed, 50 insertions(+) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index aafa78307586..5326ca5c458c 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -476,6 +476,12 @@ static int set_hw_ring_size(struct ifobject *ifobj, u32 tx, u32 rx) return 0; } +static int hw_ring_size_reset(struct ifobject *ifobj) +{ + return set_hw_ring_size(ifobj, ifobj->ring.default_tx, + ifobj->ring.default_rx); +} + static void __test_spec_init(struct test_spec *test, struct ifobject *ifobj_tx, struct ifobject *ifobj_rx) { @@ -519,6 +525,9 @@ static void __test_spec_init(struct test_spec *test, struct ifobject *ifobj_tx, } } + if (ifobj_tx->hw_ring_size_supp) + hw_ring_size_reset(ifobj_tx); + test->ifobj_tx = ifobj_tx; test->ifobj_rx = ifobj_rx; test->current_step = 0; @@ -530,6 +539,8 @@ static void __test_spec_init(struct test_spec *test, struct ifobject *ifobj_tx, test->xskmap_rx = ifobj_rx->xdp_progs->maps.xsk; test->xdp_prog_tx = ifobj_tx->xdp_progs->progs.xsk_def_prog; test->xskmap_tx = ifobj_tx->xdp_progs->maps.xsk; + test->ifobj_tx->ring.set_tx = 0; + test->ifobj_tx->ring.set_rx = 0; } static void test_spec_init(struct test_spec *test, struct ifobject *ifobj_tx, @@ -1929,6 +1940,16 @@ static int testapp_validate_traffic(struct test_spec *test) return TEST_SKIP; } + if (ifobj_tx->ring.set_tx) { + if (ifobj_tx->hw_ring_size_supp) { + return set_hw_ring_size(ifobj_tx, ifobj_tx->ring.set_tx, + ifobj_tx->ring.set_rx); + } else { + ksft_test_result_skip("Changing HW ring size not supported.\n"); + return TEST_SKIP; + } + } + xsk_attach_xdp_progs(test, ifobj_rx, ifobj_tx); return __testapp_validate_traffic(test, ifobj_rx, ifobj_tx); } @@ -2442,6 +2463,23 @@ static int testapp_xdp_metadata_mb(struct test_spec *test) return testapp_xdp_metadata_copy(test); } +static int testapp_hw_sw_min_ring_size(struct test_spec *test) +{ + int ret; + + test->total_steps = 2; + test->ifobj_tx->ring.set_tx = DEFAULT_BATCH_SIZE; + test->ifobj_tx->ring.set_rx = DEFAULT_BATCH_SIZE; + test->ifobj_rx->xsk->batch_size = 1; + ret = testapp_validate_traffic(test); + if (ret) + return ret; + + /* Set batch size to hw_ring_size - 1 */ + test->ifobj_rx->xsk->batch_size = DEFAULT_BATCH_SIZE - 1; + return testapp_validate_traffic(test); +} + static void run_pkt_test(struct test_spec *test) { int ret; @@ -2546,6 +2584,7 @@ static const struct test_spec tests[] = { {.name = "ALIGNED_INV_DESC_MULTI_BUFF", .test_func = testapp_aligned_inv_desc_mb}, {.name = "UNALIGNED_INV_DESC_MULTI_BUFF", .test_func = testapp_unaligned_inv_desc_mb}, {.name = "TOO_MANY_FRAGS", .test_func = testapp_too_many_frags}, + {.name = "HW_SW_MIN_RING_SIZE", .test_func = testapp_hw_sw_min_ring_size}, }; static void print_tests(void) @@ -2566,6 +2605,7 @@ int main(int argc, char **argv) int modes = TEST_MODE_SKB + 1; struct test_spec test; bool shared_netdev; + int ret; /* Use libbpf 1.0 API mode */ libbpf_set_strict_mode(LIBBPF_STRICT_ALL); @@ -2603,6 +2643,10 @@ int main(int argc, char **argv) modes++; } + ret = get_hw_ring_size(ifobj_tx); + if (!ret) + ifobj_tx->hw_ring_size_supp = true; + init_iface(ifobj_rx, worker_testapp_validate_rx); init_iface(ifobj_tx, worker_testapp_validate_tx); @@ -2650,6 +2694,9 @@ int main(int argc, char **argv) } } + if (ifobj_tx->hw_ring_size_supp) + hw_ring_size_reset(ifobj_tx); + pkt_stream_delete(tx_pkt_stream_default); pkt_stream_delete(rx_pkt_stream_default); xsk_unload_xdp_programs(ifobj_tx); diff --git a/tools/testing/selftests/bpf/xskxceiver.h b/tools/testing/selftests/bpf/xskxceiver.h index 4f58b70fa781..21926672f877 100644 --- a/tools/testing/selftests/bpf/xskxceiver.h +++ b/tools/testing/selftests/bpf/xskxceiver.h @@ -119,6 +119,8 @@ struct hw_ring { u32 default_rx; u32 max_tx; u32 max_rx; + u32 set_tx; + u32 set_rx; }; struct ifobject; @@ -154,6 +156,7 @@ struct ifobject { bool unaligned_supp; bool multi_buff_supp; bool multi_buff_zc_supp; + bool hw_ring_size_supp; }; struct test_spec { From patchwork Fri Mar 15 14:07:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Vyavahare X-Patchwork-Id: 13593514 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 34B293FB1B; Fri, 15 Mar 2024 14:23:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710512632; cv=none; b=q6gbBWDdcqv+hG3klKRkMFgL6AUgJD3FAYgaAcJcXShiHVmW8+Wmru9MFgZkMFfSCdPoBbA9SnLLytK6dugcsh4QIytHe4mwTWDwgpiXlwdSDOOWkAhI/AW1gVagFoYYRlFfmwbbzA+Z0Nlgzu9KZnX4N/e8WvGGFkzbs/yLAUg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710512632; c=relaxed/simple; bh=ymtlPopoAK6IcVkhxWyn3VJniXSJJ6SOqftfCTa+nu0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LNsQwmcgWJr0ggpodRk3Tz3ZF2T2XoIr4E1qL1qiL++HkS4eErwEPPglpmmJ32zLY7/f3FwboKx0r+GJ8wxtvMa9ni9L1v53/ixbkrNbaKBekb/hTD6i/pMBxvKhpVtWlxFKyaTOkKKGfUSV9QvymJqy5UGyG2kAavOBhWqTou4= 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=WOO4/P6C; arc=none smtp.client-ip=198.175.65.19 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="WOO4/P6C" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710512631; x=1742048631; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ymtlPopoAK6IcVkhxWyn3VJniXSJJ6SOqftfCTa+nu0=; b=WOO4/P6CIMbAWMpVXvT9ZzdV++1UIUc0TTh96jJh3KOmRMy8tyUMoHTh 8XVukbvGHCaqgqol6MqsEOxy7o81SoCyzEtNpzxBaaolTw+NMV+SXJ3J1 OjQ9pNbS+ULbTLp7QBNt6jXc2pFnTtf6hNGZC1wnyVzTCA6AnaUvZ37Ke H+LnljRuUoNzWA+D7taEB81I8/sQ0Sx/QE8kVkftUgRp5CXRVojq6U+5m wYrPrAJQ1dSbPHXCNQ85Xw9WoVApS7pLPdhUH7IciBicwhrEvleBDHLP1 ADx5oWvUpKnhJQQTGq0XZ4BDkO2rWU5gWtiAJzG/78hRDyGBm8ccqoCov g==; X-IronPort-AV: E=McAfee;i="6600,9927,11013"; a="5250119" X-IronPort-AV: E=Sophos;i="6.07,128,1708416000"; d="scan'208";a="5250119" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2024 07:23:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,128,1708416000"; d="scan'208";a="17140761" Received: from intel.iind.intel.com (HELO brc5..) ([10.190.162.156]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2024 07:23:47 -0700 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, tirthendu.sarkar@intel.com, tushar.vyavahare@intel.com Subject: [PATCH bpf-next 6/6] selftests/xsk: enhance framework with a new test case for AF_XDP under max ring sizes Date: Fri, 15 Mar 2024 14:07:26 +0000 Message-Id: <20240315140726.22291-7-tushar.vyavahare@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240315140726.22291-1-tushar.vyavahare@intel.com> References: <20240315140726.22291-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 test case to evaluate AF_XDP's robustness by pushing hardware and software ring sizes to their limits. This test ensures AF_XDP's reliability amidst potential producer/consumer throttling due to maximum ring utilization. The testing strategy includes: 1. Configuring rings to their maximum allowable sizes. 2. Executing a series of tests across diverse batch sizes to assess system performance under varying load conditions. Signed-off-by: Tushar Vyavahare --- tools/testing/selftests/bpf/xskxceiver.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index 5326ca5c458c..f545b529e404 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -2480,6 +2480,26 @@ static int testapp_hw_sw_min_ring_size(struct test_spec *test) return testapp_validate_traffic(test); } +static int testapp_hw_sw_max_ring_size(struct test_spec *test) +{ + u32 max_descs = XSK_RING_PROD__DEFAULT_NUM_DESCS * 2; + int ret; + + test->total_steps = 2; + test->ifobj_tx->ring.set_tx = test->ifobj_tx->ring.max_tx; + test->ifobj_tx->ring.set_rx = test->ifobj_tx->ring.max_rx; + test->ifobj_rx->umem->num_frames = max_descs; + test->ifobj_rx->xsk->rxqsize = max_descs; + test->ifobj_rx->xsk->batch_size = XSK_RING_PROD__DEFAULT_NUM_DESCS; + ret = testapp_validate_traffic(test); + if (ret) + return ret; + + /* Set batch_size to 4095 */ + test->ifobj_rx->xsk->batch_size = max_descs - 1; + return testapp_validate_traffic(test); +} + static void run_pkt_test(struct test_spec *test) { int ret; @@ -2585,6 +2605,7 @@ static const struct test_spec tests[] = { {.name = "UNALIGNED_INV_DESC_MULTI_BUFF", .test_func = testapp_unaligned_inv_desc_mb}, {.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}, }; static void print_tests(void)