From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by mail.toke.dk (Postfix) with ESMTPS id 084A09B2ED9 for ; Fri, 4 Nov 2022 04:25:55 +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=Lw1af5Fp Received: by mail-yb1-xb49.google.com with SMTP id o2-20020a5b0502000000b006cade5e7c07so3907836ybp.10 for ; Thu, 03 Nov 2022 20:25:54 -0700 (PDT) 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=LmbtQXfRONLBh7ffBd4bAoho6T1l6iyjip9uOPJH4mk=; b=Lw1af5FpHUm//u0lneQQXILnQQOe094KHIbDHo04ndW9Wm0QYP/Utudp0RwLDKflC7 mWVEfBsBrHd+y79qCH6wlEOcerziq4X7Ob1YOGYymJqg4jWPCRvjeIZgSdW5Rr6T3P1g Hj9KqnMx1aD7dTSZ3PelqdO/Sz+cjzUnoaQKT2be31CMSzLdlMEyj4fRiXVf+DIzJbMc MV8ydpUdA5p3hgcZgIR3sAX+f+h4CPdH0IQ4lrqXTS4rz50/YXzzpdROHsPSOl7sbqpO /niw+87K1NzYu5SNmxkGiY5RhsMl5WL3yE8gD5UWlVDSBhFd2pFraZUmfmSmkK6KVtW3 DhqA== 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=LmbtQXfRONLBh7ffBd4bAoho6T1l6iyjip9uOPJH4mk=; b=1poZxjM/WbcKJMt0XhXgxTy8M52elwK/xUTFAretxDXzmNgLUP1+BHkMBhOvTL3Hmh UTRNYNdMMLF4UqoMc4aygQ7zUy6inm2LY9nFimY8SOfXOZU3kmXgqZTCLBrr0I5XaO+l uNilK1p8excdSHpEa+OVlcP6XhDoyjg8Q+C9h3WcHGP8cOtE2tjAc4AibZvLz/pIgo3R Qm3e0TtezH1dz0VdN7dpX+Nxe7Mudt4iW96g+ctpvzTPxpAHwnDrfeEZCVG3IOmrSkDR +VlETg2SZUFy0btv4fiU6GzSVXwiJNfdc2wbR9yIQymZi4EVsvG368pc+bCqfXjtykru InYA== X-Gm-Message-State: ACrzQf3Y5gS8g2bT/vWRKsQGAdvMhP/e4DR1f9Qb2cfsdLQoF06XV5wo VTVRt7RV2zJJo3CxawyjlDnfmPY= X-Google-Smtp-Source: AMsMyM6oXVRxlUxBPOoqUVjc0pj8sEzbe1fz3rRjT8kX5DdfBDV7EJoYLV0dYixcNK52Ik4vHwwMmu4= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a25:e6d8:0:b0:6cb:72c:d06f with SMTP id d207-20020a25e6d8000000b006cb072cd06fmr30997529ybh.389.1667532353925; Thu, 03 Nov 2022 20:25:53 -0700 (PDT) Date: Thu, 3 Nov 2022 20:25:29 -0700 In-Reply-To: <20221104032532.1615099-1-sdf@google.com> Mime-Version: 1.0 References: <20221104032532.1615099-1-sdf@google.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Message-ID: <20221104032532.1615099-12-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: LZYS4SVNL25A3TRUUGHUUMVJ35H5UMFK X-Message-ID-Hash: LZYS4SVNL25A3TRUUGHUUMVJ35H5UMFK X-MailFrom: 3QYZkYwMKCQIufhiqqing.eqozfr-jkpvuzfr-rtqlgev.pgv@flex--sdf.bounces.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: 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, 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.5 Precedence: list Subject: [xdp-hints] [RFC bpf-next v2 11/14] mlx4: Introduce mlx4_xdp_buff wrapper for xdp_buff List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: No functional changes. Boilerplate to allow stuffing more data after xdp_buff. 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 --- 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..467356633172 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -661,17 +661,21 @@ 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_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); int factor = priv->cqe_factor; struct mlx4_en_rx_ring *ring; + struct mlx4_xdp_buff mxbuf; struct bpf_prog *xdp_prog; int cq_ring = cq->ring; 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; -- 2.38.1.431.g37b22c650d-goog