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 7C0FB41E86; Mon, 13 Mar 2023 10:35:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 102F0406BC; Mon, 13 Mar 2023 10:35:03 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 642A240151 for ; Mon, 13 Mar 2023 10:35:01 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32D6ud2r015475; Mon, 13 Mar 2023 02:35:00 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=h4+r0/kj4POMc6/GFjUSpTPGz0bI4CZF/ofp1fhr4Dw=; b=cAYkhWqfJwZpZ6tf2AGmalrSM4KeWe6Nx8tEG4yD0sTm9owAubSTUh2UQ493XacPPaqm ccLwCMQ7QhsIcqAtOq6sNhsp0fWe7mUqTWxhgPeca24xzPKjasXNYLOP5Y6ykim0y43h HtkkfZW6NTAYTWfTTqDkByY+VoKzZ1uX6JwOHzcYeO8SKuJNRdE3NsmzcmkeLjZUeHwE D9+s4umZ7eM0CYt5N+KCm8bpGf4tMUzJhZZB9DSS+wIuOamVjlQdprzjCMFrYxYPegn5 sLNbtW0s7sGhXIXp3WIsU6UB5tlAZiok/cTymPZOBqDoluuJiwv0QmnbPN7Gy95EOezw xA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3p9xxmrjdk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 13 Mar 2023 02:35:00 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 13 Mar 2023 02:34:58 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Mon, 13 Mar 2023 02:34:58 -0700 Received: from cavium-DT10.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id 4C52C3F704A; Mon, 13 Mar 2023 02:34:55 -0700 (PDT) From: Volodymyr Fialko To: , Reshma Pattan , David Marchand , Andrew Rybchenko CC: , , Volodymyr Fialko Subject: [PATCH] reorder: fix registration of dynamic field in mbuf Date: Mon, 13 Mar 2023 10:34:50 +0100 Message-ID: <20230313093450.2560058-1-vfialko@marvell.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: rQS1QLbV8OtgClb1nhj9k5ehfN8UxU-W X-Proofpoint-ORIG-GUID: rQS1QLbV8OtgClb1nhj9k5ehfN8UxU-W X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-13_02,2023-03-10_01,2023-02-09_01 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 It's possible to initialize reorder buffer with user allocated memory via rte_reorder_init() function. In such case rte_reorder_create() not required and reorder dynamic field in rte_mbuf will be not registered. Fixes: 01f3496695b5 ("reorder: switch sequence number to dynamic mbuf field") 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 = { + .name = RTE_REORDER_SEQN_DYNFIELD_NAME, + .size = sizeof(rte_reorder_seqn_t), + .align = __alignof__(rte_reorder_seqn_t), + }; + + if (rte_reorder_seqn_dynfield_offset > 0) + return 0; + + ret = rte_mbuf_dynfield_register(&reorder_seqn_dynfield_desc); + if (ret < 0) + return ret; + rte_reorder_seqn_dynfield_offset = ret; + + return 0; +} + 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, unsigned int bufsize, rte_errno = EINVAL; return NULL; } + if (rte_reorder_dynf_register()) { + RTE_LOG(ERR, REORDER, "Failed to register mbuf field for reorder sequence" + " number\n"); + rte_errno = ENOMEM; + 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 = sizeof(struct rte_reorder_buffer) + (2 * size * sizeof(struct rte_mbuf *)); - static const struct rte_mbuf_dynfield reorder_seqn_dynfield_desc = { - .name = RTE_REORDER_SEQN_DYNFIELD_NAME, - .size = sizeof(rte_reorder_seqn_t), - .align = __alignof__(rte_reorder_seqn_t), - }; reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list); @@ -128,10 +151,9 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size) return NULL; } - rte_reorder_seqn_dynfield_offset = - 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"); rte_errno = ENOMEM; return NULL; } -- 2.34.1