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 4471941CE5; Mon, 20 Feb 2023 11:48:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9F4764301C; Mon, 20 Feb 2023 11:48:52 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id EE52E43020 for ; Mon, 20 Feb 2023 11:48:50 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31K62GhG020534; Mon, 20 Feb 2023 02:48:50 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=q/u/xqZbGM4IVu2yDa6B2Ug8igZfzD6jkqHohZFaCaQ=; b=ROAwBD3MA2JsAyOflxQztZ1AMUZsTjk2wgW38zwgmNLhzaBKNk5cCke2Hb0xrL4KJJtV btq67805jhS49PtVJrj4jO3scOZLRztnopjqltzf1ooaK2cchSW0vF6X+8Wx7rNUr9+v MCAwF9JsoRFoDPin0Cz5cOkMPnYY97ehfHIERPNZoISRFR4mvnXekcyHC2qiVbAe/Bxq IOC+qu6fK2omliYbbAwZrAwN8kYTuvvQb6OkJBjKMTKP6HIfHQ0NFs4t8haBzNEJ8EzM uNpVXqrkzYtNSxu3rz3RO5AL6M2XYoNt5K2/ChLNPWEA1StjTXirtblefUZTV+43BRmL rw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3nty2yxpmr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 20 Feb 2023 02:48:50 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 20 Feb 2023 02:48:47 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Mon, 20 Feb 2023 02:48:47 -0800 Received: from cavium-DT10.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id 798743F70A8; Mon, 20 Feb 2023 02:48:45 -0800 (PST) From: Volodymyr Fialko To: , Reshma Pattan CC: , , , , Volodymyr Fialko Subject: [PATCH v2 2/2] reorder: add ability to set min sequence number Date: Mon, 20 Feb 2023 11:48:29 +0100 Message-ID: <20230220104830.4086788-3-vfialko@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220104830.4086788-1-vfialko@marvell.com> References: <20230120102146.4035460-1-vfialko@marvell.com> <20230220104830.4086788-1-vfialko@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: Rd5BYA1rJSlP6JFNR2LPlaZb-pln3GHS X-Proofpoint-ORIG-GUID: Rd5BYA1rJSlP6JFNR2LPlaZb-pln3GHS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-20_08,2023-02-17_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 Add API `rte_reorder_min_seqn_set` to allow user to specify minimum sequence number. Currently sequence number of first inserted packet is used as minimum sequence number. But for case when we want to wait for packets before the received one this will not work. Signed-off-by: Volodymyr Fialko --- app/test/test_reorder.c | 69 +++++++++++++++++++++++++++++++++++++++ lib/reorder/rte_reorder.c | 31 ++++++++++++++++++ lib/reorder/rte_reorder.h | 18 ++++++++++ lib/reorder/version.map | 1 + 4 files changed, 119 insertions(+) diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c index a37dc28f65..f391597a78 100644 --- a/app/test/test_reorder.c +++ b/app/test/test_reorder.c @@ -427,6 +427,74 @@ test_reorder_drain_up_to_seqn(void) return ret; } +static int +test_reorder_set_seqn(void) +{ + struct rte_mempool *p = test_params->p; + struct rte_reorder_buffer *b = NULL; + const unsigned int num_bufs = 7; + const unsigned int size = 4; + unsigned int i; + int ret = 0; + + struct rte_mbuf *bufs[num_bufs]; + + /* This would create a reorder buffer instance consisting of: + * reorder_seq = 0 + * ready_buf: RB[size] = {NULL, NULL, NULL, NULL} + * order_buf: OB[size] = {NULL, NULL, NULL, NULL} + */ + b = rte_reorder_create("test_min_seqn_set", rte_socket_id(), size); + TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); + + for (i = 0; i < num_bufs; i++) { + bufs[i] = rte_pktmbuf_alloc(p); + if (bufs[i] == NULL) { + printf("Packet allocation failed\n"); + goto exit; + } + *rte_reorder_seqn(bufs[i]) = i; + } + + ret = rte_reorder_min_seqn_set(b, 5); + if (ret != 0) { + printf("%s:%d: Error in setting min sequence number\n", __func__, __LINE__); + ret = -1; + goto exit; + } + + ret = rte_reorder_insert(b, bufs[0]); + if (ret >= 0) { + printf("%s:%d: Insertion with value less the min seq number\n", __func__, __LINE__); + ret = -1; + goto exit; + } + + ret = rte_reorder_insert(b, bufs[5]); + if (ret != 0) { + printf("%s:%d: Error inserting packet with valid seqn\n", __func__, __LINE__); + ret = -1; + goto exit; + } + bufs[5] = NULL; + + ret = rte_reorder_min_seqn_set(b, 0); + if (ret >= 0) { + printf("%s:%d: Error in setting min sequence number with non-empty buffer\n", + __func__, __LINE__); + ret = -1; + goto exit; + } + + ret = 0; +exit: + rte_reorder_free(b); + for (i = 0; i < num_bufs; i++) + rte_pktmbuf_free(bufs[i]); + + return ret; +} + static int test_setup(void) { @@ -478,6 +546,7 @@ static struct unit_test_suite reorder_test_suite = { TEST_CASE(test_reorder_insert), TEST_CASE(test_reorder_drain), TEST_CASE(test_reorder_drain_up_to_seqn), + TEST_CASE(test_reorder_set_seqn), TEST_CASES_END() } }; diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c index bd0e1f8793..6e029c9e02 100644 --- a/lib/reorder/rte_reorder.c +++ b/lib/reorder/rte_reorder.c @@ -485,3 +485,34 @@ rte_reorder_drain_up_to_seqn(struct rte_reorder_buffer *b, struct rte_mbuf **mbu return drain_cnt; } + +static bool +rte_reorder_is_empty(const struct rte_reorder_buffer *b) +{ + const struct cir_buffer *order_buf = &b->order_buf, *ready_buf = &b->ready_buf; + unsigned int i; + + /* Ready buffer does not have gaps */ + if (ready_buf->tail != ready_buf->head) + return false; + + /* Order buffer could have gaps, iterate */ + for (i = 0; i < order_buf->size; i++) { + if (order_buf->entries[i] != NULL) + return false; + } + + return true; +} + +unsigned int +rte_reorder_min_seqn_set(struct rte_reorder_buffer *b, rte_reorder_seqn_t min_seqn) +{ + if (!rte_reorder_is_empty(b)) + return -ENOTEMPTY; + + b->min_seqn = min_seqn; + b->is_initialized = true; + + return 0; +} diff --git a/lib/reorder/rte_reorder.h b/lib/reorder/rte_reorder.h index db740495be..cc95015fa6 100644 --- a/lib/reorder/rte_reorder.h +++ b/lib/reorder/rte_reorder.h @@ -193,6 +193,24 @@ unsigned int rte_reorder_drain_up_to_seqn(struct rte_reorder_buffer *b, struct rte_mbuf **mbufs, unsigned int max_mbufs, rte_reorder_seqn_t seqn); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Set minimum sequence number of packet allowed to be buffered. + * To successfully set new value reorder buffer has to be empty(after create, reset or drain_all). + * + * @param b + * Empty reorder buffer instance to modify. + * @param min_seqn + * New sequence number to set. + * @return + * 0 on success, a negative value otherwise. + */ +__rte_experimental +unsigned int +rte_reorder_min_seqn_set(struct rte_reorder_buffer *b, rte_reorder_seqn_t min_seqn); + #ifdef __cplusplus } #endif diff --git a/lib/reorder/version.map b/lib/reorder/version.map index d322da03bd..e21b91f526 100644 --- a/lib/reorder/version.map +++ b/lib/reorder/version.map @@ -18,4 +18,5 @@ EXPERIMENTAL { rte_reorder_seqn_dynfield_offset; # added in 23.03 rte_reorder_drain_up_to_seqn; + rte_reorder_min_seqn_set; }; -- 2.34.1