DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] examples/l2fwd-crypto: flush crypto dev buffers
@ 2016-07-06  9:38 Pablo de Lara
  2016-07-11 15:14 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Pablo de Lara @ 2016-07-06  9:38 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

Crypto operations are enqueued in the crypto devices
when the crypto device buffers are full (MAX_PKT_BURST),
in order to be more efficient.

The problem is that operations might be stuck in those buffers,
if they never get full, and therefore, those operations
will never be performed.

Therefore, it is necessary to have a buffer flush mechanism,
similar to the one used for flush the TX buffers, so eventually,
all packets received are ciphered and sent out.

Fixes: 387259bd6c67 ("examples/l2fwd-crypto: add sample application")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 examples/l2fwd-crypto/main.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 8dc616d..23b20b1 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -628,7 +628,7 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
 
 	unsigned lcore_id = rte_lcore_id();
 	uint64_t prev_tsc = 0, diff_tsc, cur_tsc, timer_tsc = 0;
-	unsigned i, j, portid, nb_rx;
+	unsigned i, j, portid, nb_rx, len;
 	struct lcore_queue_conf *qconf = &lcore_queue_conf[lcore_id];
 	const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) /
 			US_PER_S * BURST_TX_DRAIN_US;
@@ -727,10 +727,18 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
 		cur_tsc = rte_rdtsc();
 
 		/*
-		 * TX burst queue drain
+		 * Crypto device/TX burst queue drain
 		 */
 		diff_tsc = cur_tsc - prev_tsc;
 		if (unlikely(diff_tsc > drain_tsc)) {
+			/* Enqueue all crypto ops remaining in buffers */
+			for (i = 0; i < qconf->nb_crypto_devs; i++) {
+				cparams = &port_cparams[i];
+				len = qconf->op_buf[cparams->dev_id].len;
+				l2fwd_crypto_send_burst(qconf, len, cparams);
+				qconf->op_buf[cparams->dev_id].len = 0;
+			}
+			/* Transmit all packets remaining in buffers */
 			for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) {
 				if (qconf->pkt_buf[portid].len == 0)
 					continue;
-- 
2.5.5

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] examples/l2fwd-crypto: flush crypto dev buffers
  2016-07-06  9:38 [dpdk-dev] [PATCH] examples/l2fwd-crypto: flush crypto dev buffers Pablo de Lara
@ 2016-07-11 15:14 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2016-07-11 15:14 UTC (permalink / raw)
  To: Pablo de Lara; +Cc: dev, declan.doherty

2016-07-06 10:38, Pablo de Lara:
> Crypto operations are enqueued in the crypto devices
> when the crypto device buffers are full (MAX_PKT_BURST),
> in order to be more efficient.
> 
> The problem is that operations might be stuck in those buffers,
> if they never get full, and therefore, those operations
> will never be performed.
> 
> Therefore, it is necessary to have a buffer flush mechanism,
> similar to the one used for flush the TX buffers, so eventually,
> all packets received are ciphered and sent out.
> 
> Fixes: 387259bd6c67 ("examples/l2fwd-crypto: add sample application")
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-11 15:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-06  9:38 [dpdk-dev] [PATCH] examples/l2fwd-crypto: flush crypto dev buffers Pablo de Lara
2016-07-11 15:14 ` Thomas Monjalon

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).