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 DA5CBA00C4; Wed, 21 Sep 2022 14:50:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 04352427FF; Wed, 21 Sep 2022 14:50:48 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 3AF5742670 for ; Wed, 21 Sep 2022 14:50:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663764645; x=1695300645; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=o4gyK39Zn1uGQKjL+n77Z8RsUZux+vjBGgAQswa0ZOA=; b=VQe+hZ4KMP+5gORpQ2/PEXcl79GEHqebU2NX8W7QUSvcVvUVv/CXsq8n 7cey5QY85wIl3cWkPcji08wGEWY3eWWahBfS9Fu7eVbAVbAgSmmz0WLRg 6Ba8ioM9U8syP6pgtsGq3XWwOcUzoCWVemHyZPWQHFunr+RUeLre1QR6l RNc8qBzFUKSDleWhqRkchLxH56unL1D36YwGvhQA0oiz5+ukBovheSZl4 fOcvaeSu9/iuIrDnX4NYXYc49O7lUHBm+eW8Tl6T7/zGbt5yh2eZWUadB 1mxt/93HXcl7D6kYPX2om3vcQlNYyk8JbSrP41ARG2KjX+nqQitw3+G+7 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10477"; a="287064399" X-IronPort-AV: E=Sophos;i="5.93,333,1654585200"; d="scan'208";a="287064399" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2022 05:50:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,333,1654585200"; d="scan'208";a="619335532" Received: from silpixa00400355.ir.intel.com (HELO silpixa00400355.ger.corp.intel.com) ([10.237.222.163]) by orsmga002.jf.intel.com with ESMTP; 21 Sep 2022 05:50:43 -0700 From: Ciara Power To: Fan Zhang , Pablo de Lara , Akhil Goyal Cc: dev@dpdk.org, kai.ji@intel.com, Ciara Power , slawomirx.mrozowicz@intel.com Subject: [PATCH v3 2/5] crypto/ipsec_mb: fix session creation for sessionless Date: Wed, 21 Sep 2022 12:50:33 +0000 Message-Id: <20220921125036.9104-3-ciara.power@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220921125036.9104-1-ciara.power@intel.com> References: <20220812132334.75707-1-ciara.power@intel.com> <20220921125036.9104-1-ciara.power@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Currently, for a sessionless op, the session taken from the mempool contains some values previously set by a testcase that does use a session. This is due to the session object not being reset before going back into the mempool. This caused issues when multiple sessionless testcases ran, as the previously set objects were being used for the first few testcases, but subsequent testcases used empty objects, as they were being correctly reset by the sessionless testcases. To fix this, the session objects are now reset before being returned to the mempool for session testcases. In addition, rather than pulling the session object directly from the mempool for sessionless testcases, the session_create() function is now used, which sets the required values, such as nb_drivers. Fixes: c75542ae4200 ("crypto/ipsec_mb: introduce IPsec_mb framework") Fixes: b3bbd9e5f265 ("cryptodev: support device independent sessions") Cc: roy.fan.zhang@intel.com Cc: slawomirx.mrozowicz@intel.com Signed-off-by: Ciara Power --- v3: - Modified fix to reset sessions, and ensure values are then set for sessionless testcases. V2 fix just ensured the same values in session objects were reused, as they were not being reset, which was incorrect. --- drivers/crypto/ipsec_mb/ipsec_mb_private.h | 12 ++++++++---- lib/cryptodev/rte_cryptodev.c | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_private.h b/drivers/crypto/ipsec_mb/ipsec_mb_private.h index d074b33133..8ec23c172d 100644 --- a/drivers/crypto/ipsec_mb/ipsec_mb_private.h +++ b/drivers/crypto/ipsec_mb/ipsec_mb_private.h @@ -415,7 +415,7 @@ ipsec_mb_get_session_private(struct ipsec_mb_qp *qp, struct rte_crypto_op *op) uint32_t driver_id = ipsec_mb_get_driver_id(qp->pmd_type); struct rte_crypto_sym_op *sym_op = op->sym; uint8_t sess_type = op->sess_type; - void *_sess; + struct rte_cryptodev_sym_session *_sess; void *_sess_private_data = NULL; struct ipsec_mb_internals *pmd_data = &ipsec_mb_pmds[qp->pmd_type]; @@ -426,8 +426,12 @@ ipsec_mb_get_session_private(struct ipsec_mb_qp *qp, struct rte_crypto_op *op) driver_id); break; case RTE_CRYPTO_OP_SESSIONLESS: - if (!qp->sess_mp || - rte_mempool_get(qp->sess_mp, (void **)&_sess)) + if (!qp->sess_mp) + return NULL; + + _sess = rte_cryptodev_sym_session_create(qp->sess_mp); + + if (!_sess) return NULL; if (!qp->sess_mp_priv || @@ -443,7 +447,7 @@ ipsec_mb_get_session_private(struct ipsec_mb_qp *qp, struct rte_crypto_op *op) sess = NULL; } - sym_op->session = (struct rte_cryptodev_sym_session *)_sess; + sym_op->session = _sess; set_sym_session_private_data(sym_op->session, driver_id, _sess_private_data); break; diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 42f3221052..af24969ed5 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -2032,6 +2032,7 @@ rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess) /* Return session to mempool */ sess_mp = rte_mempool_from_obj(sess); + memset(sess, 0, rte_cryptodev_sym_get_existing_header_session_size(sess)); rte_mempool_put(sess_mp, sess); rte_cryptodev_trace_sym_session_free(sess); -- 2.25.1