From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by mail.toke.dk (Postfix) with ESMTPS id 321469CD103 for ; Thu, 8 Dec 2022 20:07:19 +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=A+s2Ha6R Received: by mail-pf1-x433.google.com with SMTP id 124so2055890pfy.0 for ; Thu, 08 Dec 2022 11:07:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0pERAo/ZUY9HPHqlXk6GLorKGil/4lwotRBEEP3U6BA=; b=A+s2Ha6RpdyJvZKOPICTQHccx65R6tx+6+1yRtvT+NGr+1XksaFfbh3Fyo6o0MWGLd vjXw68egtpDzwDZ3tXmdJSD+vvdzxDFYu4S+JA81KNSvBAkEOmEuvKS0ksH77zWMaJLD 1cxLoiuXot4WxmwATOci1ArkYjMyqd873MjMQSC8a3vQb2jVQYMcGzUMYzpY4GAMMIQC YDJp0Gc3djv3E6bQcZgoOSxriLkvdPH5ldZ1XRS07Jldh9oAZC30H/gi0kgGOzkRr3Gv 1pGoIIxWpiNGDjHjeVpjckToQSBMV+TuQVy2faTmWIEqNl9Tj/6FGBe/xkEZcPMOvcV3 WbyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0pERAo/ZUY9HPHqlXk6GLorKGil/4lwotRBEEP3U6BA=; b=7ODkUbiTp427o62DHTobEFVIRnkwEm0LSwru4FA2NG43CZevgS0dri0USkG9aggAPb 1EGi81uOq1oPgP+4kSvDk1lT8D8pQm4SqdQpPKzQYmbm77P/GluyB2m0FcB6fiFcOXv8 ZsXCUzofGiUHXHrQFifTcKr9QfTF7+GiftKMZeKmiVPUYnNatmI3Cz3qoisdJcErrzy/ IuLqxPcQY6ybzU7p3sWdjuMgyUQfU0T+23PsYzzWXzkPMUiFD9kUG+k5a/y26zbwrlM2 0RNVE8iKZb6LLDVD2P3KIYHgOna9XsG/BfGmFOtuRAPw9edSS3AyipZdPbyPTEz8DDy0 e/Tg== X-Gm-Message-State: ANoB5plbuUdEBw2M5sc9TXyvRwkOARf5FJEPaoZ41nMiB0FxTCpC+gsW sDQzqqsKZ51djAV0rBuYlZ2FbHjKmPoX1suLkOtRkw== X-Google-Smtp-Source: AA0mqf5dmNfyJ3xh5zt+N4zrlJJXwQvF0SdoOdXSqDlNIN4+gU3J2R3fvV2gJd0gSqaMRCEor4zBdu7N/72ru8DWnfY= X-Received: by 2002:a63:4c01:0:b0:478:b7ab:2f72 with SMTP id z1-20020a634c01000000b00478b7ab2f72mr16273057pga.186.1670526436918; Thu, 08 Dec 2022 11:07:16 -0800 (PST) MIME-Version: 1.0 References: <20221206024554.3826186-1-sdf@google.com> <20221206024554.3826186-8-sdf@google.com> <8d5f451a-c49b-1abc-6573-71831aa09739@gmail.com> In-Reply-To: <8d5f451a-c49b-1abc-6573-71831aa09739@gmail.com> From: Stanislav Fomichev Date: Thu, 8 Dec 2022 11:07:05 -0800 Message-ID: To: Tariq Toukan Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: 2J32WXH3EQOHMHKF2UL6JNX2IGTLI5HD X-Message-ID-Hash: 2J32WXH3EQOHMHKF2UL6JNX2IGTLI5HD X-MailFrom: sdf@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: bpf@vger.kernel.org, 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 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: On Wed, Dec 7, 2022 at 10:11 PM Tariq Toukan wrote: > > > > On 12/6/2022 4:45 AM, Stanislav Fomichev wrote: > > 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; > > +}; > > + > > Prefer name with 'en', struct mlx4_en_xdp_buff. Sure, will rename! > > 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;