From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by mail.toke.dk (Postfix) with ESMTPS id E38809C4952 for ; Tue, 22 Nov 2022 14:50:27 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=JjjD1XkK Received: by mail-wr1-x432.google.com with SMTP id b12so11001679wrn.2 for ; Tue, 22 Nov 2022 05:50:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=+2RxZVjn+Kqn8Jxp3X+XGyQFgx1akp5xCh6njJ2sPFk=; b=JjjD1XkKFdASsNPZSHEuPZjhLhpXaQ+Nw9q5Njff/LbrpCjHPH8v20iPG1T3N6Q1dx +k6YSb7eUpEWJ646ZodbQD+6fkbkx206H/71hCcnmDS9Lr+5grRE6SRsTAN3qOmeP8tG gIajY4glhBROAg7arJm56De/7hd5p4GFOWYu8as4RiUYAU01CmcIvNFUWjuO/pe7TZ0+ MO7dxFaDp70kzXYsBI3dvpRhRL3Z/iz3zVLfXqe1FuNwXW4qyNwc7xKtBguUJa36Krto IGPcQHMqhBrrXRLYm7tsh+UxO762W4wjSL26DrfaMebqSGYlTo7w5D4WCI8I5/N4w/Tl zcJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+2RxZVjn+Kqn8Jxp3X+XGyQFgx1akp5xCh6njJ2sPFk=; b=Ha13smzJW2mlBxhD18SLh2+Se4IqPlQYvtAC6nBQufu5GcDmTl4t11KF1dBTyc2F1m KcnMYzXVdcq6EipAYl39JXxTN4N9MVvGjOwmOegRlMxwkX0UbW1w7MDww2ZprMnHwk14 c7VEZRRpjH9I/1YoWHQd2orC3WzUGULhKzBpQzSenM+VsNy2tYBtzJKZkJjqQr9z/4CD 7SKesh5gQZEhkE0D82fVQoLpt8kGbRrDjTZdSeaMfLERW60z/dyVaLSaQa7ElHHmTJPr CrXOIJKEjN2yIVCeCKmEOlWzwFOoUvBpojt33vX0WXFQu/Fhkc2BPoWz0/mBG/ZGoasH //kg== X-Gm-Message-State: ANoB5pnxnROkahGsAowYJi4v5R91A8b2M6S8gIYDP1I0t/n4PGjunJqP pkW8/PQK34TVBpAZeT1IEpU= X-Google-Smtp-Source: AA0mqf5QGdezDzE8VAq+/Ak+BD21TrsJzoC7qm0FCPTlB828kaLZsY4B2TshJSJQ7qaXtmmx5ywuWw== X-Received: by 2002:a5d:5e87:0:b0:241:e7a6:db08 with SMTP id ck7-20020a5d5e87000000b00241e7a6db08mr665522wrb.349.1669125026995; Tue, 22 Nov 2022 05:50:26 -0800 (PST) Received: from [10.158.37.55] ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id w19-20020adfbad3000000b00241c6729c2bsm11012241wrg.26.2022.11.22.05.50.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Nov 2022 05:50:26 -0800 (PST) Message-ID: Date: Tue, 22 Nov 2022 15:50:24 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 To: Stanislav Fomichev , bpf@vger.kernel.org References: <20221121182552.2152891-1-sdf@google.com> <20221121182552.2152891-8-sdf@google.com> Content-Language: en-US From: Tariq Toukan In-Reply-To: <20221121182552.2152891-8-sdf@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: TWSXMT3QT7QXCTC4KRNQ7RTJGNCQRS4Y X-Message-ID-Hash: TWSXMT3QT7QXCTC4KRNQ7RTJGNCQRS4Y X-MailFrom: ttoukan.linux@gmail.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: 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 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. > + 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 */