From patchwork Tue Oct 18 13:53:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arkadiusz Kusztal X-Patchwork-Id: 118427 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 9B290A0560; Tue, 18 Oct 2022 17:07:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D93840395; Tue, 18 Oct 2022 17:07:12 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 956874021D for ; Tue, 18 Oct 2022 17:07:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666105629; x=1697641629; h=from:to:cc:subject:date:message-id; bh=wim32ID8QE2PkBWjr8KbkbCPSRSuFtD4DCR3uG1I0F4=; b=ixptJ6fQeFS27X2nt04s56gT7PIVwyd0GuVl9alQTC7+eJMvEa9KSqRH E85UFAfqTfu1ZwjfCSF5CQEDGNaOfTzdQo2UvE/ltJyHIA57yk7Y81C+9 wym9c7uYq8exmYBq9BxF/fJFGiYEZyyOWRF3gmuAfXaSyweZQwAKIkipK Yl06kLfROt9UWoMK5LIBLNlIHt7q76ASQmv4CUVLTm0IMOptDXhg9FxTe Q35OczwyYSfxZoxSwMAO5BmNgZxuibUkGJbmO1XfhXjoXghqN/9tQ4FoB NbPcVwbmKWDSEWeQBu45Zq3OdqQV0QLWfjV9UIi6P2H21ZF9yKVe+jNKQ A==; X-IronPort-AV: E=McAfee;i="6500,9779,10504"; a="307792737" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="307792737" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 08:02:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10504"; a="579825381" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="579825381" Received: from silpixa00399302.ir.intel.com ([10.237.214.136]) by orsmga003.jf.intel.com with ESMTP; 18 Oct 2022 08:02:27 -0700 From: Arek Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, kai.ji@intel.com, Arek Kusztal Subject: [PATCH v2 1/3] crypto/qat: fix uncleared cookies in asym Date: Tue, 18 Oct 2022 14:53:32 +0100 Message-Id: <20221018135334.34873-1-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.13.6 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 Fixed incorrectly placed clean function in asym response. Fixes: 002486db239e ("crypto/qat: refactor asymmetric session") Signed-off-by: Arek Kusztal Acked-by: Ciara Power --- v2: - fixed compilation issues - split into 3 patches drivers/crypto/qat/qat_asym.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c index 19931791c4..3d7a800392 100644 --- a/drivers/crypto/qat/qat_asym.c +++ b/drivers/crypto/qat/qat_asym.c @@ -129,20 +129,23 @@ cleanup_crt(struct qat_asym_op_cookie *cookie, static void cleanup(struct qat_asym_op_cookie *cookie, - struct rte_crypto_asym_xform *xform, int alg_size) + struct rte_crypto_asym_xform *xform) { if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODEX) cleanup_arrays(cookie, QAT_ASYM_MODEXP_NUM_IN_PARAMS, - QAT_ASYM_MODEXP_NUM_OUT_PARAMS, alg_size); + QAT_ASYM_MODEXP_NUM_OUT_PARAMS, + cookie->alg_bytesize); else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODINV) cleanup_arrays(cookie, QAT_ASYM_MODINV_NUM_IN_PARAMS, - QAT_ASYM_MODINV_NUM_OUT_PARAMS, alg_size); + QAT_ASYM_MODINV_NUM_OUT_PARAMS, + cookie->alg_bytesize); else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_RSA) { if (xform->rsa.key_type == RTE_RSA_KEY_TYPE_QT) - cleanup_crt(cookie, alg_size); + cleanup_crt(cookie, cookie->alg_bytesize); else { cleanup_arrays(cookie, QAT_ASYM_RSA_NUM_IN_PARAMS, - QAT_ASYM_RSA_NUM_OUT_PARAMS, alg_size); + QAT_ASYM_RSA_NUM_OUT_PARAMS, + cookie->alg_bytesize); } } else { cleanup_arrays(cookie, QAT_ASYM_MAX_PARAMS, @@ -804,12 +807,13 @@ qat_asym_build_request(void *in_op, uint8_t *out_msg, void *op_cookie, op->asym->session->sess_private_data; int err = 0; + op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; if (unlikely(qat_session == NULL)) { QAT_DP_LOG(ERR, "Session was not created for this device"); + op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION; goto error; } - op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; switch (op->sess_type) { case RTE_CRYPTO_OP_WITH_SESSION: request_init(qat_req); @@ -882,10 +886,11 @@ qat_asym_process_response(void **out_op, uint8_t *resp, struct rte_crypto_op *op = (struct rte_crypto_op *)(uintptr_t) (resp_msg->opaque); struct qat_asym_op_cookie *cookie = op_cookie; - struct rte_crypto_asym_xform *xform; + struct rte_crypto_asym_xform *xform = NULL; struct qat_asym_session *qat_session = (struct qat_asym_session *) op->asym->session->sess_private_data; + *out_op = op; if (cookie->error) { cookie->error = 0; if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED) @@ -917,17 +922,13 @@ qat_asym_process_response(void **out_op, uint8_t *resp, default: QAT_DP_LOG(ERR, "Invalid session/xform settings in response ring!"); - op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION; - } - - if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED) { - op->status = qat_asym_collect_response(op, - cookie, xform); - cleanup(cookie, xform, cookie->alg_bytesize); + op->status = RTE_CRYPTO_OP_STATUS_ERROR; } - - *out_op = op; + if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED) + op->status = qat_asym_collect_response(op, cookie, xform); HEXDUMP("resp_msg:", resp_msg, sizeof(struct icp_qat_fw_pke_resp)); + if (likely(xform != NULL)) + cleanup(cookie, xform); return 1; }