From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by mail.toke.dk (Postfix) with ESMTPS id B10E29FDA81 for ; Thu, 13 Apr 2023 18:34:49 +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=3AV1Vq3W Received: by mail-pg1-x52b.google.com with SMTP id s72so16927756pgs.9 for ; Thu, 13 Apr 2023 09:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681403687; x=1683995687; 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=8HvoJ679JuZRdirnHe569ZyC5ZGOdrOnvhMCfAAv7TA=; b=3AV1Vq3WEo42XDTB+pzABN4ZQGhRgzKvgGGRMpqjEY4vrCgRQLSc6nldf0HxtaKXa+ kD56HHiCSZzSyEZZfu2q0r+fSBzScCJ03zomGDfbTkvrRRm5KOh5FzGP1yIyr1JW0Rxq mblhLqRHMs7Ag9HWqRwaLyDebTDb3XuOMG+hTbZB1ULS5r2gSRm741v8pVvzIu8TeW/7 Pqt7v3nQIuQxKmJ1maXy3a2ncJNhstXZ2QWwC5TyAkwUE3W2UxNwQu3T6/C7arQaUu5/ PYJEZ1dps6WXd/BqMAuuaeE0dsGIcgrRr+a+YWF/8/P36E/Zmbrp52oKsgGKdouWF+dm +s7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681403687; x=1683995687; 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=8HvoJ679JuZRdirnHe569ZyC5ZGOdrOnvhMCfAAv7TA=; b=EQR6L0IQAgoF27RGvo+QC1+uduB44gXnY3IHcaagEXFsoY6zCdKc9I7ApDNNrBblB9 CtL3NpzeisVv1mjTIcJZ2WL1eSSO3Xp2pNXYrKaMy1HbR+f+yyvgVjJSPbdThbzSZDdz nlpPhV6FjyR3161X/UUbPG4SaLNjdzLDZcxbmRMpZtDEyb+7eV6jvxe2wJjhn+mb0ytV TL7j3j4BSOIdzHwAUmocgCbRt6BrvVJ7AklPpPKsfQLIz3eznZa7fbPTVk4SXMlTKQqe 9egtdLURX1ROy2DCVmLcFmcpfCdA/tJwMm1Lv/bfoQdCwdOLQs+UAXL+QdsVdjjhy+Yq cKmQ== X-Gm-Message-State: AAQBX9frc45g9WB46h8PwKFTP8JWho+Yk1cgAStmfSmYOIxbCy+rYLUw xzDoFLt5uL4vmyxTkLP/eRieg7lIg0+clBn2q4HFAw== X-Google-Smtp-Source: AKy350brZLSKImyACD/vTwBAWkj9JzXf2zpBwAPKP+J93fB14HCkdn9PtWI/qhlPPMVYTW639OYp4l/LOfig57cvsRQ= X-Received: by 2002:a63:642:0:b0:51b:fa5:7bce with SMTP id 63-20020a630642000000b0051b0fa57bcemr679747pgg.1.1681403686843; Thu, 13 Apr 2023 09:34:46 -0700 (PDT) MIME-Version: 1.0 References: <20230413032541.885238-1-yoong.siang.song@intel.com> <20230413032541.885238-3-yoong.siang.song@intel.com> In-Reply-To: <20230413032541.885238-3-yoong.siang.song@intel.com> From: Stanislav Fomichev Date: Thu, 13 Apr 2023 09:34:35 -0700 Message-ID: To: Song Yoong Siang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: BHJDQH2GJ564SRKO2HAR2H2XWJHXSKXQ X-Message-ID-Hash: BHJDQH2GJ564SRKO2HAR2H2XWJHXSKXQ 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: 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 v4 2/3] 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 8:26=E2=80=AFPM 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 Conceptually looks good, thanks! Acked-by: Stanislav Fomichev > --- > drivers/net/ethernet/stmicro/stmmac/stmmac.h | 3 ++ > .../net/ethernet/stmicro/stmmac/stmmac_main.c | 40 ++++++++++++++++++- > 2 files changed, 42 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/e= thernet/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 6ffce52ca837..831a3e22e0d8 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -5313,10 +5313,15 @@ static int stmmac_rx(struct stmmac_priv *priv, in= t 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 > @@ -7060,6 +7065,37 @@ void stmmac_fpe_handshake(struct stmmac_priv *priv= , bool enable) > } > } > > +static int stmmac_xdp_rx_timestamp(const struct xdp_md *_ctx, u64 *times= tamp) > +{ > + const struct stmmac_xdp_buff *ctx =3D (void *)_ctx; > + struct stmmac_priv *priv =3D ctx->priv; > + struct dma_desc *desc =3D ctx->p; > + struct dma_desc *np =3D ctx->np; > + struct dma_desc *p =3D ctx->p; > + u64 ns =3D 0; > + > + if (!priv->hwts_rx_en) > + return -ENODATA; > + > + /* For GMAC4, the valid timestamp is from CTX next desc. */ > + if (priv->plat->has_gmac4 || priv->plat->has_xgmac) > + desc =3D np; > + > + /* Check if timestamp is available */ > + if (stmmac_get_rx_timestamp_status(priv, p, np, priv->adv_ts)) { > + stmmac_get_timestamp(priv, desc, priv->adv_ts, &ns); > + ns -=3D priv->plat->cdc_error_adj; > + *timestamp =3D ns_to_ktime(ns); > + return 0; > + } > + > + return -ENODATA; > +} > + > +static const struct xdp_metadata_ops stmmac_xdp_metadata_ops =3D { > + .xmo_rx_timestamp =3D stmmac_xdp_rx_timestamp, > +}; > + > /** > * stmmac_dvr_probe > * @device: device pointer > @@ -7167,6 +7203,8 @@ int stmmac_dvr_probe(struct device *device, > > ndev->netdev_ops =3D &stmmac_netdev_ops; > > + ndev->xdp_metadata_ops =3D &stmmac_xdp_metadata_ops; > + > ndev->hw_features =3D NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6= _CSUM | > NETIF_F_RXCSUM; > ndev->xdp_features =3D NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDI= RECT | > -- > 2.34.1 >