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 4B546A0543; Tue, 4 Oct 2022 14:55:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 46810427FF; Tue, 4 Oct 2022 14:55:21 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id B768F427F3 for ; Tue, 4 Oct 2022 14:55:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664888118; x=1696424118; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HPqscDn6iOUKcEDn+/8OkTmpLWkH9W9mWP9UEZV9jis=; b=SuQKNS64AltkmO24ksQzP9NfqRgbWN9xP19VN3jvsXEpsSsApMcgsLHc xjWusNfJvp7Rdi4KrDFKO3F/3QXeZCu/GJOAHD3KTBBXcyEzb+w5/BKI0 u4p/UFlhfp1IrNbJYEakqQS5OFozvMR9Ox777lFZ0KlcLfPqySwZHsohv nLztWonjzVa7dS0GmO6SvFVKj4dQSlak3jZqkF5t6LyCi/UpiSkGNRuOO JDGGkRA0ROvZ+Wpl5tY3G6kvLOoXDBWhGYfYGmz9ek8KYB9jMaF+pl0ZB 66ZLoEjXWOQY0xKaHFc5Pcvw9sbfJnrq0x6yDKdGr3NzHfeXy6hvviqFx w==; X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="366996719" X-IronPort-AV: E=Sophos;i="5.93,157,1654585200"; d="scan'208";a="366996719" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2022 05:55:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="799106350" X-IronPort-AV: E=Sophos;i="5.93,157,1654585200"; d="scan'208";a="799106350" Received: from silpixa00400355.ir.intel.com (HELO silpixa00400355.ger.corp.intel.com) ([10.237.222.163]) by orsmga005.jf.intel.com with ESMTP; 04 Oct 2022 05:55:16 -0700 From: Ciara Power To: Kai Ji , Pablo de Lara , Akhil Goyal , Fan Zhang Cc: dev@dpdk.org, Ciara Power , roy.fan.zhang@intel.com, slawomirx.mrozowicz@intel.com Subject: [PATCH v4 2/5] crypto/ipsec_mb: fix session creation for sessionless Date: Tue, 4 Oct 2022 12:55:02 +0000 Message-Id: <20221004125505.677795-3-ciara.power@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221004125505.677795-1-ciara.power@intel.com> References: <20220812132334.75707-1-ciara.power@intel.com> <20221004125505.677795-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 Acked-by: Fan Zhang Acked-by: Pablo de Lara --- 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 472b672f08..420701a818 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 9e76a1c72d..ac0c508e76 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -2187,6 +2187,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