From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by mail.toke.dk (Postfix) with ESMTPS id 696469FD656 for ; Wed, 12 Apr 2023 23:45:48 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20221208 header.b=FZVlIxDN Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-632384295f6so918111b3a.0 for ; Wed, 12 Apr 2023 14:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681335945; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=crYbUvMM+qq+UublWGJRe3AoZOF0jnjMgrzBIUloc5g=; b=FZVlIxDNVsZwWF/x8+9ck8AoUV65kkPC7hntmEUT/3gG4c1Hh4S5+D9+VJDE0A2pyZ jyEiBgaU4tE3TOFAQ0yJfZydDVj2SaJtAcSSgmvs5c187MwaugrZnCsknQwLuh+eI6iR jHhicBe7jcyvpbl3t5ILAmyYfCCYrGdTKYoGMAn5KpsPFqFaF8l4hj8tBRPED8kces2M jnkP5yRG/Fjxq7JAm/nougsXhYUODDqFACmN6o1cxSRN6F4sgK/chMqzKShWJMxsuYtY lRkb/AoINLm0GEHDImKvIdJCo2IdYhZ12OJBzYFcMhd7rjsRYo+Cb0OO6KyQPr51YrGE lnVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681335945; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=crYbUvMM+qq+UublWGJRe3AoZOF0jnjMgrzBIUloc5g=; b=jIUYGc0/v0dq96JvVSUTQx/dOQvhUGgGyqvEXyIntNMLSeRFyukWfis8cq+V5YQZy2 PDwBQ8iIjd/ifq2sif9/crIuQIrQz3e1ZOFU6VxAOXGh9eJNJ28mfLcR955W0Z7tuG0/ OpzQeXyA4BPxawmgj2K3NqDA2e1Cj6UrbBmFGA/mROGFREFJk/14uf1TgG8TKbyM1qBT a4ZybTIN7Q7UInoRHz15IUpXngvAqaevvsKJ09DUFtvDOEp7G0qPx088rDZ1W1ty+QUs BWgdy5hhtHeyDEyTx2j1MTNHx37mY10/qec1hF8USUwc5GnxBUA0h5zFLTCNDoHafMkV HGuw== X-Gm-Message-State: AAQBX9dtYRilVJ1GTEQMavHifhYQqbJ87FvCcCJP5rq/LSYAUQ/aqVAB EYQu/J9ftM554tsSKlX1yI1PKlQ1aqUqDQkjzC2Ljg== X-Google-Smtp-Source: AKy350Y4/CZ4xHgg7rgydXEnmBND7Bc9oWAWjxox1vGjOiW+xJf6D2ah+ReO9z41JoyXkvPUW37w48iqNd537EdYth0= X-Received: by 2002:aa7:88d4:0:b0:639:fed3:c57 with SMTP id k20-20020aa788d4000000b00639fed30c57mr168839pff.5.1681335945114; Wed, 12 Apr 2023 14:45:45 -0700 (PDT) MIME-Version: 1.0 References: <20230412094235.589089-1-yoong.siang.song@intel.com> <20230412094235.589089-4-yoong.siang.song@intel.com> <677ed6c5-51fc-4b8b-d9a4-42e4cfe9006c@intel.com> In-Reply-To: <677ed6c5-51fc-4b8b-d9a4-42e4cfe9006c@intel.com> From: Stanislav Fomichev Date: Wed, 12 Apr 2023 14:45:33 -0700 Message-ID: To: Jacob Keller Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: LUFERNR7V4EROHTOVM3EVFMUMH53LTX7 X-Message-ID-Hash: LUFERNR7V4EROHTOVM3EVFMUMH53LTX7 X-MailFrom: sdf@google.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Song Yoong Siang , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Alexander Duyck , Ong Boon Leong , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, xdp-hints@xdp-project.net X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] Re: [PATCH net-next v3 3/4] net: stmmac: add Rx HWTS metadata to XDP receive pkt List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed, Apr 12, 2023 at 1:56=E2=80=AFPM Jacob Keller wrote: > > > > On 4/12/2023 10:00 AM, Stanislav Fomichev wrote: > > On 04/12, Song Yoong Siang wrote: > >> Add receive hardware timestamp metadata support via kfunc to XDP recei= ve > >> packets. > >> > >> Suggested-by: Stanislav Fomichev > >> Signed-off-by: Song Yoong Siang > >> --- > >> drivers/net/ethernet/stmicro/stmmac/stmmac.h | 3 +++ > >> .../net/ethernet/stmicro/stmmac/stmmac_main.c | 26 ++++++++++++++++++= - > >> 2 files changed, 28 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac.h > >> index ac8ccf851708..826ac0ec88c6 100644 > >> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h > >> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h > >> @@ -94,6 +94,9 @@ struct stmmac_rx_buffer { > >> > >> struct stmmac_xdp_buff { > >> struct xdp_buff xdp; > >> + struct stmmac_priv *priv; > >> + struct dma_desc *p; > >> + struct dma_desc *np; > >> }; > >> > >> struct stmmac_rx_queue { > >> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drive= rs/net/ethernet/stmicro/stmmac/stmmac_main.c > >> index f7bbdf04d20c..ed660927b628 100644 > >> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > >> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > >> @@ -5315,10 +5315,15 @@ static int stmmac_rx(struct stmmac_priv *priv,= int limit, u32 queue) > >> > >> xdp_init_buff(&ctx.xdp, buf_sz, &rx_q->xdp_rxq); > >> xdp_prepare_buff(&ctx.xdp, page_address(buf->page= ), > >> - buf->page_offset, buf1_len, fals= e); > >> + buf->page_offset, buf1_len, true= ); > >> > >> pre_len =3D ctx.xdp.data_end - ctx.xdp.data_hard_= start - > >> buf->page_offset; > >> + > >> + ctx.priv =3D priv; > >> + ctx.p =3D p; > >> + ctx.np =3D np; > >> + > >> skb =3D stmmac_xdp_run_prog(priv, &ctx.xdp); > >> /* Due xdp_adjust_tail: DMA sync for_device > >> * cover max len CPU touch > >> @@ -7071,6 +7076,23 @@ void stmmac_fpe_handshake(struct stmmac_priv *p= riv, bool enable) > >> } > >> } > >> > >> +static int stmmac_xdp_rx_timestamp(const struct xdp_md *_ctx, u64 *ti= mestamp) > >> +{ > >> + const struct stmmac_xdp_buff *ctx =3D (void *)_ctx; > >> + > >> + *timestamp =3D 0; > >> + stmmac_get_rx_hwtstamp(ctx->priv, ctx->p, ctx->np, timestamp); > >> + > > > > [..] > > > >> + if (*timestamp) > > > > Nit: does it make sense to change stmmac_get_rx_hwtstamp to return bool > > to indicate success/failure? Then you can do: > > > > if (!stmmac_get_rx_hwtstamp()) > > reutrn -ENODATA; > > I would make it return the -ENODATA directly since typically bool > true/false functions have names like "stmmac_has_rx_hwtstamp" or similar > name that infers you're answering a true/false question. > > That might also let you avoid zeroing the timestamp value first? SGTM! > Thanks, > Jake