Free mbufs from event vector list when enqueue operation fails and during event port flush for cleanup.
Signed-off-by: Rahul Bhansali <rbhans...@marvell.com> --- v2: Added dependent series info. Depends-on: series-24761 ("[v2,1/3] eventdev: add element offset to event vector") 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); + 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