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 ED7C341D79; Mon, 13 Mar 2023 11:19:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E0332406BC; Mon, 13 Mar 2023 11:19:52 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 526AD40151 for ; Mon, 13 Mar 2023 11:19:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678702790; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ang1sghFl1cRHN48U+Sy45Vcpi+Ll5MY7QDdnM3pMc4=; b=SaGzPGrsw0p3MK5fT+B1pi7sjKy79QwW8ssGWu3k80HwrQHUSjJy0y5XPCnH5Kxd4APhhD RXbRjiqZZ/4ZLyKNaTaCjKJoRO33Uh8IOSaB3QaddVRbDWALSzGmicSa462q8VMps44IMd L3npfpS1IUh5r6WCJnUYY5S0AFiPwt0= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-213-6hrVQOlvNlKrE2iXyRiLZg-1; Mon, 13 Mar 2023 06:19:47 -0400 X-MC-Unique: 6hrVQOlvNlKrE2iXyRiLZg-1 Received: by mail-pj1-f69.google.com with SMTP id t2-20020a17090a4e4200b0023d27ab43b3so50218pjl.7 for ; Mon, 13 Mar 2023 03:19:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678702786; h=content-transfer-encoding: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=ang1sghFl1cRHN48U+Sy45Vcpi+Ll5MY7QDdnM3pMc4=; b=bjOvTTApmV57nEF7IKqn26KdjnExbbcFszD3cvWyn9LvopcU34mU04M+rg4384ca8E 3x9FZhlUUVhufBxlfag9GU3oO7zd88kH89Dqqo8GCBZ2k5hj0r90Jymw1upA3A0OTJZB ibDYWEwO4J+hgim18L8Dm5zK54FJOVzx3gpXhmwqkQvi9o/9YzUI1XaVrwkOR4OxFC/q VYeYltOfn47++zFA++fLIC7mlmmOb4AOj7ubpo0ePhLdrQvgmcNh3vFx1QEe3X/EqHkY eg2yQitqhfvdR0xCnyFawmr1ZEZGnBV5/VHsYeomU2rCh9vQ1bquliSPWI7473UwDhhZ 9QGA== X-Gm-Message-State: AO0yUKX9VQDX0J9X7T8BN2pjt7Y8iRePIUr86JhOroObcTXKJ08yEL7v JvZwaIiL8/i8krVbA2zyNRxawsDpWUpFS4YuSrZYBa+K+WNlntQL5jgOJIQdV0A5N0UgsHV6M0z eQ/D5kCiaJG/eEQPy0JQmoxB+//0cEQ== X-Received: by 2002:a63:5904:0:b0:4fc:7e60:d0c with SMTP id n4-20020a635904000000b004fc7e600d0cmr11264306pgb.11.1678702786724; Mon, 13 Mar 2023 03:19:46 -0700 (PDT) X-Google-Smtp-Source: AK7set89kMVAFkfKuosMKvtnEgLfbA8q3+HQWZmOf9ZO4GvaGK/CpEYFTnBH8PllBsL1RabXbQ6Lpl1CUggJCmOUUpI= X-Received: by 2002:a63:5904:0:b0:4fc:7e60:d0c with SMTP id n4-20020a635904000000b004fc7e600d0cmr11264303pgb.11.1678702786429; Mon, 13 Mar 2023 03:19:46 -0700 (PDT) MIME-Version: 1.0 References: <20230313093450.2560058-1-vfialko@marvell.com> In-Reply-To: <20230313093450.2560058-1-vfialko@marvell.com> From: David Marchand Date: Mon, 13 Mar 2023 11:19:35 +0100 Message-ID: Subject: Re: [PATCH] reorder: fix registration of dynamic field in mbuf To: Volodymyr Fialko , Reshma Pattan Cc: dev@dpdk.org, Andrew Rybchenko , jerinj@marvell.com, anoobj@marvell.com, Thomas Monjalon X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Hello, On Mon, Mar 13, 2023 at 10:35=E2=80=AFAM Volodymyr Fialko wrote: > > It's possible to initialize reorder buffer with user allocated memory via > rte_reorder_init() function. In such case rte_reorder_create() not requir= ed > and reorder dynamic field in rte_mbuf will be not registered. Good catch. > > Fixes: 01f3496695b5 ("reorder: switch sequence number to dynamic mbuf fie= ld") It seems worth backporting. Cc: stable@dpdk.org > > Signed-off-by: Volodymyr Fialko > --- > lib/reorder/rte_reorder.c | 40 ++++++++++++++++++++++++++++++--------- > 1 file changed, 31 insertions(+), 9 deletions(-) > > diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c > index 6e029c9e02..a759a9c434 100644 > --- a/lib/reorder/rte_reorder.c > +++ b/lib/reorder/rte_reorder.c > @@ -54,6 +54,28 @@ struct rte_reorder_buffer { > static void > rte_reorder_free_mbufs(struct rte_reorder_buffer *b); > > +static int > +rte_reorder_dynf_register(void) > +{ > + int ret; > + > + static const struct rte_mbuf_dynfield reorder_seqn_dynfield_desc = =3D { > + .name =3D RTE_REORDER_SEQN_DYNFIELD_NAME, > + .size =3D sizeof(rte_reorder_seqn_t), > + .align =3D __alignof__(rte_reorder_seqn_t), > + }; > + > + if (rte_reorder_seqn_dynfield_offset > 0) > + return 0; > + > + ret =3D rte_mbuf_dynfield_register(&reorder_seqn_dynfield_desc); > + if (ret < 0) > + return ret; > + rte_reorder_seqn_dynfield_offset =3D ret; > + > + return 0; > +} We don't need this helper (see my comment below, for rte_reorder_create), you can simply move this block to rte_reorder_init(). > + > struct rte_reorder_buffer * > rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize, > const char *name, unsigned int size) > @@ -85,6 +107,12 @@ rte_reorder_init(struct rte_reorder_buffer *b, unsign= ed int bufsize, > rte_errno =3D EINVAL; > return NULL; > } > + if (rte_reorder_dynf_register()) { > + RTE_LOG(ERR, REORDER, "Failed to register mbuf field for = reorder sequence" > + " number\n"); > + rte_errno =3D ENOMEM; I think returning this new errno code is fine from a ABI pov. An application would have to check for NULL return code in any case and can't act differently based on rte_errno value. However, this is a small change to the rte_reorder_init API, so it needs some update, see: * @return * The initialized reorder buffer instance, or NULL on error * On error case, rte_errno will be set appropriately: * - EINVAL - invalid parameters > + return NULL; > + } > > memset(b, 0, bufsize); > strlcpy(b->name, name, sizeof(b->name)); > @@ -106,11 +134,6 @@ rte_reorder_create(const char *name, unsigned socket= _id, unsigned int size) > struct rte_reorder_list *reorder_list; > const unsigned int bufsize =3D sizeof(struct rte_reorder_buffer) = + > (2 * size * sizeof(struct rte_mbu= f *)); > - static const struct rte_mbuf_dynfield reorder_seqn_dynfield_desc = =3D { > - .name =3D RTE_REORDER_SEQN_DYNFIELD_NAME, > - .size =3D sizeof(rte_reorder_seqn_t), > - .align =3D __alignof__(rte_reorder_seqn_t), > - }; > > reorder_list =3D RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reord= er_list); > > @@ -128,10 +151,9 @@ rte_reorder_create(const char *name, unsigned socket= _id, unsigned int size) > return NULL; > } > > - rte_reorder_seqn_dynfield_offset =3D > - rte_mbuf_dynfield_register(&reorder_seqn_dynfield_desc); > - if (rte_reorder_seqn_dynfield_offset < 0) { > - RTE_LOG(ERR, REORDER, "Failed to register mbuf field for = reorder sequence number\n"); > + if (rte_reorder_dynf_register()) { > + RTE_LOG(ERR, REORDER, "Failed to register mbuf field for = reorder sequence" > + " number\n"); All rte_reorder_buffer objects need to go through rte_reorder_init(). You can check rte_reorder_init() return code. > rte_errno =3D ENOMEM; > return NULL; > } > -- > 2.34.1 > --=20 David Marchand