get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 127340,
    "url": "http://patches.dpdk.org/api/patches/127340/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230524160116.304-10-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-10-anoobj@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230524160116.304-10-anoobj@marvell.com",
    "date": "2023-05-24T16:01:03",
    "name": "[v3,09/22] app/test: add lib pdcp tests",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "ad4a888be5504ff4f9848b32f6c866ce61dc3ff0",
    "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-10-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/127340/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/127340/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 C486942B8F;\n\tWed, 24 May 2023 18:03:02 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 393C042D41;\n\tWed, 24 May 2023 18:02:10 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com\n [67.231.148.174])\n by mails.dpdk.org (Postfix) with ESMTP id 44EE1406BC\n for <dev@dpdk.org>; Wed, 24 May 2023 18:02:08 +0200 (CEST)",
            "from pps.filterd (m0045849.ppops.net [127.0.0.1])\n by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id\n 34OEkaoS025147; Wed, 24 May 2023 09:02:06 -0700",
            "from dc5-exch01.marvell.com ([199.233.59.181])\n by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3qsbxetjuf-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);\n Wed, 24 May 2023 09:02:06 -0700",
            "from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48;\n Wed, 24 May 2023 09:02:04 -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:02:04 -0700",
            "from BG-LT92004.corp.innovium.com (unknown [10.28.161.183])\n by maili.marvell.com (Postfix) with ESMTP id C40B73F703F;\n Wed, 24 May 2023 09:02:00 -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=On5n5RAdV5+s88GydM9axEWG/760I7HLtZ2159jpIxE=;\n b=NL1rOrg9hZk5D6q7pChTDm90lzJTjAHRXXXB0IqqVIk7X+CiNJq6hk0UUwAividEVOim\n Ax6wwDK3cJPj8jax0lXAwTWaD82Hmnp40QavoDjnwJBCntdBX87B0DXOb4f4vPule1O4\n JegtqJ2j9r9oHKVvG2O7SsWQuN7EBUrSQh7KyX5FyML8qwOK/weNv7XZq2QhlCACng8C\n TUSOY+3LkitCp3HaKMXDY545fOaizBYR0vue/bzDXn/QjmttecXTCRghGNnlqsty/jKP\n ZEeAAmB/D4Rr3E6JFiq2CrVcG9EbkRKiMgvP9NFSenCBWN+oTxhr7rP3YmRamOFaBYs+ lA==",
        "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 09/22] app/test: add lib pdcp tests",
        "Date": "Wed, 24 May 2023 21:31:03 +0530",
        "Message-ID": "<20230524160116.304-10-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-ORIG-GUID": "1cLIv3DSQqxsz4saEarqIvlG23rtxRRs",
        "X-Proofpoint-GUID": "1cLIv3DSQqxsz4saEarqIvlG23rtxRRs",
        "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 tests to verify lib PDCP operations. Tests leverage existing PDCP\ntest vectors.\n\nSigned-off-by: Anoob Joseph <anoobj@marvell.com>\nSigned-off-by: Volodymyr Fialko <vfialko@marvell.com>\n---\n app/test/meson.build      |   1 +\n app/test/test_cryptodev.h |   3 +\n app/test/test_pdcp.c      | 730 ++++++++++++++++++++++++++++++++++++++\n 3 files changed, 734 insertions(+)\n create mode 100644 app/test/test_pdcp.c",
    "diff": "diff --git a/app/test/meson.build b/app/test/meson.build\nindex b9b5432496..24e9a124fc 100644\n--- a/app/test/meson.build\n+++ b/app/test/meson.build\n@@ -96,6 +96,7 @@ test_sources = files(\n         'test_meter.c',\n         'test_mcslock.c',\n         'test_mp_secondary.c',\n+        'test_pdcp.c',\n         'test_per_lcore.c',\n         'test_pflock.c',\n         'test_pmd_perf.c',\ndiff --git a/app/test/test_cryptodev.h b/app/test/test_cryptodev.h\nindex abd795f54a..89057dba22 100644\n--- a/app/test/test_cryptodev.h\n+++ b/app/test/test_cryptodev.h\n@@ -4,6 +4,9 @@\n #ifndef TEST_CRYPTODEV_H_\n #define TEST_CRYPTODEV_H_\n \n+#include <rte_crypto.h>\n+#include <rte_cryptodev.h>\n+\n #define HEX_DUMP 0\n \n #define FALSE                           0\ndiff --git a/app/test/test_pdcp.c b/app/test/test_pdcp.c\nnew file mode 100644\nindex 0000000000..22db7020c4\n--- /dev/null\n+++ b/app/test/test_pdcp.c\n@@ -0,0 +1,730 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2023 Marvell.\n+ */\n+\n+#include <rte_errno.h>\n+#include <rte_malloc.h>\n+#include <rte_pdcp.h>\n+#include <rte_pdcp_hdr.h>\n+\n+#include \"test.h\"\n+#include \"test_cryptodev.h\"\n+#include \"test_cryptodev_security_pdcp_test_vectors.h\"\n+\n+#define NB_DESC 1024\n+#define CDEV_INVALID_ID UINT8_MAX\n+#define NB_TESTS RTE_DIM(pdcp_test_params)\n+#define PDCP_IV_LEN 16\n+\n+struct pdcp_testsuite_params {\n+\tstruct rte_mempool *mbuf_pool;\n+\tstruct rte_mempool *cop_pool;\n+\tstruct rte_mempool *sess_pool;\n+\tbool cdevs_used[RTE_CRYPTO_MAX_DEVS];\n+};\n+\n+static struct pdcp_testsuite_params testsuite_params;\n+\n+struct pdcp_test_conf {\n+\tstruct rte_pdcp_entity_conf entity;\n+\tstruct rte_crypto_sym_xform c_xfrm;\n+\tstruct rte_crypto_sym_xform a_xfrm;\n+\tbool is_integrity_protected;\n+\tuint8_t input[RTE_PDCP_CTRL_PDU_SIZE_MAX];\n+\tuint32_t input_len;\n+\tuint8_t output[RTE_PDCP_CTRL_PDU_SIZE_MAX];\n+\tuint32_t output_len;\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 int\n+cryptodev_init(int dev_id)\n+{\n+\tstruct pdcp_testsuite_params *ts_params = &testsuite_params;\n+\tstruct rte_cryptodev_qp_conf qp_conf;\n+\tstruct rte_cryptodev_info dev_info;\n+\tstruct rte_cryptodev_config config;\n+\tint ret, socket_id;\n+\n+\t/* Check if device was already initialized */\n+\tif (ts_params->cdevs_used[dev_id])\n+\t\treturn 0;\n+\n+\trte_cryptodev_info_get(dev_id, &dev_info);\n+\n+\tif (dev_info.max_nb_queue_pairs < 1) {\n+\t\tRTE_LOG(ERR, USER1, \"Cryptodev doesn't have sufficient queue pairs available\\n\");\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tsocket_id = rte_socket_id();\n+\n+\tmemset(&config, 0, sizeof(config));\n+\tconfig.nb_queue_pairs = 1;\n+\tconfig.socket_id = socket_id;\n+\n+\tret = rte_cryptodev_configure(dev_id, &config);\n+\tif (ret < 0) {\n+\t\tRTE_LOG(ERR, USER1, \"Could not configure cryptodev - %d\\n\", dev_id);\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tmemset(&qp_conf, 0, sizeof(qp_conf));\n+\tqp_conf.nb_descriptors = NB_DESC;\n+\n+\tret = rte_cryptodev_queue_pair_setup(dev_id, 0, &qp_conf, socket_id);\n+\tif (ret < 0) {\n+\t\tRTE_LOG(ERR, USER1, \"Could not configure queue pair\\n\");\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tret = rte_cryptodev_start(dev_id);\n+\tif (ret < 0) {\n+\t\tRTE_LOG(ERR, USER1, \"Could not start cryptodev\\n\");\n+\t\treturn -ENODEV;\n+\t}\n+\n+\t/* Mark device as initialized */\n+\tts_params->cdevs_used[dev_id] = true;\n+\n+\treturn 0;\n+}\n+\n+static void\n+cryptodev_fini(int dev_id)\n+{\n+\trte_cryptodev_stop(dev_id);\n+}\n+\n+static unsigned int\n+cryptodev_sess_priv_max_req_get(void)\n+{\n+\tstruct rte_cryptodev_info info;\n+\tunsigned int sess_priv_sz;\n+\tint i, nb_dev;\n+\tvoid *sec_ctx;\n+\n+\tnb_dev = rte_cryptodev_count();\n+\n+\tsess_priv_sz = 0;\n+\n+\tfor (i = 0; i < nb_dev; i++) {\n+\t\trte_cryptodev_info_get(i, &info);\n+\t\tsess_priv_sz = RTE_MAX(sess_priv_sz, rte_cryptodev_sym_get_private_session_size(i));\n+\t\tif (info.feature_flags & RTE_CRYPTODEV_FF_SECURITY) {\n+\t\t\tsec_ctx = rte_cryptodev_get_sec_ctx(i);\n+\t\t\tsess_priv_sz = RTE_MAX(sess_priv_sz,\n+\t\t\t\t\t       rte_security_session_get_size(sec_ctx));\n+\t\t}\n+\t}\n+\n+\treturn sess_priv_sz;\n+}\n+\n+static int\n+testsuite_setup(void)\n+{\n+\tstruct pdcp_testsuite_params *ts_params = &testsuite_params;\n+\tint nb_cdev, sess_priv_size, nb_sess = 1024;\n+\n+\tRTE_SET_USED(pdcp_test_hfn_threshold);\n+\n+\tnb_cdev = rte_cryptodev_count();\n+\tif (nb_cdev < 1) {\n+\t\tRTE_LOG(ERR, USER1, \"No crypto devices found.\\n\");\n+\t\treturn TEST_SKIPPED;\n+\t}\n+\n+\tmemset(ts_params, 0, sizeof(*ts_params));\n+\n+\tts_params->mbuf_pool = rte_pktmbuf_pool_create(\"mbuf_pool\", NUM_MBUFS, MBUF_CACHE_SIZE, 0,\n+\t\t\t\t\t\t       MBUF_SIZE, SOCKET_ID_ANY);\n+\tif (ts_params->mbuf_pool == NULL) {\n+\t\tRTE_LOG(ERR, USER1, \"Could not create mbuf pool\\n\");\n+\t\treturn TEST_FAILED;\n+\t}\n+\n+\tts_params->cop_pool = rte_crypto_op_pool_create(\"cop_pool\", RTE_CRYPTO_OP_TYPE_SYMMETRIC,\n+\t\t\t\t\t\t\t NUM_MBUFS, MBUF_CACHE_SIZE,\n+\t\t\t\t\t\t\t 2 * MAXIMUM_IV_LENGTH, SOCKET_ID_ANY);\n+\tif (ts_params->cop_pool == NULL) {\n+\t\tRTE_LOG(ERR, USER1, \"Could not create crypto_op pool\\n\");\n+\t\tgoto mbuf_pool_free;\n+\t}\n+\n+\t/* Get max session priv size required */\n+\tsess_priv_size = cryptodev_sess_priv_max_req_get();\n+\n+\tts_params->sess_pool = rte_cryptodev_sym_session_pool_create(\"sess_pool\", nb_sess,\n+\t\t\t\t\t\t\t\t     sess_priv_size,\n+\t\t\t\t\t\t\t\t     RTE_MEMPOOL_CACHE_MAX_SIZE,\n+\t\t\t\t\t\t\t\t     0, SOCKET_ID_ANY);\n+\tif (ts_params->sess_pool == NULL) {\n+\t\tRTE_LOG(ERR, USER1, \"Could not create session pool\\n\");\n+\t\tgoto cop_pool_free;\n+\t}\n+\n+\treturn 0;\n+\n+cop_pool_free:\n+\trte_mempool_free(ts_params->cop_pool);\n+\tts_params->cop_pool = NULL;\n+mbuf_pool_free:\n+\trte_mempool_free(ts_params->mbuf_pool);\n+\tts_params->mbuf_pool = NULL;\n+\treturn TEST_FAILED;\n+}\n+\n+static void\n+testsuite_teardown(void)\n+{\n+\tstruct pdcp_testsuite_params *ts_params = &testsuite_params;\n+\tuint8_t dev_id;\n+\n+\tfor (dev_id = 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++) {\n+\t\tif (ts_params->cdevs_used[dev_id])\n+\t\t\tcryptodev_fini(dev_id);\n+\t}\n+\n+\trte_mempool_free(ts_params->sess_pool);\n+\tts_params->sess_pool = NULL;\n+\n+\trte_mempool_free(ts_params->cop_pool);\n+\tts_params->cop_pool = NULL;\n+\n+\trte_mempool_free(ts_params->mbuf_pool);\n+\tts_params->mbuf_pool = NULL;\n+}\n+\n+static int\n+ut_setup_pdcp(void)\n+{\n+\treturn 0;\n+}\n+\n+static void\n+ut_teardown_pdcp(void)\n+{\n+}\n+\n+static int\n+crypto_caps_cipher_verify(uint8_t dev_id, const struct rte_crypto_sym_xform *c_xfrm)\n+{\n+\tconst struct rte_cryptodev_symmetric_capability *cap;\n+\tstruct rte_cryptodev_sym_capability_idx cap_idx;\n+\tint ret;\n+\n+\tcap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;\n+\tcap_idx.algo.cipher = c_xfrm->cipher.algo;\n+\n+\tcap = rte_cryptodev_sym_capability_get(dev_id, &cap_idx);\n+\tif (cap == NULL)\n+\t\treturn -1;\n+\n+\tret = rte_cryptodev_sym_capability_check_cipher(cap, c_xfrm->cipher.key.length,\n+\t\t\t\t\t\t\tc_xfrm->cipher.iv.length);\n+\n+\treturn ret;\n+}\n+\n+static int\n+crypto_caps_auth_verify(uint8_t dev_id, const struct rte_crypto_sym_xform *a_xfrm)\n+{\n+\tconst struct rte_cryptodev_symmetric_capability *cap;\n+\tstruct rte_cryptodev_sym_capability_idx cap_idx;\n+\tint ret;\n+\n+\tcap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;\n+\tcap_idx.algo.auth = a_xfrm->auth.algo;\n+\n+\tcap = rte_cryptodev_sym_capability_get(dev_id, &cap_idx);\n+\tif (cap == NULL)\n+\t\treturn -1;\n+\n+\tret = rte_cryptodev_sym_capability_check_auth(cap, a_xfrm->auth.key.length,\n+\t\t\t\t\t\t      a_xfrm->auth.digest_length,\n+\t\t\t\t\t\t      a_xfrm->auth.iv.length);\n+\n+\treturn ret;\n+}\n+\n+static int\n+cryptodev_id_get(bool is_integrity_protected, const struct rte_crypto_sym_xform *c_xfrm,\n+\t\t const struct rte_crypto_sym_xform *a_xfrm)\n+{\n+\tint i, nb_devs;\n+\n+\tnb_devs = rte_cryptodev_count();\n+\n+\t/* Check capabilities */\n+\n+\tfor (i = 0; i < nb_devs; i++) {\n+\t\tif ((crypto_caps_cipher_verify(i, c_xfrm) == 0) &&\n+\t\t    (!is_integrity_protected || crypto_caps_auth_verify(i, a_xfrm) == 0))\n+\t\t\tbreak;\n+\t}\n+\n+\tif (i == nb_devs)\n+\t\treturn -1;\n+\n+\treturn i;\n+}\n+\n+static int\n+pdcp_known_vec_verify(struct rte_mbuf *m, const uint8_t *expected, uint32_t expected_pkt_len)\n+{\n+\tuint8_t *actual = rte_pktmbuf_mtod(m, uint8_t *);\n+\tuint32_t actual_pkt_len = rte_pktmbuf_pkt_len(m);\n+\n+\tdebug_hexdump(stdout, \"Received:\", actual, actual_pkt_len);\n+\tdebug_hexdump(stdout, \"Expected:\", expected, expected_pkt_len);\n+\n+\tTEST_ASSERT_EQUAL(actual_pkt_len, expected_pkt_len,\n+\t\t\t  \"Mismatch in packet lengths [expected: %d, received: %d]\",\n+\t\t\t  expected_pkt_len, actual_pkt_len);\n+\n+\tTEST_ASSERT_BUFFERS_ARE_EQUAL(actual, expected, expected_pkt_len,\n+\t\t\t\t     \"Generated packet not as expected\");\n+\n+\treturn 0;\n+}\n+\n+static struct rte_crypto_op *\n+process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)\n+{\n+\tif (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {\n+\t\tRTE_LOG(ERR, USER1, \"Error sending packet to cryptodev\\n\");\n+\t\treturn NULL;\n+\t}\n+\n+\top = NULL;\n+\n+\twhile (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)\n+\t\trte_pause();\n+\n+\treturn op;\n+}\n+\n+static uint32_t\n+pdcp_sn_from_raw_get(const void *data, enum rte_security_pdcp_sn_size size)\n+{\n+\tuint32_t sn = 0;\n+\n+\tif (size == RTE_SECURITY_PDCP_SN_SIZE_12) {\n+\t\tsn = rte_cpu_to_be_16(*(const uint16_t *)data);\n+\t\tsn = sn & 0xfff;\n+\t} else if (size == RTE_SECURITY_PDCP_SN_SIZE_18) {\n+\t\tsn = rte_cpu_to_be_32(*(const uint32_t *)data);\n+\t\tsn = (sn & 0x3ffff00) >> 8;\n+\t}\n+\n+\treturn sn;\n+}\n+\n+static int\n+create_test_conf_from_index(const int index, struct pdcp_test_conf *conf)\n+{\n+\tconst struct pdcp_testsuite_params *ts_params = &testsuite_params;\n+\tstruct rte_crypto_sym_xform c_xfrm, a_xfrm;\n+\tuint32_t sn, expected_len;\n+\tuint8_t *data, *expected;\n+\tint pdcp_hdr_sz;\n+\n+\tmemset(conf, 0, sizeof(*conf));\n+\tmemset(&c_xfrm, 0, sizeof(c_xfrm));\n+\tmemset(&a_xfrm, 0, sizeof(a_xfrm));\n+\n+\tconf->entity.sess_mpool = ts_params->sess_pool;\n+\tconf->entity.cop_pool = ts_params->cop_pool;\n+\tconf->entity.pdcp_xfrm.bearer = pdcp_test_bearer[index];\n+\tconf->entity.pdcp_xfrm.en_ordering = 0;\n+\tconf->entity.pdcp_xfrm.remove_duplicates = 0;\n+\tconf->entity.pdcp_xfrm.domain = pdcp_test_params[index].domain;\n+\n+\tif (pdcp_test_packet_direction[index] == PDCP_DIR_UPLINK)\n+\t\tconf->entity.pdcp_xfrm.pkt_dir = RTE_SECURITY_PDCP_UPLINK;\n+\telse\n+\t\tconf->entity.pdcp_xfrm.pkt_dir = RTE_SECURITY_PDCP_DOWNLINK;\n+\n+\tconf->entity.pdcp_xfrm.sn_size = pdcp_test_data_sn_size[index];\n+\n+\t/* Zero initialize unsupported flags */\n+\tconf->entity.pdcp_xfrm.hfn_threshold = 0;\n+\tconf->entity.pdcp_xfrm.hfn_ovrd = 0;\n+\tconf->entity.pdcp_xfrm.sdap_enabled = 0;\n+\n+\tc_xfrm.type = RTE_CRYPTO_SYM_XFORM_CIPHER;\n+\tc_xfrm.cipher.algo = pdcp_test_params[index].cipher_alg;\n+\tc_xfrm.cipher.key.length = pdcp_test_params[index].cipher_key_len;\n+\tc_xfrm.cipher.key.data = pdcp_test_crypto_key[index];\n+\n+\ta_xfrm.type = RTE_CRYPTO_SYM_XFORM_AUTH;\n+\n+\tif (pdcp_test_params[index].auth_alg == 0) {\n+\t\tconf->is_integrity_protected = false;\n+\t} else {\n+\t\ta_xfrm.auth.algo = pdcp_test_params[index].auth_alg;\n+\t\ta_xfrm.auth.key.data = pdcp_test_auth_key[index];\n+\t\ta_xfrm.auth.key.length = pdcp_test_params[index].auth_key_len;\n+\t\tconf->is_integrity_protected = true;\n+\t}\n+\n+\tpdcp_hdr_sz = pdcp_hdr_size_get(pdcp_test_data_sn_size[index]);\n+\n+\t/*\n+\t * Uplink means PDCP entity is configured for transmit. Downlink means PDCP entity is\n+\t * configured for receive. When integrity protecting is enabled, PDCP always performs\n+\t * digest-encrypted or auth-gen-encrypt for uplink (and decrypt-auth-verify for downlink).\n+\t * So for uplink, crypto chain would be auth-cipher while for downlink it would be\n+\t * cipher-auth.\n+\t *\n+\t * When integrity protection is not required, xform would be cipher only.\n+\t */\n+\n+\tif (conf->is_integrity_protected) {\n+\t\tif (conf->entity.pdcp_xfrm.pkt_dir == RTE_SECURITY_PDCP_UPLINK) {\n+\t\t\tconf->entity.crypto_xfrm = &conf->a_xfrm;\n+\n+\t\t\ta_xfrm.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;\n+\t\t\ta_xfrm.next = &conf->c_xfrm;\n+\n+\t\t\tc_xfrm.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;\n+\t\t\tc_xfrm.next = NULL;\n+\t\t} else {\n+\t\t\tconf->entity.crypto_xfrm = &conf->c_xfrm;\n+\n+\t\t\tc_xfrm.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;\n+\t\t\tc_xfrm.next = &conf->a_xfrm;\n+\n+\t\t\ta_xfrm.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;\n+\t\t\ta_xfrm.next = NULL;\n+\t\t}\n+\t} else {\n+\t\tconf->entity.crypto_xfrm = &conf->c_xfrm;\n+\t\tc_xfrm.next = NULL;\n+\n+\t\tif (conf->entity.pdcp_xfrm.pkt_dir == RTE_SECURITY_PDCP_UPLINK)\n+\t\t\tc_xfrm.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;\n+\t\telse\n+\t\t\tc_xfrm.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;\n+\t}\n+\n+\t/* Update xforms to match PDCP requirements */\n+\n+\tif ((c_xfrm.cipher.algo == RTE_CRYPTO_CIPHER_AES_CTR) ||\n+\t    (c_xfrm.cipher.algo == RTE_CRYPTO_CIPHER_ZUC_EEA3 ||\n+\t    (c_xfrm.cipher.algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2)))\n+\t\tc_xfrm.cipher.iv.length = PDCP_IV_LEN;\n+\telse\n+\t\tc_xfrm.cipher.iv.length = 0;\n+\n+\tif (conf->is_integrity_protected) {\n+\t\tif (a_xfrm.auth.algo == RTE_CRYPTO_AUTH_NULL)\n+\t\t\ta_xfrm.auth.digest_length = 0;\n+\t\telse\n+\t\t\ta_xfrm.auth.digest_length = RTE_PDCP_MAC_I_LEN;\n+\n+\t\tif ((a_xfrm.auth.algo == RTE_CRYPTO_AUTH_ZUC_EIA3) ||\n+\t\t    (a_xfrm.auth.algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2))\n+\t\t\ta_xfrm.auth.iv.length = PDCP_IV_LEN;\n+\t\telse\n+\t\t\ta_xfrm.auth.iv.length = 0;\n+\t}\n+\n+\tconf->c_xfrm = c_xfrm;\n+\tconf->a_xfrm = a_xfrm;\n+\n+\tconf->entity.dev_id = (uint8_t)cryptodev_id_get(conf->is_integrity_protected,\n+\t\t\t&conf->c_xfrm, &conf->a_xfrm);\n+\n+\tif (pdcp_test_params[index].domain == RTE_SECURITY_PDCP_MODE_CONTROL ||\n+\t    pdcp_test_params[index].domain == RTE_SECURITY_PDCP_MODE_DATA) {\n+\t\tdata = pdcp_test_data_in[index];\n+\t\tsn = pdcp_sn_from_raw_get(data, pdcp_test_data_sn_size[index]);\n+\t\tconf->entity.pdcp_xfrm.hfn = pdcp_test_hfn[index];\n+\t\tconf->entity.sn = sn;\n+\t}\n+\n+\tif (conf->entity.pdcp_xfrm.pkt_dir == RTE_SECURITY_PDCP_UPLINK) {\n+#ifdef VEC_DUMP\n+\t\tdebug_hexdump(stdout, \"Original vector:\", pdcp_test_data_in[index],\n+\t\t\t\tpdcp_test_data_in_len[index]);\n+#endif\n+\t\t/* Since the vectors available already have PDCP header, trim the same */\n+\t\tconf->input_len = pdcp_test_data_in_len[index] - pdcp_hdr_sz;\n+\t\tmemcpy(conf->input, pdcp_test_data_in[index] + pdcp_hdr_sz, conf->input_len);\n+\t} else {\n+\t\tconf->input_len = pdcp_test_data_in_len[index];\n+\n+\t\tif (conf->is_integrity_protected)\n+\t\t\tconf->input_len += RTE_PDCP_MAC_I_LEN;\n+\n+\t\tmemcpy(conf->input, pdcp_test_data_out[index], conf->input_len);\n+#ifdef VEC_DUMP\n+\t\tdebug_hexdump(stdout, \"Original vector:\", conf->input, conf->input_len);\n+#endif\n+\t}\n+\n+\tif (conf->entity.pdcp_xfrm.pkt_dir == RTE_SECURITY_PDCP_UPLINK)\n+\t\texpected = pdcp_test_data_out[index];\n+\telse\n+\t\texpected = pdcp_test_data_in[index];\n+\n+\t/* Calculate expected packet length */\n+\texpected_len = pdcp_test_data_in_len[index];\n+\n+\t/* In DL processing, PDCP header would be stripped */\n+\tif (conf->entity.pdcp_xfrm.pkt_dir == RTE_SECURITY_PDCP_DOWNLINK) {\n+\t\texpected += pdcp_hdr_sz;\n+\t\texpected_len -= pdcp_hdr_sz;\n+\t}\n+\n+\t/* In UL processing with integrity protection, MAC would be added */\n+\tif (conf->is_integrity_protected &&\n+\t    conf->entity.pdcp_xfrm.pkt_dir == RTE_SECURITY_PDCP_UPLINK)\n+\t\texpected_len += 4;\n+\n+\tmemcpy(conf->output, expected, expected_len);\n+\tconf->output_len = expected_len;\n+\n+\treturn 0;\n+}\n+\n+static struct rte_pdcp_entity*\n+test_entity_create(const struct pdcp_test_conf *t_conf, int *rc)\n+{\n+\tstruct rte_pdcp_entity *pdcp_entity;\n+\tint ret;\n+\n+\tif (t_conf->entity.pdcp_xfrm.sn_size != RTE_SECURITY_PDCP_SN_SIZE_12 &&\n+\t    t_conf->entity.pdcp_xfrm.sn_size != RTE_SECURITY_PDCP_SN_SIZE_18) {\n+\t\t*rc = -ENOTSUP;\n+\t\treturn NULL;\n+\t}\n+\n+\tif (t_conf->entity.dev_id == CDEV_INVALID_ID) {\n+\t\tRTE_LOG(DEBUG, USER1, \"Could not find device with required capabilities\\n\");\n+\t\t*rc = -ENOTSUP;\n+\t\treturn NULL;\n+\t}\n+\n+\tret = cryptodev_init(t_conf->entity.dev_id);\n+\tif (ret) {\n+\t\t*rc = ret;\n+\t\tRTE_LOG(DEBUG, USER1, \"Could not initialize cryptodev\\n\");\n+\t\treturn NULL;\n+\t}\n+\n+\trte_errno = 0;\n+\n+\tpdcp_entity = rte_pdcp_entity_establish(&t_conf->entity);\n+\tif (pdcp_entity == NULL) {\n+\t\t*rc = -rte_errno;\n+\t\tRTE_LOG(DEBUG, USER1, \"Could not establish PDCP entity\\n\");\n+\t\treturn NULL;\n+\t}\n+\n+\treturn pdcp_entity;\n+}\n+\n+static uint16_t\n+test_process_packets(const struct rte_pdcp_entity *pdcp_entity, uint8_t cdev_id,\n+\t\t     struct rte_mbuf *in_mb[], uint16_t nb_in,\n+\t\t     struct rte_mbuf *out_mb[], uint16_t *nb_err)\n+{\n+\tstruct rte_crypto_op *cop, *cop_out;\n+\tstruct rte_pdcp_group grp[1];\n+\tuint16_t nb_success, nb_grp;\n+\tstruct rte_mbuf *mbuf, *mb;\n+\n+\tif (nb_in != 1)\n+\t\treturn -ENOTSUP;\n+\n+\tmbuf = in_mb[0];\n+\n+\tnb_success = rte_pdcp_pkt_pre_process(pdcp_entity, &mbuf, &cop_out, 1, nb_err);\n+\tif (nb_success != 1 || *nb_err != 0) {\n+\t\tRTE_LOG(ERR, USER1, \"Could not pre process PDCP packet\\n\");\n+\t\treturn TEST_FAILED;\n+\t}\n+\n+#ifdef VEC_DUMP\n+\tprintf(\"Pre-processed vector:\\n\");\n+\trte_pktmbuf_dump(stdout, mbuf, rte_pktmbuf_pkt_len(mbuf));\n+#endif\n+\n+\tcop = process_crypto_request(cdev_id, cop_out);\n+\tif (cop == NULL) {\n+\t\tRTE_LOG(ERR, USER1, \"Could not process crypto request\\n\");\n+\t\treturn -EIO;\n+\t}\n+\n+\tnb_grp = rte_pdcp_pkt_crypto_group(&cop_out, &mb, grp, 1);\n+\tif (nb_grp != 1 || grp[0].cnt != 1) {\n+\t\tRTE_LOG(ERR, USER1, \"Could not group PDCP crypto results\\n\");\n+\t\treturn -ENOTRECOVERABLE;\n+\t}\n+\n+\tif ((uintptr_t)pdcp_entity != grp[0].id.val) {\n+\t\tRTE_LOG(ERR, USER1, \"PDCP entity not matching the one from crypto_op\\n\");\n+\t\treturn -ENOTRECOVERABLE;\n+\t}\n+\n+#ifdef VEC_DUMP\n+\tprintf(\"Crypto processed vector:\\n\");\n+\trte_pktmbuf_dump(stdout, cop->sym->m_dst, rte_pktmbuf_pkt_len(mbuf));\n+#endif\n+\n+\treturn rte_pdcp_pkt_post_process(grp[0].id.ptr, grp[0].m, out_mb, grp[0].cnt, nb_err);\n+}\n+\n+static struct rte_mbuf*\n+mbuf_from_data_create(uint8_t *data, uint16_t data_len)\n+{\n+\tconst struct pdcp_testsuite_params *ts_params = &testsuite_params;\n+\tstruct rte_mbuf *mbuf;\n+\tuint8_t *input_text;\n+\n+\tmbuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);\n+\tif (mbuf == NULL) {\n+\t\tRTE_LOG(ERR, USER1, \"Could not create mbuf\\n\");\n+\t\treturn NULL;\n+\t}\n+\n+\tmemset(rte_pktmbuf_mtod(mbuf, uint8_t *), 0, rte_pktmbuf_tailroom(mbuf));\n+\n+\tinput_text = (uint8_t *)rte_pktmbuf_append(mbuf, data_len);\n+\tmemcpy(input_text, data, data_len);\n+\n+\treturn mbuf;\n+}\n+\n+static int\n+test_attempt_single(struct pdcp_test_conf *t_conf)\n+{\n+\tstruct rte_mbuf *mbuf, **out_mb = NULL;\n+\tstruct rte_pdcp_entity *pdcp_entity;\n+\tuint16_t nb_success, nb_err;\n+\tint ret = 0, nb_max_out_mb;\n+\n+\tpdcp_entity = test_entity_create(t_conf, &ret);\n+\tif (pdcp_entity == NULL)\n+\t\tgoto exit;\n+\n+\t/* Allocate buffer for holding mbufs returned */\n+\n+\t/* Max packets that can be cached in entity + burst size */\n+\tnb_max_out_mb = pdcp_entity->max_pkt_cache + 1;\n+\tout_mb = rte_malloc(NULL, nb_max_out_mb * sizeof(uintptr_t), 0);\n+\tif (out_mb == NULL) {\n+\t\tRTE_LOG(ERR, USER1, \"Could not allocate buffer for holding out_mb buffers\\n\");\n+\t\tret = -ENOMEM;\n+\t\tgoto entity_release;\n+\t}\n+\n+\tmbuf = mbuf_from_data_create(t_conf->input, t_conf->input_len);\n+\tif (mbuf == NULL) {\n+\t\tret = -ENOMEM;\n+\t\tgoto entity_release;\n+\t}\n+\n+#ifdef VEC_DUMP\n+\tprintf(\"Adjusted vector:\\n\");\n+\trte_pktmbuf_dump(stdout, mbuf, t_conf->input_len);\n+#endif\n+\n+\tnb_success = test_process_packets(pdcp_entity, t_conf->entity.dev_id, &mbuf, 1, out_mb,\n+\t\t\t&nb_err);\n+\tif (nb_success != 1 || nb_err != 0) {\n+\t\tRTE_LOG(ERR, USER1, \"Could not process PDCP packet\\n\");\n+\t\tret = TEST_FAILED;\n+\t\tgoto mbuf_free;\n+\t}\n+\n+\tret = pdcp_known_vec_verify(mbuf, t_conf->output, t_conf->output_len);\n+\tif (ret)\n+\t\tgoto mbuf_free;\n+\n+\tret = rte_pdcp_entity_suspend(pdcp_entity, out_mb);\n+\tif (ret) {\n+\t\tRTE_LOG(DEBUG, USER1, \"Could not suspend PDCP entity\\n\");\n+\t\tgoto mbuf_free;\n+\t}\n+\n+mbuf_free:\n+\trte_pktmbuf_free(mbuf);\n+entity_release:\n+\trte_pdcp_entity_release(pdcp_entity, out_mb);\n+\trte_free(out_mb);\n+exit:\n+\treturn ret;\n+}\n+\n+static int\n+run_test_for_one_known_vec(const void *arg)\n+{\n+\tstruct pdcp_test_conf test_conf;\n+\tint i = *(const uint32_t *)arg;\n+\n+\tcreate_test_conf_from_index(i, &test_conf);\n+\treturn test_attempt_single(&test_conf);\n+}\n+\n+struct unit_test_suite *test_suites[] = {\n+\tNULL, /* Place holder for known_vector_cases */\n+\tNULL /* End of suites list */\n+};\n+\n+static struct unit_test_suite pdcp_testsuite  = {\n+\t.suite_name = \"PDCP Unit Test Suite\",\n+\t.unit_test_cases = {TEST_CASES_END()},\n+\t.setup = testsuite_setup,\n+\t.teardown = testsuite_teardown,\n+\t.unit_test_suites = test_suites,\n+};\n+\n+static int\n+test_pdcp(void)\n+{\n+\tstruct unit_test_suite *known_vector_cases;\n+\tint ret, index[NB_TESTS];\n+\tuint32_t i, size;\n+\n+\tsize = sizeof(struct unit_test_suite);\n+\tsize += (NB_TESTS + 1) * sizeof(struct unit_test_case);\n+\n+\tknown_vector_cases = rte_zmalloc(NULL, size, 0);\n+\tif (known_vector_cases == NULL)\n+\t\treturn TEST_FAILED;\n+\n+\tknown_vector_cases->suite_name = \"Known vector cases\";\n+\n+\tfor (i = 0; i < NB_TESTS; i++) {\n+\t\tindex[i] = i;\n+\t\tknown_vector_cases->unit_test_cases[i].name = pdcp_test_params[i].name;\n+\t\tknown_vector_cases->unit_test_cases[i].data = (void *)&index[i];\n+\t\tknown_vector_cases->unit_test_cases[i].enabled = 1;\n+\t\tknown_vector_cases->unit_test_cases[i].setup = ut_setup_pdcp;\n+\t\tknown_vector_cases->unit_test_cases[i].teardown = ut_teardown_pdcp;\n+\t\tknown_vector_cases->unit_test_cases[i].testcase = NULL;\n+\t\tknown_vector_cases->unit_test_cases[i].testcase_with_data\n+\t\t\t\t= run_test_for_one_known_vec;\n+\t}\n+\n+\tknown_vector_cases->unit_test_cases[i].testcase = NULL;\n+\tknown_vector_cases->unit_test_cases[i].testcase_with_data = NULL;\n+\n+\ttest_suites[0] = known_vector_cases;\n+\n+\tret = unit_test_suite_runner(&pdcp_testsuite);\n+\n+\trte_free(known_vector_cases);\n+\treturn ret;\n+}\n+\n+REGISTER_TEST_COMMAND(pdcp_autotest, test_pdcp);\n",
    "prefixes": [
        "v3",
        "09/22"
    ]
}