From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by mail.toke.dk (Postfix) with ESMTPS id C5E5C9D92A9 for ; Wed, 4 Jan 2023 23:00:12 +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=PC0zQYtY Received: by mail-pl1-x649.google.com with SMTP id x17-20020a170902ec9100b0019294547b06so14456624plg.12 for ; Wed, 04 Jan 2023 14:00:12 -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=0Oy7FllImPrmrWnDEe5Btq4uEoMcI9LQQjpbM58Drwg=; b=PC0zQYtY9/jUMw1yTl/yAvPx34kEGE5SXcUGqetmAH3Xf+5Oj8Pk4E/tVlzuyRQ+9e +JPRZ8mK1L5WqW2Q/LYGL2/9K4nX78ooPKULiOa2cb2QItI7tY7XdlDhA8H4Emn4mRds Tm9DAFu8Uo7N33GkM+20dNA1P1qGh63SLGaDwbSmN/Q/jqL6eP57KP6g4pM4f9qtuyXk 0DvMQHe3WpF5ynPVOzkeC28J7gFOnJaYuE8yJYyiGiEc1bW44ZcOc80lGzpt7iYZZAfQ LOaf/0Ice0/vDybf+N/SNIghosIzAgplGovvh8MWX2KD3aVpyb4M3H7KtilUmUdoC2hZ n4mQ== 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=0Oy7FllImPrmrWnDEe5Btq4uEoMcI9LQQjpbM58Drwg=; b=bcgO5Pz8anv9K5eGWIRmYquP4c5Foj0HLPBsn41uxFIe57CLH/mZvgbZ33DPFUKU51 iRUALfv8eTiI6DfhLA8LOSIgCx8sCJPAB/gmRZgD/397DnZG0FX8D3lmfsp87JEUNxoN 84vRr/vP4/1PAyE8yfx8ttudfKMgLfNKDj1Lz76mwgfkFLs4k8z+ZEf3/xDrFdo6nFIq MBIY6kLV+z2DLt93v71DNZd85OSQ+lYtBYIJEuikMEOKMKdZEA5ACQA/nvuOqWAvLDSh hfRjRhpgJ6p+7n96HCsK1T8+MlVNFFLmXGg5QhANw0XwpyOk6qNhlv2lHJ6VVPtljXHz MOmg== X-Gm-Message-State: AFqh2kpkibQrH4Rwb/XKETCxtOmASFfUdiGf1pp3l9fMnwB/fA6OLAEP igFj550yCXlrtqEDTna4irJpiMY= X-Google-Smtp-Source: AMrXdXtCFEa4vGYj8h+E7QeRmTQAJ4s/vqPUMz1jII5eUe9tW7PabIc3U6Kd6gfyN9L1iF3mLseI6A8= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a17:902:6b4b:b0:191:4575:48b8 with SMTP id g11-20020a1709026b4b00b00191457548b8mr2194116plt.118.1672869610768; Wed, 04 Jan 2023 14:00:10 -0800 (PST) Date: Wed, 4 Jan 2023 13:59:44 -0800 In-Reply-To: <20230104215949.529093-1-sdf@google.com> Mime-Version: 1.0 References: <20230104215949.529093-1-sdf@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230104215949.529093-13-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: WKRFFWQN5QAAL4NPOSF63JBAOHUO2R6I X-Message-ID-Hash: WKRFFWQN5QAAL4NPOSF63JBAOHUO2R6I X-MailFrom: 36va1YwMKCdMH245DD5A3.1DBM2E-67CIHM2E-EGD831I.C3I@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, Tariq Toukan X-Mailman-Version: 3.3.7 Precedence: list Subject: [xdp-hints] [PATCH bpf-next v6 12/17] net/mlx4_en: Introduce 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 Reviewed-by: Tariq Toukan 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..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; -- 2.39.0.314.g84b9a713c41-goog