diff mbox series

examples/ipsec-secgw: free event vector mbufs

Message ID 20220923092428.344501-1-rbhansali@marvell.com (mailing list archive)
State Superseded
Delegated to: akhil goyal
Headers show
Series examples/ipsec-secgw: free event vector mbufs | expand

Checks

Context Check Description
ci/github-robot: build fail github build: failed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing fail Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation fail Compilation issues
ci/checkpatch success coding style OK

Commit Message

Rahul Bhansali Sept. 23, 2022, 9:24 a.m. UTC
Free mbufs from event vector list when enqueue operation fails
and during event port flush for cleanup.

Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
---
 examples/ipsec-secgw/ipsec_worker.c | 34 +++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 9 deletions(-)

Comments

Pavan Nikhilesh Bhagavatula Sept. 23, 2022, 2:45 p.m. UTC | #1
> Free mbufs from event vector list when enqueue operation fails
> and during event port flush for cleanup.
> 
> Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
> ---
>  examples/ipsec-secgw/ipsec_worker.c | 34 +++++++++++++++++++++------
> --
>  1 file changed, 25 insertions(+), 9 deletions(-)
> 
> diff --git a/examples/ipsec-secgw/ipsec_worker.c b/examples/ipsec-
> secgw/ipsec_worker.c
> index 5e69450d27..105326ddd3 100644
> --- a/examples/ipsec-secgw/ipsec_worker.c
> +++ b/examples/ipsec-secgw/ipsec_worker.c
> @@ -699,6 +699,14 @@
> process_ipsec_ev_drv_mode_outbound_vector(struct rte_event_vector
> *vec,
>  	return j;
>  }
> 
> +static void
> +ipsec_event_vector_free(struct rte_event *ev)
> +{
> +	struct rte_event_vector *vec = ev->vec;
> +	rte_pktmbuf_free_bulk(vec->mbufs + vec->elem_offset, vec-
> >nb_elem - vec->elem_offset);

The vector spec has changed in v2, this should be 
rte_pktmbuf_free_bulk(vec->mbufs + vec->elem_offset, vec->nb_elem);

> +	rte_mempool_put(rte_mempool_from_obj(vec), vec);
> +}
> +
>  static inline void
>  ipsec_ev_vector_process(struct lcore_conf_ev_tx_int_port_wrkr *lconf,
>  			struct eh_event_link_info *links,
> @@ -720,9 +728,10 @@ ipsec_ev_vector_process(struct
> lcore_conf_ev_tx_int_port_wrkr *lconf,
> 
>  	if (likely(ret > 0)) {
>  		vec->nb_elem = ret;
> -		rte_event_eth_tx_adapter_enqueue(links[0].eventdev_id,
> -						 links[0].event_port_id,
> -						 ev, 1, 0);
> +		ret =
> rte_event_eth_tx_adapter_enqueue(links[0].eventdev_id,
> +						       links[0].event_port_id,
> ev, 1, 0);
> +		if (unlikely(ret == 0))
> +			ipsec_event_vector_free(ev);
>  	} else {
>  		rte_mempool_put(rte_mempool_from_obj(vec), vec);
>  	}
> @@ -735,17 +744,21 @@ ipsec_ev_vector_drv_mode_process(struct
> eh_event_link_info *links,
>  {
>  	struct rte_event_vector *vec = ev->vec;
>  	struct rte_mbuf *pkt;
> +	uint16_t ret;
> 
>  	pkt = vec->mbufs[0];
> +	vec->attr_valid = 1;
> +	vec->port = pkt->port;
> 
>  	if (!is_unprotected_port(pkt->port))
>  		vec->nb_elem =
> process_ipsec_ev_drv_mode_outbound_vector(vec,
> 
> data);
> -	if (vec->nb_elem > 0)
> -		rte_event_eth_tx_adapter_enqueue(links[0].eventdev_id,
> -						 links[0].event_port_id,
> -						 ev, 1, 0);
> -	else
> +	if (likely(vec->nb_elem > 0)) {
> +		ret =
> rte_event_eth_tx_adapter_enqueue(links[0].eventdev_id,
> +						       links[0].event_port_id,
> ev, 1, 0);
> +		if (unlikely(ret == 0))
> +			ipsec_event_vector_free(ev);
> +	} else
>  		rte_mempool_put(rte_mempool_from_obj(vec), vec);
>  }
> 
> @@ -759,7 +772,10 @@ static void
>  ipsec_event_port_flush(uint8_t eventdev_id __rte_unused, struct
> rte_event ev,
>  		       void *args __rte_unused)
>  {
> -	rte_pktmbuf_free(ev.mbuf);
> +	if (ev.event_type & RTE_EVENT_TYPE_VECTOR)
> +		ipsec_event_vector_free(&ev);
> +	else
> +		rte_pktmbuf_free(ev.mbuf);
>  }
> 
>  /* Workers registered */
> --
> 2.25.1
diff mbox series

Patch

diff --git a/examples/ipsec-secgw/ipsec_worker.c b/examples/ipsec-secgw/ipsec_worker.c
index 5e69450d27..105326ddd3 100644
--- a/examples/ipsec-secgw/ipsec_worker.c
+++ b/examples/ipsec-secgw/ipsec_worker.c
@@ -699,6 +699,14 @@  process_ipsec_ev_drv_mode_outbound_vector(struct rte_event_vector *vec,
 	return j;
 }
 
+static void
+ipsec_event_vector_free(struct rte_event *ev)
+{
+	struct rte_event_vector *vec = ev->vec;
+	rte_pktmbuf_free_bulk(vec->mbufs + vec->elem_offset, vec->nb_elem - vec->elem_offset);
+	rte_mempool_put(rte_mempool_from_obj(vec), vec);
+}
+
 static inline void
 ipsec_ev_vector_process(struct lcore_conf_ev_tx_int_port_wrkr *lconf,
 			struct eh_event_link_info *links,
@@ -720,9 +728,10 @@  ipsec_ev_vector_process(struct lcore_conf_ev_tx_int_port_wrkr *lconf,
 
 	if (likely(ret > 0)) {
 		vec->nb_elem = ret;
-		rte_event_eth_tx_adapter_enqueue(links[0].eventdev_id,
-						 links[0].event_port_id,
-						 ev, 1, 0);
+		ret = rte_event_eth_tx_adapter_enqueue(links[0].eventdev_id,
+						       links[0].event_port_id, ev, 1, 0);
+		if (unlikely(ret == 0))
+			ipsec_event_vector_free(ev);
 	} else {
 		rte_mempool_put(rte_mempool_from_obj(vec), vec);
 	}
@@ -735,17 +744,21 @@  ipsec_ev_vector_drv_mode_process(struct eh_event_link_info *links,
 {
 	struct rte_event_vector *vec = ev->vec;
 	struct rte_mbuf *pkt;
+	uint16_t ret;
 
 	pkt = vec->mbufs[0];
+	vec->attr_valid = 1;
+	vec->port = pkt->port;
 
 	if (!is_unprotected_port(pkt->port))
 		vec->nb_elem = process_ipsec_ev_drv_mode_outbound_vector(vec,
 									 data);
-	if (vec->nb_elem > 0)
-		rte_event_eth_tx_adapter_enqueue(links[0].eventdev_id,
-						 links[0].event_port_id,
-						 ev, 1, 0);
-	else
+	if (likely(vec->nb_elem > 0)) {
+		ret = rte_event_eth_tx_adapter_enqueue(links[0].eventdev_id,
+						       links[0].event_port_id, ev, 1, 0);
+		if (unlikely(ret == 0))
+			ipsec_event_vector_free(ev);
+	} else
 		rte_mempool_put(rte_mempool_from_obj(vec), vec);
 }
 
@@ -759,7 +772,10 @@  static void
 ipsec_event_port_flush(uint8_t eventdev_id __rte_unused, struct rte_event ev,
 		       void *args __rte_unused)
 {
-	rte_pktmbuf_free(ev.mbuf);
+	if (ev.event_type & RTE_EVENT_TYPE_VECTOR)
+		ipsec_event_vector_free(&ev);
+	else
+		rte_pktmbuf_free(ev.mbuf);
 }
 
 /* Workers registered */