From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7BFCF461A3 for ; Thu, 6 Feb 2025 03:09:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 735244066E; Thu, 6 Feb 2025 03:09:53 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id B0135402F1 for ; Thu, 6 Feb 2025 03:09:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738807791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zXVLJMlhYbug+zGuyvJSWIvlFI444EdTQuZ6DEtian0=; b=RjEWbZ86GjawDDFAM5TjIQ384NbEFuMxhVn+RKDXhhMEPFBrARYd+VEPTJq00ipF3v4IkL ReWGBWlQANmjYsz9G1e3gUnJx0xU5TfgaocIX+5xps/TGepB4RxLlfQRLxlm2cugRsPA2Q 1lckjC+Yv3hWF9lDFscwKp2nFxmPJso= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-462-luzFraLTPK6AxFNf8AhMoQ-1; Wed, 05 Feb 2025 21:09:49 -0500 X-MC-Unique: luzFraLTPK6AxFNf8AhMoQ-1 X-Mimecast-MFC-AGG-ID: luzFraLTPK6AxFNf8AhMoQ Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-6f46fb73061so5477987b3.1 for ; Wed, 05 Feb 2025 18:09:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738807789; x=1739412589; 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=zXVLJMlhYbug+zGuyvJSWIvlFI444EdTQuZ6DEtian0=; b=BxVHJW8huYhLsxXSU386W/VajYvKw44Zlrs2AXMYXz7Y5pRhGCREt2giIn5b2V91HM KeAngGVGqYcf1QGFcwQxWgkEjvG+KR8f6U1DjyrkJ23V95wV2MUo4GHZhV54yL7v1Lav qFhaXguIbVuUamrVQt55Y7tO1nVyqWgx7BIN38wQeZOdPRGZYRspoWXLSo8zhw9lnWja Sgm597MaSprg0HvCKavZlbAv2ZEwVzKvOISMjhuKbjjD14DBcpzjT7SeMND4gGisy/N7 DNbl7Fd1P4qVc+oeFkMA+eYM6znRiPseTYDFchTyGG0V32kWwLqaW1wHNnSuwrsjOoMA +Lmg== X-Forwarded-Encrypted: i=1; AJvYcCURkHPzEZ9tI4M0YWuRlEPhFaOw0HkIQ1V0oV2/Sno3aK9WhNj8jY5N8lm1IZM2iAv+EndozRI=@dpdk.org X-Gm-Message-State: AOJu0Yx74zOTCaKPUbGdGp1busquiMvBHsELp+9NxTQ61TMWmxmDJVVa EZRjwTUJLuUBNAZOmwwnOafe2eWznSs7We5zzpKElMM9moO42k1+bmqU+fRsE1Tv6b+A6qHO1IP BKe681YGU0elKlCX7OLEZkwXBmbZrZnYbdAyCYDURTju9qgvFrS7IbP8PStHnrEtJnvWFWZLcYF eQ9NVFW+2O5p51VcXUrx4= X-Gm-Gg: ASbGncu8kEVlty/WAJbCxJn6+Uz8oH7vI+1ogpCB5IDI/SJzhmVa8unBZs4/8w6udMQ l9WeUoQCoCQ7xU+lpofzwasOvSkB9xXSTwu/XoLVKVzuQEjXL9/Yn8qLR5caTHXYvCPk+wmcf0K jDMbPGHrs1wsO9kX2Pu9uA X-Received: by 2002:a05:690c:700f:b0:6f0:3f7:ab1e with SMTP id 00721157ae682-6f99a68bbe3mr17059037b3.16.1738807789002; Wed, 05 Feb 2025 18:09:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFB/KqLt7yp75BJ23KLQkzDNTo3ixtHEvQRt1bMq0piqoZy1FhbyLIk7Uea3+YwCTaVDlQc8t0kFIAVPUmoAkI= X-Received: by 2002:a05:690c:700f:b0:6f0:3f7:ab1e with SMTP id 00721157ae682-6f99a68bbe3mr17058887b3.16.1738807788700; Wed, 05 Feb 2025 18:09:48 -0800 (PST) MIME-Version: 1.0 References: <20250116195640.68885-1-ariel.otilibili@6wind.com> <20250201100300.2194018-1-ariel.otilibili@6wind.com> <20250201100300.2194018-3-ariel.otilibili@6wind.com> In-Reply-To: <20250201100300.2194018-3-ariel.otilibili@6wind.com> From: Maryam Tahhan Date: Thu, 6 Feb 2025 02:08:16 +0000 X-Gm-Features: AWEUYZm7WZcGH61OLiBMzbe8KeB7FFMRwAMbZhYIeEqWziCvb_0c0xpzEHWShSs Message-ID: Subject: Re: [PATCH v7 2/2] net/af_xdp: Refactor af_xdp_tx_zc To: Ariel Otilibili Cc: "dev@dpdk.org" , "stable@dpdk.org" , Thomas Monjalon , David Marchand , Stephen Hemminger , Ciara Loftus X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: AAizLU3pLvPE99c-m1xYtQde2d7ccRCy53rObmuA6zw_1738807789 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="000000000000941f0b062d6fbc5b" X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org --000000000000941f0b062d6fbc5b Content-Type: text/plain; charset="UTF-8" On Sat 1 Feb 2025, 10:03 Ariel Otilibili, wrote: > Both legs of the loop share the same logic: the common parts are about > reserving and filling both address and length into the description. > > This is moved into reserve_and_fill(). > > Bugzilla ID: 1440 > Suggested-by: Maryam Tahhan > Signed-off-by: Ariel Otilibili > --- > drivers/net/af_xdp/rte_eth_af_xdp.c | 62 ++++++++++++++++------------- > 1 file changed, 34 insertions(+), 28 deletions(-) > > diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c > b/drivers/net/af_xdp/rte_eth_af_xdp.c > index 092bcb73aa0a..840a12dbf508 100644 > --- a/drivers/net/af_xdp/rte_eth_af_xdp.c > +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c > @@ -536,6 +536,31 @@ kick_tx(struct pkt_tx_queue *txq, struct > xsk_ring_cons *cq) > } > } > > +static inline struct xdp_desc * > +reserve_and_fill(struct pkt_tx_queue *txq, struct rte_mbuf *mbuf, > + struct xsk_umem_info *umem) > +{ > + struct xdp_desc *desc = NULL; > + uint32_t *idx_tx = NULL; > Took me a while to spot this but this needs to be a uint32_t not a pointer to uint32_t, because xsk_ring_prod__reserve() does not allocate memory for idx_tx it just expects to dereference a pointer to a uint32_t to store the index... + uint64_t addr, offset; > + > + if (!xsk_ring_prod__reserve(&txq->tx, 1, idx_tx)) > + goto out; > + > + desc = xsk_ring_prod__tx_desc(&txq->tx, *idx_tx); > + desc->len = mbuf->pkt_len; > + > + addr = (uint64_t)mbuf - (uint64_t)umem->buffer > + - umem->mb_pool->header_size; > + offset = rte_pktmbuf_mtod(mbuf, uint64_t) - (uint64_t)mbuf > + + umem->mb_pool->header_size; > + offset = offset << XSK_UNALIGNED_BUF_OFFSET_SHIFT; > + desc->addr = addr | offset; > + > +out: > + return desc; > +} > + > --000000000000941f0b062d6fbc5b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Sat 1 Feb 2025, 10:03 Ariel O= tilibili, <ariel.otilibili@= 6wind.com> wrote:
Both leg= s of the loop share the same logic: the common parts are about
reserving and filling both address and length into the description.

This is moved into reserve_and_fill().

Bugzilla ID: 1440
Suggested-by: Maryam Tahhan <mtahhan@redhat.com>
Signed-off-by: Ariel Otilibili <ariel.otilibili@6wind.com>=
---
=C2=A0drivers/net/af_xdp/rte_eth_af_xdp.c | 62 ++++++++++++++++------------= -
=C2=A01 file changed, 34 insertions(+), 28 deletions(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_e= th_af_xdp.c
index 092bcb73aa0a..840a12dbf508 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -536,6 +536,31 @@ kick_tx(struct pkt_tx_queue *txq, struct xsk_ring_cons= *cq)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0}

+static inline struct xdp_desc *
+reserve_and_fill(struct pkt_tx_queue *txq, struct rte_mbuf *mbuf,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct xsk_umem_in= fo *umem)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0struct xdp_desc *desc =3D NULL;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0uint32_t *idx_tx =3D NULL;

Took me a while to sp= ot this but this needs to be a uint32_t not a pointer to uint32_t, because = xsk_ring_prod__reserve() does not allocate memory for idx_tx it just expect= s to dereference a pointer to a uint32_t to store the index...

+=C2=A0 =C2=A0 =C2=A0 =C2=A0uint64_t addr, offset;
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (!xsk_ring_prod__reserve(&txq->tx, 1,= idx_tx))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0goto out;
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0desc =3D xsk_ring_prod__tx_desc(&txq->tx= , *idx_tx);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0desc->len =3D mbuf->pkt_len;
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0addr =3D (uint64_t)mbuf - (uint64_t)umem->bu= ffer
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- umem->mb_pool-= >header_size;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0offset =3D rte_pktmbuf_mtod(mbuf, uint64_t) - (= uint64_t)mbuf
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ umem->mb_pool-= >header_size;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0offset =3D offset << XSK_UNALIGNED_BUF_OF= FSET_SHIFT;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0desc->addr =3D addr | offset;
+
+out:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return desc;
+}
+
<snip>
--000000000000941f0b062d6fbc5b--