[v2,15/22] pdcp: add timer callback handlers

Message ID 20230414174512.642-16-anoobj@marvell.com (mailing list archive)
State Changes Requested, 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 April 14, 2023, 5:45 p.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(+)
  

Comments

Akhil Goyal May 18, 2023, 9:37 a.m. UTC | #1
> +struct rte_pdcp_t_reordering {
> +	/** Timer pointer, stored for later use in callback functions */
> +	void *timer;
> +	/** Timer arguments, stored for later use in callback functions */
> +	void *args;
> +	/** Timer start callback handle */
> +	rte_pdcp_t_reordering_start_cb_t start;
> +	/** Timer start callback handle */

start->stop

> +	rte_pdcp_t_reordering_stop_cb_t stop;
> +};
> +
  

Patch

diff --git a/lib/pdcp/pdcp_entity.h b/lib/pdcp/pdcp_entity.h
index 71962d7279..ca98a1d0f7 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 16d22cbe14..9ba07d5255 100644
--- a/lib/pdcp/pdcp_process.c
+++ b/lib/pdcp/pdcp_process.c
@@ -874,6 +874,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);
@@ -888,6 +889,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 c9d44ca539..755d592578 100644
--- a/lib/pdcp/rte_pdcp.c
+++ b/lib/pdcp/rte_pdcp.c
@@ -36,6 +36,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 0d2f4fe7c1..55e57c3b9b 100644
--- a/lib/pdcp/rte_pdcp.h
+++ b/lib/pdcp/rte_pdcp.h
@@ -66,6 +66,51 @@  struct rte_pdcp_entity {
 	uint64_t user_area[2];
 } __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, stored for later use in callback functions */
+	void *timer;
+	/** Timer arguments, stored for later use in callback functions */
+	void *args;
+	/** Timer start callback handle */
+	rte_pdcp_t_reordering_start_cb_t start;
+	/** Timer start callback handle */
+	rte_pdcp_t_reordering_stop_cb_t stop;
+};
+
 /**
  * PDCP entity configuration to be used for establishing an entity.
  */
@@ -105,6 +150,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. */