From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by mail.toke.dk (Postfix) with ESMTPS id 955E09C493D for ; Tue, 22 Nov 2022 14:49:51 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=qAR+HYd6 Received: by mail-wr1-x42a.google.com with SMTP id s5so7598224wru.1 for ; Tue, 22 Nov 2022 05:49:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=XNodkTSmcFgMZtJ5tvJzrfqzIK2LYeya7mLQRstpr1I=; b=qAR+HYd6/P11Sjj0B7bGv1DFE6y9xN5agRBLCirBCBP3Yp+5nDzo6T21+JfzqzPVde PFZwASQRn5u7sIOBJr0WjyUmEq1UhTMmw7kLrAhU9DIN0QEpF45VSAAHQfWrBt930YiJ lgkaHO8C2nmnaqk/QsuhYoW8mheHf8z0qelg+H5X+AjZtS75iEQDooDNYD9Cfh96Aoru w3q94pPAeoxUGEVzxRyQjCl6KF3rScZv2iysMhC4lUtrzA+tZqkwnXZ2/VQZLaLG8nAt sbuZoprb5MGchEWk0vzp/9/FsnLRLmaHrhM9vP0DmOFJTN5olpUWGVQfWCZoDEq6u7nG yMJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XNodkTSmcFgMZtJ5tvJzrfqzIK2LYeya7mLQRstpr1I=; b=WkOzojXvZkPTSkvshFmiR5Hm8Y1QNgOOLCnszTLv5LkqlIaGl35iQuiGAlK4pyKyUb LtL3A2EV7Wv+FGvo/IhtDZjfpooFrzc/3UbIz6SezJSad3b2ubhPR8Yf3QfUB67tiagS 6RGJvE1/QCibBrse3AOHLlU8brv7R/7sW6vbRWYFaVImXsc+8vL2rKCVCOkJ8sNRBIee VeIVj56ueGm02uNM5yySmhnUVZ5kxOoYp+mrcEgjBDzUTxUCHpLEvMQ+ua07GXZXRIB4 KPetJKyStmbzUrCXpxiUOlX9hywelnOoFnfhl9NB9gP0e2dunzCBckXD32WVBuI4MX+C cmxg== X-Gm-Message-State: ANoB5plr1/2+tS25Gn7X9tzNE457kF7mZwRWE9kHNVANJNeGtCKXIpRU TMpX1crExABXyUETBU0p0Eo= X-Google-Smtp-Source: AA0mqf5GZjc+F+yu1OulAo+QwK2fYL7mY3JEzJ1O+KqOF5hzPS//8PoCvHARK2zW7Lm2RM25pwPZAw== X-Received: by 2002:a05:6000:1c15:b0:241:d30c:62c4 with SMTP id ba21-20020a0560001c1500b00241d30c62c4mr6756991wrb.219.1669124989056; Tue, 22 Nov 2022 05:49:49 -0800 (PST) Received: from [10.158.37.55] ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id c9-20020a5d5289000000b00236545edc91sm14037035wrv.76.2022.11.22.05.49.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Nov 2022 05:49:48 -0800 (PST) Message-ID: Date: Tue, 22 Nov 2022 15:49:45 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Content-Language: en-US To: Stanislav Fomichev , bpf@vger.kernel.org References: <20221121182552.2152891-1-sdf@google.com> <20221121182552.2152891-7-sdf@google.com> From: Tariq Toukan In-Reply-To: <20221121182552.2152891-7-sdf@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: XCBHY2DQQ5Q6NACWT335ZGAOLBRX7SCW X-Message-ID-Hash: XCBHY2DQQ5Q6NACWT335ZGAOLBRX7SCW X-MailFrom: ttoukan.linux@gmail.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, 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 v2 6/8] 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 11/21/2022 8:25 PM, 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..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 this would helpmxbuf; as it doesn't go through an init function (only mxbuf.xdp does), better init to zero. > 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;