From: Ragothaman Jayaraman Date: Tue, 9 Oct 2018 09:07:48 +0000 (+0530) Subject: common/cpt: add crypto enqueue request manager framework X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=ba48221f4a9eecd3ae213a9bd5c9078ea282c56e;p=dpdk.git common/cpt: add crypto enqueue request manager framework Adding crypto enqueue op request manager framework. This routine won't submit to the hardware yet. 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 --- diff --git a/drivers/common/cpt/cpt_request_mgr.h b/drivers/common/cpt/cpt_request_mgr.h index fe184feeff..58a87c3e0c 100644 --- a/drivers/common/cpt/cpt_request_mgr.h +++ b/drivers/common/cpt/cpt_request_mgr.h @@ -5,8 +5,13 @@ #ifndef _CPT_REQUEST_MGR_H_ #define _CPT_REQUEST_MGR_H_ +#include "cpt_common.h" #include "cpt_mcode_defines.h" +#if CPT_MODEL == CRYPTO_OCTEONTX +#include "../../crypto/octeontx/otx_cryptodev_hw_access.h" +#endif + /* * This file defines the agreement between the common layer and the individual * crypto drivers for OCTEON TX series. Datapath in otx* directory include this @@ -29,4 +34,67 @@ cpt_get_session_size(void) return (sizeof(struct cpt_sess_misc) + RTE_ALIGN_CEIL(ctx_len, 8)); } +static __rte_always_inline int __hot +cpt_pmd_crypto_operation(struct cpt_instance *instance, + struct rte_crypto_op *op, struct pending_queue *pqueue, + uint8_t cpt_driver_id) +{ + struct cpt_sess_misc *sess = NULL; + struct rte_crypto_sym_op *sym_op = op->sym; + void *prep_req = NULL, *mdata = NULL; + 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; + + sess_len = cpt_get_session_size(); + + sess = rte_calloc(__func__, 1, sess_len, 8); + if (!sess) + return -ENOMEM; + + sess->ctx_dma_addr = rte_malloc_virt2iova(sess) + + sizeof(struct cpt_sess_misc); + + ret = instance_session_cfg(sym_op->xform, (void *)sess); + if (unlikely(ret)) + return -EINVAL; + } else { + sess = (struct cpt_sess_misc *) + get_sym_session_private_data(sym_op->session, + cpt_driver_id); + } + + cpt_op = sess->cpt_op; + + mdata = &(cptvf->meta_info); + + if (likely(cpt_op & CPT_OP_CIPHER_MASK)) + prep_req = fill_fc_params(op, sess, &mdata, &ret); + + if (unlikely(!prep_req)) { + CPT_LOG_DP_ERR("prep cryto req : op %p, cpt_op 0x%x " + "ret 0x%x", op, (unsigned int)cpt_op, ret); + goto req_fail; + } + + if (unlikely(ret)) { + if (unlikely(ret == -EAGAIN)) + goto req_fail; + CPT_LOG_DP_ERR("Error enqueing crypto request : error " + "code %d", ret); + goto req_fail; + } + + return 0; + +req_fail: + if (mdata) + free_op_meta(mdata, cptvf->meta_info.cptvf_meta_pool); + return ret; +} + #endif /* _CPT_REQUEST_MGR_H_ */ diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h index 9d4d4c80d0..9085667781 100644 --- a/drivers/common/cpt/cpt_ucode.h +++ b/drivers/common/cpt/cpt_ucode.h @@ -2117,4 +2117,47 @@ fill_fc_params(struct rte_crypto_op *cop, return prep_req; } +static __rte_always_inline int +instance_session_cfg(struct rte_crypto_sym_xform *xform, void *sess) +{ + struct rte_crypto_sym_xform *chain; + + CPT_PMD_INIT_FUNC_TRACE(); + + if (cpt_is_algo_supported(xform)) + goto err; + + chain = xform; + while (chain) { + switch (chain->type) { + case RTE_CRYPTO_SYM_XFORM_AEAD: + if (fill_sess_aead(chain, sess)) + goto err; + break; + case RTE_CRYPTO_SYM_XFORM_CIPHER: + if (fill_sess_cipher(chain, sess)) + goto err; + break; + case RTE_CRYPTO_SYM_XFORM_AUTH: + if (chain->auth.algo == RTE_CRYPTO_AUTH_AES_GMAC) { + if (fill_sess_gmac(chain, sess)) + goto err; + } else { + if (fill_sess_auth(chain, sess)) + goto err; + } + break; + default: + CPT_LOG_DP_ERR("Invalid crypto xform type"); + break; + } + chain = chain->next; + } + + return 0; + +err: + return -1; +} + #endif /*_CPT_UCODE_H_ */