From patchwork Mon Feb 26 10:25:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Radu Nicolau X-Patchwork-Id: 137198 X-Patchwork-Delegate: thomas@monjalon.net 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 7622843BE7; Mon, 26 Feb 2024 11:25:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4A90A402C8; Mon, 26 Feb 2024 11:25:58 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by mails.dpdk.org (Postfix) with ESMTP id 4DA0440144; Mon, 26 Feb 2024 11:25:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708943156; x=1740479156; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZhfnxdXlB+q6MpuPjArx4SFwPhtWZPatrnIQzcY0P8w=; b=WCmpQFyKAPDfm/Pi26FdsyqOC38OIg7dRaNJi5Y2DuU44sdJg855UidW emydSuf+qlKEVl/PoSE+dGB368mDvnoRzfehUR8+XSJTCXfZ7Uwj7rZCq rGbWKXu4BtK15ZJOAN2OvttkXZlYQwtIKvR4PZqpMKTWzZWdu55n7yA37 HZv9LJYWLummENBTIdtNbRUID2ScruAK9KAMsYTKiHcVPs+xW/C4PXuPN lklypwGlFejaEKPwfV9+7prV5T4uGQdabYjcUX+JmHMItuj85zAQM18mo 0UUZ/9QYB2cd7GH4BH8IBYcVUe3KEy+viZf6lmxMKauPEUh5c/DBmI9lC g==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3089423" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3089423" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 02:25:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="6513292" Received: from silpixa00401455.ir.intel.com (HELO silpixa00400884.ir.intel.com) ([10.243.22.53]) by fmviesa007.fm.intel.com with ESMTP; 26 Feb 2024 02:25:47 -0800 From: Radu Nicolau To: dev@dpdk.org Cc: anoobj@marvell.com, Radu Nicolau , stable@dpdk.org, vfialko@marvell.com, Ting-Kai Ku , Ciara Power , Kai Ji , Akhil Goyal Subject: [PATCH v3] examples/ipsec-secgw: fix cryptodev to SA mapping Date: Mon, 26 Feb 2024 10:25:45 +0000 Message-Id: <20240226102545.18667-1-radu.nicolau@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211095349.9895-1-radu.nicolau@intel.com> References: <20231211095349.9895-1-radu.nicolau@intel.com> MIME-Version: 1.0 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 There are use cases where a SA should be able to use different cryptodevs on different lcores, for example there can be cryptodevs with just 1 qp per VF. For this purpose this patch relaxes the check in create lookaside session function. Also add a check to verify that a CQP is available for the current lcore. Fixes: a8ade12123c3 ("examples/ipsec-secgw: create lookaside sessions at init") Cc: stable@dpdk.org Cc: vfialko@marvell.com Signed-off-by: Radu Nicolau Tested-by: Ting-Kai Ku Acked-by: Ciara Power Acked-by: Kai Ji --- v3: check if the cryptodev are not of the same type examples/ipsec-secgw/ipsec.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index f5cec4a928..b59576c049 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -288,10 +288,21 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx_lcore[], if (cdev_id == RTE_CRYPTO_MAX_DEVS) cdev_id = ipsec_ctx->tbl[cdev_id_qp].id; else if (cdev_id != ipsec_ctx->tbl[cdev_id_qp].id) { - RTE_LOG(ERR, IPSEC, - "SA mapping to multiple cryptodevs is " - "not supported!"); - return -EINVAL; + struct rte_cryptodev_info dev_info_1, dev_info_2; + rte_cryptodev_info_get(cdev_id, &dev_info_1); + rte_cryptodev_info_get(ipsec_ctx->tbl[cdev_id_qp].id, + &dev_info_2); + if (dev_info_1.driver_id == dev_info_2.driver_id) { + RTE_LOG(WARNING, IPSEC, + "SA mapped to multiple cryptodevs for SPI %d\n", + sa->spi); + + } else { + RTE_LOG(WARNING, IPSEC, + "SA mapped to multiple cryptodevs of different types for SPI %d\n", + sa->spi); + + } } /* Store per core queue pair information */ @@ -908,7 +919,11 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx, continue; } - enqueue_cop(sa->cqp[ipsec_ctx->lcore_id], &priv->cop); + if (likely(sa->cqp[ipsec_ctx->lcore_id])) + enqueue_cop(sa->cqp[ipsec_ctx->lcore_id], &priv->cop); + else + RTE_LOG(ERR, IPSEC, "No CQP available for lcore %d\n", + ipsec_ctx->lcore_id); } }