From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by mail.toke.dk (Postfix) with ESMTPS id 80B889FD435 for ; Wed, 12 Apr 2023 19:00:07 +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=0dJ9X7z1 Received: by mail-pj1-x104a.google.com with SMTP id v22-20020a17090ae99600b00246f734ea1fso1289267pjy.4 for ; Wed, 12 Apr 2023 10:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681318805; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=kpKB7SqPD1WEJcm5mP/ZS9AV7kRHrr2cruyzGPdJnmY=; b=0dJ9X7z1jh25oYOHdd+ljdJXvOW0dD6zhgL9qARYaY8+1ZTVplJLk+y5Aqe0axj3f7 rVda5IIvH/u9Mqx1YM4d0qjJrdRXlxwNLJlT3miGS7NcBeAWuFzmKipOZKiFXsHiIL6T CaKVTz/SjKtNGnp7avxMqpahnjuoTUT2P5T8gW/+RyXl9cT27GQpQ51fkvGdzeQQl5cD +fQ5My91JFTUE3tWCvY92nPuUsiGOO+mEOjRSnKlR/K+ZOhQwo6p0Yt8Zeb3AIof9tx9 0Pt0VWQRjjZjTU1US/MsJ9d5y5H4C3VMfArkbKJhdzLnma7r7K7IN7gX3VGgvRhe2V/N q8OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681318805; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kpKB7SqPD1WEJcm5mP/ZS9AV7kRHrr2cruyzGPdJnmY=; b=TMY8PYhcTNLLGUf1eE9AJu+hMPVo8cWUq87Hcy6615rV9NTY1Pnvw7ttt3PZlsvioV yzYZo+jBT9v/4y+5Kx6878wBsKrLuXt40S1U2TdIZwY3iEfiS2bx+bFY5ov2U52Gn1yo JBpUpGPymlUwNZ4KMtRaeOm+3CbcwYdMx9TwDZ2KlEThXSPAWFZo12ldHf3PbZBey/mz kd/bidoZl8AUmNuqJKEZcF/tqi3LB1SMu8RMv6G2yncIdwY3OJMPaXVPYOyVgwyVj1d7 uth4AeLidS/OMbe7UqSeSBn6ebZbUei2PPHCYF5dIspnNOwgjCNKRaPbVP0+Js6acqiL Tw6Q== X-Gm-Message-State: AAQBX9e6LRCNvZmQYFLAnWFgMGex1gVDc9HNMG95PtLPe1bNmxhtPrqc SRHoHjbcPwkkm04zsZgdaS5GJx4= X-Google-Smtp-Source: AKy350bqCRuf2+nw6G4Xo/+RMWx8JZZGxbP78hg7vN5q2J6hphsLxNUKDMeaTSlnL3vx8TUht7eSaik= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a65:60c2:0:b0:51a:52b1:1b70 with SMTP id r2-20020a6560c2000000b0051a52b11b70mr775383pgv.10.1681318805239; Wed, 12 Apr 2023 10:00:05 -0700 (PDT) Date: Wed, 12 Apr 2023 10:00:03 -0700 In-Reply-To: <20230412094235.589089-4-yoong.siang.song@intel.com> Mime-Version: 1.0 References: <20230412094235.589089-1-yoong.siang.song@intel.com> <20230412094235.589089-4-yoong.siang.song@intel.com> Message-ID: From: Stanislav Fomichev To: Song Yoong Siang Content-Type: text/plain; charset="us-ascii" Message-ID-Hash: S4GRAS7R7ADCVMTKVVIVHLNF7U5CPELC X-Message-ID-Hash: S4GRAS7R7ADCVMTKVVIVHLNF7U5CPELC X-MailFrom: 3leM2ZAMKCWAQBDEMMEJC.AMKVBN-FGLRQVBN-NPMHCAR.LCR@flex--sdf.bounces.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: 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 04/12, Song Yoong Siang wrote: > Add receive hardware timestamp metadata support via kfunc to XDP receive > 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/net/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/drivers/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, false); > + buf->page_offset, buf1_len, true); > > pre_len = ctx.xdp.data_end - ctx.xdp.data_hard_start - > buf->page_offset; > + > + ctx.priv = priv; > + ctx.p = p; > + ctx.np = np; > + > skb = 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 *priv, bool enable) > } > } > > +static int stmmac_xdp_rx_timestamp(const struct xdp_md *_ctx, u64 *timestamp) > +{ > + const struct stmmac_xdp_buff *ctx = (void *)_ctx; > + > + *timestamp = 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;