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 2/3] reorder: add ability to set min sequence number
Date: Fri, 20 Jan 2023 11:21:45 +0100 [thread overview]
Message-ID: <20230120102146.4035460-3-vfialko@marvell.com> (raw)
In-Reply-To: <20230120102146.4035460-1-vfialko@marvell.com>
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 <vfialko@marvell.com>
---
lib/reorder/rte_reorder.c | 31 +++++++++++++++++++++++++++++++
lib/reorder/rte_reorder.h | 18 ++++++++++++++++++
lib/reorder/version.map | 1 +
3 files changed, 50 insertions(+)
diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c
index 57cc1b286b..0d4c7209f9 100644
--- a/lib/reorder/rte_reorder.c
+++ b/lib/reorder/rte_reorder.c
@@ -483,3 +483,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, uint32_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 c5b354b53d..9f6710bad2 100644
--- a/lib/reorder/rte_reorder.h
+++ b/lib/reorder/rte_reorder.h
@@ -192,6 +192,24 @@ __rte_experimental
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, uint32_t min_seqn);
#ifdef __cplusplus
}
#endif
diff --git a/lib/reorder/version.map b/lib/reorder/version.map
index e3f41ea7ef..aafdf0b5ae 100644
--- a/lib/reorder/version.map
+++ b/lib/reorder/version.map
@@ -17,4 +17,5 @@ EXPERIMENTAL {
rte_reorder_seqn_dynfield_offset;
rte_reorder_drain_up_to_seqn;
+ rte_reorder_min_seqn_set;
};
--
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 ` Volodymyr Fialko [this message]
2023-01-20 10:21 ` [PATCH 3/3] test/reorder: add cases to cover new API Volodymyr Fialko
2023-01-20 12:43 ` 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-3-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).