get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 76971,
    "url": "http://patches.dpdk.org/api/patches/76971/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200908201830.74206-39-cristian.dumitrescu@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": "<20200908201830.74206-39-cristian.dumitrescu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200908201830.74206-39-cristian.dumitrescu@intel.com",
    "date": "2020-09-08T20:18:27",
    "name": "[v3,38/41] examples/pipeline: add configuration commands",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "2dcadd6ff329b5de84031a9859d91611af335a69",
    "submitter": {
        "id": 19,
        "url": "http://patches.dpdk.org/api/people/19/?format=api",
        "name": "Cristian Dumitrescu",
        "email": "cristian.dumitrescu@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200908201830.74206-39-cristian.dumitrescu@intel.com/mbox/",
    "series": [
        {
            "id": 12034,
            "url": "http://patches.dpdk.org/api/series/12034/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=12034",
            "date": "2020-09-08T20:17:52",
            "name": "Pipeline alignment with the P4 language",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/12034/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/76971/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/76971/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 3AD55A04B1;\n\tTue,  8 Sep 2020 22:25:09 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 53BB91C0D2;\n\tTue,  8 Sep 2020 22:19:49 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n by dpdk.org (Postfix) with ESMTP id 257001C19F\n for <dev@dpdk.org>; Tue,  8 Sep 2020 22:19:11 +0200 (CEST)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 08 Sep 2020 13:19:11 -0700",
            "from silpixa00400573.ir.intel.com (HELO\n silpixa00400573.ger.corp.intel.com) ([10.237.223.107])\n by fmsmga006.fm.intel.com with ESMTP; 08 Sep 2020 13:19:10 -0700"
        ],
        "IronPort-SDR": [
            "\n YCGze8bnBRHuhoCuueLat3Y+1MiQlPPlkj/ZEzcchp3LKQjUizB+yDhzK4/CnRFUpUpgf+nyW9\n 8PFsYlbeEIhw==",
            "\n nWqHmhkiPR6KWo9NvzGJIc5RdBrqdOrFsP1gOgOy4PF+NW3FAwyqvj+FBqcAvvHoEBXQJavk2R\n JVN07DmZvpvg=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9738\"; a=\"145939460\"",
            "E=Sophos;i=\"5.76,407,1592895600\"; d=\"scan'208\";a=\"145939460\"",
            "E=Sophos;i=\"5.76,406,1592895600\"; d=\"scan'208\";a=\"504493563\""
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "From": "Cristian Dumitrescu <cristian.dumitrescu@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Tue,  8 Sep 2020 21:18:27 +0100",
        "Message-Id": "<20200908201830.74206-39-cristian.dumitrescu@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20200908201830.74206-1-cristian.dumitrescu@intel.com>",
        "References": "<20200907214032.95052-2-cristian.dumitrescu@intel.com>\n <20200908201830.74206-1-cristian.dumitrescu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v3 38/41] examples/pipeline: add configuration\n\tcommands",
        "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 <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",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add CLI commands for application configuration and query.\n\nSigned-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\n---\n examples/pipeline/Makefile    |    1 +\n examples/pipeline/cli.c       | 1400 +++++++++++++++++++++++++++++++++\n examples/pipeline/cli.h       |   19 +\n examples/pipeline/main.c      |   11 +-\n examples/pipeline/meson.build |    1 +\n 5 files changed, 1431 insertions(+), 1 deletion(-)\n create mode 100644 examples/pipeline/cli.c\n create mode 100644 examples/pipeline/cli.h",
    "diff": "diff --git a/examples/pipeline/Makefile b/examples/pipeline/Makefile\nindex 2cb5edc1a..ff32ad19b 100644\n--- a/examples/pipeline/Makefile\n+++ b/examples/pipeline/Makefile\n@@ -5,6 +5,7 @@\n APP = pipeline\n \n # all source are stored in SRCS-y\n+SRCS-y += cli.c\n SRCS-y += conn.c\n SRCS-y += main.c\n SRCS-y += obj.c\ndiff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c\nnew file mode 100644\nindex 000000000..7a1863ee7\n--- /dev/null\n+++ b/examples/pipeline/cli.c\n@@ -0,0 +1,1400 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2010-2020 Intel Corporation\n+ */\n+\n+#include <stdio.h>\n+#include <stdint.h>\n+#include <stdlib.h>\n+#include <string.h>\n+\n+#include <rte_common.h>\n+#include <rte_ethdev.h>\n+#include <rte_swx_port_ethdev.h>\n+#include <rte_swx_port_source_sink.h>\n+#include <rte_swx_pipeline.h>\n+#include <rte_swx_ctl.h>\n+\n+#include \"cli.h\"\n+\n+#include \"obj.h\"\n+#include \"thread.h\"\n+\n+#ifndef CMD_MAX_TOKENS\n+#define CMD_MAX_TOKENS     256\n+#endif\n+\n+#define MSG_OUT_OF_MEMORY   \"Not enough memory.\\n\"\n+#define MSG_CMD_UNKNOWN     \"Unknown command \\\"%s\\\".\\n\"\n+#define MSG_CMD_UNIMPLEM    \"Command \\\"%s\\\" not implemented.\\n\"\n+#define MSG_ARG_NOT_ENOUGH  \"Not enough arguments for command \\\"%s\\\".\\n\"\n+#define MSG_ARG_TOO_MANY    \"Too many arguments for command \\\"%s\\\".\\n\"\n+#define MSG_ARG_MISMATCH    \"Wrong number of arguments for command \\\"%s\\\".\\n\"\n+#define MSG_ARG_NOT_FOUND   \"Argument \\\"%s\\\" not found.\\n\"\n+#define MSG_ARG_INVALID     \"Invalid value for argument \\\"%s\\\".\\n\"\n+#define MSG_FILE_ERR        \"Error in file \\\"%s\\\" at line %u.\\n\"\n+#define MSG_FILE_NOT_ENOUGH \"Not enough rules in file \\\"%s\\\".\\n\"\n+#define MSG_CMD_FAIL        \"Command \\\"%s\\\" failed.\\n\"\n+\n+#define skip_white_spaces(pos)\t\t\t\\\n+({\t\t\t\t\t\t\\\n+\t__typeof__(pos) _p = (pos);\t\t\\\n+\tfor ( ; isspace(*_p); _p++)\t\t\\\n+\t\t;\t\t\t\t\\\n+\t_p;\t\t\t\t\t\\\n+})\n+\n+static int\n+parser_read_uint64(uint64_t *value, const char *p)\n+{\n+\tchar *next;\n+\tuint64_t val;\n+\n+\tp = skip_white_spaces(p);\n+\tif (!isdigit(*p))\n+\t\treturn -EINVAL;\n+\n+\tval = strtoul(p, &next, 10);\n+\tif (p == next)\n+\t\treturn -EINVAL;\n+\n+\tp = next;\n+\tswitch (*p) {\n+\tcase 'T':\n+\t\tval *= 1024ULL;\n+\t\t/* fall through */\n+\tcase 'G':\n+\t\tval *= 1024ULL;\n+\t\t/* fall through */\n+\tcase 'M':\n+\t\tval *= 1024ULL;\n+\t\t/* fall through */\n+\tcase 'k':\n+\tcase 'K':\n+\t\tval *= 1024ULL;\n+\t\tp++;\n+\t\tbreak;\n+\t}\n+\n+\tp = skip_white_spaces(p);\n+\tif (*p != '\\0')\n+\t\treturn -EINVAL;\n+\n+\t*value = val;\n+\treturn 0;\n+}\n+\n+static int\n+parser_read_uint32(uint32_t *value, const char *p)\n+{\n+\tuint64_t val = 0;\n+\tint ret = parser_read_uint64(&val, p);\n+\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tif (val > UINT32_MAX)\n+\t\treturn -ERANGE;\n+\n+\t*value = val;\n+\treturn 0;\n+}\n+\n+static int\n+parser_read_uint16(uint16_t *value, const char *p)\n+{\n+\tuint64_t val = 0;\n+\tint ret = parser_read_uint64(&val, p);\n+\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tif (val > UINT16_MAX)\n+\t\treturn -ERANGE;\n+\n+\t*value = val;\n+\treturn 0;\n+}\n+\n+#define PARSE_DELIMITER \" \\f\\n\\r\\t\\v\"\n+\n+static int\n+parse_tokenize_string(char *string, char *tokens[], uint32_t *n_tokens)\n+{\n+\tuint32_t i;\n+\n+\tif ((string == NULL) ||\n+\t\t(tokens == NULL) ||\n+\t\t(*n_tokens < 1))\n+\t\treturn -EINVAL;\n+\n+\tfor (i = 0; i < *n_tokens; i++) {\n+\t\ttokens[i] = strtok_r(string, PARSE_DELIMITER, &string);\n+\t\tif (tokens[i] == NULL)\n+\t\t\tbreak;\n+\t}\n+\n+\tif ((i == *n_tokens) && strtok_r(string, PARSE_DELIMITER, &string))\n+\t\treturn -E2BIG;\n+\n+\t*n_tokens = i;\n+\treturn 0;\n+}\n+\n+static int\n+is_comment(char *in)\n+{\n+\tif ((strlen(in) && index(\"!#%;\", in[0])) ||\n+\t\t(strncmp(in, \"//\", 2) == 0) ||\n+\t\t(strncmp(in, \"--\", 2) == 0))\n+\t\treturn 1;\n+\n+\treturn 0;\n+}\n+\n+static const char cmd_mempool_help[] =\n+\"mempool <mempool_name>\\n\"\n+\"   buffer <buffer_size>\\n\"\n+\"   pool <pool_size>\\n\"\n+\"   cache <cache_size>\\n\"\n+\"   cpu <cpu_id>\\n\";\n+\n+static void\n+cmd_mempool(char **tokens,\n+\tuint32_t n_tokens,\n+\tchar *out,\n+\tsize_t out_size,\n+\tvoid *obj)\n+{\n+\tstruct mempool_params p;\n+\tchar *name;\n+\tstruct mempool *mempool;\n+\n+\tif (n_tokens != 10) {\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], \"buffer\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"buffer\");\n+\t\treturn;\n+\t}\n+\n+\tif (parser_read_uint32(&p.buffer_size, tokens[3]) != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"buffer_size\");\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[4], \"pool\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"pool\");\n+\t\treturn;\n+\t}\n+\n+\tif (parser_read_uint32(&p.pool_size, tokens[5]) != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"pool_size\");\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[6], \"cache\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"cache\");\n+\t\treturn;\n+\t}\n+\n+\tif (parser_read_uint32(&p.cache_size, tokens[7]) != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"cache_size\");\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[8], \"cpu\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"cpu\");\n+\t\treturn;\n+\t}\n+\n+\tif (parser_read_uint32(&p.cpu_id, tokens[9]) != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"cpu_id\");\n+\t\treturn;\n+\t}\n+\n+\tmempool = mempool_create(obj, name, &p);\n+\tif (mempool == NULL) {\n+\t\tsnprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);\n+\t\treturn;\n+\t}\n+}\n+\n+static const char cmd_link_help[] =\n+\"link <link_name>\\n\"\n+\"   dev <device_name> | port <port_id>\\n\"\n+\"   rxq <n_queues> <queue_size> <mempool_name>\\n\"\n+\"   txq <n_queues> <queue_size>\\n\"\n+\"   promiscuous on | off\\n\"\n+\"   [rss <qid_0> ... <qid_n>]\\n\";\n+\n+static void\n+cmd_link(char **tokens,\n+\tuint32_t n_tokens,\n+\tchar *out,\n+\tsize_t out_size,\n+\tvoid *obj)\n+{\n+\tstruct link_params p;\n+\tstruct link_params_rss rss;\n+\tstruct link *link;\n+\tchar *name;\n+\n+\tmemset(&p, 0, sizeof(p));\n+\n+\tif ((n_tokens < 13) || (n_tokens > 14 + LINK_RXQ_RSS_MAX)) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+\tname = tokens[1];\n+\n+\tif (strcmp(tokens[2], \"dev\") == 0)\n+\t\tp.dev_name = tokens[3];\n+\telse if (strcmp(tokens[2], \"port\") == 0) {\n+\t\tp.dev_name = NULL;\n+\n+\t\tif (parser_read_uint16(&p.port_id, tokens[3]) != 0) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"port_id\");\n+\t\t\treturn;\n+\t\t}\n+\t} else {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"dev or port\");\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[4], \"rxq\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"rxq\");\n+\t\treturn;\n+\t}\n+\n+\tif (parser_read_uint32(&p.rx.n_queues, tokens[5]) != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"n_queues\");\n+\t\treturn;\n+\t}\n+\tif (parser_read_uint32(&p.rx.queue_size, tokens[6]) != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"queue_size\");\n+\t\treturn;\n+\t}\n+\n+\tp.rx.mempool_name = tokens[7];\n+\n+\tif (strcmp(tokens[8], \"txq\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"txq\");\n+\t\treturn;\n+\t}\n+\n+\tif (parser_read_uint32(&p.tx.n_queues, tokens[9]) != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"n_queues\");\n+\t\treturn;\n+\t}\n+\n+\tif (parser_read_uint32(&p.tx.queue_size, tokens[10]) != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"queue_size\");\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[11], \"promiscuous\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"promiscuous\");\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[12], \"on\") == 0)\n+\t\tp.promiscuous = 1;\n+\telse if (strcmp(tokens[12], \"off\") == 0)\n+\t\tp.promiscuous = 0;\n+\telse {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"on or off\");\n+\t\treturn;\n+\t}\n+\n+\t/* RSS */\n+\tp.rx.rss = NULL;\n+\tif (n_tokens > 13) {\n+\t\tuint32_t queue_id, i;\n+\n+\t\tif (strcmp(tokens[13], \"rss\") != 0) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"rss\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tp.rx.rss = &rss;\n+\n+\t\trss.n_queues = 0;\n+\t\tfor (i = 14; i < n_tokens; i++) {\n+\t\t\tif (parser_read_uint32(&queue_id, tokens[i]) != 0) {\n+\t\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID,\n+\t\t\t\t\t\"queue_id\");\n+\t\t\t\treturn;\n+\t\t\t}\n+\n+\t\t\trss.queue_id[rss.n_queues] = queue_id;\n+\t\t\trss.n_queues++;\n+\t\t}\n+\t}\n+\n+\tlink = link_create(obj, name, &p);\n+\tif (link == NULL) {\n+\t\tsnprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);\n+\t\treturn;\n+\t}\n+}\n+\n+/* Print the link stats and info */\n+static void\n+print_link_info(struct link *link, char *out, size_t out_size)\n+{\n+\tstruct rte_eth_stats stats;\n+\tstruct rte_ether_addr mac_addr;\n+\tstruct rte_eth_link eth_link;\n+\tuint16_t mtu;\n+\tint ret;\n+\n+\tmemset(&stats, 0, sizeof(stats));\n+\trte_eth_stats_get(link->port_id, &stats);\n+\n+\tret = rte_eth_macaddr_get(link->port_id, &mac_addr);\n+\tif (ret != 0) {\n+\t\tsnprintf(out, out_size, \"\\n%s: MAC address get failed: %s\",\n+\t\t\t link->name, rte_strerror(-ret));\n+\t\treturn;\n+\t}\n+\n+\tret = rte_eth_link_get(link->port_id, &eth_link);\n+\tif (ret < 0) {\n+\t\tsnprintf(out, out_size, \"\\n%s: link get failed: %s\",\n+\t\t\t link->name, rte_strerror(-ret));\n+\t\treturn;\n+\t}\n+\n+\trte_eth_dev_get_mtu(link->port_id, &mtu);\n+\n+\tsnprintf(out, out_size,\n+\t\t\"\\n\"\n+\t\t\"%s: flags=<%s> mtu %u\\n\"\n+\t\t\"\\tether %02X:%02X:%02X:%02X:%02X:%02X rxqueues %u txqueues %u\\n\"\n+\t\t\"\\tport# %u  speed %u Mbps\\n\"\n+\t\t\"\\tRX packets %\" PRIu64\"  bytes %\" PRIu64\"\\n\"\n+\t\t\"\\tRX errors %\" PRIu64\"  missed %\" PRIu64\"  no-mbuf %\" PRIu64\"\\n\"\n+\t\t\"\\tTX packets %\" PRIu64\"  bytes %\" PRIu64\"\\n\"\n+\t\t\"\\tTX errors %\" PRIu64\"\\n\",\n+\t\tlink->name,\n+\t\teth_link.link_status == 0 ? \"DOWN\" : \"UP\",\n+\t\tmtu,\n+\t\tmac_addr.addr_bytes[0], mac_addr.addr_bytes[1],\n+\t\tmac_addr.addr_bytes[2], mac_addr.addr_bytes[3],\n+\t\tmac_addr.addr_bytes[4], mac_addr.addr_bytes[5],\n+\t\tlink->n_rxq,\n+\t\tlink->n_txq,\n+\t\tlink->port_id,\n+\t\teth_link.link_speed,\n+\t\tstats.ipackets,\n+\t\tstats.ibytes,\n+\t\tstats.ierrors,\n+\t\tstats.imissed,\n+\t\tstats.rx_nombuf,\n+\t\tstats.opackets,\n+\t\tstats.obytes,\n+\t\tstats.oerrors);\n+}\n+\n+/*\n+ * link show [<link_name>]\n+ */\n+static void\n+cmd_link_show(char **tokens,\n+\t      uint32_t n_tokens,\n+\t      char *out,\n+\t      size_t out_size,\n+\t      void *obj)\n+{\n+\tstruct link *link;\n+\tchar *link_name;\n+\n+\tif (n_tokens != 2 && n_tokens != 3) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tif (n_tokens == 2) {\n+\t\tlink = link_next(obj, NULL);\n+\n+\t\twhile (link != NULL) {\n+\t\t\tout_size = out_size - strlen(out);\n+\t\t\tout = &out[strlen(out)];\n+\n+\t\t\tprint_link_info(link, out, out_size);\n+\t\t\tlink = link_next(obj, link);\n+\t\t}\n+\t} else {\n+\t\tout_size = out_size - strlen(out);\n+\t\tout = &out[strlen(out)];\n+\n+\t\tlink_name = tokens[2];\n+\t\tlink = link_find(obj, link_name);\n+\n+\t\tif (link == NULL) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID,\n+\t\t\t\t\t\"Link does not exist\");\n+\t\t\treturn;\n+\t\t}\n+\t\tprint_link_info(link, out, out_size);\n+\t}\n+}\n+\n+static const char cmd_pipeline_create_help[] =\n+\"pipeline <pipeline_name> create <numa_node>\\n\";\n+\n+static void\n+cmd_pipeline_create(char **tokens,\n+\tuint32_t n_tokens,\n+\tchar *out,\n+\tsize_t out_size,\n+\tvoid *obj)\n+{\n+\tstruct pipeline *p;\n+\tchar *name;\n+\tuint32_t numa_node;\n+\n+\tif (n_tokens != 4) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tname = tokens[1];\n+\n+\tif (parser_read_uint32(&numa_node, tokens[3]) != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"numa_node\");\n+\t\treturn;\n+\t}\n+\n+\tp = pipeline_create(obj, name, (int)numa_node);\n+\tif (!p) {\n+\t\tsnprintf(out, out_size, \"pipeline create error.\");\n+\t\treturn;\n+\t}\n+}\n+\n+static const char cmd_pipeline_port_in_help[] =\n+\"pipeline <pipeline_name> port in <port_id>\\n\"\n+\"   link <link_name> rxq <queue_id> bsz <burst_size>\\n\"\n+\"   source <mempool_name> <fie_name>\\n\";\n+\n+static void\n+cmd_pipeline_port_in(char **tokens,\n+\tuint32_t n_tokens,\n+\tchar *out,\n+\tsize_t out_size,\n+\tvoid *obj)\n+{\n+\tstruct pipeline *p;\n+\tint status;\n+\tuint32_t port_id = 0, t0;\n+\n+\tif (n_tokens < 6) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tp = pipeline_find(obj, tokens[1]);\n+\tif (!p || p->ctl) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[2], \"port\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"port\");\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[3], \"in\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"in\");\n+\t\treturn;\n+\t}\n+\n+\tif (parser_read_uint32(&port_id, tokens[4]) != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"port_id\");\n+\t\treturn;\n+\t}\n+\n+\tt0 = 5;\n+\n+\tif (strcmp(tokens[t0], \"link\") == 0) {\n+\t\tstruct rte_swx_port_ethdev_reader_params params;\n+\t\tstruct link *link;\n+\n+\t\tif (n_tokens < t0 + 6) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH,\n+\t\t\t\t\"pipeline port in link\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tlink = link_find(obj, tokens[t0 + 1]);\n+\t\tif (!link) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID,\n+\t\t\t\t\"link_name\");\n+\t\t\treturn;\n+\t\t}\n+\t\tparams.dev_name = link->dev_name;\n+\n+\t\tif (strcmp(tokens[t0 + 2], \"rxq\") != 0) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"rxq\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (parser_read_uint16(&params.queue_id, tokens[t0 + 3]) != 0) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID,\n+\t\t\t\t\"queue_id\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (strcmp(tokens[t0 + 4], \"bsz\") != 0) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"bsz\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (parser_read_uint32(&params.burst_size, tokens[t0 + 5])) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID,\n+\t\t\t\t\"burst_size\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tt0 += 6;\n+\n+\t\tstatus = rte_swx_pipeline_port_in_config(p->p,\n+\t\t\tport_id,\n+\t\t\t\"ethdev\",\n+\t\t\t&params);\n+\t} else if (strcmp(tokens[t0], \"source\") == 0) {\n+\t\tstruct rte_swx_port_source_params params;\n+\t\tstruct mempool *mp;\n+\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 source\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tmp = mempool_find(obj, tokens[t0 + 1]);\n+\t\tif (!mp) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID,\n+\t\t\t\t\"mempool_name\");\n+\t\t\treturn;\n+\t\t}\n+\t\tparams.pool = mp->m;\n+\n+\t\tparams.file_name = tokens[t0 + 2];\n+\n+\t\tt0 += 3;\n+\n+\t\tstatus = rte_swx_pipeline_port_in_config(p->p,\n+\t\t\tport_id,\n+\t\t\t\"source\",\n+\t\t\t&params);\n+\t} else {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tif (status) {\n+\t\tsnprintf(out, out_size, \"port in error.\");\n+\t\treturn;\n+\t}\n+\n+\tif (n_tokens != t0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+}\n+\n+static const char cmd_pipeline_port_out_help[] =\n+\"pipeline <pipeline_name> port out <port_id>\\n\"\n+\"   link <link_name> txq <txq_id> bsz <burst_size>\\n\"\n+\"   | sink <file_name> | none\\n\";\n+\n+static void\n+cmd_pipeline_port_out(char **tokens,\n+\tuint32_t n_tokens,\n+\tchar *out,\n+\tsize_t out_size,\n+\tvoid *obj)\n+{\n+\tstruct pipeline *p;\n+\tint status;\n+\tuint32_t port_id = 0, t0;\n+\n+\tif (n_tokens < 6) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tp = pipeline_find(obj, tokens[1]);\n+\tif (!p || p->ctl) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[2], \"port\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"port\");\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[3], \"out\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"out\");\n+\t\treturn;\n+\t}\n+\n+\tif (parser_read_uint32(&port_id, tokens[4]) != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"port_id\");\n+\t\treturn;\n+\t}\n+\n+\tt0 = 5;\n+\n+\tif (strcmp(tokens[t0], \"link\") == 0) {\n+\t\tstruct rte_swx_port_ethdev_writer_params params;\n+\t\tstruct link *link;\n+\n+\t\tif (n_tokens < t0 + 6) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH,\n+\t\t\t\t\"pipeline port out link\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tlink = link_find(obj, tokens[t0 + 1]);\n+\t\tif (!link) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID,\n+\t\t\t\t\"link_name\");\n+\t\t\treturn;\n+\t\t}\n+\t\tparams.dev_name = link->dev_name;\n+\n+\t\tif (strcmp(tokens[t0 + 2], \"txq\") != 0) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"txq\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (parser_read_uint16(&params.queue_id, tokens[t0 + 3]) != 0) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID,\n+\t\t\t\t\"queue_id\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (strcmp(tokens[t0 + 4], \"bsz\") != 0) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"bsz\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (parser_read_uint32(&params.burst_size, tokens[t0 + 5])) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID,\n+\t\t\t\t\"burst_size\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tt0 += 6;\n+\n+\t\tstatus = rte_swx_pipeline_port_out_config(p->p,\n+\t\t\tport_id,\n+\t\t\t\"ethdev\",\n+\t\t\t&params);\n+\t} else if (strcmp(tokens[t0], \"sink\") == 0) {\n+\t\tstruct rte_swx_port_sink_params params;\n+\n+\t\tparams.file_name = strcmp(tokens[t0 + 1], \"none\") ?\n+\t\t\ttokens[t0 + 1] : NULL;\n+\n+\t\tt0 += 2;\n+\n+\t\tstatus = rte_swx_pipeline_port_out_config(p->p,\n+\t\t\tport_id,\n+\t\t\t\"sink\",\n+\t\t\t&params);\n+\t} else {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tif (status) {\n+\t\tsnprintf(out, out_size, \"port out error.\");\n+\t\treturn;\n+\t}\n+\n+\tif (n_tokens != t0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+}\n+\n+static const char cmd_pipeline_build_help[] =\n+\"pipeline <pipeline_name> build <spec_file>\\n\";\n+\n+static void\n+cmd_pipeline_build(char **tokens,\n+\tuint32_t n_tokens,\n+\tchar *out,\n+\tsize_t out_size,\n+\tvoid *obj)\n+{\n+\tstruct pipeline *p = NULL;\n+\tFILE *spec = NULL;\n+\tuint32_t err_line;\n+\tconst char *err_msg;\n+\tint status;\n+\n+\tif (n_tokens != 4) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tp = pipeline_find(obj, tokens[1]);\n+\tif (!p || p->ctl) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tspec = fopen(tokens[3], \"r\");\n+\tif (!spec) {\n+\t\tsnprintf(out, out_size, \"Cannot open file %s.\\n\", tokens[3]);\n+\t\treturn;\n+\t}\n+\n+\tstatus = rte_swx_pipeline_build_from_spec(p->p,\n+\t\tspec,\n+\t\t&err_line,\n+\t\t&err_msg);\n+\tfclose(spec);\n+\tif (status) {\n+\t\tsnprintf(out, out_size, \"Error %d at line %u: %s\\n.\",\n+\t\t\tstatus, err_line, err_msg);\n+\t\treturn;\n+\t}\n+\n+\tp->ctl = rte_swx_ctl_pipeline_create(p->p);\n+\tif (!p->ctl) {\n+\t\tsnprintf(out, out_size, \"Pipeline control create failed.\");\n+\t\trte_swx_pipeline_free(p->p);\n+\t\treturn;\n+\t}\n+}\n+\n+static const char cmd_pipeline_table_update_help[] =\n+\"pipeline <pipeline_name> table <table_name> update <file_name_add> \"\n+\"<file_name_delete> <file_name_default>\";\n+\n+static void\n+cmd_pipeline_table_update(char **tokens,\n+\tuint32_t n_tokens,\n+\tchar *out,\n+\tsize_t out_size,\n+\tvoid *obj)\n+{\n+\tstruct pipeline *p;\n+\tchar *pipeline_name, *table_name, *line = NULL;\n+\tchar *file_name_add, *file_name_delete, *file_name_default;\n+\tFILE *file_add = NULL, *file_delete = NULL, *file_default = NULL;\n+\tuint32_t line_id;\n+\tint status;\n+\n+\tif (n_tokens != 8) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tpipeline_name = tokens[1];\n+\tp = pipeline_find(obj, pipeline_name);\n+\tif (!p || !p->ctl) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"pipeline_name\");\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[2], \"table\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"table\");\n+\t\treturn;\n+\t}\n+\n+\ttable_name = tokens[3];\n+\n+\tif (strcmp(tokens[4], \"update\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"update\");\n+\t\treturn;\n+\t}\n+\n+\tfile_name_add = tokens[5];\n+\tfile_name_delete = tokens[6];\n+\tfile_name_default = tokens[7];\n+\n+\t/* File open. */\n+\tif (strcmp(file_name_add, \"none\")) {\n+\t\tfile_add = fopen(file_name_add, \"r\");\n+\t\tif (!file_add) {\n+\t\t\tsnprintf(out, out_size, \"Cannot open file %s\",\n+\t\t\t\tfile_name_add);\n+\t\t\tgoto error;\n+\t\t}\n+\t}\n+\n+\tif (strcmp(file_name_delete, \"none\")) {\n+\t\tfile_add = fopen(file_name_delete, \"r\");\n+\t\tif (!file_add) {\n+\t\t\tsnprintf(out, out_size, \"Cannot open file %s\",\n+\t\t\t\tfile_name_delete);\n+\t\t\tgoto error;\n+\t\t}\n+\t}\n+\n+\tif (strcmp(file_name_default, \"none\")) {\n+\t\tfile_add = fopen(file_name_default, \"r\");\n+\t\tif (!file_add) {\n+\t\t\tsnprintf(out, out_size, \"Cannot open file %s\",\n+\t\t\t\tfile_name_default);\n+\t\t\tgoto error;\n+\t\t}\n+\t}\n+\n+\tif (!file_add && !file_delete && !file_default) {\n+\t\tsnprintf(out, out_size, \"Nothing to be done.\");\n+\t\treturn;\n+\t}\n+\n+\t/* Buffer allocation. */\n+\tline = malloc(2048);\n+\tif (!line) {\n+\t\tsnprintf(out, out_size, MSG_OUT_OF_MEMORY);\n+\t\tgoto error;\n+\t}\n+\n+\t/* Add. */\n+\tif (file_add) {\n+\t\tfor (line_id = 1; ; line_id++) {\n+\t\t\tstruct rte_swx_table_entry *entry;\n+\n+\t\t\tif (fgets(line, 2048, file_add) == NULL)\n+\t\t\t\tbreak;\n+\n+\t\t\tentry = rte_swx_ctl_pipeline_table_entry_read(p->ctl,\n+\t\t\t\ttable_name,\n+\t\t\t\tline);\n+\t\t\tif (!entry) {\n+\t\t\t\tsnprintf(out, out_size, MSG_FILE_ERR,\n+\t\t\t\t\tfile_name_add, line_id);\n+\t\t\t\tgoto error;\n+\t\t\t}\n+\n+\t\t\tstatus = rte_swx_ctl_pipeline_table_entry_add(p->ctl,\n+\t\t\t\ttable_name,\n+\t\t\t\tentry);\n+\t\t\tif (status) {\n+\t\t\t\tsnprintf(out, out_size,\n+\t\t\t\t\t\"Invalid entry in file %s at line %u\",\n+\t\t\t\t\tfile_name_add, line_id);\n+\t\t\t\tgoto error;\n+\t\t\t}\n+\t\t}\n+\n+\t\tfclose(file_add);\n+\t}\n+\n+\t/* Delete. */\n+\tif (file_delete) {\n+\t\tfor (line_id = 1; ; line_id++) {\n+\t\t\tstruct rte_swx_table_entry *entry;\n+\n+\t\t\tif (fgets(line, 2048, file_delete) == NULL)\n+\t\t\t\tbreak;\n+\n+\t\t\tentry = rte_swx_ctl_pipeline_table_entry_read(p->ctl,\n+\t\t\t\ttable_name,\n+\t\t\t\tline);\n+\t\t\tif (!entry) {\n+\t\t\t\tsnprintf(out, out_size, MSG_FILE_ERR,\n+\t\t\t\t\tfile_name_delete, line_id);\n+\t\t\t\tgoto error;\n+\t\t\t}\n+\n+\t\t\tstatus = rte_swx_ctl_pipeline_table_entry_delete(p->ctl,\n+\t\t\t\ttable_name,\n+\t\t\t\tentry);\n+\t\t\tif (status)  {\n+\t\t\t\tsnprintf(out, out_size,\n+\t\t\t\t\t\"Invalid entry in file %s at line %u\",\n+\t\t\t\t\tfile_name_delete, line_id);\n+\t\t\t\tgoto error;\n+\t\t\t}\n+\t\t}\n+\n+\t\tfclose(file_delete);\n+\t}\n+\n+\t/* Default. */\n+\tif (file_default) {\n+\t\tfor (line_id = 1; ; line_id++) {\n+\t\t\tstruct rte_swx_table_entry *entry;\n+\n+\t\t\tif (fgets(line, 2048, file_default) == NULL)\n+\t\t\t\tbreak;\n+\n+\t\t\tentry = rte_swx_ctl_pipeline_table_entry_read(p->ctl,\n+\t\t\t\ttable_name,\n+\t\t\t\tline);\n+\t\t\tif (!entry) {\n+\t\t\t\tsnprintf(out, out_size, MSG_FILE_ERR,\n+\t\t\t\t\tfile_name_default, line_id);\n+\t\t\t\tgoto error;\n+\t\t\t}\n+\n+\t\t\tstatus = rte_swx_ctl_pipeline_table_default_entry_add(p->ctl,\n+\t\t\t\ttable_name,\n+\t\t\t\tentry);\n+\t\t\tif (status) {\n+\t\t\t\tsnprintf(out, out_size,\n+\t\t\t\t\t\"Invalid entry in file %s at line %u\",\n+\t\t\t\t\tfile_name_default, line_id);\n+\t\t\t\tgoto error;\n+\t\t\t}\n+\t\t}\n+\n+\t\tfclose(file_default);\n+\t}\n+\n+\tstatus = rte_swx_ctl_pipeline_commit(p->ctl, 1);\n+\tif (status) {\n+\t\tsnprintf(out, out_size, \"Commit failed.\");\n+\t\tgoto error;\n+\t}\n+\n+\tfree(line);\n+\n+\trte_swx_ctl_pipeline_table_fprintf(stdout, p->ctl, table_name);\n+\n+\treturn;\n+\n+error:\n+\trte_swx_ctl_pipeline_abort(p->ctl);\n+\tfree(line);\n+\tif (file_add)\n+\t\tfclose(file_add);\n+\tif (file_delete)\n+\t\tfclose(file_delete);\n+\tif (file_default)\n+\t\tfclose(file_default);\n+}\n+\n+static const char cmd_pipeline_stats_help[] =\n+\"pipeline <pipeline_name> stats\\n\";\n+\n+static void\n+cmd_pipeline_stats(char **tokens,\n+\tuint32_t n_tokens,\n+\tchar *out,\n+\tsize_t out_size,\n+\tvoid *obj)\n+{\n+\tstruct rte_swx_ctl_pipeline_info info;\n+\tstruct pipeline *p;\n+\tuint32_t i;\n+\tint status;\n+\n+\tif (n_tokens != 3) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tp = pipeline_find(obj, tokens[1]);\n+\tif (!p || !p->ctl) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"pipeline_name\");\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[2], \"stats\")) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"stats\");\n+\t\treturn;\n+\t}\n+\n+\tstatus = rte_swx_ctl_pipeline_info_get(p->p, &info);\n+\tif (status) {\n+\t\tsnprintf(out, out_size, \"Pipeline info get error.\");\n+\t\treturn;\n+\t}\n+\n+\tsnprintf(out, out_size, \"Input ports:\\n\");\n+\tout_size -= strlen(out);\n+\tout += strlen(out);\n+\n+\tfor (i = 0; i < info.n_ports_in; i++) {\n+\t\tstruct rte_swx_port_in_stats stats;\n+\n+\t\trte_swx_ctl_pipeline_port_in_stats_read(p->p, i, &stats);\n+\n+\t\tsnprintf(out, out_size, \"\\tPort %u:\"\n+\t\t\t\" packets %\" PRIu64\n+\t\t\t\" bytes %\" PRIu64\n+\t\t\t\" empty %\" PRIu64 \"\\n\",\n+\t\t\ti, stats.n_pkts, stats.n_bytes, stats.n_empty);\n+\t\tout_size -= strlen(out);\n+\t\tout += strlen(out);\n+\t}\n+\n+\tsnprintf(out, out_size, \"Output ports:\\n\");\n+\tout_size -= strlen(out);\n+\tout += strlen(out);\n+\n+\tfor (i = 0; i < info.n_ports_out; i++) {\n+\t\tstruct rte_swx_port_out_stats stats;\n+\n+\t\trte_swx_ctl_pipeline_port_out_stats_read(p->p, i, &stats);\n+\n+\t\tsnprintf(out, out_size, \"\\tPort %u:\"\n+\t\t\t\" packets %\" PRIu64\n+\t\t\t\" bytes %\" PRIu64 \"\\n\",\n+\t\t\ti, stats.n_pkts, stats.n_bytes);\n+\t\tout_size -= strlen(out);\n+\t\tout += strlen(out);\n+\t}\n+}\n+\n+static const char cmd_thread_pipeline_enable_help[] =\n+\"thread <thread_id> pipeline <pipeline_name> enable\\n\";\n+\n+static void\n+cmd_thread_pipeline_enable(char **tokens,\n+\tuint32_t n_tokens,\n+\tchar *out,\n+\tsize_t out_size,\n+\tvoid *obj)\n+{\n+\tchar *pipeline_name;\n+\tstruct pipeline *p;\n+\tuint32_t thread_id;\n+\tint status;\n+\n+\tif (n_tokens != 5) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tif (parser_read_uint32(&thread_id, tokens[1]) != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"thread_id\");\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[2], \"pipeline\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"pipeline\");\n+\t\treturn;\n+\t}\n+\n+\tpipeline_name = tokens[3];\n+\tp = pipeline_find(obj, pipeline_name);\n+\tif (!p || !p->ctl) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"pipeline_name\");\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[4], \"enable\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"enable\");\n+\t\treturn;\n+\t}\n+\n+\tstatus = thread_pipeline_enable(thread_id, obj, pipeline_name);\n+\tif (status) {\n+\t\tsnprintf(out, out_size, MSG_CMD_FAIL, \"thread pipeline enable\");\n+\t\treturn;\n+\t}\n+}\n+\n+static const char cmd_thread_pipeline_disable_help[] =\n+\"thread <thread_id> pipeline <pipeline_name> disable\\n\";\n+\n+static void\n+cmd_thread_pipeline_disable(char **tokens,\n+\tuint32_t n_tokens,\n+\tchar *out,\n+\tsize_t out_size,\n+\tvoid *obj)\n+{\n+\tstruct pipeline *p;\n+\tchar *pipeline_name;\n+\tuint32_t thread_id;\n+\tint status;\n+\n+\tif (n_tokens != 5) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tif (parser_read_uint32(&thread_id, tokens[1]) != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"thread_id\");\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[2], \"pipeline\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"pipeline\");\n+\t\treturn;\n+\t}\n+\n+\tpipeline_name = tokens[3];\n+\tp = pipeline_find(obj, pipeline_name);\n+\tif (!p || !p->ctl) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"pipeline_name\");\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[4], \"disable\") != 0) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"disable\");\n+\t\treturn;\n+\t}\n+\n+\tstatus = thread_pipeline_disable(thread_id, obj, pipeline_name);\n+\tif (status) {\n+\t\tsnprintf(out, out_size, MSG_CMD_FAIL,\n+\t\t\t\"thread pipeline disable\");\n+\t\treturn;\n+\t}\n+}\n+\n+static void\n+cmd_help(char **tokens,\n+\t uint32_t n_tokens,\n+\t char *out,\n+\t size_t out_size,\n+\t void *arg __rte_unused)\n+{\n+\ttokens++;\n+\tn_tokens--;\n+\n+\tif (n_tokens == 0) {\n+\t\tsnprintf(out, out_size,\n+\t\t\t\"Type 'help <command>' for command details.\\n\\n\");\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[0], \"mempool\") == 0) {\n+\t\tsnprintf(out, out_size, \"\\n%s\\n\", cmd_mempool_help);\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[0], \"link\") == 0) {\n+\t\tsnprintf(out, out_size, \"\\n%s\\n\", cmd_link_help);\n+\t\treturn;\n+\t}\n+\n+\tif ((strcmp(tokens[0], \"pipeline\") == 0) &&\n+\t\t((n_tokens == 1) && (strcmp(tokens[2], \"create\")) == 0)) {\n+\t\tsnprintf(out, out_size, \"\\n%s\\n\", cmd_pipeline_create_help);\n+\t\treturn;\n+\t}\n+\n+\tif ((strcmp(tokens[0], \"pipeline\") == 0) &&\n+\t\t(strcmp(tokens[1], \"port\") == 0)) {\n+\t\tif ((n_tokens == 3) && (strcmp(tokens[2], \"in\")) == 0) {\n+\t\t\tsnprintf(out, out_size, \"\\n%s\\n\",\n+\t\t\t\tcmd_pipeline_port_in_help);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif ((n_tokens == 3) && (strcmp(tokens[2], \"out\")) == 0) {\n+\t\t\tsnprintf(out, out_size, \"\\n%s\\n\",\n+\t\t\t\tcmd_pipeline_port_out_help);\n+\t\t\treturn;\n+\t\t}\n+\t}\n+\n+\tif ((strcmp(tokens[0], \"pipeline\") == 0) &&\n+\t\t((n_tokens >= 2) && (strcmp(tokens[2], \"build\")) == 0)) {\n+\t\tsnprintf(out, out_size, \"\\n%s\\n\", cmd_pipeline_build_help);\n+\t\treturn;\n+\t}\n+\n+\tif ((strcmp(tokens[0], \"pipeline\") == 0) &&\n+\t\t((n_tokens >= 2) && (strcmp(tokens[2], \"table\")) == 0)) {\n+\t\tsnprintf(out, out_size, \"\\n%s\\n\",\n+\t\t\tcmd_pipeline_table_update_help);\n+\t\treturn;\n+\t}\n+\n+\tif ((strcmp(tokens[0], \"pipeline\") == 0) &&\n+\t\t((n_tokens >= 2) && (strcmp(tokens[2], \"stats\")) == 0)) {\n+\t\tsnprintf(out, out_size, \"\\n%s\\n\", cmd_pipeline_stats_help);\n+\t\treturn;\n+\t}\n+\n+\tif ((n_tokens == 3) &&\n+\t\t(strcmp(tokens[0], \"thread\") == 0) &&\n+\t\t(strcmp(tokens[1], \"pipeline\") == 0)) {\n+\t\tif (strcmp(tokens[2], \"enable\") == 0) {\n+\t\t\tsnprintf(out, out_size, \"\\n%s\\n\",\n+\t\t\t\tcmd_thread_pipeline_enable_help);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (strcmp(tokens[2], \"disable\") == 0) {\n+\t\t\tsnprintf(out, out_size, \"\\n%s\\n\",\n+\t\t\t\tcmd_thread_pipeline_disable_help);\n+\t\t\treturn;\n+\t\t}\n+\t}\n+\n+\tsnprintf(out, out_size, \"Invalid command\\n\");\n+}\n+\n+void\n+cli_process(char *in, char *out, size_t out_size, void *obj)\n+{\n+\tchar *tokens[CMD_MAX_TOKENS];\n+\tuint32_t n_tokens = RTE_DIM(tokens);\n+\tint status;\n+\n+\tif (is_comment(in))\n+\t\treturn;\n+\n+\tstatus = parse_tokenize_string(in, tokens, &n_tokens);\n+\tif (status) {\n+\t\tsnprintf(out, out_size, MSG_ARG_TOO_MANY, \"\");\n+\t\treturn;\n+\t}\n+\n+\tif (n_tokens == 0)\n+\t\treturn;\n+\n+\tif (strcmp(tokens[0], \"help\") == 0) {\n+\t\tcmd_help(tokens, n_tokens, out, out_size, obj);\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[0], \"mempool\") == 0) {\n+\t\tcmd_mempool(tokens, n_tokens, out, out_size, obj);\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[0], \"link\") == 0) {\n+\t\tif (strcmp(tokens[1], \"show\") == 0) {\n+\t\t\tcmd_link_show(tokens, n_tokens, out, out_size, obj);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tcmd_link(tokens, n_tokens, out, out_size, obj);\n+\t\treturn;\n+\t}\n+\n+\tif (strcmp(tokens[0], \"pipeline\") == 0) {\n+\t\tif ((n_tokens >= 3) &&\n+\t\t\t(strcmp(tokens[2], \"create\") == 0)) {\n+\t\t\tcmd_pipeline_create(tokens, n_tokens, out, out_size,\n+\t\t\t\tobj);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif ((n_tokens >= 4) &&\n+\t\t\t(strcmp(tokens[2], \"port\") == 0) &&\n+\t\t\t(strcmp(tokens[3], \"in\") == 0)) {\n+\t\t\tcmd_pipeline_port_in(tokens, n_tokens, out, out_size,\n+\t\t\t\tobj);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif ((n_tokens >= 4) &&\n+\t\t\t(strcmp(tokens[2], \"port\") == 0) &&\n+\t\t\t(strcmp(tokens[3], \"out\") == 0)) {\n+\t\t\tcmd_pipeline_port_out(tokens, n_tokens, out, out_size,\n+\t\t\t\tobj);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif ((n_tokens >= 3) &&\n+\t\t\t(strcmp(tokens[2], \"build\") == 0)) {\n+\t\t\tcmd_pipeline_build(tokens, n_tokens, out, out_size,\n+\t\t\t\tobj);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif ((n_tokens >= 3) &&\n+\t\t\t(strcmp(tokens[2], \"table\") == 0)) {\n+\t\t\tcmd_pipeline_table_update(tokens, n_tokens, out,\n+\t\t\t\tout_size, obj);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif ((n_tokens >= 3) &&\n+\t\t\t(strcmp(tokens[2], \"stats\") == 0)) {\n+\t\t\tcmd_pipeline_stats(tokens, n_tokens, out, out_size,\n+\t\t\t\tobj);\n+\t\t\treturn;\n+\t\t}\n+\t}\n+\n+\tif (strcmp(tokens[0], \"thread\") == 0) {\n+\t\tif ((n_tokens >= 5) &&\n+\t\t\t(strcmp(tokens[4], \"enable\") == 0)) {\n+\t\t\tcmd_thread_pipeline_enable(tokens, n_tokens,\n+\t\t\t\tout, out_size, obj);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif ((n_tokens >= 5) &&\n+\t\t\t(strcmp(tokens[4], \"disable\") == 0)) {\n+\t\t\tcmd_thread_pipeline_disable(tokens, n_tokens,\n+\t\t\t\tout, out_size, obj);\n+\t\t\treturn;\n+\t\t}\n+\t}\n+\n+\tsnprintf(out, out_size, MSG_CMD_UNKNOWN, tokens[0]);\n+}\n+\n+int\n+cli_script_process(const char *file_name,\n+\tsize_t msg_in_len_max,\n+\tsize_t msg_out_len_max,\n+\tvoid *obj)\n+{\n+\tchar *msg_in = NULL, *msg_out = NULL;\n+\tFILE *f = NULL;\n+\n+\t/* Check input arguments */\n+\tif ((file_name == NULL) ||\n+\t\t(strlen(file_name) == 0) ||\n+\t\t(msg_in_len_max == 0) ||\n+\t\t(msg_out_len_max == 0))\n+\t\treturn -EINVAL;\n+\n+\tmsg_in = malloc(msg_in_len_max + 1);\n+\tmsg_out = malloc(msg_out_len_max + 1);\n+\tif ((msg_in == NULL) ||\n+\t\t(msg_out == NULL)) {\n+\t\tfree(msg_out);\n+\t\tfree(msg_in);\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\t/* Open input file */\n+\tf = fopen(file_name, \"r\");\n+\tif (f == NULL) {\n+\t\tfree(msg_out);\n+\t\tfree(msg_in);\n+\t\treturn -EIO;\n+\t}\n+\n+\t/* Read file */\n+\tfor ( ; ; ) {\n+\t\tif (fgets(msg_in, msg_in_len_max + 1, f) == NULL)\n+\t\t\tbreak;\n+\n+\t\tprintf(\"%s\", msg_in);\n+\t\tmsg_out[0] = 0;\n+\n+\t\tcli_process(msg_in,\n+\t\t\tmsg_out,\n+\t\t\tmsg_out_len_max,\n+\t\t\tobj);\n+\n+\t\tif (strlen(msg_out))\n+\t\t\tprintf(\"%s\", msg_out);\n+\t}\n+\n+\t/* Close file */\n+\tfclose(f);\n+\tfree(msg_out);\n+\tfree(msg_in);\n+\treturn 0;\n+}\ndiff --git a/examples/pipeline/cli.h b/examples/pipeline/cli.h\nnew file mode 100644\nindex 000000000..dad7233fe\n--- /dev/null\n+++ b/examples/pipeline/cli.h\n@@ -0,0 +1,19 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2010-2020 Intel Corporation\n+ */\n+\n+#ifndef __INCLUDE_CLI_H__\n+#define __INCLUDE_CLI_H__\n+\n+#include <stddef.h>\n+\n+void\n+cli_process(char *in, char *out, size_t out_size, void *arg);\n+\n+int\n+cli_script_process(const char *file_name,\n+\tsize_t msg_in_len_max,\n+\tsize_t msg_out_len_max,\n+\tvoid *arg);\n+\n+#endif\ndiff --git a/examples/pipeline/main.c b/examples/pipeline/main.c\nindex 1a63c1237..97bb66288 100644\n--- a/examples/pipeline/main.c\n+++ b/examples/pipeline/main.c\n@@ -11,6 +11,7 @@\n #include <rte_launch.h>\n #include <rte_eal.h>\n \n+#include \"cli.h\"\n #include \"conn.h\"\n #include \"obj.h\"\n #include \"thread.h\"\n@@ -30,7 +31,7 @@ static struct app_params {\n \t\t.buf_size = 1024 * 1024,\n \t\t.msg_in_len_max = 1024,\n \t\t.msg_out_len_max = 1024 * 1024,\n-\t\t.msg_handle = NULL,\n+\t\t.msg_handle = cli_process,\n \t\t.msg_handle_arg = NULL, /* set later. */\n \t},\n \t.script_name = NULL,\n@@ -167,6 +168,13 @@ main(int argc, char **argv)\n \t\tNULL,\n \t\tSKIP_MASTER);\n \n+\t/* Script */\n+\tif (app.script_name)\n+\t\tcli_script_process(app.script_name,\n+\t\t\tapp.conn.msg_in_len_max,\n+\t\t\tapp.conn.msg_out_len_max,\n+\t\t\tobj);\n+\n \t/* Connectivity */\n \tapp.conn.msg_handle_arg = obj;\n \tconn = conn_init(&app.conn);\n@@ -175,6 +183,7 @@ main(int argc, char **argv)\n \t\t\tstatus);\n \t\treturn status;\n \t};\n+\n \t/* Dispatch loop */\n \tfor ( ; ; ) {\n \t\tconn_poll_for_conn(conn);\ndiff --git a/examples/pipeline/meson.build b/examples/pipeline/meson.build\nindex a92e84677..4f47dec3e 100644\n--- a/examples/pipeline/meson.build\n+++ b/examples/pipeline/meson.build\n@@ -10,6 +10,7 @@ build = cc.has_header('sys/epoll.h')\n deps += ['pipeline', 'bus_pci']\n allow_experimental_apis = true\n sources = files(\n+\t'cli.c',\n \t'conn.c',\n \t'main.c',\n \t'obj.c',\n",
    "prefixes": [
        "v3",
        "38/41"
    ]
}