get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/127333/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 127333,
    "url": "http://patches.dpdk.org/api/patches/127333/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230524160116.304-3-anoobj@marvell.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20230524160116.304-3-anoobj@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230524160116.304-3-anoobj@marvell.com",
    "date": "2023-05-24T16:00:56",
    "name": "[v3,02/22] lib: add pdcp protocol",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "ae9856cab64dbeb7e631432b0eb836477ccc4922",
    "submitter": {
        "id": 1205,
        "url": "http://patches.dpdk.org/api/people/1205/?format=api",
        "name": "Anoob Joseph",
        "email": "anoobj@marvell.com"
    },
    "delegate": {
        "id": 6690,
        "url": "http://patches.dpdk.org/api/users/6690/?format=api",
        "username": "akhil",
        "first_name": "akhil",
        "last_name": "goyal",
        "email": "gakhil@marvell.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20230524160116.304-3-anoobj@marvell.com/mbox/",
    "series": [
        {
            "id": 28158,
            "url": "http://patches.dpdk.org/api/series/28158/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=28158",
            "date": "2023-05-24T16:00:54",
            "name": "lib: add pdcp protocol",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/28158/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/127333/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/127333/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "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])\n\tby inbox.dpdk.org (Postfix) with ESMTP id D65DF42B8F;\n\tWed, 24 May 2023 18:01:39 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 2FF484114B;\n\tWed, 24 May 2023 18:01:36 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com\n [67.231.156.173])\n by mails.dpdk.org (Postfix) with ESMTP id B7BDA42D36\n for <dev@dpdk.org>; Wed, 24 May 2023 18:01:34 +0200 (CEST)",
            "from pps.filterd (m0045851.ppops.net [127.0.0.1])\n by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id\n 34OCK9jT020238; Wed, 24 May 2023 09:01:33 -0700",
            "from dc5-exch02.marvell.com ([199.233.59.182])\n by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3qsh90h0y7-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);\n Wed, 24 May 2023 09:01:33 -0700",
            "from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48;\n Wed, 24 May 2023 09:01:31 -0700",
            "from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend\n Transport; Wed, 24 May 2023 09:01:31 -0700",
            "from BG-LT92004.corp.innovium.com (unknown [10.28.161.183])\n by maili.marvell.com (Postfix) with ESMTP id F24E33F704A;\n Wed, 24 May 2023 09:01:26 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-transfer-encoding : content-type; s=pfpt0220;\n bh=vNuUi1QRQCHYQcURrPm4tIjX1dZCePD3UnS9yDGbXVI=;\n b=M8vmz3EkSZX8vmBtsMuGGLUuNRVGGmhzMb+5zHJGTvY2uU7GiSKPEmBZ0WCDCdCKZRJm\n k2u1i6pMSe4v+pYlWBrCq1SK6UMCp+HzQlKt18/SWPzFF4fXntiviXt2shARyUfMOs8n\n bKB7C54PmoAOQgZ0l+a1Z28nYTy+ZBlm//7nzgrrWzDLKVHk+e/sV3ukyLtFMawhW08K\n uL/PyY36ZA3ILf3kYtTGOC69VniGMuAB6YZteEeNJZtWDMck8XmKEfqDOnBz5+Wa59oD\n agrZI676VWEGIR/omKfZBCztl6TTLRAaB6I8c5l4mAbGHq1R6MHRbhz1XxPi6rqv8NEG sQ==",
        "From": "Anoob Joseph <anoobj@marvell.com>",
        "To": "Thomas Monjalon <thomas@monjalon.net>, Akhil Goyal <gakhil@marvell.com>,\n Jerin Jacob <jerinj@marvell.com>, Konstantin Ananyev\n <konstantin.v.ananyev@yandex.ru>, Bernard Iremonger\n <bernard.iremonger@intel.com>",
        "CC": "Hemant Agrawal <hemant.agrawal@nxp.com>,\n =?utf-8?q?Mattias_R=C3=B6nnblom?= <mattias.ronnblom@ericsson.com>,\n \"Kiran Kumar K\" <kirankumark@marvell.com>,\n Volodymyr Fialko <vfialko@marvell.com>, <dev@dpdk.org>,\n Olivier Matz <olivier.matz@6wind.com>",
        "Subject": "[PATCH v3 02/22] lib: add pdcp protocol",
        "Date": "Wed, 24 May 2023 21:30:56 +0530",
        "Message-ID": "<20230524160116.304-3-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>\n <20230524160116.304-1-anoobj@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Proofpoint-GUID": "IJB5xIPLmOh0rK1WgPVLe0uCNlmGcYF4",
        "X-Proofpoint-ORIG-GUID": "IJB5xIPLmOh0rK1WgPVLe0uCNlmGcYF4",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26\n 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 <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "Add Packet Data Convergence Protocol (PDCP) processing library.\n\nThe library is similar to lib_ipsec which provides IPsec processing\ncapabilities in DPDK.\n\nPDCP would involve roughly the following options,\n1. Transfer of user plane data\n2. Transfer of control plane data\n3. Header compression\n4. Uplink data compression\n5. Ciphering and integrity protection\n\nPDCP library provides following control path APIs that is used to\nconfigure various PDCP entities,\n1. rte_pdcp_entity_establish()\n2. rte_pdcp_entity_suspend()\n3. rte_pdcp_entity_release()\n\nSigned-off-by: Anoob Joseph <anoobj@marvell.com>\nSigned-off-by: Kiran Kumar K <kirankumark@marvell.com>\nSigned-off-by: Volodymyr Fialko <vfialko@marvell.com>\n---\n doc/api/doxy-api-index.md |   3 +-\n doc/api/doxy-api.conf.in  |   1 +\n lib/meson.build           |   1 +\n lib/pdcp/meson.build      |  17 ++++\n lib/pdcp/pdcp_crypto.c    |  21 +++++\n lib/pdcp/pdcp_crypto.h    |  15 ++++\n lib/pdcp/pdcp_entity.h    | 113 ++++++++++++++++++++++++++\n lib/pdcp/pdcp_process.c   | 138 +++++++++++++++++++++++++++++++\n lib/pdcp/pdcp_process.h   |  13 +++\n lib/pdcp/rte_pdcp.c       | 141 ++++++++++++++++++++++++++++++++\n lib/pdcp/rte_pdcp.h       | 167 ++++++++++++++++++++++++++++++++++++++\n lib/pdcp/version.map      |  10 +++\n 12 files changed, 639 insertions(+), 1 deletion(-)\n create mode 100644 lib/pdcp/meson.build\n create mode 100644 lib/pdcp/pdcp_crypto.c\n create mode 100644 lib/pdcp/pdcp_crypto.h\n create mode 100644 lib/pdcp/pdcp_entity.h\n create mode 100644 lib/pdcp/pdcp_process.c\n create mode 100644 lib/pdcp/pdcp_process.h\n create mode 100644 lib/pdcp/rte_pdcp.c\n create mode 100644 lib/pdcp/rte_pdcp.h\n create mode 100644 lib/pdcp/version.map",
    "diff": "diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md\nindex debbe4134f..cd7a6cae44 100644\n--- a/doc/api/doxy-api-index.md\n+++ b/doc/api/doxy-api-index.md\n@@ -128,7 +128,8 @@ The public API headers are grouped by topics:\n   [eCPRI](@ref rte_ecpri.h),\n   [L2TPv2](@ref rte_l2tpv2.h),\n   [PPP](@ref rte_ppp.h),\n-  [PDCP hdr](@ref rte_pdcp_hdr.h)\n+  [PDCP hdr](@ref rte_pdcp_hdr.h),\n+  [PDCP](@ref rte_pdcp.h)\n \n - **QoS**:\n   [metering](@ref rte_meter.h),\ndiff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in\nindex d230a19e1f..58789308a9 100644\n--- a/doc/api/doxy-api.conf.in\n+++ b/doc/api/doxy-api.conf.in\n@@ -62,6 +62,7 @@ INPUT                   = @TOPDIR@/doc/api/doxy-api-index.md \\\n                           @TOPDIR@/lib/net \\\n                           @TOPDIR@/lib/pcapng \\\n                           @TOPDIR@/lib/pci \\\n+                          @TOPDIR@/lib/pdcp \\\n                           @TOPDIR@/lib/pdump \\\n                           @TOPDIR@/lib/pipeline \\\n                           @TOPDIR@/lib/port \\\ndiff --git a/lib/meson.build b/lib/meson.build\nindex dc8aa4ac84..a6a54c196c 100644\n--- a/lib/meson.build\n+++ b/lib/meson.build\n@@ -64,6 +64,7 @@ libraries = [\n         'flow_classify', # flow_classify lib depends on pkt framework table lib\n         'graph',\n         'node',\n+        'pdcp', # pdcp lib depends on crypto and security\n ]\n \n optional_libs = [\ndiff --git a/lib/pdcp/meson.build b/lib/pdcp/meson.build\nnew file mode 100644\nindex 0000000000..ccaf426240\n--- /dev/null\n+++ b/lib/pdcp/meson.build\n@@ -0,0 +1,17 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(C) 2023 Marvell.\n+\n+if is_windows\n+    build = false\n+    reason = 'not supported on Windows'\n+    subdir_done()\n+endif\n+\n+sources = files(\n+        'pdcp_crypto.c',\n+        'pdcp_process.c',\n+        'rte_pdcp.c',\n+        )\n+headers = files('rte_pdcp.h')\n+\n+deps += ['mbuf', 'net', 'cryptodev', 'security']\ndiff --git a/lib/pdcp/pdcp_crypto.c b/lib/pdcp/pdcp_crypto.c\nnew file mode 100644\nindex 0000000000..755e27ec9e\n--- /dev/null\n+++ b/lib/pdcp/pdcp_crypto.c\n@@ -0,0 +1,21 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2023 Marvell.\n+ */\n+\n+#include <rte_pdcp.h>\n+\n+#include \"pdcp_crypto.h\"\n+\n+int\n+pdcp_crypto_sess_create(struct rte_pdcp_entity *entity, const struct rte_pdcp_entity_conf *conf)\n+{\n+\tRTE_SET_USED(entity);\n+\tRTE_SET_USED(conf);\n+\treturn 0;\n+}\n+\n+void\n+pdcp_crypto_sess_destroy(struct rte_pdcp_entity *entity)\n+{\n+\tRTE_SET_USED(entity);\n+}\ndiff --git a/lib/pdcp/pdcp_crypto.h b/lib/pdcp/pdcp_crypto.h\nnew file mode 100644\nindex 0000000000..6563331d37\n--- /dev/null\n+++ b/lib/pdcp/pdcp_crypto.h\n@@ -0,0 +1,15 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2023 Marvell.\n+ */\n+\n+#ifndef PDCP_CRYPTO_H\n+#define PDCP_CRYPTO_H\n+\n+#include <rte_pdcp.h>\n+\n+int pdcp_crypto_sess_create(struct rte_pdcp_entity *entity,\n+\t\t\t    const struct rte_pdcp_entity_conf *conf);\n+\n+void pdcp_crypto_sess_destroy(struct rte_pdcp_entity *entity);\n+\n+#endif /* PDCP_CRYPTO_H */\ndiff --git a/lib/pdcp/pdcp_entity.h b/lib/pdcp/pdcp_entity.h\nnew file mode 100644\nindex 0000000000..000297588f\n--- /dev/null\n+++ b/lib/pdcp/pdcp_entity.h\n@@ -0,0 +1,113 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2023 Marvell.\n+ */\n+\n+#ifndef PDCP_ENTITY_H\n+#define PDCP_ENTITY_H\n+\n+#include <rte_common.h>\n+#include <rte_crypto_sym.h>\n+#include <rte_mempool.h>\n+#include <rte_pdcp.h>\n+#include <rte_security.h>\n+\n+struct entity_priv;\n+\n+/* IV generation function based on the entity configuration */\n+typedef void (*iv_gen_t)(struct rte_crypto_op *cop, const struct entity_priv *en_priv,\n+\t\t\t uint32_t count);\n+\n+struct entity_state {\n+\tuint32_t rx_next;\n+\tuint32_t tx_next;\n+\tuint32_t rx_deliv;\n+\tuint32_t rx_reord;\n+};\n+\n+/*\n+ * Layout of PDCP entity: [rte_pdcp_entity] [entity_priv] [entity_dl/ul]\n+ */\n+\n+struct entity_priv {\n+\t/** Crypto sym session. */\n+\tstruct rte_cryptodev_sym_session *crypto_sess;\n+\t/** Entity specific IV generation function. */\n+\tiv_gen_t iv_gen;\n+\t/** Entity state variables. */\n+\tstruct entity_state state;\n+\t/** Flags. */\n+\tstruct {\n+\t\t/** PDCP PDU has 4 byte MAC-I. */\n+\t\tuint64_t is_authenticated : 1;\n+\t\t/** Cipher offset & length in bits. */\n+\t\tuint64_t is_cipher_in_bits : 1;\n+\t\t/** Auth offset & length in bits. */\n+\t\tuint64_t is_auth_in_bits : 1;\n+\t\t/** Is UL/transmitting PDCP entity. */\n+\t\tuint64_t is_ul_entity : 1;\n+\t\t/** Is NULL auth. */\n+\t\tuint64_t is_null_auth : 1;\n+\t} flags;\n+\t/** Crypto op pool. */\n+\tstruct rte_mempool *cop_pool;\n+\t/** PDCP header size. */\n+\tuint8_t hdr_sz;\n+\t/** PDCP AAD size. For AES-CMAC, additional message is prepended for the operation. */\n+\tuint8_t aad_sz;\n+\t/** Device ID of the device to be used for offload. */\n+\tuint8_t dev_id;\n+};\n+\n+struct entity_priv_dl_part {\n+\t/* NOTE: when in-order-delivery is supported, post PDCP packets would need to cached. */\n+\tuint8_t dummy;\n+};\n+\n+struct entity_priv_ul_part {\n+\t/*\n+\t * NOTE: when re-establish is supported, plain PDCP packets & COUNT values need to be\n+\t * cached.\n+\t */\n+\tuint8_t dummy;\n+};\n+\n+static inline struct entity_priv *\n+entity_priv_get(const struct rte_pdcp_entity *entity) {\n+\treturn RTE_PTR_ADD(entity, sizeof(struct rte_pdcp_entity));\n+}\n+\n+static inline struct entity_priv_dl_part *\n+entity_dl_part_get(const struct rte_pdcp_entity *entity) {\n+\treturn RTE_PTR_ADD(entity, sizeof(struct rte_pdcp_entity) + sizeof(struct entity_priv));\n+}\n+\n+static inline struct entity_priv_ul_part *\n+entity_ul_part_get(const struct rte_pdcp_entity *entity) {\n+\treturn RTE_PTR_ADD(entity, sizeof(struct rte_pdcp_entity) + sizeof(struct entity_priv));\n+}\n+\n+static inline int\n+pdcp_hdr_size_get(enum rte_security_pdcp_sn_size sn_size)\n+{\n+\treturn RTE_ALIGN_MUL_CEIL(sn_size, 8) / 8;\n+}\n+\n+static inline uint32_t\n+pdcp_sn_mask_get(enum rte_security_pdcp_sn_size sn_size)\n+{\n+\treturn (1 << sn_size) - 1;\n+}\n+\n+static inline uint32_t\n+pdcp_hfn_mask_get(enum rte_security_pdcp_sn_size sn_size)\n+{\n+\treturn ~pdcp_sn_mask_get(sn_size);\n+}\n+\n+static inline uint32_t\n+pdcp_count_from_hfn_sn_get(uint32_t hfn, uint32_t sn, enum rte_security_pdcp_sn_size sn_size)\n+{\n+\treturn (((hfn << sn_size) & pdcp_hfn_mask_get(sn_size)) | (sn & pdcp_sn_mask_get(sn_size)));\n+}\n+\n+#endif /* PDCP_ENTITY_H */\ndiff --git a/lib/pdcp/pdcp_process.c b/lib/pdcp/pdcp_process.c\nnew file mode 100644\nindex 0000000000..79f5dce5db\n--- /dev/null\n+++ b/lib/pdcp/pdcp_process.c\n@@ -0,0 +1,138 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2023 Marvell.\n+ */\n+\n+#include <rte_crypto.h>\n+#include <rte_crypto_sym.h>\n+#include <rte_cryptodev.h>\n+#include <rte_memcpy.h>\n+#include <rte_pdcp.h>\n+#include <rte_pdcp_hdr.h>\n+\n+#include \"pdcp_crypto.h\"\n+#include \"pdcp_entity.h\"\n+#include \"pdcp_process.h\"\n+\n+static int\n+pdcp_crypto_xfrm_get(const struct rte_pdcp_entity_conf *conf, struct rte_crypto_sym_xform **c_xfrm,\n+\t\t     struct rte_crypto_sym_xform **a_xfrm)\n+{\n+\t*c_xfrm = NULL;\n+\t*a_xfrm = NULL;\n+\n+\tif (conf->crypto_xfrm == NULL)\n+\t\treturn -EINVAL;\n+\n+\tif (conf->crypto_xfrm->type == RTE_CRYPTO_SYM_XFORM_CIPHER) {\n+\t\t*c_xfrm = conf->crypto_xfrm;\n+\t\t*a_xfrm = conf->crypto_xfrm->next;\n+\t} else if (conf->crypto_xfrm->type == RTE_CRYPTO_SYM_XFORM_AUTH) {\n+\t\t*a_xfrm = conf->crypto_xfrm;\n+\t\t*c_xfrm = conf->crypto_xfrm->next;\n+\t} else {\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+pdcp_entity_priv_populate(struct entity_priv *en_priv, const struct rte_pdcp_entity_conf *conf)\n+{\n+\tstruct rte_crypto_sym_xform *c_xfrm, *a_xfrm;\n+\tint ret;\n+\n+\tret = pdcp_crypto_xfrm_get(conf, &c_xfrm, &a_xfrm);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/**\n+\t * flags.is_authenticated\n+\t *\n+\t * MAC-I would be added in case of control plane packets and when authentication\n+\t * transform is not NULL.\n+\t */\n+\n+\tif ((conf->pdcp_xfrm.domain == RTE_SECURITY_PDCP_MODE_CONTROL) && (a_xfrm == NULL))\n+\t\treturn -EINVAL;\n+\n+\tif (a_xfrm != NULL)\n+\t\ten_priv->flags.is_authenticated = 1;\n+\n+\t/**\n+\t * flags.is_cipher_in_bits\n+\t *\n+\t * For ZUC & SNOW3G cipher algos, offset & length need to be provided in bits.\n+\t */\n+\n+\tif ((c_xfrm->cipher.algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2) ||\n+\t    (c_xfrm->cipher.algo == RTE_CRYPTO_CIPHER_ZUC_EEA3))\n+\t\ten_priv->flags.is_cipher_in_bits = 1;\n+\n+\t/**\n+\t * flags.is_auth_in_bits\n+\t *\n+\t * For ZUC & SNOW3G authentication algos, offset & length need to be provided in bits.\n+\t */\n+\n+\tif (a_xfrm != NULL) {\n+\t\tif ((a_xfrm->auth.algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2) ||\n+\t\t    (a_xfrm->auth.algo == RTE_CRYPTO_AUTH_ZUC_EIA3))\n+\t\t\ten_priv->flags.is_auth_in_bits = 1;\n+\t}\n+\n+\t/**\n+\t * flags.is_ul_entity\n+\t *\n+\t * Indicate whether the entity is UL/transmitting PDCP entity.\n+\t */\n+\tif (conf->pdcp_xfrm.pkt_dir == RTE_SECURITY_PDCP_UPLINK)\n+\t\ten_priv->flags.is_ul_entity = 1;\n+\n+\t/**\n+\t * flags.is_null_auth\n+\t *\n+\t * For NULL auth, 4B zeros need to be added by lib PDCP. Indicate that\n+\t * algo is NULL auth to perform the same.\n+\t */\n+\tif (a_xfrm != NULL && a_xfrm->auth.algo == RTE_CRYPTO_AUTH_NULL)\n+\t\ten_priv->flags.is_null_auth = 1;\n+\n+\t/**\n+\t * hdr_sz\n+\t *\n+\t * PDCP header size of the entity\n+\t */\n+\ten_priv->hdr_sz = pdcp_hdr_size_get(conf->pdcp_xfrm.sn_size);\n+\n+\t/**\n+\t * aad_sz\n+\t *\n+\t * For AES-CMAC, additional message is prepended for processing. Need to be trimmed after\n+\t * crypto processing is done.\n+\t */\n+\tif (a_xfrm != NULL && a_xfrm->auth.algo == RTE_CRYPTO_AUTH_AES_CMAC)\n+\t\ten_priv->aad_sz = 8;\n+\telse\n+\t\ten_priv->aad_sz = 0;\n+\n+\treturn 0;\n+}\n+\n+int\n+pdcp_process_func_set(struct rte_pdcp_entity *entity, const struct rte_pdcp_entity_conf *conf)\n+{\n+\tstruct entity_priv *en_priv;\n+\tint ret;\n+\n+\tif (entity == NULL || conf == NULL)\n+\t\treturn -EINVAL;\n+\n+\ten_priv = entity_priv_get(entity);\n+\n+\tret = pdcp_entity_priv_populate(en_priv, conf);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\treturn 0;\n+}\ndiff --git a/lib/pdcp/pdcp_process.h b/lib/pdcp/pdcp_process.h\nnew file mode 100644\nindex 0000000000..fd53fff0aa\n--- /dev/null\n+++ b/lib/pdcp/pdcp_process.h\n@@ -0,0 +1,13 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2023 Marvell.\n+ */\n+\n+#ifndef PDCP_PROCESS_H\n+#define PDCP_PROCESS_H\n+\n+#include <rte_pdcp.h>\n+\n+int\n+pdcp_process_func_set(struct rte_pdcp_entity *entity, const struct rte_pdcp_entity_conf *conf);\n+\n+#endif /* PDCP_PROCESS_H */\ndiff --git a/lib/pdcp/rte_pdcp.c b/lib/pdcp/rte_pdcp.c\nnew file mode 100644\nindex 0000000000..adcad5dd25\n--- /dev/null\n+++ b/lib/pdcp/rte_pdcp.c\n@@ -0,0 +1,141 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2023 Marvell.\n+ */\n+\n+#include <rte_errno.h>\n+#include <rte_pdcp.h>\n+#include <rte_malloc.h>\n+\n+#include \"pdcp_crypto.h\"\n+#include \"pdcp_entity.h\"\n+#include \"pdcp_process.h\"\n+\n+static int\n+pdcp_entity_size_get(const struct rte_pdcp_entity_conf *conf)\n+{\n+\tint size;\n+\n+\tsize = sizeof(struct rte_pdcp_entity) + sizeof(struct entity_priv);\n+\n+\tif (conf->pdcp_xfrm.pkt_dir == RTE_SECURITY_PDCP_DOWNLINK)\n+\t\tsize += sizeof(struct entity_priv_dl_part);\n+\telse if (conf->pdcp_xfrm.pkt_dir == RTE_SECURITY_PDCP_UPLINK)\n+\t\tsize += sizeof(struct entity_priv_ul_part);\n+\telse\n+\t\treturn -EINVAL;\n+\n+\treturn RTE_ALIGN_CEIL(size, RTE_CACHE_LINE_SIZE);\n+}\n+\n+struct rte_pdcp_entity *\n+rte_pdcp_entity_establish(const struct rte_pdcp_entity_conf *conf)\n+{\n+\tstruct rte_pdcp_entity *entity = NULL;\n+\tstruct entity_priv *en_priv;\n+\tint ret, entity_size;\n+\tuint32_t count;\n+\n+\tif (conf == NULL || conf->cop_pool == NULL) {\n+\t\trte_errno = EINVAL;\n+\t\treturn NULL;\n+\t}\n+\n+\tif (conf->pdcp_xfrm.en_ordering || conf->pdcp_xfrm.remove_duplicates || conf->is_slrb ||\n+\t    conf->en_sec_offload) {\n+\t\trte_errno = ENOTSUP;\n+\t\treturn NULL;\n+\t}\n+\n+\t/*\n+\t * 6.3.2 PDCP SN\n+\t * Length: 12 or 18 bits as indicated in table 6.3.2-1. The length of the PDCP SN is\n+\t * configured by upper layers (pdcp-SN-SizeUL, pdcp-SN-SizeDL, or sl-PDCP-SN-Size in\n+\t * TS 38.331 [3])\n+\t */\n+\tif ((conf->pdcp_xfrm.sn_size != RTE_SECURITY_PDCP_SN_SIZE_12) &&\n+\t    (conf->pdcp_xfrm.sn_size != RTE_SECURITY_PDCP_SN_SIZE_18)) {\n+\t\trte_errno = ENOTSUP;\n+\t\treturn NULL;\n+\t}\n+\n+\tif (conf->pdcp_xfrm.hfn_threshold) {\n+\t\trte_errno = EINVAL;\n+\t\treturn NULL;\n+\t}\n+\n+\tentity_size = pdcp_entity_size_get(conf);\n+\tif (entity_size < 0) {\n+\t\trte_errno = EINVAL;\n+\t\treturn NULL;\n+\t}\n+\n+\tentity = rte_zmalloc_socket(\"pdcp_entity\", entity_size, RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);\n+\tif (entity == NULL) {\n+\t\trte_errno = ENOMEM;\n+\t\treturn NULL;\n+\t}\n+\n+\ten_priv = entity_priv_get(entity);\n+\n+\tcount = pdcp_count_from_hfn_sn_get(conf->pdcp_xfrm.hfn, conf->sn, conf->pdcp_xfrm.sn_size);\n+\n+\ten_priv->state.rx_deliv = count;\n+\ten_priv->state.tx_next = count;\n+\ten_priv->cop_pool = conf->cop_pool;\n+\n+\t/* Setup crypto session */\n+\tret = pdcp_crypto_sess_create(entity, conf);\n+\tif (ret)\n+\t\tgoto entity_free;\n+\n+\tret = pdcp_process_func_set(entity, conf);\n+\tif (ret)\n+\t\tgoto crypto_sess_destroy;\n+\n+\treturn entity;\n+\n+crypto_sess_destroy:\n+\tpdcp_crypto_sess_destroy(entity);\n+entity_free:\n+\trte_free(entity);\n+\trte_errno = -ret;\n+\treturn NULL;\n+}\n+\n+int\n+rte_pdcp_entity_release(struct rte_pdcp_entity *pdcp_entity, struct rte_mbuf *out_mb[])\n+{\n+\tif (pdcp_entity == NULL)\n+\t\treturn -EINVAL;\n+\n+\t/* Teardown crypto sessions */\n+\tpdcp_crypto_sess_destroy(pdcp_entity);\n+\n+\trte_free(pdcp_entity);\n+\n+\tRTE_SET_USED(out_mb);\n+\treturn 0;\n+}\n+\n+int\n+rte_pdcp_entity_suspend(struct rte_pdcp_entity *pdcp_entity,\n+\t\t\tstruct rte_mbuf *out_mb[])\n+{\n+\tstruct entity_priv *en_priv;\n+\n+\tif (pdcp_entity == NULL)\n+\t\treturn -EINVAL;\n+\n+\ten_priv = entity_priv_get(pdcp_entity);\n+\n+\tif (en_priv->flags.is_ul_entity) {\n+\t\ten_priv->state.tx_next = 0;\n+\t} else {\n+\t\ten_priv->state.rx_next = 0;\n+\t\ten_priv->state.rx_deliv = 0;\n+\t}\n+\n+\tRTE_SET_USED(out_mb);\n+\n+\treturn 0;\n+}\ndiff --git a/lib/pdcp/rte_pdcp.h b/lib/pdcp/rte_pdcp.h\nnew file mode 100644\nindex 0000000000..1f96fdc9a1\n--- /dev/null\n+++ b/lib/pdcp/rte_pdcp.h\n@@ -0,0 +1,167 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2023 Marvell.\n+ */\n+\n+#ifndef RTE_PDCP_H\n+#define RTE_PDCP_H\n+\n+/**\n+ * @file rte_pdcp.h\n+ *\n+ * RTE PDCP support.\n+ *\n+ * A framework for PDCP protocol processing.\n+ */\n+\n+#include <rte_compat.h>\n+#include <rte_common.h>\n+#include <rte_mempool.h>\n+#include <rte_security.h>\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+/**\n+ * PDCP entity.\n+ *\n+ * 4.2.2 PDCP entities\n+ *\n+ * The PDCP entities are located in the PDCP sublayer. Several PDCP entities may\n+ * be defined for a UE. Each PDCP entity is carrying the data of one radio\n+ * bearer. A PDCP entity is associated either to the control plane or the user\n+ * plane depending on which radio bearer it is carrying data for.\n+ */\n+struct rte_pdcp_entity {\n+\t/**\n+\t * PDCP entities may hold packets for purposes of in-order delivery (in\n+\t * case of receiving PDCP entity) and re-transmission (in case of\n+\t * transmitting PDCP entity).\n+\t *\n+\t * The field 'max_pkt_cache' would be used to indicate the maximum\n+\t * number of packets that may be cached in an entity at any point of\n+\t * time. When application provides buffers to receive packets from\n+\t * PDCP entity, the size of the buffer should be such that it can\n+\t * hold additionally 'max_pkt_cache' number of packets.\n+\t */\n+\tuint32_t max_pkt_cache;\n+} __rte_cache_aligned;\n+\n+/**\n+ * PDCP entity configuration to be used for establishing an entity.\n+ */\n+/* Structure rte_pdcp_entity_conf 8< */\n+struct rte_pdcp_entity_conf {\n+\t/** PDCP transform for the entity. */\n+\tstruct rte_security_pdcp_xform pdcp_xfrm;\n+\t/** Crypto transform applicable for the entity. */\n+\tstruct rte_crypto_sym_xform *crypto_xfrm;\n+\t/** Mempool for crypto symmetric session. */\n+\tstruct rte_mempool *sess_mpool;\n+\t/** Crypto op pool.*/\n+\tstruct rte_mempool *cop_pool;\n+\t/**\n+\t * SN value to be used. 32 bit count value to be used for the first\n+\t * packet would be derived based on HFN (`rte_security_pdcp_xform.hfn`)\n+\t * and SN.\n+\t */\n+\tuint32_t sn;\n+\t/**\n+\t * Indicate whether the PDCP entity belongs to Side Link Radio Bearer.\n+\t */\n+\tbool is_slrb;\n+\t/** Enable security offload on the device specified. */\n+\tbool en_sec_offload;\n+\t/** Device on which security/crypto session need to be created. */\n+\tuint8_t dev_id;\n+\t/**\n+\t * Reverse direction during IV generation. Can be used to simulate UE\n+\t * crypto processing.\n+\t */\n+\tbool reverse_iv_direction;\n+};\n+/* >8 End of structure rte_pdcp_entity_conf. */\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * 5.1.1 PDCP entity establishment\n+ *\n+ * Establish PDCP entity based on provided input configuration.\n+ *\n+ * @param conf\n+ *   Parameters to be used for initializing PDCP entity object.\n+ * @return\n+ *   - Valid handle if success\n+ *   - NULL in case of failure. rte_errno will be set to error code\n+ */\n+__rte_experimental\n+struct rte_pdcp_entity *\n+rte_pdcp_entity_establish(const struct rte_pdcp_entity_conf *conf);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * 5.1.3 PDCP entity release\n+ *\n+ * Release PDCP entity.\n+ *\n+ * For UL/transmitting PDCP entity, all stored PDCP SDUs would be dropped.\n+ * For DL/receiving PDCP entity, the stored PDCP SDUs would be returned in\n+ * *out_mb* buffer. The buffer should be large enough to hold all cached\n+ * packets in the entity.\n+ *\n+ * Entity release would result in freeing all memory associated with the PDCP\n+ * entity as well as any crypto/security sessions created.\n+ *\n+ * @param pdcp_entity\n+ *   Pointer to the PDCP entity to be released.\n+ * @param[out] out_mb\n+ *   The address of an array that can hold up to *rte_pdcp_entity.max_pkt_cache*\n+ *   pointers to *rte_mbuf* structures.\n+ * @return\n+ *   -  0: Success and no cached packets to return\n+ *   - >0: Success and the number of packets returned in out_mb\n+ *   - <0: Error code in case of failures\n+ */\n+__rte_experimental\n+int\n+rte_pdcp_entity_release(struct rte_pdcp_entity *pdcp_entity,\n+\t\t\tstruct rte_mbuf *out_mb[]);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * 5.1.4 PDCP entity suspend\n+ *\n+ * Suspend PDCP entity.\n+ *\n+ * For DL/receiving PDCP entity, the stored PDCP SDUs would be returned in\n+ * *out_mb* buffer. The buffer should be large enough to hold all cached\n+ * packets in the entity.\n+ *\n+ * For UL/transmitting PDCP entity, *out_mb* buffer would be unused.\n+ *\n+ * @param pdcp_entity\n+ *   Pointer to the PDCP entity to be suspended.\n+ * @param[out] out_mb\n+ *   The address of an array that can hold up to *rte_pdcp_entity.max_pkt_cache*\n+ *   pointers to *rte_mbuf* structures.\n+ * @return\n+ *   -  0: Success and no cached packets to return\n+ *   - >0: Success and the number of packets returned in out_mb\n+ *   - <0: Error code in case of failures\n+ */\n+__rte_experimental\n+int\n+rte_pdcp_entity_suspend(struct rte_pdcp_entity *pdcp_entity,\n+\t\t\tstruct rte_mbuf *out_mb[]);\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif /* RTE_PDCP_H */\ndiff --git a/lib/pdcp/version.map b/lib/pdcp/version.map\nnew file mode 100644\nindex 0000000000..923e165f3f\n--- /dev/null\n+++ b/lib/pdcp/version.map\n@@ -0,0 +1,10 @@\n+EXPERIMENTAL {\n+\tglobal:\n+\n+\t# added in 23.07\n+\trte_pdcp_entity_establish;\n+\trte_pdcp_entity_release;\n+\trte_pdcp_entity_suspend;\n+\n+\tlocal: *;\n+};\n",
    "prefixes": [
        "v3",
        "02/22"
    ]
}