From a01a7347c0092c733a1f2ef3b956c2a012b1d060 Mon Sep 17 00:00:00 2001 From: Matias Elo Date: Thu, 7 Jun 2018 15:28:24 +0300 Subject: linux-dpdk: crypto: add retry to rte_cryptodev_dequeue_burst() There may be a delay until a DPDK crypto operation is completed. E.g. when using QAT PCIe cards. Retries max 100ms before failing. Signed-off-by: Matias Elo Reviewed-by: Dmitry Eremin-Solenikov Signed-off-by: Maxim Uvarov --- platform/linux-dpdk/odp_crypto.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/platform/linux-dpdk/odp_crypto.c b/platform/linux-dpdk/odp_crypto.c index b8417dcb5..352a2e9dd 100644 --- a/platform/linux-dpdk/odp_crypto.c +++ b/platform/linux-dpdk/odp_crypto.c @@ -41,6 +41,10 @@ #define IV_OFFSET (sizeof(struct rte_crypto_op) + \ sizeof(struct rte_crypto_sym_op)) +/* Max number of rte_cryptodev_dequeue_burst() retries (1 usec wait between + * retries). */ +#define MAX_DEQ_RETRIES 100000 + typedef struct crypto_session_entry_s { struct crypto_session_entry_s *next; @@ -1720,6 +1724,7 @@ int odp_crypto_int(odp_packet_t pkt_in, if (rc_cipher == ODP_CRYPTO_ALG_ERR_NONE && rc_auth == ODP_CRYPTO_ALG_ERR_NONE) { + int retry_count = 0; int queue_pair = odp_cpu_id(); int rc; @@ -1734,8 +1739,18 @@ int odp_crypto_int(odp_packet_t pkt_in, goto err_op_free; } - rc = rte_cryptodev_dequeue_burst(session->cdev_id, - queue_pair, &op, 1); + /* There may be a delay until the crypto operation is + * completed. */ + while (1) { + rc = rte_cryptodev_dequeue_burst(session->cdev_id, + queue_pair, &op, 1); + if (rc == 0 && retry_count < MAX_DEQ_RETRIES) { + odp_time_wait_ns(ODP_TIME_USEC_IN_NS); + retry_count++; + continue; + } + break; + } if (rc == 0) { ODP_ERR("Failed to dequeue packet"); goto err_op_free; -- cgit v1.2.3