From: Volodymyr Fialko <vfialko@marvell.com>
To: <dev@dpdk.org>, Reshma Pattan <reshma.pattan@intel.com>
Cc: <jerinj@marvell.com>, <anoobj@marvell.com>,
Volodymyr Fialko <vfialko@marvell.com>
Subject: [PATCH 3/3] test/reorder: add cases to cover new API
Date: Fri, 20 Jan 2023 11:21:46 +0100 [thread overview]
Message-ID: <20230120102146.4035460-4-vfialko@marvell.com> (raw)
In-Reply-To: <20230120102146.4035460-1-vfialko@marvell.com>
Add new test cases to cover `rte_reorder_drain_up_to_seqn` and
`rte_reorder_min_seqn_set`.
Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
---
app/test/test_reorder.c | 160 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 160 insertions(+)
diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c
index f0714a5c18..c345a72e0c 100644
--- a/app/test/test_reorder.c
+++ b/app/test/test_reorder.c
@@ -335,6 +335,164 @@ test_reorder_drain(void)
return ret;
}
+static void
+buffer_to_reorder_move(struct rte_mbuf **mbuf, struct rte_reorder_buffer *b)
+{
+ rte_reorder_insert(b, *mbuf);
+ *mbuf = NULL;
+}
+
+static int
+test_reorder_drain_up_to_seqn(void)
+{
+ struct rte_mempool *p = test_params->p;
+ struct rte_reorder_buffer *b = NULL;
+ const unsigned int num_bufs = 10;
+ const unsigned int size = 4;
+ unsigned int i, cnt;
+ int ret = 0;
+
+ struct rte_mbuf *bufs[num_bufs];
+ struct rte_mbuf *robufs[num_bufs];
+
+ /* initialize all robufs to NULL */
+ memset(robufs, 0, sizeof(robufs));
+
+ /* 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_drain_up_to_seqn", 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);
+ TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n");
+ *rte_reorder_seqn(bufs[i]) = i;
+ }
+
+ /* Insert packet with seqn 1 and 3:
+ * RB[] = {NULL, NULL, NULL, NULL}
+ * OB[] = {1, 2, 3, NULL}
+ */
+ buffer_to_reorder_move(&bufs[1], b);
+ buffer_to_reorder_move(&bufs[2], b);
+ buffer_to_reorder_move(&bufs[3], b);
+ /* Draining 1, 2 */
+ cnt = rte_reorder_drain_up_to_seqn(b, robufs, num_bufs, 3);
+ if (cnt != 2) {
+ printf("%s:%d:%d: number of expected packets not drained\n",
+ __func__, __LINE__, cnt);
+ ret = -1;
+ goto exit;
+ }
+ for (i = 0; i < 2; i++)
+ rte_pktmbuf_free(robufs[i]);
+ memset(robufs, 0, sizeof(robufs));
+
+ /* Insert more packets
+ * RB[] = {NULL, NULL, NULL, NULL}
+ * OB[] = {3, 4, NULL, 6}
+ */
+ buffer_to_reorder_move(&bufs[4], b);
+ buffer_to_reorder_move(&bufs[6], b);
+ /* Insert more packets to utilize Ready buffer
+ * RB[] = {3, NULL, 5, 6}
+ * OB[] = {NULL, NULL, 8, NULL}
+ */
+ buffer_to_reorder_move(&bufs[8], b);
+
+ /* Drain 3 and 5 */
+ cnt = rte_reorder_drain_up_to_seqn(b, robufs, num_bufs, 6);
+ if (cnt != 2) {
+ printf("%s:%d:%d: number of expected packets not drained\n",
+ __func__, __LINE__, cnt);
+ ret = -1;
+ goto exit;
+ }
+ for (i = 0; i < 2; i++)
+ rte_pktmbuf_free(robufs[i]);
+ memset(robufs, 0, sizeof(robufs));
+
+ ret = 0;
+exit:
+ rte_reorder_free(b);
+ for (i = 0; i < num_bufs; i++) {
+ rte_pktmbuf_free(bufs[i]);
+ rte_pktmbuf_free(robufs[i]);
+ }
+ 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)
{
@@ -385,6 +543,8 @@ static struct unit_test_suite reorder_test_suite = {
TEST_CASE(test_reorder_free),
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()
}
};
--
2.34.1
next prev parent reply other threads:[~2023-01-20 10:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-20 10:21 [PATCH 0/3] reorder: introduce new APIs Volodymyr Fialko
2023-01-20 10:21 ` [PATCH 1/3] reorder: add new drain up to seq number API Volodymyr Fialko
2023-02-19 23:30 ` Thomas Monjalon
2023-01-20 10:21 ` [PATCH 2/3] reorder: add ability to set min sequence number Volodymyr Fialko
2023-01-20 10:21 ` Volodymyr Fialko [this message]
2023-01-20 12:43 ` [PATCH 3/3] test/reorder: add cases to cover new API Volodymyr Fialko
2023-02-19 23:32 ` Thomas Monjalon
2023-01-26 15:48 ` [PATCH 0/3] reorder: introduce new APIs David Marchand
2023-02-20 10:48 ` [PATCH v2 0/2] " Volodymyr Fialko
2023-02-20 10:48 ` [PATCH v2 1/2] reorder: add new drain up to seq number API Volodymyr Fialko
2023-02-20 10:48 ` [PATCH v2 2/2] reorder: add ability to set min sequence number Volodymyr Fialko
2023-02-20 11:01 ` [PATCH v2 0/2] reorder: introduce new APIs Thomas Monjalon
2023-02-20 15:48 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230120102146.4035460-4-vfialko@marvell.com \
--to=vfialko@marvell.com \
--cc=anoobj@marvell.com \
--cc=dev@dpdk.org \
--cc=jerinj@marvell.com \
--cc=reshma.pattan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).