[v6,15/21] pdcp: add timer callback handlers

Message ID 20230530100158.1428-16-anoobj@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series lib: add pdcp protocol |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Anoob Joseph May 30, 2023, 10:01 a.m. UTC
  From: Volodymyr Fialko <vfialko@marvell.com>

PDCP has a windowing mechanism which allows only packets that fall in a
reception window. The pivot point for this window is RX_REORD which
happens to be the first missing or next expected packet. If the missing
packet is not received after a specified time, then the RX_REORD state
variable needs to be moved up to slide the reception window. PDCP relies
on timers for such operations.

The timer needs to be armed when PDCP library doesn't receive all
packets in-order and starts buffering packets that arrived after a
missing packet. The timer needs to be cancelled when a missing packet
is received.

To avoid dependency on particular timer implementation, PDCP library
allows application to register two callbacks, timer_start() and
timer_stop() that will be called later by library.

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
---
 lib/pdcp/pdcp_entity.h  |  2 ++
 lib/pdcp/pdcp_process.c |  2 ++
 lib/pdcp/rte_pdcp.c     |  1 +
 lib/pdcp/rte_pdcp.h     | 47 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 52 insertions(+)
  

Patch

diff --git a/lib/pdcp/pdcp_entity.h b/lib/pdcp/pdcp_entity.h
index 34341cdc11..efc74ba9b9 100644
--- a/lib/pdcp/pdcp_entity.h
+++ b/lib/pdcp/pdcp_entity.h
@@ -120,6 +120,8 @@  enum timer_state {
 struct pdcp_t_reordering {
 	/** Represent timer state */
 	enum timer_state state;
+	/** User defined callback handles */
+	struct rte_pdcp_t_reordering handle;
 };
 
 struct pdcp_cnt_bitmap {
diff --git a/lib/pdcp/pdcp_process.c b/lib/pdcp/pdcp_process.c
index 84a0f3a43f..daf2c27363 100644
--- a/lib/pdcp/pdcp_process.c
+++ b/lib/pdcp/pdcp_process.c
@@ -902,6 +902,7 @@  pdcp_post_process_update_entity_state(const struct rte_pdcp_entity *entity,
 	if (t_reorder->state == TIMER_RUNNING &&
 			en_priv->state.rx_deliv >= en_priv->state.rx_reord) {
 		t_reorder->state = TIMER_STOP;
+		t_reorder->handle.stop(t_reorder->handle.timer, t_reorder->handle.args);
 		/* Stop reorder buffer, only if it's empty */
 		if (en_priv->state.rx_deliv == en_priv->state.rx_next)
 			pdcp_reorder_stop(reorder);
@@ -916,6 +917,7 @@  pdcp_post_process_update_entity_state(const struct rte_pdcp_entity *entity,
 		en_priv->state.rx_reord = en_priv->state.rx_next;
 		/* Start t-Reordering */
 		t_reorder->state = TIMER_RUNNING;
+		t_reorder->handle.start(t_reorder->handle.timer, t_reorder->handle.args);
 	}
 
 	return processed;
diff --git a/lib/pdcp/rte_pdcp.c b/lib/pdcp/rte_pdcp.c
index be37ff392c..a0558b99ae 100644
--- a/lib/pdcp/rte_pdcp.c
+++ b/lib/pdcp/rte_pdcp.c
@@ -56,6 +56,7 @@  pdcp_dl_establish(struct rte_pdcp_entity *entity, const struct rte_pdcp_entity_c
 	struct entity_priv_dl_part *dl = entity_dl_part_get(entity);
 
 	entity->max_pkt_cache = RTE_MAX(entity->max_pkt_cache, window_size);
+	dl->t_reorder.handle = conf->t_reordering;
 
 	return pdcp_reorder_create(&dl->reorder, window_size);
 }
diff --git a/lib/pdcp/rte_pdcp.h b/lib/pdcp/rte_pdcp.h
index 9c4d06962a..9cdce7d3a4 100644
--- a/lib/pdcp/rte_pdcp.h
+++ b/lib/pdcp/rte_pdcp.h
@@ -68,6 +68,51 @@  struct rte_pdcp_entity {
 	uint32_t max_pkt_cache;
 } __rte_cache_aligned;
 
+/**
+ * Callback function type for t-Reordering timer start, set during PDCP entity establish.
+ * This callback is invoked by PDCP library, during t-Reordering timer start event.
+ * Only one t-Reordering per receiving PDCP entity would be running at a given time.
+ *
+ * @see struct rte_pdcp_timer
+ * @see rte_pdcp_entity_establish()
+ *
+ * @param timer
+ *   Pointer to timer.
+ * @param args
+ *   Pointer to timer arguments.
+ */
+typedef void (*rte_pdcp_t_reordering_start_cb_t)(void *timer, void *args);
+
+/**
+ * Callback function type for t-Reordering timer stop, set during PDCP entity establish.
+ * This callback will be invoked by PDCP library, during t-Reordering timer stop event.
+ *
+ * @see struct rte_pdcp_timer
+ * @see rte_pdcp_entity_establish()
+ *
+ * @param timer
+ *   Pointer to timer.
+ * @param args
+ *   Pointer to timer arguments.
+ */
+typedef void (*rte_pdcp_t_reordering_stop_cb_t)(void *timer, void *args);
+
+/**
+ * PDCP t-Reordering timer interface
+ *
+ * Configuration provided by user, that PDCP library will invoke according to timer behaviour.
+ */
+struct rte_pdcp_t_reordering {
+	/** Timer pointer, to be used in callback functions. */
+	void *timer;
+	/** Timer arguments, to be used in callback functions. */
+	void *args;
+	/** Timer start callback handle. */
+	rte_pdcp_t_reordering_start_cb_t start;
+	/** Timer stop callback handle. */
+	rte_pdcp_t_reordering_stop_cb_t stop;
+};
+
 /**
  * PDCP entity configuration to be used for establishing an entity.
  */
@@ -112,6 +157,8 @@  struct rte_pdcp_entity_conf {
 	bool status_report_required;
 	/** Enable out of order delivery. */
 	bool out_of_order_delivery;
+	/** t-Reordering timer configuration. */
+	struct rte_pdcp_t_reordering t_reordering;
 };
 /* >8 End of structure rte_pdcp_entity_conf. */