From: "Song, Yoong Siang" <yoong.siang.song@intel.com>
To: Stanislav Fomichev <stfomichev@gmail.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Willem de Bruijn <willemb@google.com>,
"Bezdeka, Florian" <florian.bezdeka@siemens.com>,
Donald Hunter <donald.hunter@gmail.com>,
Jonathan Corbet <corbet@lwn.net>, Bjorn Topel <bjorn@kernel.org>,
"Karlsson, Magnus" <magnus.karlsson@intel.com>,
"Fijalkowski, Maciej" <maciej.fijalkowski@intel.com>,
Jonathan Lemon <jonathan.lemon@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
"Damato, Joe" <jdamato@fastly.com>,
Stanislav Fomichev <sdf@fomichev.me>,
Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
Mina Almasry <almasrymina@google.com>,
Daniel Jurgens <danielj@nvidia.com>,
Amritha Nambiar <amritha.nambiar@intel.com>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Mykola Lysenko <mykolal@fb.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
KP Singh <kpsingh@kernel.org>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Jose Abreu <joabreu@synopsys.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
"Nguyen, Anthony L" <anthony.l.nguyen@intel.com>,
"Kitszel, Przemyslaw" <przemyslaw.kitszel@intel.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
"linux-kselftest@vger.kernel.org"
<linux-kselftest@vger.kernel.org>,
"linux-stm32@st-md-mailman.stormreply.com"
<linux-stm32@st-md-mailman.stormreply.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"intel-wired-lan@lists.osuosl.org"
<intel-wired-lan@lists.osuosl.org>,
"xdp-hints@xdp-project.net" <xdp-hints@xdp-project.net>
Subject: [xdp-hints] Re: [PATCH bpf-next v4 2/4] selftests/bpf: Add Launch Time request to xdp_hw_metadata
Date: Thu, 9 Jan 2025 07:08:32 +0000 [thread overview]
Message-ID: <PH0PR11MB58308DE8330F4CDE6A954534D8132@PH0PR11MB5830.namprd11.prod.outlook.com> (raw)
In-Reply-To: <Z31c_3j9MEP7Z3bd@mini-arch>
On Wednesday, January 8, 2025 12:58 AM, Stanislav Fomichev <stfomichev@gmail.com> wrote:
>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 <yoong.siang.song@intel.com>
>> ---
>> 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 <test_progs.h>
>> @@ -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..
Agree that your code is more readable.
I will use your suggestion in next version.
Thanks & Regards
Siang
prev parent reply other threads:[~2025-01-09 7:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-06 13:56 [xdp-hints] " Song Yoong Siang
2025-01-07 16:57 ` [xdp-hints] " Stanislav Fomichev
2025-01-09 7:08 ` Song, Yoong Siang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.xdp-project.net/postorius/lists/xdp-hints.xdp-project.net/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=PH0PR11MB58308DE8330F4CDE6A954534D8132@PH0PR11MB5830.namprd11.prod.outlook.com \
--to=yoong.siang.song@intel.com \
--cc=alexandre.torgue@foss.st.com \
--cc=almasrymina@google.com \
--cc=amritha.nambiar@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrii@kernel.org \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=daniel@iogearbox.net \
--cc=danielj@nvidia.com \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=eddyz87@gmail.com \
--cc=edumazet@google.com \
--cc=florian.bezdeka@siemens.com \
--cc=haoluo@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jdamato@fastly.com \
--cc=joabreu@synopsys.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=jonathan.lemon@gmail.com \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=mcoquelin.stm32@gmail.com \
--cc=mykolal@fb.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=stfomichev@gmail.com \
--cc=willemb@google.com \
--cc=xdp-hints@xdp-project.net \
--cc=xuanzhuo@linux.alibaba.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox