From patchwork Wed May 24 16:00:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anoob Joseph X-Patchwork-Id: 127335 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 EA36142B8F; Wed, 24 May 2023 18:02:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BF10F42D3B; Wed, 24 May 2023 18:01:46 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 3266F42D3B for ; Wed, 24 May 2023 18:01:45 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34OEaqXt025791; Wed, 24 May 2023 09:01:43 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=eU7Y/ZRPqkx/j8/6x5kc1F3N9CA1T7DyM8DOHmtwKVM=; b=UpJ3DWpwN1zO/5URd/v9d9wuatVbeAoDOh50WTMWHikHqU75f9r0cIDsoILZNW4vFC2c eWnpzo67zBYETv5gFdSn87CTw8q671qaCvJBqyvskhfxxqf6cF4c8O3LE/SKuHO+FU+T aShf+2gtUIHRJVSeWk3bQNW7QjivtFAJ6qjOGgt/O0yyC0gvDceWwItUAugjJ7gcUxb+ igjuQOSkxOpT5JUsuRgaZvYATDpCFw9qWY72xX4umlXy/X4ZrjUchXKH3exdpBgLfbKo WOD4vXuPpquBZfFy3kVn0QZFf3JDjTuioWYjjq2MzTEcb6IYB5uAqJpsmWozYWUHoCmW CA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3qsbxetjqq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 24 May 2023 09:01:43 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 24 May 2023 09:01:41 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Wed, 24 May 2023 09:01:41 -0700 Received: from BG-LT92004.corp.innovium.com (unknown [10.28.161.183]) by maili.marvell.com (Postfix) with ESMTP id 6D4573F70AA; Wed, 24 May 2023 09:01:36 -0700 (PDT) From: Anoob Joseph To: Thomas Monjalon , Akhil Goyal , Jerin Jacob , Konstantin Ananyev , Bernard Iremonger CC: Hemant Agrawal , =?utf-8?q?Mattias_R=C3=B6nnblom?= , "Kiran Kumar K" , Volodymyr Fialko , , Olivier Matz Subject: [PATCH v3 04/22] pdcp: add packet group Date: Wed, 24 May 2023 21:30:58 +0530 Message-ID: <20230524160116.304-5-anoobj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230524160116.304-1-anoobj@marvell.com> References: <20230414174512.642-1-anoobj@marvell.com> <20230524160116.304-1-anoobj@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: XlJtIZ3m3TRxRrUh35Ei_75ZqWlA1ZLw X-Proofpoint-GUID: XlJtIZ3m3TRxRrUh35Ei_75ZqWlA1ZLw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-24_11,2023-05-24_01,2023-05-22_02 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 Crypto processing in PDCP is performed asynchronously by rte_cryptodev_enqueue_burst() and rte_cryptodev_dequeue_burst(). Since cryptodev dequeue can return crypto operations belonging to multiple entities, rte_pdcp_pkt_crypto_group() is added to help grouping crypto operations belonging to same entity. Signed-off-by: Anoob Joseph Signed-off-by: Kiran Kumar K Signed-off-by: Volodymyr Fialko --- lib/pdcp/meson.build | 1 + lib/pdcp/rte_pdcp.h | 2 + lib/pdcp/rte_pdcp_group.h | 131 ++++++++++++++++++++++++++++++++++++++ lib/pdcp/version.map | 3 + 4 files changed, 137 insertions(+) create mode 100644 lib/pdcp/rte_pdcp_group.h diff --git a/lib/pdcp/meson.build b/lib/pdcp/meson.build index ccaf426240..08679b743a 100644 --- a/lib/pdcp/meson.build +++ b/lib/pdcp/meson.build @@ -13,5 +13,6 @@ sources = files( 'rte_pdcp.c', ) headers = files('rte_pdcp.h') +indirect_headers += files('rte_pdcp_group.h') deps += ['mbuf', 'net', 'cryptodev', 'security'] diff --git a/lib/pdcp/rte_pdcp.h b/lib/pdcp/rte_pdcp.h index 46c3c2a416..4143fae0b2 100644 --- a/lib/pdcp/rte_pdcp.h +++ b/lib/pdcp/rte_pdcp.h @@ -257,6 +257,8 @@ rte_pdcp_pkt_post_process(const struct rte_pdcp_entity *entity, return entity->post_process(entity, in_mb, out_mb, num, nb_err); } +#include + #ifdef __cplusplus } #endif diff --git a/lib/pdcp/rte_pdcp_group.h b/lib/pdcp/rte_pdcp_group.h new file mode 100644 index 0000000000..ece3e8c0ff --- /dev/null +++ b/lib/pdcp/rte_pdcp_group.h @@ -0,0 +1,131 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2023 Marvell. + */ + +#ifndef RTE_PDCP_GROUP_H +#define RTE_PDCP_GROUP_H + +/** + * @file rte_pdcp_group.h + * + * RTE PDCP grouping support. + * It is not recommended to include this file directly, include + * instead. + * Provides helper functions to process completed crypto-ops and group related + * packets by sessions they belong to. + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Group packets belonging to same PDCP entity. + */ +struct rte_pdcp_group { + union { + uint64_t val; + void *ptr; + } id; /**< Grouped by value */ + struct rte_mbuf **m; /**< Start of the group */ + uint32_t cnt; /**< Number of entries in the group */ + int32_t rc; /**< Status code associated with the group */ +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Take crypto-op as an input and extract pointer to related PDCP entity. + * @param cop + * The address of an input *rte_crypto_op* structure. + * @return + * The pointer to the related *rte_pdcp_entity* structure. + */ +static inline struct rte_pdcp_entity * +rte_pdcp_en_from_cop(const struct rte_crypto_op *cop) +{ + void *sess = cop->sym[0].session; + + return (struct rte_pdcp_entity *)(uintptr_t) + rte_cryptodev_sym_session_opaque_data_get(sess); +} + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Take as input completed crypto ops, extract related mbufs and group them by + * *rte_pdcp_entity* they belong to. Mbuf for which the crypto operation has + * failed would be flagged using *RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED* flag + * in rte_mbuf.ol_flags. The crypto_ops would be freed after the grouping. + * + * Note that application must ensure only crypto-ops prepared by lib_pdcp is + * provided back to @see rte_pdcp_pkt_crypto_group(). + * + * @param cop + * The address of an array of *num* pointers to the input *rte_crypto_op* + * structures. + * @param[out] mb + * The address of an array of *num* pointers to output *rte_mbuf* structures. + * @param[out] grp + * The address of an array of *num* to output *rte_pdcp_group* structures. + * @param num + * The maximum number of crypto-ops to process. + * @return + * Number of filled elements in *grp* array. + * + */ +static inline uint16_t +rte_pdcp_pkt_crypto_group(struct rte_crypto_op *cop[], struct rte_mbuf *mb[], + struct rte_pdcp_group grp[], uint16_t num) +{ + uint32_t i, j = 0, n = 0; + void *ns, *ps = NULL; + struct rte_mbuf *m; + + for (i = 0; i != num; i++) { + m = cop[i]->sym[0].m_src; + ns = cop[i]->sym[0].session; + + m->ol_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD; + if (cop[i]->status != RTE_CRYPTO_OP_STATUS_SUCCESS) + m->ol_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED; + + /* Different entity */ + if (ps != ns) { + + /* Finalize open group and start a new one */ + if (ps != NULL) { + grp[n].cnt = mb + j - grp[n].m; + n++; + } + + /* Start new group */ + grp[n].m = mb + j; + ps = ns; + grp[n].id.ptr = rte_pdcp_en_from_cop(cop[i]); + } + + mb[j++] = m; + rte_crypto_op_free(cop[i]); + } + + /* Finalize last group */ + if (ps != NULL) { + grp[n].cnt = mb + j - grp[n].m; + n++; + } + + return n; +} + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_PDCP_GROUP_H */ diff --git a/lib/pdcp/version.map b/lib/pdcp/version.map index f9ff30600a..d564f155e0 100644 --- a/lib/pdcp/version.map +++ b/lib/pdcp/version.map @@ -2,12 +2,15 @@ EXPERIMENTAL { global: # added in 23.07 + rte_pdcp_en_from_cop; + rte_pdcp_entity_establish; rte_pdcp_entity_release; rte_pdcp_entity_suspend; rte_pdcp_pkt_post_process; rte_pdcp_pkt_pre_process; + rte_pdcp_pkt_crypto_group; local: *; };