From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anoob Joseph Subject: [PATCH v3 27/32] common/cpt: add common code for enqueuing cpt instruction Date: Fri, 5 Oct 2018 18:29:18 +0530 Message-ID: <1538744363-30340-28-git-send-email-anoob.joseph@caviumnetworks.com> References: <1536033560-21541-1-git-send-email-ajoseph@caviumnetworks.com> <1538744363-30340-1-git-send-email-anoob.joseph@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain Cc: Tejasree Kondoj , Jerin Jacob , Narayana Prasad , dev@dpdk.org, Ankur Dwivedi , Anoob Joseph , Murthy NSSR , Nithin Dabilpuram , Ragothaman Jayaraman , Srisivasubramanian S To: Akhil Goyal , Pablo de Lara , Thomas Monjalon Return-path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0065.outbound.protection.outlook.com [104.47.33.65]) by dpdk.org (Postfix) with ESMTP id E4B637CDC for ; Fri, 5 Oct 2018 15:02:27 +0200 (CEST) In-Reply-To: <1538744363-30340-1-git-send-email-anoob.joseph@caviumnetworks.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Tejasree Kondoj Signed-off-by: Ankur Dwivedi Signed-off-by: Anoob Joseph Signed-off-by: Murthy NSSR Signed-off-by: Nithin Dabilpuram Signed-off-by: Ragothaman Jayaraman Signed-off-by: Srisivasubramanian S Signed-off-by: Tejasree Kondoj --- drivers/common/cpt/cpt_common.h | 3 +++ drivers/common/cpt/cpt_request_mgr.h | 46 +++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/drivers/common/cpt/cpt_common.h b/drivers/common/cpt/cpt_common.h index 7333c13..1823939 100644 --- a/drivers/common/cpt/cpt_common.h +++ b/drivers/common/cpt/cpt_common.h @@ -15,6 +15,9 @@ */ #define CRYPTO_OCTEONTX 0x1 +/* Default command timeout in seconds */ +#define DEFAULT_COMMAND_TIMEOUT 4 + #define CPT_COUNT_THOLD 32 #define CPT_TIMER_THOLD 0x3F diff --git a/drivers/common/cpt/cpt_request_mgr.h b/drivers/common/cpt/cpt_request_mgr.h index 4d21f46..dea89f8 100644 --- a/drivers/common/cpt/cpt_request_mgr.h +++ b/drivers/common/cpt/cpt_request_mgr.h @@ -5,6 +5,9 @@ #ifndef _CPT_REQUEST_MGR_H_ #define _CPT_REQUEST_MGR_H_ +#include +#include + #include "cpt_common.h" #include "cpt_mcode_defines.h" @@ -34,6 +37,45 @@ cpt_get_session_size(void) return (sizeof(struct cpt_sess_misc) + RTE_ALIGN_CEIL(ctx_len, 8)); } +static __rte_always_inline int32_t __hot +cpt_enqueue_req(struct cpt_instance *instance, struct pending_queue *pqueue, + void *req) +{ + struct cpt_request_info *user_req = (struct cpt_request_info *)req; + int32_t ret = 0; + + if (unlikely(!req)) + return 0; + + if (unlikely(pqueue->pending_count >= DEFAULT_CMD_QLEN)) + return -EAGAIN; + + fill_cpt_inst(instance, req); + + CPT_LOG_DP_DEBUG("req: %p op: %p ", req, user_req->op); + + /* Fill time_out cycles */ + user_req->time_out = rte_get_timer_cycles() + + DEFAULT_COMMAND_TIMEOUT * rte_get_timer_hz(); + user_req->extra_time = 0; + + /* Default mode of software queue */ + mark_cpt_inst(instance); + + pqueue->rid_queue[pqueue->enq_tail].rid = + (uintptr_t)user_req; + /* We will use soft queue length here to limit + * requests + */ + MOD_INC(pqueue->enq_tail, DEFAULT_CMD_QLEN); + pqueue->pending_count += 1; + + CPT_LOG_DP_DEBUG("Submitted NB cmd with request: %p " + "op: %p", user_req, user_req->op); + + return ret; +} + static __rte_always_inline int __hot cpt_pmd_crypto_operation(struct cpt_instance *instance, struct rte_crypto_op *op, struct pending_queue *pqueue, @@ -45,7 +87,6 @@ cpt_pmd_crypto_operation(struct cpt_instance *instance, int ret = 0; uint64_t cpt_op; struct cpt_vf *cptvf = (struct cpt_vf *)instance; - RTE_SET_USED(pqueue); if (unlikely(op->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) { int sess_len; @@ -83,6 +124,9 @@ cpt_pmd_crypto_operation(struct cpt_instance *instance, goto req_fail; } + /* Enqueue prepared instruction to HW */ + ret = cpt_enqueue_req(instance, pqueue, prep_req); + if (unlikely(ret)) { if (unlikely(ret == -EAGAIN)) goto req_fail; -- 2.7.4