From fadc1ea15c61136fa11a0416b08b46e9e6d59274 Mon Sep 17 00:00:00 2001 From: Kanaka Durga Kotamarthy Date: Fri, 11 Oct 2019 18:31:34 +0530 Subject: [PATCH] common/cpt: add helper functions for asymmetric crypto Add helper functions to get meta len for asymmetric operations Signed-off-by: Anoob Joseph Signed-off-by: Kanaka Durga Kotamarthy Signed-off-by: Sunila Sahu Acked-by: Akhil Goyal --- drivers/common/cpt/cpt_pmd_ops_helper.c | 15 +++++++ drivers/common/cpt/cpt_pmd_ops_helper.h | 9 +++++ drivers/common/cpt/rte_common_cpt_version.map | 8 ++++ .../crypto/octeontx/otx_cryptodev_hw_access.c | 39 +++++++++++++------ 4 files changed, 60 insertions(+), 11 deletions(-) diff --git a/drivers/common/cpt/cpt_pmd_ops_helper.c b/drivers/common/cpt/cpt_pmd_ops_helper.c index 1c18180f8a..09b762f81e 100644 --- a/drivers/common/cpt/cpt_pmd_ops_helper.c +++ b/drivers/common/cpt/cpt_pmd_ops_helper.c @@ -11,6 +11,8 @@ #define CPT_MAX_IV_LEN 16 #define CPT_OFFSET_CONTROL_BYTES 8 +#define CPT_MAX_ASYM_OP_NUM_PARAMS 5 +#define CPT_MAX_ASYM_OP_MOD_LEN 1024 int32_t cpt_pmd_ops_helper_get_mlen_direct_mode(void) @@ -39,3 +41,16 @@ cpt_pmd_ops_helper_get_mlen_sg_mode(void) len += 2 * sizeof(cpt_res_s_t); return len; } + +int +cpt_pmd_ops_helper_asym_get_mlen(void) +{ + uint32_t len; + + /* Get meta len for linear buffer (direct) mode */ + len = cpt_pmd_ops_helper_get_mlen_direct_mode(); + + /* Get meta len for asymmetric operations */ + len += CPT_MAX_ASYM_OP_NUM_PARAMS * CPT_MAX_ASYM_OP_MOD_LEN; + return len; +} diff --git a/drivers/common/cpt/cpt_pmd_ops_helper.h b/drivers/common/cpt/cpt_pmd_ops_helper.h index dd32f9a406..24c3559a0b 100644 --- a/drivers/common/cpt/cpt_pmd_ops_helper.h +++ b/drivers/common/cpt/cpt_pmd_ops_helper.h @@ -31,4 +31,13 @@ cpt_pmd_ops_helper_get_mlen_direct_mode(void); */ int cpt_pmd_ops_helper_get_mlen_sg_mode(void); + +/* + * Get size of meta buffer to be allocated for asymmetric crypto operations + * + * @return + * - length + */ +int +cpt_pmd_ops_helper_asym_get_mlen(void); #endif /* _CPT_PMD_OPS_HELPER_H_ */ diff --git a/drivers/common/cpt/rte_common_cpt_version.map b/drivers/common/cpt/rte_common_cpt_version.map index dec614f0de..382ec4bd44 100644 --- a/drivers/common/cpt/rte_common_cpt_version.map +++ b/drivers/common/cpt/rte_common_cpt_version.map @@ -4,3 +4,11 @@ DPDK_18.11 { cpt_pmd_ops_helper_get_mlen_direct_mode; cpt_pmd_ops_helper_get_mlen_sg_mode; }; + +DPDK_19.11 { + global: + + cpt_pmd_ops_helper_asym_get_mlen; + + local: *; +}; diff --git a/drivers/crypto/octeontx/otx_cryptodev_hw_access.c b/drivers/crypto/octeontx/otx_cryptodev_hw_access.c index ad64bf4911..ce546c2ffe 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_hw_access.c +++ b/drivers/crypto/octeontx/otx_cryptodev_hw_access.c @@ -412,24 +412,41 @@ otx_cpt_metabuf_mempool_create(const struct rte_cryptodev *dev, int nb_elements) { char mempool_name[RTE_MEMPOOL_NAMESIZE]; - int sg_mlen, lb_mlen, max_mlen, ret; struct cpt_qp_meta_info *meta_info; struct rte_mempool *pool; + int max_mlen = 0; + int sg_mlen = 0; + int lb_mlen = 0; + int ret; - /* Get meta len for scatter gather mode */ - sg_mlen = cpt_pmd_ops_helper_get_mlen_sg_mode(); + /* + * Calculate metabuf length required. The 'crypto_octeontx' device + * would be either SYMMETRIC or ASYMMETRIC. + */ - /* Extra 32B saved for future considerations */ - sg_mlen += 4 * sizeof(uint64_t); + if (dev->feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) { - /* Get meta len for linear buffer (direct) mode */ - lb_mlen = cpt_pmd_ops_helper_get_mlen_direct_mode(); + /* Get meta len for scatter gather mode */ + sg_mlen = cpt_pmd_ops_helper_get_mlen_sg_mode(); - /* Extra 32B saved for future considerations */ - lb_mlen += 4 * sizeof(uint64_t); + /* Extra 32B saved for future considerations */ + sg_mlen += 4 * sizeof(uint64_t); - /* Check max requirement for meta buffer */ - max_mlen = RTE_MAX(lb_mlen, sg_mlen); + /* Get meta len for linear buffer (direct) mode */ + lb_mlen = cpt_pmd_ops_helper_get_mlen_direct_mode(); + + /* Extra 32B saved for future considerations */ + lb_mlen += 4 * sizeof(uint64_t); + + /* Check max requirement for meta buffer */ + max_mlen = RTE_MAX(lb_mlen, sg_mlen); + } else { + + /* Asymmetric device */ + + /* Get meta len for asymmetric operations */ + max_mlen = cpt_pmd_ops_helper_asym_get_mlen(); + } /* Allocate mempool */ -- 2.20.1