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 D5FCD461A3; Thu, 6 Feb 2025 03:09:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B1E5B4068A; Thu, 6 Feb 2025 03:09:54 +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 4C92D402F1 for ; Thu, 6 Feb 2025 03:09:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738807792; 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=YJme0/d/W/F85tErG0FplIMnCbxC9ZjOqARTbtJl8DKrZ99r1yM6KvLCgdbScp6UuhCYVH Iu7U/f9b8dbZo9jgBXHIX8YlZWH9GnGsYqQDiwN7A1iGXgg4H3LFzZN1l8jr58c56NwSTd cUb69v134AlfqOncWT0G6+9jlFq+wKQ= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-414-Xr8M1N-WPl2lijdohe1tLQ-1; Wed, 05 Feb 2025 21:09:49 -0500 X-MC-Unique: Xr8M1N-WPl2lijdohe1tLQ-1 X-Mimecast-MFC-AGG-ID: Xr8M1N-WPl2lijdohe1tLQ Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-6f46fb73061so5477997b3.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=pzP7ahI3Fuq+jUQPOrxDlrnji8HbsIdY0PwZQwI56EM7dFhUi0Wx0nuheTcNMnWfZz XkwECxRXoZ7vT1067bqSxzfXzw7J2TRuYKtaFrC+r4ooXCc/VQDpQA/vRbewAjc3uhbe IyzNIi/UB2bjEsO76Eeu48yNQq9SRb7npR8+K/4W1Ri5Kd9K2H+vb/57Jc0FUzLPhVRz ZbU/rH0BpodBchbbGL6jUf8USrmOkli+hqF8SI2m2USZB76+qR7CnZG5Sq9rgo3NRYKD n58lDTVSOBz9hLuk9n8u+rFciEfxuqFGvV0bUKEwKnmwpztTc3xufjDZusJJ9U4RlRXE l6iw== X-Gm-Message-State: AOJu0Yw+7YiIqJdSJR58f6v3/IDYvl7KtvetcHAKbP9icdAwy7MGZiSW isxZtPrZdZbmuIRu+bR5Cf2rnCfNB6HaWs6lVux59qYbG6uVTal4xhsK3VqGULtYPXxhYAy/EiE SqFknuyX8ukkd5mPjNMB2cLlMKyPKL9gbFxwxdPR3dwH3GtkhTDEbL12I+ycklAeR66rEnurhI5 6KF26l3pYRcR5EMu4= X-Gm-Gg: ASbGnctDPB0nwlh7CMDtLBHh7HYeMBMH7/XsFfzjHXM42Q9pRAdK5+ZGViyNMXmc8Y1 +tZfpjpKll0yZ46qmWXtdv/BIyednrmU9cebgSH48Ys82SovJbDB8C9H7n6zmTqAWP6hh44DE+V 9xZAkRc0K9DDgoomy/BC2V X-Received: by 2002:a05:690c:700f:b0:6f0:3f7:ab1e with SMTP id 00721157ae682-6f99a68bbe3mr17059067b3.16.1738807789003; 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: -APbdiQ2Z5oDJ7mkVjtB39wDWgUL1KU4w52whLxLo9k_1738807789 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="000000000000941f0b062d6fbc5b" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-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--