From patchwork Thu Oct 20 15:09:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arkadiusz Kusztal X-Patchwork-Id: 118828 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A3CDBA0553; Thu, 20 Oct 2022 18:18:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6101A427F9; Thu, 20 Oct 2022 18:18:39 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id BD018427EC for ; Thu, 20 Oct 2022 18:18:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666282717; x=1697818717; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=DWOlCxlJT2btvycUHLyPSzlpSvCYApQcy/cfvtkOm5E=; b=WHgl0Ygkg3onU9FA+LwyT1hzknwWo+usv/ViHYpNkVoaRb14qO8diKDk Vkx0uIsmdr8rwWVQGU6XYKWJVIDWIn+1XVeVb9TnuAQ0CgEJ7+dA1jLME +HuGohM8oQ4ovLW0YiU7bfm6GhIzRS3h1PDJlUeA8NfsDKFrpv+BbPUr/ xL4/hkfm6XOI5cI/aha6u7gf3AmkFnMVPfA7QetJnzUp3i0/4Moa3iJ5U aliTWP+gUm5ubjjJBR66Mmy6vzFdkTU0sSdShyVdi8xT1Jnv33piVVzF6 hH+UlWClJ9ACYEva4ueMdO6dNUJAOWlHRChYt79yN69kEz7x+KetQdByJ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="287161670" X-IronPort-AV: E=Sophos;i="5.95,199,1661842800"; d="scan'208";a="287161670" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2022 09:18:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="629913429" X-IronPort-AV: E=Sophos;i="5.95,199,1661842800"; d="scan'208";a="629913429" Received: from silpixa00399302.ir.intel.com ([10.237.214.136]) by orsmga002.jf.intel.com with ESMTP; 20 Oct 2022 09:18:35 -0700 From: Arek Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, kai.ji@intel.com, Arek Kusztal Subject: [PATCH v2 2/4] crypto/qat: improve freeing of asym cookies Date: Thu, 20 Oct 2022 16:09:38 +0100 Message-Id: <20221020150940.62465-3-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20221020150940.62465-1-arkadiuszx.kusztal@intel.com> References: <20221020150940.62465-1-arkadiuszx.kusztal@intel.com> 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 Improve the way that cookies are freed and cleared. Signed-off-by: Arek Kusztal Acked-by: Kai Ji --- drivers/crypto/qat/qat_asym.c | 73 ++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c index 6a079424b9..a77f7bfcd0 100644 --- a/drivers/crypto/qat/qat_asym.c +++ b/drivers/crypto/qat/qat_asym.c @@ -70,27 +70,33 @@ static const struct rte_driver cryptodev_qat_asym_driver = { } while (0) #define SET_PKE_LN(what, how, idx) \ - rte_memcpy(cookie->input_array[idx] + how - \ - what.length, \ - what.data, \ - what.length) + rte_memcpy(cookie->input_array[idx] + how - \ + what.length, \ + what.data, \ + what.length) #define SET_PKE_LN_EC(curve, p, idx) \ - rte_memcpy(cookie->input_array[idx] + \ - qat_func_alignsize - curve.bytesize, \ - curve.p.data, curve.bytesize) + rte_memcpy(cookie->input_array[idx] + \ + qat_func_alignsize - curve.bytesize, \ + curve.p.data, curve.bytesize) #define SET_PKE_9A_IN(what, idx) \ - rte_memcpy(&cookie->input_buffer[idx * \ - qat_func_alignsize] + \ - qat_func_alignsize - what.length, \ - what.data, what.length) + rte_memcpy(&cookie->input_buffer[idx * \ + qat_func_alignsize] + \ + qat_func_alignsize - what.length, \ + what.data, what.length) #define SET_PKE_9A_EC(curve, p, idx) \ - rte_memcpy(&cookie->input_buffer[idx * \ - qat_func_alignsize] + \ - qat_func_alignsize - curve.bytesize, \ - curve.p.data, curve.bytesize) + rte_memcpy(&cookie->input_buffer[idx * \ + qat_func_alignsize] + \ + qat_func_alignsize - curve.bytesize, \ + curve.p.data, curve.bytesize) + +#define PARAM_CLR(what) \ + do { \ + memset(what.data, 0, what.length); \ + rte_free(what.data); \ + } while (0) static void request_init(struct icp_qat_fw_pke_request *qat_req) @@ -98,8 +104,8 @@ request_init(struct icp_qat_fw_pke_request *qat_req) memset(qat_req, 0, sizeof(*qat_req)); qat_req->pke_hdr.service_type = ICP_QAT_FW_COMN_REQ_CPM_FW_PKE; qat_req->pke_hdr.hdr_flags = - ICP_QAT_FW_COMN_HDR_FLAGS_BUILD - (ICP_QAT_FW_COMN_REQ_FLAG_SET); + ICP_QAT_FW_COMN_HDR_FLAGS_BUILD + (ICP_QAT_FW_COMN_REQ_FLAG_SET); } static void @@ -1146,40 +1152,29 @@ qat_asym_session_get_private_size(struct rte_cryptodev *dev __rte_unused) static void session_clear_modexp(struct rte_crypto_modex_xform *modex) { - memset(modex->modulus.data, 0, modex->modulus.length); - rte_free(modex->modulus.data); - memset(modex->exponent.data, 0, modex->exponent.length); - rte_free(modex->exponent.data); + PARAM_CLR(modex->modulus); + PARAM_CLR(modex->exponent); } static void session_clear_modinv(struct rte_crypto_modinv_xform *modinv) { - memset(modinv->modulus.data, 0, modinv->modulus.length); - rte_free(modinv->modulus.data); + PARAM_CLR(modinv->modulus); } static void session_clear_rsa(struct rte_crypto_rsa_xform *rsa) { - memset(rsa->n.data, 0, rsa->n.length); - rte_free(rsa->n.data); - memset(rsa->e.data, 0, rsa->e.length); - rte_free(rsa->e.data); + PARAM_CLR(rsa->n); + PARAM_CLR(rsa->e); if (rsa->key_type == RTE_RSA_KEY_TYPE_EXP) { - memset(rsa->d.data, 0, rsa->d.length); - rte_free(rsa->d.data); + PARAM_CLR(rsa->d); } else { - memset(rsa->qt.p.data, 0, rsa->qt.p.length); - rte_free(rsa->qt.p.data); - memset(rsa->qt.q.data, 0, rsa->qt.q.length); - rte_free(rsa->qt.q.data); - memset(rsa->qt.dP.data, 0, rsa->qt.dP.length); - rte_free(rsa->qt.dP.data); - memset(rsa->qt.dQ.data, 0, rsa->qt.dQ.length); - rte_free(rsa->qt.dQ.data); - memset(rsa->qt.qInv.data, 0, rsa->qt.qInv.length); - rte_free(rsa->qt.qInv.data); + PARAM_CLR(rsa->qt.p); + PARAM_CLR(rsa->qt.q); + PARAM_CLR(rsa->qt.dP); + PARAM_CLR(rsa->qt.dQ); + PARAM_CLR(rsa->qt.qInv); } }