From patchwork Tue Dec 13 02:36:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13071658 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6077EC4167B for ; Tue, 13 Dec 2022 02:37:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234297AbiLMChZ (ORCPT ); Mon, 12 Dec 2022 21:37:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234142AbiLMCgx (ORCPT ); Mon, 12 Dec 2022 21:36:53 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A26021E3C0 for ; Mon, 12 Dec 2022 18:36:24 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id v195-20020a252fcc000000b007125383fe0dso15046358ybv.23 for ; Mon, 12 Dec 2022 18:36:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=C/11ZOv9dp252wO/iEY3od+QlXFjWbrw8VnfZvsdseQ=; b=iQaWTQ5i1WvyXxuNWFfpK7w9ehir2Z3DToOJHH41njvgWtJnqHTmF56TPUBGXig1nK phTS/1JNvryB2RIv+AC5pH6jXdnZBgHvdM/Tsmn29gU/FC/OD7y5i6jyjy2knETUFic8 Gku+m6kmuTBNdUJR0w1A5SRy5F3R8YTk8pLptcNBVpAaJ3DbiZ9NDYGI6d3N99zZXYmt 8+DykWXSOktCM8iKBybTe640ku7NoeyXNKL8Gj8n3eqpsSdJdOWMZMLWgq5c5Q0mOhtf xa6lEXdIoiVL/KqnlNVKect6GwYmgx4vocch2rPQfLchGTK5/mimE6khbFKQQGnw2W4I q12A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=C/11ZOv9dp252wO/iEY3od+QlXFjWbrw8VnfZvsdseQ=; b=3AIMV4jgBk1bO/AU5XF4quZygqup4Nah3k6Om6QdAW4FU2l2wjQaxygXACvDa/rTQK p0GeX4zd24RIs8ZzUs7OyAq3OaENhev7EiCT8Uh8MvIS/oX+uFg+gPUUj5i7dNLHjlJO JgHVp+Q8RZthOFyUw9POFEogVS4z+uwJoRrZos+mpn/84KN+5HcQVUCGnJRr1yZpIlwC +dUdBYXtc4PFkHWJYY70vceuZ+Sczy0cd5Luy4CccSTY8AbrTSrWp2KABcnmSX5MknKP DjfraYfbsAANN0RPK38sfyb9yQxwxfgg4gapz954k7RIGxvNNp3JVf1ttAKK264DtJUw cEzQ== X-Gm-Message-State: ANoB5pn4SPC1LYf7/edb6MF3vJch4q6k7g0t697T56LCoEauiuTmIuBC AbZE9ioMPo5u6JW7PjILkHplSG0= X-Google-Smtp-Source: AA0mqf5dAKxHGHyFgsfH9XrSykz/CB7VXBqYxTBVzbVlj7f8zEbeHflmDccnZ+4b52BT5bpCBcri3HI= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a81:194f:0:b0:3de:7599:c5fd with SMTP id 76-20020a81194f000000b003de7599c5fdmr30393429ywz.84.1670898983671; Mon, 12 Dec 2022 18:36:23 -0800 (PST) Date: Mon, 12 Dec 2022 18:36:00 -0800 In-Reply-To: <20221213023605.737383-1-sdf@google.com> Mime-Version: 1.0 References: <20221213023605.737383-1-sdf@google.com> X-Mailer: git-send-email 2.39.0.rc1.256.g54fd8350bd-goog Message-ID: <20221213023605.737383-11-sdf@google.com> Subject: [PATCH bpf-next v4 10/15] net/mlx4_en: Introduce wrapper for xdp_buff From: Stanislav Fomichev To: bpf@vger.kernel.org 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, sdf@google.com, 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net No functional changes. Boilerplate to allow stuffing more data after xdp_buff. 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 Reviewed-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index 8f762fc170b3..014a80af2813 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -661,9 +661,14 @@ static int check_csum(struct mlx4_cqe *cqe, struct sk_buff *skb, void *va, #define MLX4_CQE_STATUS_IP_ANY (MLX4_CQE_STATUS_IPV4) #endif +struct mlx4_en_xdp_buff { + struct xdp_buff xdp; +}; + 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); + struct mlx4_en_xdp_buff mxbuf = {}; int factor = priv->cqe_factor; struct mlx4_en_rx_ring *ring; struct bpf_prog *xdp_prog; @@ -671,7 +676,6 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud bool doorbell_pending; bool xdp_redir_flush; struct mlx4_cqe *cqe; - struct xdp_buff xdp; int polled = 0; int index; @@ -681,7 +685,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud ring = priv->rx_ring[cq_ring]; xdp_prog = rcu_dereference_bh(ring->xdp_prog); - xdp_init_buff(&xdp, priv->frag_info[0].frag_stride, &ring->xdp_rxq); + xdp_init_buff(&mxbuf.xdp, priv->frag_info[0].frag_stride, &ring->xdp_rxq); doorbell_pending = false; xdp_redir_flush = false; @@ -776,24 +780,24 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud priv->frag_info[0].frag_size, DMA_FROM_DEVICE); - xdp_prepare_buff(&xdp, va - frags[0].page_offset, + xdp_prepare_buff(&mxbuf.xdp, va - frags[0].page_offset, frags[0].page_offset, length, false); - orig_data = xdp.data; + orig_data = mxbuf.xdp.data; - act = bpf_prog_run_xdp(xdp_prog, &xdp); + act = bpf_prog_run_xdp(xdp_prog, &mxbuf.xdp); - length = xdp.data_end - xdp.data; - if (xdp.data != orig_data) { - frags[0].page_offset = xdp.data - - xdp.data_hard_start; - va = xdp.data; + length = mxbuf.xdp.data_end - mxbuf.xdp.data; + if (mxbuf.xdp.data != orig_data) { + frags[0].page_offset = mxbuf.xdp.data - + mxbuf.xdp.data_hard_start; + va = mxbuf.xdp.data; } switch (act) { case XDP_PASS: break; case XDP_REDIRECT: - if (likely(!xdp_do_redirect(dev, &xdp, xdp_prog))) { + if (likely(!xdp_do_redirect(dev, &mxbuf.xdp, xdp_prog))) { ring->xdp_redirect++; xdp_redir_flush = true; frags[0].page = NULL;