From: Rahul Bhansali <rbhansali@marvell.com>
To: <dev@dpdk.org>, Radu Nicolau <radu.nicolau@intel.com>,
Akhil Goyal <gakhil@marvell.com>
Cc: Rahul Bhansali <rbhansali@marvell.com>
Subject: [PATCH] examples/ipsec-secgw: free event vector mbufs
Date: Fri, 23 Sep 2022 14:54:28 +0530 [thread overview]
Message-ID: <20220923092428.344501-1-rbhansali@marvell.com> (raw)
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);
+ 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
next reply other threads:[~2022-09-23 9:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-23 9:24 Rahul Bhansali [this message]
2022-09-23 14:45 ` [EXT] " Pavan Nikhilesh Bhagavatula
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=20220923092428.344501-1-rbhansali@marvell.com \
--to=rbhansali@marvell.com \
--cc=dev@dpdk.org \
--cc=gakhil@marvell.com \
--cc=radu.nicolau@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).