get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 26210,
    "url": "http://patches.dpdk.org/api/patches/26210/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20170702054127.75610-25-pablo.de.lara.guarch@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": "<20170702054127.75610-25-pablo.de.lara.guarch@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20170702054127.75610-25-pablo.de.lara.guarch@intel.com",
    "date": "2017-07-02T05:41:25",
    "name": "[dpdk-dev,v4,24/26] examples/l2fwd-crypto: add AEAD parameters",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "0c7bee1507cd31da65ca2d8a1fe48b3c11205ca4",
    "submitter": {
        "id": 9,
        "url": "http://patches.dpdk.org/api/people/9/?format=api",
        "name": "De Lara Guarch, Pablo",
        "email": "pablo.de.lara.guarch@intel.com"
    },
    "delegate": {
        "id": 22,
        "url": "http://patches.dpdk.org/api/users/22/?format=api",
        "username": "pdelarag",
        "first_name": "Pablo",
        "last_name": "de Lara Guarch",
        "email": "pablo.de.lara.guarch@intel.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20170702054127.75610-25-pablo.de.lara.guarch@intel.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/26210/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/26210/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id E5F557D3F;\n\tSun,  2 Jul 2017 15:42:20 +0200 (CEST)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id F236F7D2F\n\tfor <dev@dpdk.org>; Sun,  2 Jul 2017 15:42:15 +0200 (CEST)",
            "from orsmga004.jf.intel.com ([10.7.209.38])\n\tby fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t02 Jul 2017 06:42:15 -0700",
            "from silpixa00399464.ir.intel.com (HELO\n\tsilpixa00399464.ger.corp.intel.com) ([10.237.222.157])\n\tby orsmga004.jf.intel.com with ESMTP; 02 Jul 2017 06:42:13 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.40,297,1496127600\"; d=\"scan'208\";a=\"103708590\"",
        "From": "Pablo de Lara <pablo.de.lara.guarch@intel.com>",
        "To": "declan.doherty@intel.com, zbigniew.bodek@caviumnetworks.com,\n\tjerin.jacob@caviumnetworks.com, akhil.goyal@nxp.com,\n\themant.agrawal@nxp.com, fiona.trahe@intel.com, john.griffin@intel.com,\n\tdeepak.k.jain@intel.com",
        "Cc": "dev@dpdk.org,\n\tPablo de Lara <pablo.de.lara.guarch@intel.com>",
        "Date": "Sun,  2 Jul 2017 06:41:25 +0100",
        "Message-Id": "<20170702054127.75610-25-pablo.de.lara.guarch@intel.com>",
        "X-Mailer": "git-send-email 2.9.4",
        "In-Reply-To": "<20170702054127.75610-1-pablo.de.lara.guarch@intel.com>",
        "References": "<20170629113521.5560-1-pablo.de.lara.guarch@intel.com>\n\t<20170702054127.75610-1-pablo.de.lara.guarch@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v4 24/26] examples/l2fwd-crypto: add AEAD\n\tparameters",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Since there is a new operation type (AEAD), add parameters\nfor this in the application.\n\nSigned-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>\nAcked-by: Akhil Goyal <akhil.goyal@nxp.com>\nAcked-by: Fiona Trahe <fiona.trahe@intel.com>\n---\n doc/guides/sample_app_ug/l2_forward_crypto.rst |  24 +-\n examples/l2fwd-crypto/main.c                   | 388 +++++++++++++++++++++----\n 2 files changed, 357 insertions(+), 55 deletions(-)",
    "diff": "diff --git a/doc/guides/sample_app_ug/l2_forward_crypto.rst b/doc/guides/sample_app_ug/l2_forward_crypto.rst\nindex b9aa573..2880c43 100644\n--- a/doc/guides/sample_app_ug/l2_forward_crypto.rst\n+++ b/doc/guides/sample_app_ug/l2_forward_crypto.rst\n@@ -110,7 +110,9 @@ where,\n \n *   chain: select the operation chaining to perform: Cipher->Hash (CIPHER_HASH),\n \n-    Hash->Cipher (HASH_CIPHER), Cipher (CIPHER_ONLY), Hash(HASH_ONLY)\n+    Hash->Cipher (HASH_CIPHER), Cipher (CIPHER_ONLY), Hash (HASH_ONLY)\n+\n+    or AEAD (AEAD)\n \n     (default is Cipher->Hash)\n \n@@ -154,6 +156,26 @@ where,\n \n     Note that if --auth_iv is used, this will be ignored.\n \n+*   aead_algo: select the AEAD algorithm\n+\n+*   aead_op: select the AEAD operation to perform: ENCRYPT or DECRYPT\n+\n+    (default is ENCRYPT)\n+\n+*   aead_key: set the AEAD key to be used. Bytes has to be separated with \":\"\n+\n+*   aead_key_random_size: set the size of the AEAD key,\n+\n+    which will be generated randomly.\n+\n+    Note that if --aead_key is used, this will be ignored.\n+\n+*   aead_iv: set the AEAD IV to be used. Bytes has to be separated with \":\"\n+\n+*   aead_iv_random_size: set the size of the AEAD IV, which will be generated randomly.\n+\n+    Note that if --aead_iv is used, this will be ignored.\n+\n *   aad: set the AAD to be used. Bytes has to be separated with \":\"\n \n *   aad_random_size: set the size of the AAD, which will be generated randomly.\ndiff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c\nindex fb829e3..914f8ed 100644\n--- a/examples/l2fwd-crypto/main.c\n+++ b/examples/l2fwd-crypto/main.c\n@@ -130,7 +130,8 @@ enum l2fwd_crypto_xform_chain {\n \tL2FWD_CRYPTO_CIPHER_HASH,\n \tL2FWD_CRYPTO_HASH_CIPHER,\n \tL2FWD_CRYPTO_CIPHER_ONLY,\n-\tL2FWD_CRYPTO_HASH_ONLY\n+\tL2FWD_CRYPTO_HASH_ONLY,\n+\tL2FWD_CRYPTO_AEAD\n };\n \n struct l2fwd_key {\n@@ -172,6 +173,14 @@ struct l2fwd_crypto_options {\n \tunsigned int auth_iv_param;\n \tint auth_iv_random_size;\n \n+\tstruct rte_crypto_sym_xform aead_xform;\n+\tunsigned int aead_key_param;\n+\tint aead_key_random_size;\n+\n+\tstruct l2fwd_iv aead_iv;\n+\tunsigned int aead_iv_param;\n+\tint aead_iv_random_size;\n+\n \tstruct l2fwd_key aad;\n \tunsigned aad_param;\n \tint aad_random_size;\n@@ -194,15 +203,18 @@ struct l2fwd_crypto_params {\n \n \tstruct l2fwd_iv cipher_iv;\n \tstruct l2fwd_iv auth_iv;\n+\tstruct l2fwd_iv aead_iv;\n \tstruct l2fwd_key aad;\n \tstruct rte_cryptodev_sym_session *session;\n \n \tuint8_t do_cipher;\n \tuint8_t do_hash;\n+\tuint8_t do_aead;\n \tuint8_t hash_verify;\n \n \tenum rte_crypto_cipher_algorithm cipher_algo;\n \tenum rte_crypto_auth_algorithm auth_algo;\n+\tenum rte_crypto_aead_algorithm aead_algo;\n };\n \n /** lcore configuration */\n@@ -492,14 +504,6 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,\n \t\t\top->sym->auth.data.offset = ipdata_offset;\n \t\t\top->sym->auth.data.length = data_len;\n \t\t}\n-\n-\t\tif (cparams->aad.length) {\n-\t\t\top->sym->auth.aad.data = cparams->aad.data;\n-\t\t\top->sym->auth.aad.phys_addr = cparams->aad.phys_addr;\n-\t\t} else {\n-\t\t\top->sym->auth.aad.data = NULL;\n-\t\t\top->sym->auth.aad.phys_addr = 0;\n-\t\t}\n \t}\n \n \tif (cparams->do_cipher) {\n@@ -521,6 +525,33 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,\n \t\t}\n \t}\n \n+\tif (cparams->do_aead) {\n+\t\tuint8_t *iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,\n+\t\t\t\t\t\t\tIV_OFFSET);\n+\t\t/* Copy IV at the end of the crypto operation */\n+\t\trte_memcpy(iv_ptr, cparams->aead_iv.data, cparams->aead_iv.length);\n+\n+\t\top->sym->aead.data.offset = ipdata_offset;\n+\t\top->sym->aead.data.length = data_len;\n+\n+\t\tif (!cparams->hash_verify) {\n+\t\t\t/* Append space for digest to end of packet */\n+\t\t\top->sym->aead.digest.data = (uint8_t *)rte_pktmbuf_append(m,\n+\t\t\t\tcparams->digest_length);\n+\t\t} else {\n+\t\t\top->sym->aead.digest.data = rte_pktmbuf_mtod(m,\n+\t\t\t\tuint8_t *) + ipdata_offset + data_len;\n+\t\t}\n+\n+\t\top->sym->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(m,\n+\t\t\t\trte_pktmbuf_pkt_len(m) - cparams->digest_length);\n+\n+\t\tif (cparams->aad.length) {\n+\t\t\top->sym->aead.aad.data = cparams->aad.data;\n+\t\t\top->sym->aead.aad.phys_addr = cparams->aad.phys_addr;\n+\t\t}\n+\t}\n+\n \top->sym->m_src = m;\n \n \treturn l2fwd_crypto_enqueue(op, cparams);\n@@ -617,7 +648,9 @@ initialize_crypto_session(struct l2fwd_crypto_options *options,\n {\n \tstruct rte_crypto_sym_xform *first_xform;\n \n-\tif (options->xform_chain == L2FWD_CRYPTO_CIPHER_HASH) {\n+\tif (options->xform_chain == L2FWD_CRYPTO_AEAD) {\n+\t\tfirst_xform = &options->aead_xform;\n+\t} else if (options->xform_chain == L2FWD_CRYPTO_CIPHER_HASH) {\n \t\tfirst_xform = &options->cipher_xform;\n \t\tfirst_xform->next = &options->auth_xform;\n \t} else if (options->xform_chain == L2FWD_CRYPTO_HASH_CIPHER) {\n@@ -669,8 +702,12 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)\n \tfor (i = 0; i < qconf->nb_crypto_devs; i++) {\n \t\tport_cparams[i].do_cipher = 0;\n \t\tport_cparams[i].do_hash = 0;\n+\t\tport_cparams[i].do_aead = 0;\n \n \t\tswitch (options->xform_chain) {\n+\t\tcase L2FWD_CRYPTO_AEAD:\n+\t\t\tport_cparams[i].do_aead = 1;\n+\t\t\tbreak;\n \t\tcase L2FWD_CRYPTO_CIPHER_HASH:\n \t\tcase L2FWD_CRYPTO_HASH_CIPHER:\n \t\t\tport_cparams[i].do_cipher = 1;\n@@ -695,6 +732,12 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)\n \t\t\tif (!options->auth_iv_param)\n \t\t\t\tgenerate_random_key(port_cparams[i].auth_iv.data,\n \t\t\t\t\t\tport_cparams[i].auth_iv.length);\n+\t\t\tif (options->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY)\n+\t\t\t\tport_cparams[i].hash_verify = 1;\n+\t\t\telse\n+\t\t\t\tport_cparams[i].hash_verify = 0;\n+\n+\t\t\tport_cparams[i].auth_algo = options->auth_xform.auth.algo;\n \t\t\t/* Set IV parameters */\n \t\t\tif (options->auth_iv.length) {\n \t\t\t\toptions->auth_xform.auth.iv.offset =\n@@ -702,11 +745,16 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)\n \t\t\t\toptions->auth_xform.auth.iv.length =\n \t\t\t\t\toptions->auth_iv.length;\n \t\t\t}\n+\t\t}\n+\n+\t\tif (port_cparams[i].do_aead) {\n+\t\t\tport_cparams[i].aead_algo = options->aead_xform.aead.algo;\n \t\t\tport_cparams[i].digest_length =\n-\t\t\t\t\toptions->auth_xform.auth.digest_length;\n-\t\t\tif (options->auth_xform.auth.add_auth_data_length) {\n+\t\t\t\t\toptions->aead_xform.aead.digest_length;\n+\t\t\tif (options->aead_xform.aead.add_auth_data_length) {\n \t\t\t\tport_cparams[i].aad.data = options->aad.data;\n \t\t\t\tport_cparams[i].aad.phys_addr = options->aad.phys_addr;\n+\t\t\t\tport_cparams[i].aad.length = options->aad.length;\n \t\t\t\tif (!options->aad_param)\n \t\t\t\t\tgenerate_random_key(port_cparams[i].aad.data,\n \t\t\t\t\t\tport_cparams[i].aad.length);\n@@ -714,12 +762,14 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)\n \t\t\t} else\n \t\t\t\tport_cparams[i].aad.length = 0;\n \n-\t\t\tif (options->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY)\n+\t\t\tif (options->aead_xform.aead.op == RTE_CRYPTO_AEAD_OP_DECRYPT)\n \t\t\t\tport_cparams[i].hash_verify = 1;\n \t\t\telse\n \t\t\t\tport_cparams[i].hash_verify = 0;\n \n-\t\t\tport_cparams[i].auth_algo = options->auth_xform.auth.algo;\n+\t\t\t/* Set IV parameters */\n+\t\t\toptions->aead_xform.aead.iv.offset = IV_OFFSET;\n+\t\t\toptions->aead_xform.aead.iv.length = options->aead_iv.length;\n \t\t}\n \n \t\tif (port_cparams[i].do_cipher) {\n@@ -881,7 +931,7 @@ l2fwd_crypto_usage(const char *prgname)\n \n \t\t\"  --cdev_type HW / SW / ANY\\n\"\n \t\t\"  --chain HASH_CIPHER / CIPHER_HASH / CIPHER_ONLY /\"\n-\t\t\" HASH_ONLY\\n\"\n+\t\t\" HASH_ONLY / AEAD\\n\"\n \n \t\t\"  --cipher_algo ALGO\\n\"\n \t\t\"  --cipher_op ENCRYPT / DECRYPT\\n\"\n@@ -896,8 +946,16 @@ l2fwd_crypto_usage(const char *prgname)\n \t\t\"  --auth_key_random_size SIZE: size of auth key when generated randomly\\n\"\n \t\t\"  --auth_iv IV (bytes separated with \\\":\\\")\\n\"\n \t\t\"  --auth_iv_random_size SIZE: size of auth IV when generated randomly\\n\"\n+\n+\t\t\"  --aead_algo ALGO\\n\"\n+\t\t\"  --aead_op ENCRYPT / DECRYPT\\n\"\n+\t\t\"  --aead_key KEY (bytes separated with \\\":\\\")\\n\"\n+\t\t\"  --aead_key_random_size SIZE: size of AEAD key when generated randomly\\n\"\n+\t\t\"  --aead_iv IV (bytes separated with \\\":\\\")\\n\"\n+\t\t\"  --aead_iv_random_size SIZE: size of AEAD IV when generated randomly\\n\"\n \t\t\"  --aad AAD (bytes separated with \\\":\\\")\\n\"\n \t\t\"  --aad_random_size SIZE: size of AAD when generated randomly\\n\"\n+\n \t\t\"  --digest_size SIZE: size of digest to be generated/verified\\n\"\n \n \t\t\"  --sessionless\\n\"\n@@ -939,6 +997,9 @@ parse_crypto_opt_chain(struct l2fwd_crypto_options *options, char *optarg)\n \t} else if (strcmp(\"HASH_ONLY\", optarg) == 0) {\n \t\toptions->xform_chain = L2FWD_CRYPTO_HASH_ONLY;\n \t\treturn 0;\n+\t} else if (strcmp(\"AEAD\", optarg) == 0) {\n+\t\toptions->xform_chain = L2FWD_CRYPTO_AEAD;\n+\t\treturn 0;\n \t}\n \n \treturn -1;\n@@ -1046,6 +1107,32 @@ parse_auth_op(enum rte_crypto_auth_operation *op, char *optarg)\n }\n \n static int\n+parse_aead_algo(enum rte_crypto_aead_algorithm *algo, char *optarg)\n+{\n+\tif (rte_cryptodev_get_aead_algo_enum(algo, optarg) < 0) {\n+\t\tRTE_LOG(ERR, USER1, \"AEAD algorithm specified \"\n+\t\t\t\t\"not supported!\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+parse_aead_op(enum rte_crypto_aead_operation *op, char *optarg)\n+{\n+\tif (strcmp(\"ENCRYPT\", optarg) == 0) {\n+\t\t*op = RTE_CRYPTO_AEAD_OP_ENCRYPT;\n+\t\treturn 0;\n+\t} else if (strcmp(\"DECRYPT\", optarg) == 0) {\n+\t\t*op = RTE_CRYPTO_AEAD_OP_DECRYPT;\n+\t\treturn 0;\n+\t}\n+\n+\tprintf(\"AEAD operation specified not supported!\\n\");\n+\treturn -1;\n+}\n+static int\n parse_cryptodev_mask(struct l2fwd_crypto_options *options,\n \t\tconst char *q_arg)\n {\n@@ -1143,7 +1230,6 @@ l2fwd_crypto_parse_args_long_options(struct l2fwd_crypto_options *options,\n \t\treturn parse_size(&options->akey_random_size, optarg);\n \t}\n \n-\n \telse if (strcmp(lgopts[option_index].name, \"auth_iv\") == 0) {\n \t\toptions->auth_iv_param = 1;\n \t\toptions->auth_iv.length =\n@@ -1157,6 +1243,43 @@ l2fwd_crypto_parse_args_long_options(struct l2fwd_crypto_options *options,\n \telse if (strcmp(lgopts[option_index].name, \"auth_iv_random_size\") == 0)\n \t\treturn parse_size(&options->auth_iv_random_size, optarg);\n \n+\t/* AEAD options */\n+\telse if (strcmp(lgopts[option_index].name, \"aead_algo\") == 0) {\n+\t\treturn parse_aead_algo(&options->aead_xform.aead.algo,\n+\t\t\t\toptarg);\n+\t}\n+\n+\telse if (strcmp(lgopts[option_index].name, \"aead_op\") == 0)\n+\t\treturn parse_aead_op(&options->aead_xform.aead.op,\n+\t\t\t\toptarg);\n+\n+\telse if (strcmp(lgopts[option_index].name, \"aead_key\") == 0) {\n+\t\toptions->aead_key_param = 1;\n+\t\toptions->aead_xform.aead.key.length =\n+\t\t\tparse_key(options->aead_xform.aead.key.data, optarg);\n+\t\tif (options->aead_xform.aead.key.length > 0)\n+\t\t\treturn 0;\n+\t\telse\n+\t\t\treturn -1;\n+\t}\n+\n+\telse if (strcmp(lgopts[option_index].name, \"aead_key_random_size\") == 0)\n+\t\treturn parse_size(&options->aead_key_random_size, optarg);\n+\n+\n+\telse if (strcmp(lgopts[option_index].name, \"aead_iv\") == 0) {\n+\t\toptions->aead_iv_param = 1;\n+\t\toptions->aead_iv.length =\n+\t\t\tparse_key(options->aead_iv.data, optarg);\n+\t\tif (options->aead_iv.length > 0)\n+\t\t\treturn 0;\n+\t\telse\n+\t\t\treturn -1;\n+\t}\n+\n+\telse if (strcmp(lgopts[option_index].name, \"aead_iv_random_size\") == 0)\n+\t\treturn parse_size(&options->aead_iv_random_size, optarg);\n+\n \telse if (strcmp(lgopts[option_index].name, \"aad\") == 0) {\n \t\toptions->aad_param = 1;\n \t\toptions->aad.length =\n@@ -1291,13 +1414,25 @@ l2fwd_crypto_default_options(struct l2fwd_crypto_options *options)\n \toptions->auth_iv_param = 0;\n \toptions->auth_iv_random_size = -1;\n \toptions->auth_iv.length = 0;\n+\n+\toptions->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;\n+\toptions->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;\n+\n+\t/* AEAD Data */\n+\toptions->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;\n+\toptions->aead_xform.next = NULL;\n+\toptions->aead_key_param = 0;\n+\toptions->aead_key_random_size = -1;\n+\toptions->aead_xform.aead.key.length = 0;\n+\toptions->aead_iv_param = 0;\n+\toptions->aead_iv_random_size = -1;\n+\toptions->aead_iv.length = 0;\n+\n \toptions->aad_param = 0;\n \toptions->aad_random_size = -1;\n \toptions->aad.length = 0;\n-\toptions->digest_size = -1;\n \n-\toptions->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;\n-\toptions->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;\n+\toptions->digest_size = -1;\n \n \toptions->type = CDEV_TYPE_ANY;\n \toptions->cryptodev_mask = UINT64_MAX;\n@@ -1325,6 +1460,18 @@ display_auth_info(struct l2fwd_crypto_options *options)\n \t\t\toptions->auth_xform.auth.key.data,\n \t\t\toptions->auth_xform.auth.key.length);\n \trte_hexdump(stdout, \"IV:\", options->auth_iv.data, options->auth_iv.length);\n+}\n+\n+static void\n+display_aead_info(struct l2fwd_crypto_options *options)\n+{\n+\tprintf(\"\\n---- AEAD information ---\\n\");\n+\tprintf(\"Algorithm: %s\\n\",\n+\t\trte_crypto_aead_algorithm_strings[options->aead_xform.aead.algo]);\n+\trte_hexdump(stdout, \"AEAD key:\",\n+\t\t\toptions->aead_xform.aead.key.data,\n+\t\t\toptions->aead_xform.aead.key.length);\n+\trte_hexdump(stdout, \"IV:\", options->aead_iv.data, options->aead_iv.length);\n \trte_hexdump(stdout, \"AAD:\", options->aad.data, options->aad.length);\n }\n \n@@ -1333,6 +1480,7 @@ l2fwd_crypto_options_print(struct l2fwd_crypto_options *options)\n {\n \tchar string_cipher_op[MAX_STR_LEN];\n \tchar string_auth_op[MAX_STR_LEN];\n+\tchar string_aead_op[MAX_STR_LEN];\n \n \tif (options->cipher_xform.cipher.op == RTE_CRYPTO_CIPHER_OP_ENCRYPT)\n \t\tstrcpy(string_cipher_op, \"Encrypt\");\n@@ -1344,6 +1492,12 @@ l2fwd_crypto_options_print(struct l2fwd_crypto_options *options)\n \telse\n \t\tstrcpy(string_auth_op, \"Auth verify\");\n \n+\tif (options->aead_xform.aead.op == RTE_CRYPTO_AEAD_OP_ENCRYPT)\n+\t\tstrcpy(string_aead_op, \"Authenticated encryption\");\n+\telse\n+\t\tstrcpy(string_aead_op, \"Authenticated decryption\");\n+\n+\n \tprintf(\"Options:-\\nn\");\n \tprintf(\"portmask: %x\\n\", options->portmask);\n \tprintf(\"ports per lcore: %u\\n\", options->nb_ports_per_lcore);\n@@ -1373,6 +1527,10 @@ l2fwd_crypto_options_print(struct l2fwd_crypto_options *options)\n \n \tprintf(\"\\nCrypto chain: \");\n \tswitch (options->xform_chain) {\n+\tcase L2FWD_CRYPTO_AEAD:\n+\t\tprintf(\"Input --> %s --> Output\\n\", string_aead_op);\n+\t\tdisplay_aead_info(options);\n+\t\tbreak;\n \tcase L2FWD_CRYPTO_CIPHER_HASH:\n \t\tprintf(\"Input --> %s --> %s --> Output\\n\",\n \t\t\tstring_cipher_op, string_auth_op);\n@@ -1424,8 +1582,16 @@ l2fwd_crypto_parse_args(struct l2fwd_crypto_options *options,\n \t\t\t{ \"auth_iv\", required_argument, 0, 0 },\n \t\t\t{ \"auth_iv_random_size\", required_argument, 0, 0 },\n \n+\t\t\t{ \"aead_algo\", required_argument, 0, 0 },\n+\t\t\t{ \"aead_op\", required_argument, 0, 0 },\n+\t\t\t{ \"aead_key\", required_argument, 0, 0 },\n+\t\t\t{ \"aead_key_random_size\", required_argument, 0, 0 },\n+\t\t\t{ \"aead_iv\", required_argument, 0, 0 },\n+\t\t\t{ \"aead_iv_random_size\", required_argument, 0, 0 },\n+\n \t\t\t{ \"aad\", required_argument, 0, 0 },\n \t\t\t{ \"aad_random_size\", required_argument, 0, 0 },\n+\n \t\t\t{ \"digest_size\", required_argument, 0, 0 },\n \n \t\t\t{ \"sessionless\", no_argument, 0, 0 },\n@@ -1639,6 +1805,40 @@ check_device_support_auth_algo(const struct l2fwd_crypto_options *options,\n \treturn cap;\n }\n \n+static const struct rte_cryptodev_capabilities *\n+check_device_support_aead_algo(const struct l2fwd_crypto_options *options,\n+\t\tconst struct rte_cryptodev_info *dev_info,\n+\t\tuint8_t cdev_id)\n+{\n+\tunsigned int i = 0;\n+\tconst struct rte_cryptodev_capabilities *cap = &dev_info->capabilities[0];\n+\tenum rte_crypto_aead_algorithm cap_aead_algo;\n+\tenum rte_crypto_aead_algorithm opt_aead_algo =\n+\t\t\t\t\toptions->aead_xform.aead.algo;\n+\n+\twhile (cap->op != RTE_CRYPTO_OP_TYPE_UNDEFINED) {\n+\t\tcap_aead_algo = cap->sym.aead.algo;\n+\t\tif (cap->sym.xform_type == RTE_CRYPTO_SYM_XFORM_AEAD) {\n+\t\t\tif (cap_aead_algo == opt_aead_algo) {\n+\t\t\t\tif (check_type(options, dev_info) == 0)\n+\t\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\t\tcap = &dev_info->capabilities[++i];\n+\t}\n+\n+\tif (cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED) {\n+\t\tprintf(\"Algorithm %s not supported by cryptodev %u\"\n+\t\t\t\" or device not of preferred type (%s)\\n\",\n+\t\t\trte_crypto_aead_algorithm_strings[opt_aead_algo],\n+\t\t\tcdev_id,\n+\t\t\toptions->string_type);\n+\t\treturn NULL;\n+\t}\n+\n+\treturn cap;\n+}\n+\n /* Check if the device is enabled by cryptodev_mask */\n static int\n check_cryptodev_mask(struct l2fwd_crypto_options *options,\n@@ -1745,6 +1945,112 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,\n \n \t\trte_cryptodev_info_get(cdev_id, &dev_info);\n \n+\t\t/* Set AEAD parameters */\n+\t\tif (options->xform_chain == L2FWD_CRYPTO_AEAD) {\n+\t\t\t/* Check if device supports AEAD algo */\n+\t\t\tcap = check_device_support_aead_algo(options, &dev_info,\n+\t\t\t\t\t\t\tcdev_id);\n+\t\t\tif (cap == NULL)\n+\t\t\t\tcontinue;\n+\n+\t\t\toptions->block_size = cap->sym.aead.block_size;\n+\n+\t\t\tcheck_iv_param(&cap->sym.aead.iv_size,\n+\t\t\t\t\toptions->aead_iv_param,\n+\t\t\t\t\toptions->aead_iv_random_size,\n+\t\t\t\t\t&options->aead_iv.length);\n+\n+\t\t\t/*\n+\t\t\t * Check if length of provided AEAD key is supported\n+\t\t\t * by the algorithm chosen.\n+\t\t\t */\n+\t\t\tif (options->aead_key_param) {\n+\t\t\t\tif (check_supported_size(\n+\t\t\t\t\t\toptions->aead_xform.aead.key.length,\n+\t\t\t\t\t\tcap->sym.aead.key_size.min,\n+\t\t\t\t\t\tcap->sym.aead.key_size.max,\n+\t\t\t\t\t\tcap->sym.aead.key_size.increment)\n+\t\t\t\t\t\t\t!= 0) {\n+\t\t\t\t\tprintf(\"Unsupported aead key length\\n\");\n+\t\t\t\t\treturn -1;\n+\t\t\t\t}\n+\t\t\t/*\n+\t\t\t * Check if length of the aead key to be randomly generated\n+\t\t\t * is supported by the algorithm chosen.\n+\t\t\t */\n+\t\t\t} else if (options->aead_key_random_size != -1) {\n+\t\t\t\tif (check_supported_size(options->ckey_random_size,\n+\t\t\t\t\t\tcap->sym.aead.key_size.min,\n+\t\t\t\t\t\tcap->sym.aead.key_size.max,\n+\t\t\t\t\t\tcap->sym.aead.key_size.increment)\n+\t\t\t\t\t\t\t!= 0) {\n+\t\t\t\t\tprintf(\"Unsupported aead key length\\n\");\n+\t\t\t\t\treturn -1;\n+\t\t\t\t}\n+\t\t\t\toptions->aead_xform.aead.key.length =\n+\t\t\t\t\t\t\toptions->ckey_random_size;\n+\t\t\t/* No size provided, use minimum size. */\n+\t\t\t} else\n+\t\t\t\toptions->aead_xform.aead.key.length =\n+\t\t\t\t\t\tcap->sym.aead.key_size.min;\n+\n+\t\t\tif (!options->aead_key_param)\n+\t\t\t\tgenerate_random_key(\n+\t\t\t\t\toptions->aead_xform.aead.key.data,\n+\t\t\t\t\toptions->aead_xform.aead.key.length);\n+\n+\t\t\t/*\n+\t\t\t * Check if length of provided AAD is supported\n+\t\t\t * by the algorithm chosen.\n+\t\t\t */\n+\t\t\tif (options->aad_param) {\n+\t\t\t\tif (check_supported_size(options->aad.length,\n+\t\t\t\t\t\tcap->sym.aead.aad_size.min,\n+\t\t\t\t\t\tcap->sym.aead.aad_size.max,\n+\t\t\t\t\t\tcap->sym.aead.aad_size.increment)\n+\t\t\t\t\t\t\t!= 0) {\n+\t\t\t\t\tprintf(\"Unsupported AAD length\\n\");\n+\t\t\t\t\treturn -1;\n+\t\t\t\t}\n+\t\t\t/*\n+\t\t\t * Check if length of AAD to be randomly generated\n+\t\t\t * is supported by the algorithm chosen.\n+\t\t\t */\n+\t\t\t} else if (options->aad_random_size != -1) {\n+\t\t\t\tif (check_supported_size(options->aad_random_size,\n+\t\t\t\t\t\tcap->sym.aead.aad_size.min,\n+\t\t\t\t\t\tcap->sym.aead.aad_size.max,\n+\t\t\t\t\t\tcap->sym.aead.aad_size.increment)\n+\t\t\t\t\t\t\t!= 0) {\n+\t\t\t\t\tprintf(\"Unsupported AAD length\\n\");\n+\t\t\t\t\treturn -1;\n+\t\t\t\t}\n+\t\t\t\toptions->aad.length = options->aad_random_size;\n+\t\t\t/* No size provided, use minimum size. */\n+\t\t\t} else\n+\t\t\t\toptions->aad.length = cap->sym.auth.aad_size.min;\n+\n+\t\t\toptions->aead_xform.aead.add_auth_data_length =\n+\t\t\t\t\t\toptions->aad.length;\n+\n+\t\t\t/* Check if digest size is supported by the algorithm. */\n+\t\t\tif (options->digest_size != -1) {\n+\t\t\t\tif (check_supported_size(options->digest_size,\n+\t\t\t\t\t\tcap->sym.aead.digest_size.min,\n+\t\t\t\t\t\tcap->sym.aead.digest_size.max,\n+\t\t\t\t\t\tcap->sym.aead.digest_size.increment)\n+\t\t\t\t\t\t\t!= 0) {\n+\t\t\t\t\tprintf(\"Unsupported digest length\\n\");\n+\t\t\t\t\treturn -1;\n+\t\t\t\t}\n+\t\t\t\toptions->aead_xform.aead.digest_length =\n+\t\t\t\t\t\t\toptions->digest_size;\n+\t\t\t/* No size provided, use minimum size. */\n+\t\t\t} else\n+\t\t\t\toptions->aead_xform.aead.digest_length =\n+\t\t\t\t\t\tcap->sym.aead.digest_size.min;\n+\t\t}\n+\n \t\t/* Set cipher parameters */\n \t\tif (options->xform_chain == L2FWD_CRYPTO_CIPHER_HASH ||\n \t\t\t\toptions->xform_chain == L2FWD_CRYPTO_HASH_CIPHER ||\n@@ -1818,40 +2124,6 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,\n \t\t\t\t\toptions->auth_iv_random_size,\n \t\t\t\t\t&options->auth_iv.length);\n \t\t\t/*\n-\t\t\t * Check if length of provided AAD is supported\n-\t\t\t * by the algorithm chosen.\n-\t\t\t */\n-\t\t\tif (options->aad_param) {\n-\t\t\t\tif (check_supported_size(options->aad.length,\n-\t\t\t\t\t\tcap->sym.auth.aad_size.min,\n-\t\t\t\t\t\tcap->sym.auth.aad_size.max,\n-\t\t\t\t\t\tcap->sym.auth.aad_size.increment)\n-\t\t\t\t\t\t\t!= 0) {\n-\t\t\t\t\tprintf(\"Unsupported AAD length\\n\");\n-\t\t\t\t\treturn -1;\n-\t\t\t\t}\n-\t\t\t/*\n-\t\t\t * Check if length of AAD to be randomly generated\n-\t\t\t * is supported by the algorithm chosen.\n-\t\t\t */\n-\t\t\t} else if (options->aad_random_size != -1) {\n-\t\t\t\tif (check_supported_size(options->aad_random_size,\n-\t\t\t\t\t\tcap->sym.auth.aad_size.min,\n-\t\t\t\t\t\tcap->sym.auth.aad_size.max,\n-\t\t\t\t\t\tcap->sym.auth.aad_size.increment)\n-\t\t\t\t\t\t\t!= 0) {\n-\t\t\t\t\tprintf(\"Unsupported AAD length\\n\");\n-\t\t\t\t\treturn -1;\n-\t\t\t\t}\n-\t\t\t\toptions->aad.length = options->aad_random_size;\n-\t\t\t/* No size provided, use minimum size. */\n-\t\t\t} else\n-\t\t\t\toptions->aad.length = cap->sym.auth.aad_size.min;\n-\n-\t\t\toptions->auth_xform.auth.add_auth_data_length =\n-\t\t\t\t\t\toptions->aad.length;\n-\n-\t\t\t/*\n \t\t\t * Check if length of provided auth key is supported\n \t\t\t * by the algorithm chosen.\n \t\t\t */\n@@ -2052,12 +2324,16 @@ reserve_key_memory(struct l2fwd_crypto_options *options)\n \tif (options->cipher_xform.cipher.key.data == NULL)\n \t\trte_exit(EXIT_FAILURE, \"Failed to allocate memory for cipher key\");\n \n-\n \toptions->auth_xform.auth.key.data = rte_malloc(\"auth key\",\n \t\t\t\t\t\tMAX_KEY_SIZE, 0);\n \tif (options->auth_xform.auth.key.data == NULL)\n \t\trte_exit(EXIT_FAILURE, \"Failed to allocate memory for auth key\");\n \n+\toptions->aead_xform.aead.key.data = rte_malloc(\"aead key\",\n+\t\t\t\t\t\tMAX_KEY_SIZE, 0);\n+\tif (options->aead_xform.aead.key.data == NULL)\n+\t\trte_exit(EXIT_FAILURE, \"Failed to allocate memory for AEAD key\");\n+\n \toptions->cipher_iv.data = rte_malloc(\"cipher iv\", MAX_KEY_SIZE, 0);\n \tif (options->cipher_iv.data == NULL)\n \t\trte_exit(EXIT_FAILURE, \"Failed to allocate memory for cipher IV\");\n@@ -2066,6 +2342,10 @@ reserve_key_memory(struct l2fwd_crypto_options *options)\n \tif (options->auth_iv.data == NULL)\n \t\trte_exit(EXIT_FAILURE, \"Failed to allocate memory for auth IV\");\n \n+\toptions->aead_iv.data = rte_malloc(\"aead_iv\", MAX_KEY_SIZE, 0);\n+\tif (options->aead_iv.data == NULL)\n+\t\trte_exit(EXIT_FAILURE, \"Failed to allocate memory for AEAD iv\");\n+\n \toptions->aad.data = rte_malloc(\"aad\", MAX_KEY_SIZE, 0);\n \tif (options->aad.data == NULL)\n \t\trte_exit(EXIT_FAILURE, \"Failed to allocate memory for AAD\");\n",
    "prefixes": [
        "dpdk-dev",
        "v4",
        "24/26"
    ]
}