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 AA0F44416A; Thu, 6 Jun 2024 15:35:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9788540EAB; Thu, 6 Jun 2024 15:35:17 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by mails.dpdk.org (Postfix) with ESMTP id 9CDD940E96 for ; Thu, 6 Jun 2024 15:35:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717680915; x=1749216915; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IrL+zLoO5JjGbE+FZMxipj7cHlHpzqQ9OAYuzSpXV1k=; b=nVa2FK586WrF7AJLUf19CF309fnY+FIHwZlzhRPycqHRqldJhxPUBvaN I8yalw7mnQqxFlLOxPyMaXOeMPQs5WQMKZnWq+yU3J8yFY6A4kq+e/90d pFfh0YBjeDBjFDEFque/O9338OSOyffk6BVILhPi16idQjFslM1Nfec4A LcuIu0/4IV2AnMcfG9qpN8xcaXPwnqZREjUarypCG0VRjgp7yEtJd5lmu lGNfYQ3xPoIz20fpenuVArHNgMg4F2YfJT7aqdwf3hBrP5R7/hv55Vujy 1gmXmHMeqrXh0h8DT9CGEVLHrxv4Wt7iu2H6LzbXuqWi2Gyv3SiTFTtxL w==; X-CSE-ConnectionGUID: i/1gZo0NSduFe8Ul2VO75Q== X-CSE-MsgGUID: oxYZhYr9TjKc6sLuAiV2Ng== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="24919414" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="24919414" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 06:35:14 -0700 X-CSE-ConnectionGUID: 0CfjMZslT/q3eo9DsguyRw== X-CSE-MsgGUID: VsQyqRQZQVGbejptsa8hLw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="68765269" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by orviesa002.jf.intel.com with ESMTP; 06 Jun 2024 06:35:14 -0700 From: Ganapati Kundapura To: dev@dpdk.org, jerinj@marvell.com, abhinandan.gujjar@intel.com Cc: jay.jayatheerthan@intel.com, s.v.naga.harish.k@intel.com Subject: [PATCH v4] eventdev/crypto: restore opaque field between dequeue and enqueue Date: Thu, 6 Jun 2024 08:35:11 -0500 Message-Id: <20240606133511.2047397-1-ganapati.kundapura@intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20240606114637.2022802-1-ganapati.kundapura@intel.com> References: <20240606114637.2022802-1-ganapati.kundapura@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 For session-less crypto operations, event info is contained in crypto op metadata for each event which is restored in event from the crypto op metadata response info. For session based crypto operations, crypto op contains per session based event info in crypto op metadata. If any PMD passes any implementation specific data in "struct rte_event::impl_opaque" on each event, it's not getting restored. This patch stores "struct rte_event::impl_opaque" in mbuf dynamic field before enqueueing to cryptodev and restores "struct rte_event::impl_opaque" from mbuf dynamic field after dequeueing crypto op from cryptodev for session based crypto operations. Fixes: 7901eac3409a ("eventdev: add crypto adapter implementation") Acked-by: Abhinandan Gujjar Signed-off-by: Ganapati Kundapura --- v4: * Replaced ev::impl_opaque with "struct rte_event::impl_opaque" * Added Acked-by v3: * Added Fixes tag v2: * Fixed TYPO_SPELLING warning in commit header diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c index db1c7f3..b2b54bb 100644 --- a/lib/eventdev/rte_event_crypto_adapter.c +++ b/lib/eventdev/rte_event_crypto_adapter.c @@ -138,6 +138,28 @@ static struct event_crypto_adapter **event_crypto_adapter; } \ } while (0) +#define ECA_DYNFIELD_NAME "eca_ev_opaque_data" +/* Device-specific metadata field type */ +typedef uint8_t eca_dynfield_t; + +/* mbuf dynamic field offset for device-specific metadata */ +int eca_dynfield_offset = -1; + +static int +eca_dynfield_register(void) +{ + static const struct rte_mbuf_dynfield eca_dynfield_desc = { + .name = ECA_DYNFIELD_NAME, + .size = sizeof(eca_dynfield_t), + .align = alignof(eca_dynfield_t), + .flags = 0, + }; + + eca_dynfield_offset = + rte_mbuf_dynfield_register(&eca_dynfield_desc); + return eca_dynfield_offset; +} + static inline int eca_valid_id(uint8_t id) { @@ -491,6 +513,25 @@ eca_enq_to_cryptodev(struct event_crypto_adapter *adapter, struct rte_event *ev, crypto_op = ev[i].event_ptr; if (crypto_op == NULL) continue; + + /** "struct rte_event::impl_opaque" field passed on from + * eventdev PMD could have different value per event. + * For session-based crypto operations retain + * "struct rte_event::impl_opaque" into mbuf dynamic field and + * restore it back after copying event information from + * session event metadata. + * For session-less, each crypto operation carries event + * metadata and retains "struct rte_event:impl_opaque" + * information to be passed back to eventdev PMD. + */ + if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { + struct rte_mbuf *mbuf = crypto_op->sym->m_src; + + *RTE_MBUF_DYNFIELD(mbuf, + eca_dynfield_offset, + eca_dynfield_t *) = ev[i].impl_opaque; + } + m_data = rte_cryptodev_session_event_mdata_get(crypto_op); if (m_data == NULL) { rte_pktmbuf_free(crypto_op->sym->m_src); @@ -657,6 +698,21 @@ eca_ops_enqueue_burst(struct event_crypto_adapter *adapter, rte_memcpy(ev, &m_data->response_info, sizeof(*ev)); ev->event_ptr = ops[i]; + + /** Restore "struct rte_event::impl_opaque" from mbuf + * dynamic field for session based crypto operation. + * For session-less, each crypto operations carries event + * metadata and retains "struct rte_event::impl_opaque" + * information to be passed back to eventdev PMD. + */ + if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { + struct rte_mbuf *mbuf = ops[i]->sym->m_src; + + ev->impl_opaque = *RTE_MBUF_DYNFIELD(mbuf, + eca_dynfield_offset, + eca_dynfield_t *); + } + ev->event_type = RTE_EVENT_TYPE_CRYPTODEV; if (adapter->implicit_release_disabled) ev->op = RTE_EVENT_OP_FORWARD; @@ -895,6 +951,16 @@ eca_init_service(struct event_crypto_adapter *adapter, uint8_t id) } adapter->implicit_release_disabled = (uint8_t)impl_rel; + + /* Register for mbuf dyn field to store/restore ev::impl_opaque */ + eca_dynfield_offset = eca_dynfield_register(); + if (eca_dynfield_offset < 0) { + RTE_EDEV_LOG_ERR("Failed to register eca mbuf dyn field"); + eca_circular_buffer_free(&adapter->ebuf); + rte_free(adapter); + return -EINVAL; + } + adapter->service_inited = 1; return ret; -- 2.6.4