Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2696100rwl; Thu, 13 Apr 2023 09:37:18 -0700 (PDT) X-Google-Smtp-Source: AKy350YbYGQiujxabiZh1zbxgVJFlMexLUIVaTVDUEPbbNfikofzZxLVECLEPMP2AYMjQe7CHRKv X-Received: by 2002:a05:6a00:180e:b0:637:aea0:b23d with SMTP id y14-20020a056a00180e00b00637aea0b23dmr4683012pfa.10.1681403837978; Thu, 13 Apr 2023 09:37:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681403837; cv=none; d=google.com; s=arc-20160816; b=Kc4DFJatnbVC3n6k0aB1EPSKgw0KYz0665VeWVPvvP7/LKY7B88wT8JnyDm4mier9q PdZMz3HefMwpk8LxBQ4DpU5bgxhkj0Oxa+rLhaPanF1Uh26lWmPoiZCdzKEdXkD1J1xh 0zjmBS/7ivA5nQFklr4qO5bPAWes1fP6ykNpMr+nJBzVJnkJTsSC5Xu81ZIDN5ifHJ+2 WUW7gvUyNhuhZ1/s4W3GEkB+QNRIoPgWGjON6zF+TIOmqGr9ySYv6HwF8ATVWMUVknjC AchZQDTY8uUndL9dQ0w4uRCGKyF18iG15MUkt9V9gbi4SRiQ40yJrwryqiNU1JC/snXd Sfhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=8HvoJ679JuZRdirnHe569ZyC5ZGOdrOnvhMCfAAv7TA=; b=Ty90KfHxDIYkUkcDhBU5qofmNEQMqIB08cplspFKkfiYgMyAMPDU5AmIEQOwSCRSWJ esec8XYfVpKdOe/JD3ICCses5ZddRfitV3+b0BKCk+YstVVCk5fnJnzDnR2Z/5dE4rPj op0XAHbwpMWye0nI+DthIwbZjsQwjNUCD51jP+oK2pKShdG6S6KM1Ul4s3tpa5akm7E5 dO+243djcYA0E+716+lXJSUb7yvldl4YGfwnxT2HBywRzMZtHVNQao+mdxDwr94hN0We yssbxb2dy0sy/kimShtVdNfliHtjH9g/IscEBwVQKOFZasgExTkAk2OfZ4skw04tNMwo yJvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=3AV1Vq3W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h18-20020a63c012000000b0051460f12600si2404590pgg.554.2023.04.13.09.37.04; Thu, 13 Apr 2023 09:37:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=3AV1Vq3W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbjDMQeu (ORCPT + 99 others); Thu, 13 Apr 2023 12:34:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229910AbjDMQet (ORCPT ); Thu, 13 Apr 2023 12:34:49 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90B9C4697 for ; Thu, 13 Apr 2023 09:34:47 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id az2so834216pgb.11 for ; Thu, 13 Apr 2023 09:34:47 -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=KdoEkt8SVHWrKlt6Vr5I/Lxa1Jwkx+VfuzqawHwkIw3ygTFHSrDwn5LcLMl9Tbhusq IiygAELsu/rCqsbXOmuhOL2JUtyu7L8VmAKDmz8rp0LQG0ouccYwBHnmmfn2SAYgXgH9 ngBgfpOjJwUxJSuQJvxpCQNS4DH26rZvss6/fSsP4Ezeo80bBr1kBsCQPILbluja7Vn2 R8RYbcfOR7qG675q+TtuSqGJ/VjaQGQ5VRP1R4t+zGdKXEsv+IeMnreBJrMG9go7qAaF ebl81ZpafhiQstnN2uuAMfDEbYCcql8B/Nwk9vhpwqYnjM/a8ZtshLTG4PXFmxa5dm/A W9DA== X-Gm-Message-State: AAQBX9df9ShmkKKd9En+wUQXLfdWNfwaX0+oDY5ALikD2XgFAcMZfmkP G2Nq2CiK6q3E92YvctuFIkQxukmod4FM0pUdi7IEoA== 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: Subject: Re: [PATCH net-next v4 2/3] net: stmmac: add Rx HWTS metadata to XDP receive pkt To: Song Yoong Siang 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >