From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by mail.toke.dk (Postfix) with ESMTPS id 353BFABA4F2 for ; Tue, 07 Jan 2025 17:58:38 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=IH8/wldn Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-216426b0865so227385355ad.0 for ; Tue, 07 Jan 2025 08:58:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736269057; x=1736873857; darn=xdp-project.net; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Rb1pOcXu31lYFeGfpMgDjeg52e6mYQb5OHgfqtIS2po=; b=IH8/wldnZjZV2bjJCOY1QTo6TitMrx3qzpnwjkffMR7WmBN4ZrXyF2ZceII1Lizj8C WFTC/RP8BTZj0BrPySZkEZaITAyc7/QY84s+kBS1+HB1VhtM8z0d9RVMb6AjH1aWajZV E0p5g8IY2zwDNXdBHwhlOwUtPvTXp9Bvzrioh8cDiPNGQm/ZJrnltJA0p9kAgyI/JzlJ pbs4rIchJWiDxzqlVZGgpIQYme0RHvfxY7clfQ6hk9ilJ7FLWHzbspX57MR59SKp63wv 3Yj7FsZPtnb7kigQ5thmv8Yj3xJhuh8O6lPlEITuHp8UTlC4gdlzEJFZJx3a1zolckcO Zqcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736269057; x=1736873857; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Rb1pOcXu31lYFeGfpMgDjeg52e6mYQb5OHgfqtIS2po=; b=bjVWtMKUhmOV/VjFFI0EYr82968BILfknkZmNM9Y5MK/5/dW9BgsfYH4GPEjPcQ/Mj bSv8VlDROFo+jgtjp7cTjLsqXWd8tR5NyDbsiyT5MqrjFMwDQIb3scqVICBT7yauodBT 7e3yTEgkzzvNRy7oHMUdMlU5vPlOfdzn1dOWAO8WIcIYb3lsnAGTX1y3Uq5tpf4jtKvY HhUjmvhQ4m4zCyUKEOoMgO9FpbSvSqzSUNZni0k9hGrnT+JrcFJ6WxmmdMXL4/EBZyKS OcMLoi9rrGfETicv/9MRoefb2d3va5mM5wPjvpIBaLaUGo/2YtXpEGg8Bjri+wOHoWCV g0IA== X-Forwarded-Encrypted: i=1; AJvYcCXWCsSXlqtnOMnrd8OuGY0IT8r0Z2doqelFYAHbedeZOlzN9CJH8pf92yGWHO6PhTIy97pnuYzi5P0=@xdp-project.net X-Gm-Message-State: AOJu0YzSf8QNbTsB7JfQynAMqDuDWzXCT1kXQ7y/O2FkFWRRewZWFTxz ggqeKj5g5XO7W+USaxj78Spf+cqa3lKprFO1RAqQg9fvt8UprEE= X-Gm-Gg: ASbGncv1flpXIlptVRo3RJSLr2YdqQ/TgfMyBxSkKsUk1Oe2jqnqvSQ7NreFy/RwB7g grBp5qtSWX1VSx9pJfasG4wc9Ga/dGJTxsLjh11bZqw79mFDagG5PwBPzal3hc4MNMz2uSiXMXJ ODg+HD8ubIS0NjQcDrTTDBOeLyVqqXIJf9NOAGkEImt/FluVyanmHT9QGLvu+TdvYkiw5axySrj LkA62OdykUehVGgyVBwiv7RDJD3uFDjVPvLJdP+ERD7McOC+S37CPxG X-Google-Smtp-Source: AGHT+IFlhKI33ii68VDZqo5j2PH+n5VdBpF5kgNaO5PfE/xaemL0ooS2ho/W9ZBFXWggOucM2FsUEA== X-Received: by 2002:a17:903:182:b0:216:1eb9:4a48 with SMTP id d9443c01a7336-219e6f289a0mr710448725ad.56.1736269056620; Tue, 07 Jan 2025 08:57:36 -0800 (PST) Received: from localhost ([2601:646:9e00:f56e:123b:cea3:439a:b3e3]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc962d0asm314014085ad.53.2025.01.07.08.57.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 08:57:36 -0800 (PST) Date: Tue, 7 Jan 2025 08:57:35 -0800 From: Stanislav Fomichev To: Song Yoong Siang Message-ID: References: <20250106135638.9719-1-yoong.siang.song@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20250106135638.9719-1-yoong.siang.song@intel.com> Message-ID-Hash: AEHXCPEKDCVEAVBVCMYVA4BC5VNNN6GU X-Message-ID-Hash: AEHXCPEKDCVEAVBVCMYVA4BC5VNNN6GU X-MailFrom: stfomichev@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Willem de Bruijn , Florian Bezdeka , Donald Hunter , Jonathan Corbet , Bjorn Topel , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Andrew Lunn , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Joe Damato , Stanislav Fomichev , Xuan Zhuo , Mina Almasry , Daniel Jurgens , Amritha Nambiar , Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Hao Luo , Jiri Olsa , Shuah Khan , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Tony Nguyen , Przemek Kitszel , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, intel-wired-lan@lists.osuosl.org, xdp-hints@xdp-project.net X-Mailman-Version: 3.3.10 Precedence: list Subject: [xdp-hints] Re: [PATCH bpf-next v4 2/4] selftests/bpf: Add Launch Time request to xdp_hw_metadata List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 01/06, Song Yoong Siang wrote: > Add Launch Time hw offload request to xdp_hw_metadata. User can configure > the delta of launch time to HW RX-time by using "-l" argument. The default > delta is 100,000,000 nanosecond. > > Signed-off-by: Song Yoong Siang > --- > tools/testing/selftests/bpf/xdp_hw_metadata.c | 30 +++++++++++++++++-- > 1 file changed, 27 insertions(+), 3 deletions(-) > > diff --git a/tools/testing/selftests/bpf/xdp_hw_metadata.c b/tools/testing/selftests/bpf/xdp_hw_metadata.c > index 6f7b15d6c6ed..795c1d14e02d 100644 > --- a/tools/testing/selftests/bpf/xdp_hw_metadata.c > +++ b/tools/testing/selftests/bpf/xdp_hw_metadata.c > @@ -13,6 +13,7 @@ > * - UDP 9091 packets trigger TX reply > * - TX HW timestamp is requested and reported back upon completion > * - TX checksum is requested > + * - TX launch time HW offload is requested for transmission > */ > > #include > @@ -64,6 +65,8 @@ int rxq; > bool skip_tx; > __u64 last_hw_rx_timestamp; > __u64 last_xdp_rx_timestamp; > +__u64 last_launch_time; > +__u64 launch_time_delta_to_hw_rx_timestamp = 100000000; /* 0.1 second */ > > void test__fail(void) { /* for network_helpers.c */ } > > @@ -298,6 +301,8 @@ static bool complete_tx(struct xsk *xsk, clockid_t clock_id) > if (meta->completion.tx_timestamp) { > __u64 ref_tstamp = gettime(clock_id); > > + print_tstamp_delta("HW Launch-time", "HW TX-complete-time", > + last_launch_time, meta->completion.tx_timestamp); > print_tstamp_delta("HW TX-complete-time", "User TX-complete-time", > meta->completion.tx_timestamp, ref_tstamp); > print_tstamp_delta("XDP RX-time", "User TX-complete-time", > @@ -395,6 +400,14 @@ static void ping_pong(struct xsk *xsk, void *rx_packet, clockid_t clock_id) > xsk, ntohs(udph->check), ntohs(want_csum), > meta->request.csum_start, meta->request.csum_offset); > > + /* Set the value of launch time */ > + meta->flags |= XDP_TXMD_FLAGS_LAUNCH_TIME; > + meta->request.launch_time = last_hw_rx_timestamp + > + launch_time_delta_to_hw_rx_timestamp; > + last_launch_time = meta->request.launch_time; > + print_tstamp_delta("HW RX-time", "HW Launch-time", last_hw_rx_timestamp, > + meta->request.launch_time); > + > memcpy(data, rx_packet, len); /* don't share umem chunk for simplicity */ > tx_desc->options |= XDP_TX_METADATA; > tx_desc->len = len; > @@ -402,10 +415,14 @@ static void ping_pong(struct xsk *xsk, void *rx_packet, clockid_t clock_id) > xsk_ring_prod__submit(&xsk->tx, 1); > } > > +#define SLEEP_PER_ITERATION_IN_US 10 > +#define SLEEP_PER_ITERATION_IN_NS (SLEEP_PER_ITERATION_IN_US * 1000) > +#define MAX_ITERATION(x) (((x) / SLEEP_PER_ITERATION_IN_NS) + 500) > static int verify_metadata(struct xsk *rx_xsk, int rxq, int server_fd, clockid_t clock_id) > { > const struct xdp_desc *rx_desc; > struct pollfd fds[rxq + 1]; > + int max_iterations; > __u64 comp_addr; > __u64 addr; > __u32 idx = 0; > @@ -418,6 +435,9 @@ static int verify_metadata(struct xsk *rx_xsk, int rxq, int server_fd, clockid_t > fds[i].revents = 0; > } > > + /* Calculate max iterations to wait for transmit completion */ > + max_iterations = MAX_ITERATION(launch_time_delta_to_hw_rx_timestamp); > + > fds[rxq].fd = server_fd; > fds[rxq].events = POLLIN; > fds[rxq].revents = 0; > @@ -477,10 +497,10 @@ static int verify_metadata(struct xsk *rx_xsk, int rxq, int server_fd, clockid_t > if (ret) > printf("kick_tx ret=%d\n", ret); > [..] > - for (int j = 0; j < 500; j++) { > + for (int j = 0; j < max_iterations; j++) { > if (complete_tx(xsk, clock_id)) > break; > - usleep(10); > + usleep(SLEEP_PER_ITERATION_IN_US); nit: instead of doing MAX_ITERATION/max_iterations, can we simplify this to the following? static u64 now(void) { clock_gettime(...); return ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec; } /* wait 5 seconds + cover launch time */ deadline = now() + 5 * NSEC_PER_SEC + launch_time_delta_to_hw_rx_timestamp; while (true) { if (complete_tx()) break; if (now() >= deadline) break; usleep(10); } It is a bit more readable than converting time to wait to the iterations..