From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by mail.toke.dk (Postfix) with ESMTPS id DEEED9CB615 for ; Tue, 6 Dec 2022 03:46:09 +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=jzKf5vuX Received: by mail-pf1-x44a.google.com with SMTP id 67-20020a621946000000b00575f8210320so12183884pfz.10 for ; Mon, 05 Dec 2022 18:46:09 -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=nQeMNAXSvtEuYcIlZ03Sp5Z7s1yFLSbG448s72LvA8E=; b=jzKf5vuX89qjI4b5fE8iPrTEg2hyI8Yym1a3qyQFKi2JpBKl939zlQdC0MnUhaqktt ABOKSg9mtDi2UsCKoJkd0BXwqvKr/72JcVqZOndBMBpZ4ozhxR4nyNxowx8UHmA9purW uX1Xq1vmpQgFAw1KZkoW2JdmWwxRRadm/+cTyyXc0d/Y+ggtK0fO3fCdZRp7JqMybI23 uribklVJNAJ56GZzrisSD/qUmPZcVwRn7aj+kzu84OPdZurXjPlDW/OUA7fnUX/wQcOV MPHQjfHe1Eu/t1romkuybo1EroJOaGI70UF+qYa0XGx3JHp3C/fE/g2q4KiAEHy2Qfkv KxGQ== 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=nQeMNAXSvtEuYcIlZ03Sp5Z7s1yFLSbG448s72LvA8E=; b=JqLUOAFE49DXzV6uFnFXwoZABikC5fnUiWlmqfQhWEgB0myffKxT0uovXxJhiAMyw+ VeQJ2RTUxzNrq0i1sGCaCxxnkk1cpZDmenJxDCU1nreIwU8XHGNn2OZWNIpIVV+ZZCmx LI6h12PqoSIXfB41pT+W9Ig5kv7hx/h1p3E2lyd67v1VdQiwCNdqrnLoWYHDkMkHqpYC Zp3l7k0COzk5pqLNZ68jxZNjdQFzqSs2GchJxO4F30/nxGKLfKImsJcuMURzcnbuEcZs wxp+Ov6Z2N6VKDeBELTXxtzfF4Tos2epPHMMtnFUFGhf5zwYS+Z3lH20JRr2OTrKYjaf fCrg== X-Gm-Message-State: ANoB5pkCT9PWe8cjick6vcsh96baGI9yLJD31/fiqhbXIY9uvUJKnUJu iTlgqXC1x+kwMLEgDGxf3i/+3m4= X-Google-Smtp-Source: AA0mqf6MWZkcAPR7Ml+lQGeM7JUCA+2NSWk7DEjakG7MnoqPJmllJ8KlzYpAuEH/yTiYaUoF5JqYv3c= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a17:90a:d086:b0:219:227d:d91f with SMTP id k6-20020a17090ad08600b00219227dd91fmr4694402pju.0.1670294767948; Mon, 05 Dec 2022 18:46:07 -0800 (PST) Date: Mon, 5 Dec 2022 18:45:49 -0800 In-Reply-To: <20221206024554.3826186-1-sdf@google.com> Mime-Version: 1.0 References: <20221206024554.3826186-1-sdf@google.com> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog Message-ID: <20221206024554.3826186-8-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: 4QMCEQS37B2XYRNWFSHSZTK2FTDFFYLE X-Message-ID-Hash: 4QMCEQS37B2XYRNWFSHSZTK2FTDFFYLE X-MailFrom: 376yOYwMKCaYYJLMUUMRK.IUSdJV-NOTZYdJV-VXUPKIZ.TKZ@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, 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] [PATCH bpf-next v3 07/12] 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: 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 --- 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..9c114fc723e3 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_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_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; -- 2.39.0.rc0.267.gcb52ba06e7-goog