From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EF3B4A0C4A; Fri, 16 Jul 2021 07:17:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 70C664014D; Fri, 16 Jul 2021 07:17:57 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 3563240143 for ; Fri, 16 Jul 2021 07:17:55 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16G5CC3E017246 for ; Thu, 15 Jul 2021 22:17:54 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=uDmAdxpnJNDtQw+/4ah/pSdofUuj9qLVGbZntnn0Y1w=; b=DVMB57zTVrRyX8a0EIAw/wlWooTKPXsuioqeie501sjZYpvzQv1GNqR/t9cSzT29znyV 6qggRPJEmn47Gbn7ohZzThpTbijknCNO3TSBxUAu+Ed+Vsr02Q70EQBenB4rg8AaMyS4 keOMw4z8tKLmcVrOmWLkFTXqKKCk/+Jtr84mc9cny65I1Mg2eOUsiJRBFpWnX3Sgf0Be Ax3Wae7tTzNkp4+Bqaij0U2p3E77c9r+NmSOo9slCYA7jbubb/Gv0df9ozFtIK67pvlR XjosTv4FPNxHnCPazi43a3GVAvsGkp0jyMfSeUVC+VLlAX5lF3lYg/MjwrMQ+gPXtCSV gQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 39tw30h8rf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 15 Jul 2021 22:17:54 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 15 Jul 2021 22:17:52 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 15 Jul 2021 22:17:52 -0700 Received: from HY-LT1002.marvell.com (unknown [10.193.66.246]) by maili.marvell.com (Postfix) with ESMTP id 908F73F703F; Thu, 15 Jul 2021 22:17:49 -0700 (PDT) From: Anoob Joseph To: Akhil Goyal , Jerin Jacob CC: Anoob Joseph , Ankur Dwivedi , Tejasree Kondoj , Date: Fri, 16 Jul 2021 10:43:29 +0530 Message-ID: <1626412409-268-1-git-send-email-anoobj@marvell.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: 1_px7Fb84B-JpWfNuGRf3FxQSO3z75E- X-Proofpoint-GUID: 1_px7Fb84B-JpWfNuGRf3FxQSO3z75E- X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-16_02:2021-07-16, 2021-07-16 signatures=0 Subject: [dpdk-dev] [PATCH] common/cnxk: allocate auth key mem dynamically X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Reduce session private data size by allocating auth_key dynamically as required. Signed-off-by: Anoob Joseph --- drivers/common/cnxk/roc_se.c | 6 +++++- drivers/common/cnxk/roc_se.h | 2 +- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 11 +++++++++++ drivers/crypto/cnxk/cnxk_se.h | 3 +-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/common/cnxk/roc_se.c b/drivers/common/cnxk/roc_se.c index 3f74175..b04de79 100644 --- a/drivers/common/cnxk/roc_se.c +++ b/drivers/common/cnxk/roc_se.c @@ -206,7 +206,11 @@ roc_se_auth_key_set(struct roc_se_ctx *se_ctx, roc_se_auth_type type, if (key_len) { se_ctx->hmac = 1; - memset(se_ctx->auth_key, 0, sizeof(se_ctx->auth_key)); + + se_ctx->auth_key = plt_zmalloc(key_len, 8); + if (se_ctx->auth_key == NULL) + return -1; + memcpy(se_ctx->auth_key, key, key_len); se_ctx->auth_key_len = key_len; memset(fctx->hmac.ipad, 0, sizeof(fctx->hmac.ipad)); diff --git a/drivers/common/cnxk/roc_se.h b/drivers/common/cnxk/roc_se.h index 43a40dd..5c7e2ca 100644 --- a/drivers/common/cnxk/roc_se.h +++ b/drivers/common/cnxk/roc_se.h @@ -261,7 +261,7 @@ struct roc_se_ctx { struct roc_se_zuc_snow3g_ctx zs_ctx; struct roc_se_kasumi_ctx k_ctx; } se_ctx; - uint8_t auth_key[1024]; + uint8_t *auth_key; }; int __roc_api roc_se_auth_key_set(struct roc_se_ctx *se_ctx, diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c index 694eef7..440dbc3a 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c @@ -552,6 +552,11 @@ sym_session_configure(struct roc_cpt *roc_cpt, int driver_id, if ((sess_priv->roc_se_ctx.fc_type == ROC_SE_HASH_HMAC) && cpt_mac_len_verify(&xform->auth)) { plt_dp_err("MAC length is not supported"); + if (sess_priv->roc_se_ctx.auth_key != NULL) { + plt_free(sess_priv->roc_se_ctx.auth_key); + sess_priv->roc_se_ctx.auth_key = NULL; + } + ret = -ENOTSUP; goto priv_put; } @@ -587,11 +592,17 @@ void sym_session_clear(int driver_id, struct rte_cryptodev_sym_session *sess) { void *priv = get_sym_session_private_data(sess, driver_id); + struct cnxk_se_sess *sess_priv; struct rte_mempool *pool; if (priv == NULL) return; + sess_priv = priv; + + if (sess_priv->roc_se_ctx.auth_key != NULL) + plt_free(sess_priv->roc_se_ctx.auth_key); + memset(priv, 0, cnxk_cpt_sym_session_get_size(NULL)); pool = rte_mempool_from_obj(priv); diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h index d83910f..3ed6b90 100644 --- a/drivers/crypto/cnxk/cnxk_se.h +++ b/drivers/crypto/cnxk/cnxk_se.h @@ -273,8 +273,7 @@ cpt_digest_gen_prep(uint32_t flags, uint64_t d_lens, i = 0; if (ctx->hmac) { - uint64_t k_vaddr = (uint64_t)params->ctx_buf.vaddr + - offsetof(struct roc_se_ctx, auth_key); + uint64_t k_vaddr = (uint64_t)ctx->auth_key; /* Key */ i = fill_sg_comp(gather_comp, i, k_vaddr, RTE_ALIGN_CEIL(key_len, 8)); -- 2.7.4