get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 107280,
    "url": "http://patches.dpdk.org/api/patches/107280/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20220210155404.3598576-2-ciara.power@intel.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": "<20220210155404.3598576-2-ciara.power@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20220210155404.3598576-2-ciara.power@intel.com",
    "date": "2022-02-10T15:54:00",
    "name": "[v6,1/5] doc: replace asym crypto code with literal includes",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "dbbef7a5ff82daafb661de4dfcd66ec267e0685a",
    "submitter": {
        "id": 978,
        "url": "http://patches.dpdk.org/api/people/978/?format=api",
        "name": "Power, Ciara",
        "email": "ciara.power@intel.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/20220210155404.3598576-2-ciara.power@intel.com/mbox/",
    "series": [
        {
            "id": 21608,
            "url": "http://patches.dpdk.org/api/series/21608/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=21608",
            "date": "2022-02-10T15:53:59",
            "name": "crypto: improve asym session usage",
            "version": 6,
            "mbox": "http://patches.dpdk.org/series/21608/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/107280/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/107280/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 92A8FA00BE;\n\tThu, 10 Feb 2022 16:54:17 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id AC89842761;\n\tThu, 10 Feb 2022 16:54:13 +0100 (CET)",
            "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n by mails.dpdk.org (Postfix) with ESMTP id AF10A4274D\n for <dev@dpdk.org>; Thu, 10 Feb 2022 16:54:11 +0100 (CET)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 10 Feb 2022 07:54:11 -0800",
            "from silpixa00400355.ir.intel.com (HELO\n silpixa00400355.ger.corp.intel.com) ([10.237.222.49])\n by orsmga008.jf.intel.com with ESMTP; 10 Feb 2022 07:54:08 -0800"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1644508451; x=1676044451;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=v2SWKO9JUNFJOWRTxF1etpjN9kr27z8MuWncXxwaHLA=;\n b=IHPLA9Ds2hEArb9Ukt2XtQ4arX85e+Vi+eBbbOHmmK58CCNFxxcVADbw\n W/2eMsVLgQXLVsYBXGMDDi5nBGw7+jtd7qddM1J6j039zwkHvjFTfHyP5\n ZvUt0Md364trhUYpPDhqJOtEVb6VsGJgYxotlTK/gWRmEutaACOwcSoFl\n aUjTCg2LOCvfE0N5KEmvz4gqFrvn+ydmhp0WKUx22bcecsC34x7hgzte7\n V32ETaYW3k8S1ndw3JQCQhYyH+fIBwz/wl8gzti3dl6yvjN9s7yCr5YuX\n YfGfu1n+9WomaGbFxM0LAX6PA9w/uJZV2CwtW1I4PHt/651J/GOCwOEw9 g==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6200,9189,10254\"; a=\"229486782\"",
            "E=Sophos;i=\"5.88,359,1635231600\"; d=\"scan'208\";a=\"229486782\"",
            "E=Sophos;i=\"5.88,359,1635231600\"; d=\"scan'208\";a=\"541658586\""
        ],
        "X-ExtLoop1": "1",
        "From": "Ciara Power <ciara.power@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "roy.fan.zhang@intel.com, gakhil@marvell.com, anoobj@marvell.com,\n mdr@ashroe.eu, Ciara Power <ciara.power@intel.com>,\n Declan Doherty <declan.doherty@intel.com>",
        "Subject": "[PATCH v6 1/5] doc: replace asym crypto code with literal includes",
        "Date": "Thu, 10 Feb 2022 15:54:00 +0000",
        "Message-Id": "<20220210155404.3598576-2-ciara.power@intel.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20220210155404.3598576-1-ciara.power@intel.com>",
        "References": "<20220209153854.2740455-1-ciara.power@intel.com>\n <20220210155404.3598576-1-ciara.power@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 <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": "The programmer's guide for cryptodev included sample code for using\nAsymmetric crypto. This is now replaced with direct code from the test\napplication, using literal includes. It is broken into snippets as the\ntest application didn't have all of the required code in one function.\n\nSigned-off-by: Ciara Power <ciara.power@intel.com>\nAcked-by: Anoob Joseph <anoobj@marvell.com>\n---\n app/test/test_cryptodev_asym.c             |   7 +-\n app/test/test_cryptodev_mod_test_vectors.h |   4 +\n doc/guides/prog_guide/cryptodev_lib.rst    | 176 ++++-----------------\n 3 files changed, 37 insertions(+), 150 deletions(-)",
    "diff": "diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c\nindex 9d3a5589bb..8d7290f9ed 100644\n--- a/app/test/test_cryptodev_asym.c\n+++ b/app/test/test_cryptodev_asym.c\n@@ -855,6 +855,7 @@ testsuite_setup(void)\n \ttest_vector.size = 0;\n \tload_test_vectors();\n \n+\t/* Device, op pool and session configuration for asymmetric crypto. 8< */\n \tts_params->op_mpool = rte_crypto_op_pool_create(\n \t\t\t\"CRYPTO_ASYM_OP_POOL\",\n \t\t\tRTE_CRYPTO_OP_TYPE_ASYMMETRIC,\n@@ -953,7 +954,7 @@ testsuite_setup(void)\n \n \tTEST_ASSERT_NOT_NULL(ts_params->session_mpool,\n \t\t\t\"session mempool allocation failed\");\n-\n+\t/* >8 End of device, op pool and session configuration for asymmetric crypto section. */\n \treturn TEST_SUCCESS;\n }\n \n@@ -1637,7 +1638,7 @@ test_mod_exp(void)\n \t\t\t\treturn TEST_SKIPPED;\n \t\t}\n \n-\t/* generate crypto op data structure */\n+\t/* Create op, create session, and process packets. 8< */\n \top = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);\n \tif (!op) {\n \t\tRTE_LOG(ERR, USER1,\n@@ -1696,7 +1697,7 @@ test_mod_exp(void)\n \t\tstatus = TEST_FAILED;\n \t\tgoto error_exit;\n \t}\n-\n+\t/* >8 End of create op, create session, and process packets section. */\n \tret = verify_modexp(mod_exp, result_op);\n \tif (ret) {\n \t\tRTE_LOG(ERR, USER1,\ndiff --git a/app/test/test_cryptodev_mod_test_vectors.h b/app/test/test_cryptodev_mod_test_vectors.h\nindex c66f4b18bc..807ca7a47e 100644\n--- a/app/test/test_cryptodev_mod_test_vectors.h\n+++ b/app/test/test_cryptodev_mod_test_vectors.h\n@@ -979,6 +979,7 @@ uint8_t base[] = {\n \t0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50\n };\n \n+/* MODEX data. 8< */\n uint8_t mod_p[] = {\n \t0x00, 0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00,\n \t0x0a, 0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5,\n@@ -1000,6 +1001,7 @@ uint8_t mod_p[] = {\n };\n \n uint8_t mod_e[] = {0x01, 0x00, 0x01};\n+/* >8 End of MODEX data. */\n \n /* Precomputed modular exponentiation for verification */\n uint8_t mod_exp[] = {\n@@ -1041,6 +1043,7 @@ uint8_t mod_inv[] = {\n \t0x9a, 0x66, 0x9a, 0x3a, 0xc1, 0xb8, 0x4b, 0xc3\n };\n \n+/* MODEX vector. 8< */\n struct rte_crypto_asym_xform modex_xform = {\n \t.next = NULL,\n \t.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,\n@@ -1055,6 +1058,7 @@ struct rte_crypto_asym_xform modex_xform = {\n \t\t}\n \t}\n };\n+/* >8 End of MODEX vector. */\n \n struct rte_crypto_asym_xform modinv_xform = {\n \t.next = NULL,\ndiff --git a/doc/guides/prog_guide/cryptodev_lib.rst b/doc/guides/prog_guide/cryptodev_lib.rst\nindex 8766bc34a9..9f33f7a177 100644\n--- a/doc/guides/prog_guide/cryptodev_lib.rst\n+++ b/doc/guides/prog_guide/cryptodev_lib.rst\n@@ -1119,162 +1119,44 @@ Asymmetric crypto Sample code\n There's a unit test application test_cryptodev_asym.c inside unit test framework that\n show how to setup and process asymmetric operations using cryptodev library.\n \n-The following sample code shows the basic steps to compute modular exponentiation\n-using 1024-bit modulus length using openssl PMD available in DPDK (performing other\n-crypto operations is similar except change to respective op and xform setup).\n+The following code samples are taken from the test application mentioned above,\n+and show basic steps to compute modular exponentiation using an openssl PMD\n+available in DPDK (performing other crypto operations is similar except change\n+to respective op and xform setup).\n \n-.. code-block:: c\n+.. note::\n+   The following code snippets are taken from multiple functions, so variable\n+   names may differ slightly between sections.\n \n-    /*\n-     * Simple example to compute modular exponentiation with 1024-bit key\n-     *\n-     */\n-    #define MAX_ASYM_SESSIONS\t10\n-    #define NUM_ASYM_BUFS\t10\n-\n-    struct rte_mempool *crypto_op_pool, *asym_session_pool;\n-    unsigned int asym_session_size;\n-    int ret;\n+Configure the virtual device, queue pairs, crypto op pool and session mempool.\n \n-    /* Initialize EAL. */\n-    ret = rte_eal_init(argc, argv);\n-    if (ret < 0)\n-        rte_exit(EXIT_FAILURE, \"Invalid EAL arguments\\n\");\n+.. literalinclude:: ../../../app/test/test_cryptodev_asym.c\n+   :language: c\n+   :start-after: Device, op pool and session configuration for asymmetric crypto. 8<\n+   :end-before: >8 End of device, op pool and session configuration for asymmetric crypto section.\n+   :dedent: 1\n \n-    uint8_t socket_id = rte_socket_id();\n-\n-    /* Create crypto operation pool. */\n-    crypto_op_pool = rte_crypto_op_pool_create(\n-                                    \"crypto_op_pool\",\n-                                    RTE_CRYPTO_OP_TYPE_ASYMMETRIC,\n-                                    NUM_ASYM_BUFS, 0, 0,\n-                                    socket_id);\n-    if (crypto_op_pool == NULL)\n-        rte_exit(EXIT_FAILURE, \"Cannot create crypto op pool\\n\");\n-\n-    /* Create the virtual crypto device. */\n-    char args[128];\n-    const char *crypto_name = \"crypto_openssl\";\n-    snprintf(args, sizeof(args), \"socket_id=%d\", socket_id);\n-    ret = rte_vdev_init(crypto_name, args);\n-    if (ret != 0)\n-        rte_exit(EXIT_FAILURE, \"Cannot create virtual device\");\n+Create MODEX data vectors.\n \n-    uint8_t cdev_id = rte_cryptodev_get_dev_id(crypto_name);\n+.. literalinclude:: ../../../app/test/test_cryptodev_mod_test_vectors.h\n+   :language: c\n+   :start-after: MODEX data. 8<\n+   :end-before: >8 End of MODEX data.\n \n-    /* Get private asym session data size. */\n-    asym_session_size = rte_cryptodev_get_asym_private_session_size(cdev_id);\n+Setup crypto xform to do modular exponentiation using data vectors.\n \n-    /*\n-     * Create session mempool, with two objects per session,\n-     * one for the session header and another one for the\n-     * private asym session data for the crypto device.\n-     */\n-    asym_session_pool = rte_mempool_create(\"asym_session_pool\",\n-                                    MAX_ASYM_SESSIONS * 2,\n-                                    asym_session_size,\n-                                    0,\n-                                    0, NULL, NULL, NULL,\n-                                    NULL, socket_id,\n-                                    0);\n+.. literalinclude:: ../../../app/test/test_cryptodev_mod_test_vectors.h\n+   :language: c\n+   :start-after: MODEX vector. 8<\n+   :end-before: >8 End of MODEX vector.\n \n-    /* Configure the crypto device. */\n-    struct rte_cryptodev_config conf = {\n-        .nb_queue_pairs = 1,\n-        .socket_id = socket_id\n-    };\n-    struct rte_cryptodev_qp_conf qp_conf = {\n-        .nb_descriptors = 2048\n-    };\n+Generate crypto op, create and attach a session, then process packets.\n \n-    if (rte_cryptodev_configure(cdev_id, &conf) < 0)\n-        rte_exit(EXIT_FAILURE, \"Failed to configure cryptodev %u\", cdev_id);\n-\n-    if (rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf,\n-                            socket_id, asym_session_pool) < 0)\n-        rte_exit(EXIT_FAILURE, \"Failed to setup queue pair\\n\");\n-\n-    if (rte_cryptodev_start(cdev_id) < 0)\n-        rte_exit(EXIT_FAILURE, \"Failed to start device\\n\");\n-\n-    /* Setup crypto xform to do modular exponentiation with 1024 bit\n-\t * length modulus\n-\t */\n-    struct rte_crypto_asym_xform modex_xform = {\n-\t\t.next = NULL,\n-\t\t.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,\n-\t\t.modex = {\n-\t\t\t.modulus = {\n-\t\t\t\t.data =\n-\t\t\t\t(uint8_t *)\n-\t\t\t\t(\"\\xb3\\xa1\\xaf\\xb7\\x13\\x08\\x00\\x0a\\x35\\xdc\\x2b\\x20\\x8d\"\n-\t\t\t\t\"\\xa1\\xb5\\xce\\x47\\x8a\\xc3\\x80\\xf4\\x7d\\x4a\\xa2\\x62\\xfd\\x61\\x7f\"\n-\t\t\t\t\"\\xb5\\xa8\\xde\\x0a\\x17\\x97\\xa0\\xbf\\xdf\\x56\\x5a\\x3d\\x51\\x56\\x4f\"\n-\t\t\t\t\"\\x70\\x70\\x3f\\x63\\x6a\\x44\\x5b\\xad\\x84\\x0d\\x3f\\x27\\x6e\\x3b\\x34\"\n-\t\t\t\t\"\\x91\\x60\\x14\\xb9\\xaa\\x72\\xfd\\xa3\\x64\\xd2\\x03\\xa7\\x53\\x87\\x9e\"\n-\t\t\t\t\"\\x88\\x0b\\xc1\\x14\\x93\\x1a\\x62\\xff\\xb1\\x5d\\x74\\xcd\\x59\\x63\\x18\"\n-\t\t\t\t\"\\x11\\x3d\\x4f\\xba\\x75\\xd4\\x33\\x4e\\x23\\x6b\\x7b\\x57\\x44\\xe1\\xd3\"\n-\t\t\t\t\"\\x03\\x13\\xa6\\xf0\\x8b\\x60\\xb0\\x9e\\xee\\x75\\x08\\x9d\\x71\\x63\\x13\"\n-\t\t\t\t\"\\xcb\\xa6\\x81\\x92\\x14\\x03\\x22\\x2d\\xde\\x55\"),\n-\t\t\t\t.length = 128\n-\t\t\t},\n-\t\t\t.exponent = {\n-\t\t\t\t.data = (uint8_t *)(\"\\x01\\x00\\x01\"),\n-\t\t\t\t.length = 3\n-\t\t\t}\n-\t\t}\n-    };\n-    /* Create asym crypto session and initialize it for the crypto device. */\n-    struct rte_cryptodev_asym_session *asym_session;\n-    asym_session = rte_cryptodev_asym_session_create(asym_session_pool);\n-    if (asym_session == NULL)\n-        rte_exit(EXIT_FAILURE, \"Session could not be created\\n\");\n-\n-    if (rte_cryptodev_asym_session_init(cdev_id, asym_session,\n-                    &modex_xform, asym_session_pool) < 0)\n-        rte_exit(EXIT_FAILURE, \"Session could not be initialized \"\n-                    \"for the crypto device\\n\");\n-\n-    /* Get a burst of crypto operations. */\n-    struct rte_crypto_op *crypto_ops[1];\n-    if (rte_crypto_op_bulk_alloc(crypto_op_pool,\n-                            RTE_CRYPTO_OP_TYPE_ASYMMETRIC,\n-                            crypto_ops, 1) == 0)\n-        rte_exit(EXIT_FAILURE, \"Not enough crypto operations available\\n\");\n-\n-    /* Set up the crypto operations. */\n-    struct rte_crypto_asym_op *asym_op = crypto_ops[0]->asym;\n-\n-\t/* calculate mod exp of value 0xf8 */\n-    static unsigned char base[] = {0xF8};\n-    asym_op->modex.base.data = base;\n-    asym_op->modex.base.length = sizeof(base);\n-\tasym_op->modex.base.iova = base;\n-\n-    /* Attach the asym crypto session to the operation */\n-    rte_crypto_op_attach_asym_session(op, asym_session);\n-\n-    /* Enqueue the crypto operations in the crypto device. */\n-    uint16_t num_enqueued_ops = rte_cryptodev_enqueue_burst(cdev_id, 0,\n-                                            crypto_ops, 1);\n-\n-    /*\n-     * Dequeue the crypto operations until all the operations\n-     * are processed in the crypto device.\n-     */\n-    uint16_t num_dequeued_ops, total_num_dequeued_ops = 0;\n-    do {\n-        struct rte_crypto_op *dequeued_ops[1];\n-        num_dequeued_ops = rte_cryptodev_dequeue_burst(cdev_id, 0,\n-                                        dequeued_ops, 1);\n-        total_num_dequeued_ops += num_dequeued_ops;\n-\n-        /* Check if operation was processed successfully */\n-        if (dequeued_ops[0]->status != RTE_CRYPTO_OP_STATUS_SUCCESS)\n-                rte_exit(EXIT_FAILURE,\n-                        \"Some operations were not processed correctly\");\n-\n-    } while (total_num_dequeued_ops < num_enqueued_ops);\n+.. literalinclude:: ../../../app/test/test_cryptodev_asym.c\n+   :language: c\n+   :start-after: Create op, create session, and process packets. 8<\n+   :end-before: >8 End of create op, create session, and process packets section.\n+   :dedent: 1\n \n \n Asymmetric Crypto Device API\n",
    "prefixes": [
        "v6",
        "1/5"
    ]
}