From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by mail.toke.dk (Postfix) with ESMTPS id E32C09C4A53 for ; Tue, 22 Nov 2022 19:08:46 +0100 (CET) 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=20210112 header.b=PCho3K/y Received: by mail-oi1-x22d.google.com with SMTP id n186so16648240oih.7 for ; Tue, 22 Nov 2022 10:08:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zaxCls2YnixP/+mVX2V2w/QOTiZcMWJ2TjjBK6+PNeA=; b=PCho3K/yx0e+sIXMHl+jPB+G3Hq5echJhyIk+pVrAssdC8HFbdNqDiOX6pyktVHLsf /Rb2K2v2QoXx1mzMFEDUpwEVZ/dBWmwi9naz0tPWRbvqkSOhmtqpiVcHMFkU+qDOiSOu F8jK+MzsDFvxvUx0ryJd9IXHihMx8BaC89ifzdlToMqF2+cbwF28nmFiU59lBNBcutJX 296PPuPxsSjXKh54RtdOxteoI5UTvmwENDT8a6lMhIwnN83U0krxHSh5a8Xukv3HvOgS gYlutGs/Go2NM/H2bXjcX06ZuRsV4oGomv8ASdMnWm+E4URbvx9cJIZMXVNfJ/tDiv4I Z13g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=zaxCls2YnixP/+mVX2V2w/QOTiZcMWJ2TjjBK6+PNeA=; b=5tl3jm5hmeAJ6YeXkyquY2oAKSFzoCX9HWcoP2LhmvG8sn2fKdA9Kbogu0gkEPUmZl Omy+Yg4X/TtWJkO8AgFEYp+CwXhx5gegPGMy3A7wssg87U2jOskQ+KQCHrwFo6nZwEtS +7ZZO3whQxCOMF3RmuPqzsf42v+DOKr4AJHx0fyH7ihofb/NqnN1qHLQ09PH2Zb8mpit DHiIbn+4BfFevKXrDlaHafe47M2ooY12EW/sbf5FEKoEukfqoaCu0fjlWMenQ5hwZTqd APWZOoaVcEUiJELYXa2jb+p8bEg/CBzX35gqUDBLy6hN8iRuoyH0gRGdI2hEk8QdFmtt 3fyA== X-Gm-Message-State: ANoB5pme4XK5DLiagnPuDfn8kkTYgYuzDuv+834wxi0khLRThfCpX8zk YoKg+Pn3t4HGtQPp+TWVDiuhVJ4lGxK8IUksyz882g== X-Google-Smtp-Source: AA0mqf79pIhBy6++Vd9PPoNma0xSWxxVfrOU+xR4DUWinCfU3NfxU3zysoIBdQF78YuSYidvJfcdg1Vemcn5+oiHZXQ= X-Received: by 2002:a05:6808:f09:b0:354:8922:4a1a with SMTP id m9-20020a0568080f0900b0035489224a1amr2192816oiw.181.1669140524869; Tue, 22 Nov 2022 10:08:44 -0800 (PST) MIME-Version: 1.0 References: <20221121182552.2152891-1-sdf@google.com> <20221121182552.2152891-8-sdf@google.com> In-Reply-To: From: Stanislav Fomichev Date: Tue, 22 Nov 2022 10:08:34 -0800 Message-ID: To: Tariq Toukan Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: CDIFFT6XP7WUJZOIEVVILS5D3SJES3OQ X-Message-ID-Hash: CDIFFT6XP7WUJZOIEVVILS5D3SJES3OQ 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: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, haoluo@google.com, jolsa@kernel.org, Tariq Toukan , David Ahern , Jakub Kicinski , Willem de Bruijn , Jesper Dangaard Brouer , Anatoly Burakov , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org X-Mailman-Version: 3.3.7 Precedence: list Subject: [xdp-hints] Re: [PATCH bpf-next v2 7/8] mxl4: Support RX XDP metadata List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue, Nov 22, 2022 at 5:50 AM Tariq Toukan wrote: > > > > On 11/21/2022 8:25 PM, Stanislav Fomichev wrote: > > RX timestamp and hash for now. Tested using the prog from the next > > patch. > > > > Also enabling xdp metadata support; don't see why it's disabled, > > there is enough headroom.. > > > > Cc: Tariq Toukan > > Cc: John Fastabend > > Cc: David Ahern > > Cc: Martin KaFai Lau > > Cc: Jakub Kicinski > > Cc: Willem de Bruijn > > Cc: Jesper Dangaard Brouer > > Cc: Anatoly Burakov > > Cc: Alexander Lobakin > > Cc: Magnus Karlsson > > Cc: Maryam Tahhan > > Cc: xdp-hints@xdp-project.net > > Cc: netdev@vger.kernel.org > > Signed-off-by: Stanislav Fomichev > > --- > > .../net/ethernet/mellanox/mlx4/en_netdev.c | 10 ++++ > > drivers/net/ethernet/mellanox/mlx4/en_rx.c | 48 ++++++++++++++++++- > > include/linux/mlx4/device.h | 7 +++ > > 3 files changed, 64 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c > > index 8800d3f1f55c..1cb63746a851 100644 > > --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c > > +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c > > @@ -2855,6 +2855,11 @@ static const struct net_device_ops mlx4_netdev_ops = { > > .ndo_features_check = mlx4_en_features_check, > > .ndo_set_tx_maxrate = mlx4_en_set_tx_maxrate, > > .ndo_bpf = mlx4_xdp, > > + > > + .ndo_xdp_rx_timestamp_supported = mlx4_xdp_rx_timestamp_supported, > > + .ndo_xdp_rx_timestamp = mlx4_xdp_rx_timestamp, > > + .ndo_xdp_rx_hash_supported = mlx4_xdp_rx_hash_supported, > > + .ndo_xdp_rx_hash = mlx4_xdp_rx_hash, > > }; > > > > static const struct net_device_ops mlx4_netdev_ops_master = { > > @@ -2887,6 +2892,11 @@ static const struct net_device_ops mlx4_netdev_ops_master = { > > .ndo_features_check = mlx4_en_features_check, > > .ndo_set_tx_maxrate = mlx4_en_set_tx_maxrate, > > .ndo_bpf = mlx4_xdp, > > + > > + .ndo_xdp_rx_timestamp_supported = mlx4_xdp_rx_timestamp_supported, > > + .ndo_xdp_rx_timestamp = mlx4_xdp_rx_timestamp, > > + .ndo_xdp_rx_hash_supported = mlx4_xdp_rx_hash_supported, > > + .ndo_xdp_rx_hash = mlx4_xdp_rx_hash, > > }; > > > > struct mlx4_en_bond { > > diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c > > index 467356633172..fd14d59f6cbf 100644 > > --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c > > +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c > > @@ -663,8 +663,50 @@ static int check_csum(struct mlx4_cqe *cqe, struct sk_buff *skb, void *va, > > > > struct mlx4_xdp_buff { > > struct xdp_buff xdp; > > + struct mlx4_cqe *cqe; > > + struct mlx4_en_dev *mdev; > > + struct mlx4_en_rx_ring *ring; > > + struct net_device *dev; > > }; > > > > +bool mlx4_xdp_rx_timestamp_supported(const struct xdp_md *ctx) > > +{ > > + struct mlx4_xdp_buff *_ctx = (void *)ctx; > > + > > + return _ctx->ring->hwtstamp_rx_filter == HWTSTAMP_FILTER_ALL; > > +} > > + > > +u64 mlx4_xdp_rx_timestamp(const struct xdp_md *ctx) > > +{ > > + struct mlx4_xdp_buff *_ctx = (void *)ctx; > > + unsigned int seq; > > + u64 timestamp; > > + u64 nsec; > > + > > + timestamp = mlx4_en_get_cqe_ts(_ctx->cqe); > > + > > + do { > > + seq = read_seqbegin(&_ctx->mdev->clock_lock); > > + nsec = timecounter_cyc2time(&_ctx->mdev->clock, timestamp); > > + } while (read_seqretry(&_ctx->mdev->clock_lock, seq)); > > + > > This is open-code version of mlx4_en_fill_hwtstamps. > Better use the existing function. That one assumes the skb_shared_hwtstamps argument :-( Should I try to separate the common parts into some new helper function instead? Or maybe I can just change mlx4_en_fill_hwtstamps to the following? u64 mlx4_en_fill_hwtstamps(struct mlx4_en_dev *mdev, u64 timestamp) { ... return ns_to_ktime(nsec); } And replace existing callers with: skb_hwtstamps(skb)->hwtstamp = mlx4_en_fill_hwtstamps(priv->mdev, timestamp). ? > > + return ns_to_ktime(nsec); > > +} > > + > > +bool mlx4_xdp_rx_hash_supported(const struct xdp_md *ctx) > > +{ > > + struct mlx4_xdp_buff *_ctx = (void *)ctx; > > + > > + return _ctx->dev->features & NETIF_F_RXHASH; > > +} > > + > > +u32 mlx4_xdp_rx_hash(const struct xdp_md *ctx) > > +{ > > + struct mlx4_xdp_buff *_ctx = (void *)ctx; > > + > > + return be32_to_cpu(_ctx->cqe->immed_rss_invalid); > > +} > > + > > int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int budget) > > { > > struct mlx4_en_priv *priv = netdev_priv(dev); > > @@ -781,8 +823,12 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud > > DMA_FROM_DEVICE); > > > > xdp_prepare_buff(&mxbuf.xdp, va - frags[0].page_offset, > > - frags[0].page_offset, length, false); > > + frags[0].page_offset, length, true); > > orig_data = mxbuf.xdp.data; > > + mxbuf.cqe = cqe; > > + mxbuf.mdev = priv->mdev; > > + mxbuf.ring = ring; > > + mxbuf.dev = dev; > > > > act = bpf_prog_run_xdp(xdp_prog, &mxbuf.xdp); > > > > diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h > > index 6646634a0b9d..d5904da1d490 100644 > > --- a/include/linux/mlx4/device.h > > +++ b/include/linux/mlx4/device.h > > @@ -1585,4 +1585,11 @@ static inline int mlx4_get_num_reserved_uar(struct mlx4_dev *dev) > > /* The first 128 UARs are used for EQ doorbells */ > > return (128 >> (PAGE_SHIFT - dev->uar_page_shift)); > > } > > + > > +struct xdp_md; > > +bool mlx4_xdp_rx_timestamp_supported(const struct xdp_md *ctx); > > +u64 mlx4_xdp_rx_timestamp(const struct xdp_md *ctx); > > +bool mlx4_xdp_rx_hash_supported(const struct xdp_md *ctx); > > +u32 mlx4_xdp_rx_hash(const struct xdp_md *ctx); > > + > > #endif /* MLX4_DEVICE_H */