get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 45582,
    "url": "http://patches.dpdk.org/api/patches/45582/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180928122615.48390-6-roy.fan.zhang@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": "<20180928122615.48390-6-roy.fan.zhang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180928122615.48390-6-roy.fan.zhang@intel.com",
    "date": "2018-09-28T12:26:13",
    "name": "[v2,5/7] examples/ip_pipeline: update cli parsing",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "3fec5e9a14a3c2e5e0f8bbb3f1322580d5eec45f",
    "submitter": {
        "id": 304,
        "url": "http://patches.dpdk.org/api/people/304/?format=api",
        "name": "Fan Zhang",
        "email": "roy.fan.zhang@intel.com"
    },
    "delegate": {
        "id": 10018,
        "url": "http://patches.dpdk.org/api/users/10018/?format=api",
        "username": "cristian_dumitrescu",
        "first_name": "Cristian",
        "last_name": "Dumitrescu",
        "email": "cristian.dumitrescu@intel.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20180928122615.48390-6-roy.fan.zhang@intel.com/mbox/",
    "series": [
        {
            "id": 1572,
            "url": "http://patches.dpdk.org/api/series/1572/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1572",
            "date": "2018-09-28T12:26:08",
            "name": "pipeline: add symmetric crypto to action",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/1572/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/45582/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/45582/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 0B16A1B487;\n\tFri, 28 Sep 2018 14:41:51 +0200 (CEST)",
            "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n\tby dpdk.org (Postfix) with ESMTP id 61D131B43E\n\tfor <dev@dpdk.org>; Fri, 28 Sep 2018 14:41:36 +0200 (CEST)",
            "from orsmga007.jf.intel.com ([10.7.209.58])\n\tby fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t28 Sep 2018 05:41:33 -0700",
            "from silpixa00398673.ir.intel.com (HELO\n\tsilpixa00398673.ger.corp.intel.com) ([10.237.223.54])\n\tby orsmga007.jf.intel.com with ESMTP; 28 Sep 2018 05:41:24 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.54,314,1534834800\"; d=\"scan'208\";a=\"76853817\"",
        "From": "Fan Zhang <roy.fan.zhang@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "cristian.dumitrescu@intel.com,\n\t\"Zhang, Roy Fan\" <roy.fan.zhang@intel.com>, Zhang@dpdk.org",
        "Date": "Fri, 28 Sep 2018 13:26:13 +0100",
        "Message-Id": "<20180928122615.48390-6-roy.fan.zhang@intel.com>",
        "X-Mailer": "git-send-email 2.13.6",
        "In-Reply-To": "<20180928122615.48390-1-roy.fan.zhang@intel.com>",
        "References": "<20180828081929.34085-1-roy.fan.zhang@intel.com>\n\t<20180928122615.48390-1-roy.fan.zhang@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2 5/7] examples/ip_pipeline: update cli parsing",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: \"Zhang, Roy Fan\" <roy.fan.zhang@intel.com>\n\nThis patch updates the cli parsing of ip_pipeline application\nwith extra symmetric crypto, port, session, and action support.\n\nSigned-off-by: Zhang, Roy Fan <roy.fan.zhang@intel.com>\nAcked-by: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>\n---\n examples/ip_pipeline/cli.c | 577 ++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 575 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c\nindex 01c37691f..3ff7caaca 100644\n--- a/examples/ip_pipeline/cli.c\n+++ b/examples/ip_pipeline/cli.c\n@@ -12,6 +12,8 @@\n #include <rte_ethdev.h>\n \n #include \"cli.h\"\n+\n+#include \"cryptodev.h\"\n #include \"kni.h\"\n #include \"link.h\"\n #include \"mempool.h\"\n@@ -785,6 +787,65 @@ cmd_kni(char **tokens,\n \t}\n }\n \n+static const char cmd_cryptodev_help[] =\n+\"cryptodev <cryptodev_name>\\n\"\n+\"   dev <device_name> | dev_id <device_id>\\n\"\n+\"   queue <n_queues> <queue_size>\\n\";\n+\n+static void\n+cmd_cryptodev(char **tokens,\n+\tuint32_t n_tokens,\n+\tchar *out,\n+\tsize_t out_size)\n+{\n+\tstruct cryptodev_params params;\n+\tchar *name;\n+\n+\tmemset(&params, 0, sizeof(params));\n+\tif (n_tokens != 7) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tname = tokens[1];\n+\n+\tif (strcmp(tokens[2], \"dev\") == 0)\n+\t\tparams.dev_name = tokens[3];\n+\telse if (strcmp(tokens[2], \"dev_id\") == 0) {\n+\t\tif (parser_read_uint32(&params.dev_id, tokens[3]) < 0) {\n+\t\t\tsnprintf(out, out_size,\tMSG_ARG_INVALID,\n+\t\t\t\t\"dev_id\");\n+\t\t\treturn;\n+\t\t}\n+\t} else {\n+\t\tsnprintf(out, out_size,\tMSG_ARG_INVALID,\n+\t\t\t\"cryptodev\");\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[4], \"queue\")) {\n+\t\tsnprintf(out, out_size,\tMSG_ARG_NOT_FOUND,\n+\t\t\t\"4\");\n+\t\treturn;\n+\t}\n+\n+\tif (parser_read_uint32(&params.n_queues, tokens[5]) < 0) {\n+\t\tsnprintf(out, out_size,\tMSG_ARG_INVALID,\n+\t\t\t\"q\");\n+\t\treturn;\n+\t}\n+\n+\tif (parser_read_uint32(&params.queue_size, tokens[6]) < 0) {\n+\t\tsnprintf(out, out_size,\tMSG_ARG_INVALID,\n+\t\t\t\"queue_size\");\n+\t\treturn;\n+\t}\n+\n+\tif (cryptodev_create(name, &params) == NULL) {\n+\t\tsnprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);\n+\t\treturn;\n+\t}\n+}\n \n static const char cmd_port_in_action_profile_help[] =\n \"port in action profile <profile_name>\\n\"\n@@ -968,7 +1029,10 @@ static const char cmd_table_action_profile_help[] =\n \"   [ttl drop | fwd\\n\"\n \"       stats none | pkts]\\n\"\n \"   [stats pkts | bytes | both]\\n\"\n-\"   [time]\\n\";\n+\"   [time]\\n\"\n+\"   [sym_crypto dev <CRYPTODEV_NAME> offset <op_offset> \"\n+\"       mempool_create <mempool_name>\\n\"\n+\"       mempool_init <mempool_name>]\\n\";\n \n static void\n cmd_table_action_profile(char **tokens,\n@@ -1336,6 +1400,57 @@ cmd_table_action_profile(char **tokens,\n \t\tt0 += 1;\n \t} /* time */\n \n+\tif ((t0 < n_tokens) && (strcmp(tokens[t0], \"sym_crypto\") == 0)) {\n+\t\tstruct cryptodev *cryptodev;\n+\t\tstruct mempool *mempool;\n+\n+\t\tif (n_tokens < t0 + 9 ||\n+\t\t\t\tstrcmp(tokens[t0 + 1], \"dev\") ||\n+\t\t\t\tstrcmp(tokens[t0 + 3], \"offset\") ||\n+\t\t\t\tstrcmp(tokens[t0 + 5], \"mempool_create\") ||\n+\t\t\t\tstrcmp(tokens[t0 + 7], \"mempool_init\")) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH,\n+\t\t\t\t\"table action profile sym_crypto\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tcryptodev = cryptodev_find(tokens[t0 + 2]);\n+\t\tif (cryptodev == NULL) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID,\n+\t\t\t\t\"table action profile sym_crypto\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tp.sym_crypto.cryptodev_id = cryptodev->dev_id;\n+\n+\t\tif (parser_read_uint32(&p.sym_crypto.op_offset,\n+\t\t\t\ttokens[t0 + 4]) != 0) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID,\n+\t\t\t\t\t\"table action profile sym_crypto\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tmempool = mempool_find(tokens[t0 + 6]);\n+\t\tif (mempool == NULL) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID,\n+\t\t\t\t\"table action profile sym_crypto\");\n+\t\t\treturn;\n+\t\t}\n+\t\tp.sym_crypto.mp_create = mempool->m;\n+\n+\t\tmempool = mempool_find(tokens[t0 + 8]);\n+\t\tif (mempool == NULL) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID,\n+\t\t\t\t\"table action profile sym_crypto\");\n+\t\t\treturn;\n+\t\t}\n+\t\tp.sym_crypto.mp_init = mempool->m;\n+\n+\t\tp.action_mask |= 1LLU << RTE_TABLE_ACTION_SYM_CRYPTO;\n+\n+\t\tt0 += 9;\n+\t} /* sym_crypto */\n+\n \tif (t0 < n_tokens) {\n \t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n \t\treturn;\n@@ -1417,6 +1532,7 @@ static const char cmd_pipeline_port_in_help[] =\n \"   | tap <tap_name> mempool <mempool_name> mtu <mtu>\\n\"\n \"   | kni <kni_name>\\n\"\n \"   | source mempool <mempool_name> file <file_name> bpp <n_bytes_per_pkt>\\n\"\n+\"   | cryptodev <cryptodev_name> rxq <queue_id>\\n\"\n \"   [action <port_in_action_profile_name>]\\n\"\n \"   [disabled]\\n\";\n \n@@ -1589,6 +1705,26 @@ cmd_pipeline_port_in(char **tokens,\n \t\t}\n \n \t\tt0 += 7;\n+\t} else if (strcmp(tokens[t0], \"cryptodev\") == 0) {\n+\t\tif (n_tokens < t0 + 3) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH,\n+\t\t\t\t\"pipeline port in cryptodev\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tp.type = PORT_IN_CRYPTODEV;\n+\n+\t\tp.dev_name = tokens[t0 + 1];\n+\t\tif (parser_read_uint16(&p.rxq.queue_id, tokens[t0 + 3]) != 0) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID,\n+\t\t\t\t\"rxq\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tp.cryptodev.arg_callback = NULL;\n+\t\tp.cryptodev.f_callback = NULL;\n+\n+\t\tt0 += 4;\n \t} else {\n \t\tsnprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);\n \t\treturn;\n@@ -1635,7 +1771,8 @@ static const char cmd_pipeline_port_out_help[] =\n \"   | tmgr <tmgr_name>\\n\"\n \"   | tap <tap_name>\\n\"\n \"   | kni <kni_name>\\n\"\n-\"   | sink [file <file_name> pkts <max_n_pkts>]\\n\";\n+\"   | sink [file <file_name> pkts <max_n_pkts>]\\n\"\n+\"   | cryptodev <cryptodev_name> txq <txq_id> offset <crypto_op_offset>\\n\";\n \n static void\n cmd_pipeline_port_out(char **tokens,\n@@ -1769,6 +1906,41 @@ cmd_pipeline_port_out(char **tokens,\n \t\t\t\treturn;\n \t\t\t}\n \t\t}\n+\n+\t} else if (strcmp(tokens[6], \"cryptodev\") == 0) {\n+\t\tif (n_tokens != 12) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH,\n+\t\t\t\t\"pipeline port out cryptodev\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tp.type = PORT_OUT_CRYPTODEV;\n+\n+\t\tp.dev_name = tokens[7];\n+\n+\t\tif (strcmp(tokens[8], \"txq\")) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH,\n+\t\t\t\t\"pipeline port out cryptodev\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (parser_read_uint16(&p.cryptodev.queue_id, tokens[9])\n+\t\t\t\t!= 0) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"queue_id\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (strcmp(tokens[10], \"offset\")) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH,\n+\t\t\t\t\"pipeline port out cryptodev\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (parser_read_uint32(&p.cryptodev.op_offset, tokens[11])\n+\t\t\t\t!= 0) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"queue_id\");\n+\t\t\treturn;\n+\t\t}\n \t} else {\n \t\tsnprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);\n \t\treturn;\n@@ -2923,6 +3095,18 @@ parse_match(char **tokens,\n  *    [ttl dec | keep]\n  *    [stats]\n  *    [time]\n+ *    [sym_crypto\n+ *       encrypt | decrypt\n+ *       type\n+ *       | cipher\n+ *          cipher_algo <algo> cipher_key <key> cipher_iv <iv>\n+ *       | cipher_auth\n+ *          cipher_algo <algo> cipher_key <key> cipher_iv <iv>\n+ *          auth_algo <algo> auth_key <key> digest_size <size>\n+ *       | aead\n+ *          aead_algo <algo> aead_key <key> aead_iv <iv> aead_aad <aad>\n+ *          digest_size <size>\n+ *       data_offset <data_offset>]\n  *\n  * where:\n  *    <pa> ::= g | y | r | drop\n@@ -3521,6 +3705,368 @@ parse_table_action_time(char **tokens,\n \treturn 1;\n }\n \n+static void\n+parse_free_sym_crypto_param_data(struct rte_table_action_sym_crypto_params *p)\n+{\n+\tstruct rte_crypto_sym_xform *xform[2] = {NULL};\n+\tuint32_t i;\n+\n+\txform[0] = p->xform;\n+\tif (xform[0])\n+\t\txform[1] = xform[0]->next;\n+\n+\tfor (i = 0; i < 2; i++) {\n+\t\tif (xform[i] == NULL)\n+\t\t\tcontinue;\n+\n+\t\tswitch (xform[i]->type) {\n+\t\tcase RTE_CRYPTO_SYM_XFORM_CIPHER:\n+\t\t\tif (xform[i]->cipher.key.data)\n+\t\t\t\tfree(xform[i]->cipher.key.data);\n+\t\t\tif (p->cipher_auth.cipher_iv.val)\n+\t\t\t\tfree(p->cipher_auth.cipher_iv.val);\n+\t\t\tif (p->cipher_auth.cipher_iv_update.val)\n+\t\t\t\tfree(p->cipher_auth.cipher_iv_update.val);\n+\t\t\tbreak;\n+\t\tcase RTE_CRYPTO_SYM_XFORM_AUTH:\n+\t\t\tif (xform[i]->auth.key.data)\n+\t\t\t\tfree(xform[i]->cipher.key.data);\n+\t\t\tif (p->cipher_auth.auth_iv.val)\n+\t\t\t\tfree(p->cipher_auth.cipher_iv.val);\n+\t\t\tif (p->cipher_auth.auth_iv_update.val)\n+\t\t\t\tfree(p->cipher_auth.cipher_iv_update.val);\n+\t\t\tbreak;\n+\t\tcase RTE_CRYPTO_SYM_XFORM_AEAD:\n+\t\t\tif (xform[i]->aead.key.data)\n+\t\t\t\tfree(xform[i]->cipher.key.data);\n+\t\t\tif (p->aead.iv.val)\n+\t\t\t\tfree(p->aead.iv.val);\n+\t\t\tif (p->aead.aad.val)\n+\t\t\t\tfree(p->aead.aad.val);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tcontinue;\n+\t\t}\n+\t}\n+\n+}\n+\n+static struct rte_crypto_sym_xform *\n+parse_table_action_cipher(struct rte_table_action_sym_crypto_params *p,\n+\t\tchar **tokens, uint32_t n_tokens, uint32_t encrypt,\n+\t\tuint32_t *used_n_tokens)\n+{\n+\tstruct rte_crypto_sym_xform *xform_cipher;\n+\tint status;\n+\tsize_t len;\n+\n+\tif (n_tokens < 7 || strcmp(tokens[1], \"cipher_algo\") ||\n+\t\t\tstrcmp(tokens[3], \"cipher_key\") ||\n+\t\t\tstrcmp(tokens[5], \"cipher_iv\"))\n+\t\treturn NULL;\n+\n+\txform_cipher = calloc(1, sizeof(*xform_cipher));\n+\tif (xform_cipher == NULL)\n+\t\treturn NULL;\n+\n+\txform_cipher->type = RTE_CRYPTO_SYM_XFORM_CIPHER;\n+\txform_cipher->cipher.op = encrypt ? RTE_CRYPTO_CIPHER_OP_ENCRYPT :\n+\t\t\tRTE_CRYPTO_CIPHER_OP_DECRYPT;\n+\n+\t/* cipher_algo */\n+\tstatus = rte_cryptodev_get_cipher_algo_enum(\n+\t\t\t&xform_cipher->cipher.algo, tokens[2]);\n+\tif (status < 0)\n+\t\tgoto error_exit;\n+\n+\t/* cipher_key */\n+\tlen = strlen(tokens[4]);\n+\txform_cipher->cipher.key.data = calloc(1, len / 2 + 1);\n+\tif (xform_cipher->cipher.key.data == NULL)\n+\t\tgoto error_exit;\n+\n+\tstatus = parse_hex_string(tokens[4],\n+\t\t\txform_cipher->cipher.key.data,\n+\t\t\t(uint32_t *)&len);\n+\tif (status < 0)\n+\t\tgoto error_exit;\n+\n+\txform_cipher->cipher.key.length = (uint16_t)len;\n+\n+\t/* cipher_iv */\n+\tlen = strlen(tokens[6]);\n+\n+\tp->cipher_auth.cipher_iv.val = calloc(1, len / 2 + 1);\n+\tif (p->cipher_auth.cipher_iv.val == NULL)\n+\t\tgoto error_exit;\n+\n+\tstatus = parse_hex_string(tokens[6],\n+\t\t\tp->cipher_auth.cipher_iv.val,\n+\t\t\t(uint32_t *)&len);\n+\tif (status < 0)\n+\t\tgoto error_exit;\n+\n+\txform_cipher->cipher.iv.length = (uint16_t)len;\n+\txform_cipher->cipher.iv.offset = RTE_TABLE_ACTION_SYM_CRYPTO_IV_OFFSET;\n+\tp->cipher_auth.cipher_iv.length = (uint32_t)len;\n+\t*used_n_tokens = 7;\n+\n+\treturn xform_cipher;\n+\n+error_exit:\n+\tif (xform_cipher->cipher.key.data)\n+\t\tfree(xform_cipher->cipher.key.data);\n+\n+\tif (p->cipher_auth.cipher_iv.val) {\n+\t\tfree(p->cipher_auth.cipher_iv.val);\n+\t\tp->cipher_auth.cipher_iv.val = NULL;\n+\t}\n+\n+\tfree(xform_cipher);\n+\n+\treturn NULL;\n+}\n+\n+static struct rte_crypto_sym_xform *\n+parse_table_action_cipher_auth(struct rte_table_action_sym_crypto_params *p,\n+\t\tchar **tokens, uint32_t n_tokens, uint32_t encrypt,\n+\t\tuint32_t *used_n_tokens)\n+{\n+\tstruct rte_crypto_sym_xform *xform_cipher;\n+\tstruct rte_crypto_sym_xform *xform_auth;\n+\tint status;\n+\tsize_t len;\n+\n+\tif (n_tokens < 13 ||\n+\t\t\tstrcmp(tokens[7], \"auth_algo\") ||\n+\t\t\tstrcmp(tokens[9], \"auth_key\") ||\n+\t\t\tstrcmp(tokens[11], \"digest_size\"))\n+\t\treturn NULL;\n+\n+\txform_auth = calloc(1, sizeof(*xform_auth));\n+\tif (xform_auth == NULL)\n+\t\treturn NULL;\n+\n+\txform_auth->type = RTE_CRYPTO_SYM_XFORM_AUTH;\n+\txform_auth->auth.op = encrypt ? RTE_CRYPTO_AUTH_OP_GENERATE :\n+\t\t\tRTE_CRYPTO_AUTH_OP_VERIFY;\n+\n+\t/* auth_algo */\n+\tstatus = rte_cryptodev_get_auth_algo_enum(&xform_auth->auth.algo,\n+\t\t\ttokens[8]);\n+\tif (status < 0)\n+\t\tgoto error_exit;\n+\n+\t/* auth_key */\n+\tlen = strlen(tokens[10]);\n+\txform_auth->auth.key.data = calloc(1, len / 2 + 1);\n+\tif (xform_auth->auth.key.data == NULL)\n+\t\tgoto error_exit;\n+\n+\tstatus = parse_hex_string(tokens[10],\n+\t\t\txform_auth->auth.key.data, (uint32_t *)&len);\n+\tif (status < 0)\n+\t\tgoto error_exit;\n+\n+\txform_auth->auth.key.length = (uint16_t)len;\n+\n+\tif (strcmp(tokens[11], \"digest_size\"))\n+\t\tgoto error_exit;\n+\n+\tstatus = parser_read_uint16(&xform_auth->auth.digest_length,\n+\t\t\ttokens[12]);\n+\tif (status < 0)\n+\t\tgoto error_exit;\n+\n+\txform_cipher = parse_table_action_cipher(p, tokens, 7, encrypt,\n+\t\t\tused_n_tokens);\n+\tif (xform_cipher == NULL)\n+\t\tgoto error_exit;\n+\n+\t*used_n_tokens += 6;\n+\n+\tif (encrypt) {\n+\t\txform_cipher->next = xform_auth;\n+\t\treturn xform_cipher;\n+\t} else {\n+\t\txform_auth->next = xform_cipher;\n+\t\treturn xform_auth;\n+\t}\n+\n+error_exit:\n+\tif (xform_auth->auth.key.data)\n+\t\tfree(xform_auth->auth.key.data);\n+\tif (p->cipher_auth.auth_iv.val) {\n+\t\tfree(p->cipher_auth.auth_iv.val);\n+\t\tp->cipher_auth.auth_iv.val = 0;\n+\t}\n+\n+\tfree(xform_auth);\n+\n+\treturn NULL;\n+}\n+\n+static struct rte_crypto_sym_xform *\n+parse_table_action_aead(struct rte_table_action_sym_crypto_params *p,\n+\t\tchar **tokens, uint32_t n_tokens, uint32_t encrypt,\n+\t\tuint32_t *used_n_tokens)\n+{\n+\tstruct rte_crypto_sym_xform *xform_aead;\n+\tint status;\n+\tsize_t len;\n+\n+\tif (n_tokens < 11 || strcmp(tokens[1], \"aead_algo\") ||\n+\t\t\tstrcmp(tokens[3], \"aead_key\") ||\n+\t\t\tstrcmp(tokens[5], \"aead_iv\") ||\n+\t\t\tstrcmp(tokens[7], \"aead_aad\") ||\n+\t\t\tstrcmp(tokens[9], \"digest_size\"))\n+\t\treturn NULL;\n+\n+\txform_aead = calloc(1, sizeof(*xform_aead));\n+\tif (xform_aead == NULL)\n+\t\treturn NULL;\n+\n+\txform_aead->type = RTE_CRYPTO_SYM_XFORM_AEAD;\n+\txform_aead->aead.op = encrypt ? RTE_CRYPTO_AEAD_OP_ENCRYPT :\n+\t\t\tRTE_CRYPTO_AEAD_OP_DECRYPT;\n+\n+\t/* aead_algo */\n+\tstatus = rte_cryptodev_get_aead_algo_enum(&xform_aead->aead.algo,\n+\t\t\ttokens[2]);\n+\tif (status < 0)\n+\t\tgoto error_exit;\n+\n+\t/* aead_key */\n+\tlen = strlen(tokens[4]);\n+\txform_aead->aead.key.data = calloc(1, len / 2 + 1);\n+\tif (xform_aead->aead.key.data == NULL)\n+\t\tgoto error_exit;\n+\n+\tstatus = parse_hex_string(tokens[4], xform_aead->aead.key.data,\n+\t\t\t(uint32_t *)&len);\n+\tif (status < 0)\n+\t\tgoto error_exit;\n+\n+\txform_aead->aead.key.length = (uint16_t)len;\n+\n+\t/* aead_iv */\n+\tlen = strlen(tokens[6]);\n+\tp->aead.iv.val = calloc(1, len / 2 + 1);\n+\tif (p->aead.iv.val == NULL)\n+\t\tgoto error_exit;\n+\n+\tstatus = parse_hex_string(tokens[6], p->aead.iv.val,\n+\t\t\t(uint32_t *)&len);\n+\tif (status < 0)\n+\t\tgoto error_exit;\n+\n+\txform_aead->aead.iv.length = (uint16_t)len;\n+\txform_aead->aead.iv.offset = RTE_TABLE_ACTION_SYM_CRYPTO_IV_OFFSET;\n+\tp->aead.iv.length = (uint32_t)len;\n+\n+\t/* aead_aad */\n+\tlen = strlen(tokens[8]);\n+\tp->aead.aad.val = calloc(1, len / 2 + 1);\n+\tif (p->aead.aad.val == NULL)\n+\t\tgoto error_exit;\n+\n+\tstatus = parse_hex_string(tokens[8], p->aead.aad.val, (uint32_t *)&len);\n+\tif (status < 0)\n+\t\tgoto error_exit;\n+\n+\txform_aead->aead.aad_length = (uint16_t)len;\n+\tp->aead.aad.length = (uint32_t)len;\n+\n+\t/* digest_size */\n+\tstatus = parser_read_uint16(&xform_aead->aead.digest_length,\n+\t\t\ttokens[10]);\n+\tif (status < 0)\n+\t\tgoto error_exit;\n+\n+\t*used_n_tokens = 11;\n+\n+\treturn xform_aead;\n+\n+error_exit:\n+\tif (xform_aead->aead.key.data)\n+\t\tfree(xform_aead->aead.key.data);\n+\tif (p->aead.iv.val) {\n+\t\tfree(p->aead.iv.val);\n+\t\tp->aead.iv.val = NULL;\n+\t}\n+\tif (p->aead.aad.val) {\n+\t\tfree(p->aead.aad.val);\n+\t\tp->aead.aad.val = NULL;\n+\t}\n+\n+\tfree(xform_aead);\n+\n+\treturn NULL;\n+}\n+\n+\n+static uint32_t\n+parse_table_action_sym_crypto(char **tokens,\n+\tuint32_t n_tokens,\n+\tstruct table_rule_action *a)\n+{\n+\tstruct rte_table_action_sym_crypto_params *p = &a->sym_crypto;\n+\tstruct rte_crypto_sym_xform *xform = NULL;\n+\tuint32_t used_n_tokens;\n+\tuint32_t encrypt;\n+\tint status;\n+\n+\tif ((n_tokens < 12) ||\n+\t\tstrcmp(tokens[0], \"sym_crypto\") ||\n+\t\tstrcmp(tokens[2], \"type\"))\n+\t\treturn 0;\n+\n+\tmemset(p, 0, sizeof(*p));\n+\n+\tif (strcmp(tokens[1], \"encrypt\") == 0)\n+\t\tencrypt = 1;\n+\telse\n+\t\tencrypt = 0;\n+\n+\tstatus = parser_read_uint32(&p->data_offset, tokens[n_tokens - 1]);\n+\tif (status < 0)\n+\t\treturn 0;\n+\n+\tif (strcmp(tokens[3], \"cipher\") == 0) {\n+\t\ttokens += 3;\n+\t\tn_tokens -= 3;\n+\n+\t\txform = parse_table_action_cipher(p, tokens, n_tokens, encrypt,\n+\t\t\t\t&used_n_tokens);\n+\t} else if (strcmp(tokens[3], \"cipher_auth\") == 0) {\n+\t\ttokens += 3;\n+\t\tn_tokens -= 3;\n+\n+\t\txform = parse_table_action_cipher_auth(p, tokens, n_tokens,\n+\t\t\t\tencrypt, &used_n_tokens);\n+\t} else if (strcmp(tokens[3], \"aead\") == 0) {\n+\t\ttokens += 3;\n+\t\tn_tokens -= 3;\n+\n+\t\txform = parse_table_action_aead(p, tokens, n_tokens, encrypt,\n+\t\t\t\t&used_n_tokens);\n+\t}\n+\n+\tif (xform == NULL)\n+\t\treturn 0;\n+\n+\tp->xform = xform;\n+\n+\tif (strcmp(tokens[used_n_tokens], \"data_offset\")) {\n+\t\tparse_free_sym_crypto_param_data(p);\n+\t\treturn 0;\n+\t}\n+\n+\ta->action_mask |= 1 << RTE_TABLE_ACTION_SYM_CRYPTO;\n+\n+\treturn used_n_tokens + 5;\n+}\n+\n static uint32_t\n parse_table_action(char **tokens,\n \tuint32_t n_tokens,\n@@ -3665,6 +4211,20 @@ parse_table_action(char **tokens,\n \t\tn_tokens -= n;\n \t}\n \n+\tif (n_tokens && (strcmp(tokens[0], \"sym_crypto\") == 0)) {\n+\t\tuint32_t n;\n+\n+\t\tn = parse_table_action_sym_crypto(tokens, n_tokens, a);\n+\t\tif (n == 0) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID,\n+\t\t\t\t\"action sym_crypto\");\n+\t\t\treturn 0;\n+\t\t}\n+\n+\t\ttokens += n;\n+\t\tn_tokens -= n;\n+\t}\n+\n \tif (n_tokens0 - n_tokens == 1) {\n \t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"action\");\n \t\treturn 0;\n@@ -3752,6 +4312,9 @@ cmd_pipeline_table_rule_add(char **tokens,\n \t\tsnprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);\n \t\treturn;\n \t}\n+\n+\tif (a.action_mask & 1 << RTE_TABLE_ACTION_SYM_CRYPTO)\n+\t\tparse_free_sym_crypto_param_data(&a.sym_crypto);\n }\n \n \n@@ -4743,6 +5306,11 @@ cmd_help(char **tokens, uint32_t n_tokens, char *out, size_t out_size)\n \t\treturn;\n \t}\n \n+\tif (strcmp(tokens[0], \"cryptodev\") == 0) {\n+\t\tsnprintf(out, out_size, \"\\n%s\\n\", cmd_cryptodev_help);\n+\t\treturn;\n+\t}\n+\n \tif ((n_tokens == 4) &&\n \t\t(strcmp(tokens[0], \"port\") == 0) &&\n \t\t(strcmp(tokens[1], \"in\") == 0) &&\n@@ -5033,6 +5601,11 @@ cli_process(char *in, char *out, size_t out_size)\n \t\treturn;\n \t}\n \n+\tif (strcmp(tokens[0], \"cryptodev\") == 0) {\n+\t\tcmd_cryptodev(tokens, n_tokens, out, out_size);\n+\t\treturn;\n+\t}\n+\n \tif (strcmp(tokens[0], \"port\") == 0) {\n \t\tcmd_port_in_action_profile(tokens, n_tokens, out, out_size);\n \t\treturn;\n",
    "prefixes": [
        "v2",
        "5/7"
    ]
}