get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 54794,
    "url": "http://patches.dpdk.org/api/patches/54794/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190614021940.78631-5-xiaoyun.li@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": "<20190614021940.78631-5-xiaoyun.li@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190614021940.78631-5-xiaoyun.li@intel.com",
    "date": "2019-06-14T02:19:38",
    "name": "[v5,4/6] examples/ntb: enable an example for ntb",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "6d9fcb6bd36c505b721a00f23d2cb14ae12fa57c",
    "submitter": {
        "id": 798,
        "url": "http://patches.dpdk.org/api/people/798/?format=api",
        "name": "Li, Xiaoyun",
        "email": "xiaoyun.li@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/20190614021940.78631-5-xiaoyun.li@intel.com/mbox/",
    "series": [
        {
            "id": 5008,
            "url": "http://patches.dpdk.org/api/series/5008/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=5008",
            "date": "2019-06-14T02:19:34",
            "name": "rawdev driver for ntb",
            "version": 5,
            "mbox": "http://patches.dpdk.org/series/5008/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/54794/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/54794/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 389FA1D485;\n\tFri, 14 Jun 2019 04:20:37 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id 094321D473\n\tfor <dev@dpdk.org>; Fri, 14 Jun 2019 04:20:32 +0200 (CEST)",
            "from orsmga007.jf.intel.com ([10.7.209.58])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t13 Jun 2019 19:20:32 -0700",
            "from dpdk-xiaoyun3.sh.intel.com ([10.67.119.132])\n\tby orsmga007.jf.intel.com with ESMTP; 13 Jun 2019 19:20:31 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "From": "Xiaoyun Li <xiaoyun.li@intel.com>",
        "To": "jingjing.wu@intel.com, keith.wiles@intel.com, cunming.liang@intel.com,\n\tomkar.maslekar@intel.com",
        "Cc": "dev@dpdk.org,\n\tXiaoyun Li <xiaoyun.li@intel.com>",
        "Date": "Fri, 14 Jun 2019 10:19:38 +0800",
        "Message-Id": "<20190614021940.78631-5-xiaoyun.li@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20190614021940.78631-1-xiaoyun.li@intel.com>",
        "References": "<20190613075649.67472-1-xiaoyun.li@intel.com>\n\t<20190614021940.78631-1-xiaoyun.li@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v5 4/6] examples/ntb: enable an example for ntb",
        "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": "Enable an example for rawdev ntb. Support interactive mode to send\nfile on one host and receive file from another host. The command line\nwould be 'send [filepath]' and 'receive [filepath]'.\n\nBut since the FIFO is not enabled right now, use rte_memcpy as the enqueue\nand dequeue functions and only support transmitting file no more than 4M.\n\nSigned-off-by: Xiaoyun Li <xiaoyun.li@intel.com>\n---\n drivers/raw/ntb_rawdev/ntb_rawdev.c |  28 ++-\n examples/Makefile                   |   1 +\n examples/meson.build                |   2 +-\n examples/ntb/Makefile               |  68 +++++\n examples/ntb/meson.build            |  16 ++\n examples/ntb/ntb_fwd.c              | 377 ++++++++++++++++++++++++++++\n 6 files changed, 483 insertions(+), 9 deletions(-)\n create mode 100644 examples/ntb/Makefile\n create mode 100644 examples/ntb/meson.build\n create mode 100644 examples/ntb/ntb_fwd.c",
    "diff": "diff --git a/drivers/raw/ntb_rawdev/ntb_rawdev.c b/drivers/raw/ntb_rawdev/ntb_rawdev.c\nindex d9088e825..9d7b8c07b 100644\n--- a/drivers/raw/ntb_rawdev/ntb_rawdev.c\n+++ b/drivers/raw/ntb_rawdev/ntb_rawdev.c\n@@ -240,11 +240,19 @@ ntb_enqueue_bufs(struct rte_rawdev *dev,\n \t\t unsigned int count,\n \t\t rte_rawdev_obj_t context)\n {\n-\tRTE_SET_USED(dev);\n-\tRTE_SET_USED(buffers);\n-\tRTE_SET_USED(count);\n-\tRTE_SET_USED(context);\n+\t/* Not FIFO right now. Just for testing memory write. */\n+\tstruct ntb_hw *hw = dev->dev_private;\n+\tunsigned int i;\n+\tvoid *bar_addr;\n+\tsize_t size;\n+\n+\tif (hw->ntb_ops->get_peer_mw_addr == NULL)\n+\t\treturn -ENOTSUP;\n+\tbar_addr = (*hw->ntb_ops->get_peer_mw_addr)(dev, 0);\n+\tsize = (size_t)context;\n \n+\tfor (i = 0; i < count; i++)\n+\t\trte_memcpy(bar_addr, buffers[i]->buf_addr, size);\n \treturn 0;\n }\n \n@@ -254,11 +262,15 @@ ntb_dequeue_bufs(struct rte_rawdev *dev,\n \t\t unsigned int count,\n \t\t rte_rawdev_obj_t context)\n {\n-\tRTE_SET_USED(dev);\n-\tRTE_SET_USED(buffers);\n-\tRTE_SET_USED(count);\n-\tRTE_SET_USED(context);\n+\t/* Not FIFO. Just for testing memory read. */\n+\tstruct ntb_hw *hw = dev->dev_private;\n+\tunsigned int i;\n+\tsize_t size;\n+\n+\tsize = (size_t)context;\n \n+\tfor (i = 0; i < count; i++)\n+\t\trte_memcpy(buffers[i]->buf_addr, hw->mz[i]->addr, size);\n \treturn 0;\n }\n \ndiff --git a/examples/Makefile b/examples/Makefile\nindex 7562424d9..de11dd487 100644\n--- a/examples/Makefile\n+++ b/examples/Makefile\n@@ -53,6 +53,7 @@ DIRS-y += link_status_interrupt\n DIRS-$(CONFIG_RTE_LIBRTE_LPM) += load_balancer\n DIRS-y += multi_process\n DIRS-y += netmap_compat/bridge\n+DIRS-y += ntb\n DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += packet_ordering\n ifeq ($(CONFIG_RTE_ARCH_X86_64),y)\n DIRS-y += performance-thread\ndiff --git a/examples/meson.build b/examples/meson.build\nindex c695d52c9..2a4a084af 100644\n--- a/examples/meson.build\n+++ b/examples/meson.build\n@@ -30,7 +30,7 @@ all_examples = [\n \t'multi_process/hotplug_mp',\n \t'multi_process/simple_mp',\n \t'multi_process/symmetric_mp',\n-\t'netmap_compat', 'packet_ordering',\n+\t'netmap_compat', 'ntb', 'packet_ordering',\n \t'performance-thread', 'ptpclient',\n \t'qos_meter', 'qos_sched',\n \t'quota_watermark', 'rxtx_callbacks',\ndiff --git a/examples/ntb/Makefile b/examples/ntb/Makefile\nnew file mode 100644\nindex 000000000..5ddd9b95f\n--- /dev/null\n+++ b/examples/ntb/Makefile\n@@ -0,0 +1,68 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2019 Intel Corporation\n+\n+# binary name\n+APP = ntb_fwd\n+\n+# all source are stored in SRCS-y\n+SRCS-y := ntb_fwd.c\n+\n+# Build using pkg-config variables if possible\n+$(shell pkg-config --exists libdpdk)\n+ifeq ($(.SHELLSTATUS),0)\n+\n+all: shared\n+.PHONY: shared static\n+shared: build/$(APP)-shared\n+\tln -sf $(APP)-shared build/$(APP)\n+static: build/$(APP)-static\n+\tln -sf $(APP)-static build/$(APP)\n+\n+CFLAGS += -D_FILE_OFFSET_BITS=64\n+LDFLAGS += -pthread\n+\n+PC_FILE := $(shell pkg-config --path libdpdk)\n+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)\n+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)\n+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)\n+\n+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build\n+\t$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)\n+\n+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build\n+\t$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)\n+\n+build:\n+\t@mkdir -p $@\n+\n+.PHONY: clean\n+clean:\n+\trm -f build/$(APP) build/$(APP)-static build/$(APP)-shared\n+\trmdir --ignore-fail-on-non-empty build\n+\n+else # Build using legacy build system\n+\n+ifeq ($(RTE_SDK),)\n+$(error \"Please define RTE_SDK environment variable\")\n+endif\n+\n+# Default target, can be overridden by command line or environment\n+RTE_TARGET ?= x86_64-native-linuxapp-gcc\n+\n+include $(RTE_SDK)/mk/rte.vars.mk\n+\n+ifneq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)\n+$(info This application can only operate in a linuxapp environment, \\\n+please change the definition of the RTE_TARGET environment variable)\n+all:\n+else\n+\n+CFLAGS += -D_FILE_OFFSET_BITS=64\n+CFLAGS += -O2\n+CFLAGS += $(WERROR_FLAGS)\n+CFLAGS += -DALLOW_EXPERIMENTAL_API\n+\n+include $(RTE_SDK)/mk/rte.extapp.mk\n+\n+endif\n+endif\ndiff --git a/examples/ntb/meson.build b/examples/ntb/meson.build\nnew file mode 100644\nindex 000000000..9a6288f4f\n--- /dev/null\n+++ b/examples/ntb/meson.build\n@@ -0,0 +1,16 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2019 Intel Corporation\n+\n+# meson file, for building this example as part of a main DPDK build.\n+#\n+# To build this example as a standalone application with an already-installed\n+# DPDK instance, use 'make'\n+\n+if host_machine.system() != 'linux'\n+\tbuild = false\n+endif\n+deps += 'rawdev'\n+cflags += ['-D_FILE_OFFSET_BITS=64']\n+sources = files(\n+\t'ntb_fwd.c'\n+)\ndiff --git a/examples/ntb/ntb_fwd.c b/examples/ntb/ntb_fwd.c\nnew file mode 100644\nindex 000000000..020e20bb5\n--- /dev/null\n+++ b/examples/ntb/ntb_fwd.c\n@@ -0,0 +1,377 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2019 Intel Corporation\n+ */\n+#include <stdint.h>\n+#include <stdio.h>\n+#include <inttypes.h>\n+#include <unistd.h>\n+#include <signal.h>\n+#include <string.h>\n+#include <getopt.h>\n+\n+#include <cmdline_parse_string.h>\n+#include <cmdline_socket.h>\n+#include <cmdline.h>\n+#include <rte_common.h>\n+#include <rte_rawdev.h>\n+#include <rte_lcore.h>\n+\n+#define NTB_DRV_NAME_LEN\t7\n+static uint64_t max_file_size = 0x400000;\n+static uint8_t interactive = 1;\n+static uint16_t dev_id;\n+\n+/* *** Help command with introduction. *** */\n+struct cmd_help_result {\n+\tcmdline_fixed_string_t help;\n+};\n+\n+static void cmd_help_parsed(__attribute__((unused)) void *parsed_result,\n+\t\t\t    struct cmdline *cl,\n+\t\t\t    __attribute__((unused)) void *data)\n+{\n+\tcmdline_printf(\n+\t\tcl,\n+\t\t\"\\n\"\n+\t\t\"The following commands are currently available:\\n\\n\"\n+\t\t\"Control:\\n\"\n+\t\t\"    quit                                      :\"\n+\t\t\" Quit the application.\\n\"\n+\t\t\"\\nFile transmit:\\n\"\n+\t\t\"    send [path]                               :\"\n+\t\t\" Send [path] file. (No more than %\"PRIu64\")\\n\"\n+\t\t\"    recv [path]                            :\"\n+\t\t\" Receive file to [path]. Make sure sending is done\"\n+\t\t\" on the other side.\\n\",\n+\t\tmax_file_size\n+\t);\n+\n+}\n+\n+cmdline_parse_token_string_t cmd_help_help =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_help_result, help, \"help\");\n+\n+cmdline_parse_inst_t cmd_help = {\n+\t.f = cmd_help_parsed,\n+\t.data = NULL,\n+\t.help_str = \"show help\",\n+\t.tokens = {\n+\t\t(void *)&cmd_help_help,\n+\t\tNULL,\n+\t},\n+};\n+\n+/* *** QUIT *** */\n+struct cmd_quit_result {\n+\tcmdline_fixed_string_t quit;\n+};\n+\n+static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,\n+\t\t\t    struct cmdline *cl,\n+\t\t\t    __attribute__((unused)) void *data)\n+{\n+\t/* Stop traffic and Close port. */\n+\trte_rawdev_stop(dev_id);\n+\trte_rawdev_close(dev_id);\n+\n+\tcmdline_quit(cl);\n+}\n+\n+cmdline_parse_token_string_t cmd_quit_quit =\n+\t\tTOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, \"quit\");\n+\n+cmdline_parse_inst_t cmd_quit = {\n+\t.f = cmd_quit_parsed,\n+\t.data = NULL,\n+\t.help_str = \"exit application\",\n+\t.tokens = {\n+\t\t(void *)&cmd_quit_quit,\n+\t\tNULL,\n+\t},\n+};\n+\n+/* *** SEND FILE PARAMETERS *** */\n+struct cmd_sendfile_result {\n+\tcmdline_fixed_string_t send_string;\n+\tchar filepath[];\n+};\n+\n+static void\n+cmd_sendfile_parsed(void *parsed_result,\n+\t\t    __attribute__((unused)) struct cmdline *cl,\n+\t\t    __attribute__((unused)) void *data)\n+{\n+\tstruct cmd_sendfile_result *res = parsed_result;\n+\tstruct rte_rawdev_buf *pkts_send[1];\n+\tuint64_t rsize, size, link;\n+\tuint8_t *buff;\n+\tuint32_t val;\n+\tFILE *file;\n+\n+\tif (!rte_rawdevs[dev_id].started) {\n+\t\tprintf(\"Device needs to be up first. Try later.\\n\");\n+\t\treturn;\n+\t}\n+\n+\trte_rawdev_get_attr(dev_id, \"link_status\", &link);\n+\tif (!link) {\n+\t\tprintf(\"Link is not up, cannot send file.\\n\");\n+\t\treturn;\n+\t}\n+\n+\tfile = fopen(res->filepath, \"r\");\n+\tif (file == NULL) {\n+\t\tprintf(\"Fail to open the file.\\n\");\n+\t\treturn;\n+\t}\n+\n+\tfseek(file, 0, SEEK_END);\n+\tsize = ftell(file);\n+\tfseek(file, 0, SEEK_SET);\n+\n+\t/**\n+\t * No FIFO now. Only test memory. Limit sending file\n+\t * size <= max_file_size.\n+\t */\n+\tif (size > max_file_size) {\n+\t\tprintf(\"Warning: The file is too large. Only send first\"\n+\t\t       \" %\"PRIu64\" bits.\\n\", max_file_size);\n+\t\tsize = max_file_size;\n+\t}\n+\n+\tbuff = (uint8_t *)malloc(size);\n+\trsize = fread(buff, size, 1, file);\n+\tif (rsize != 1) {\n+\t\tprintf(\"Fail to read file.\\n\");\n+\t\tfclose(file);\n+\t\tfree(buff);\n+\t\treturn;\n+\t}\n+\n+\t/* Tell remote about the file size. */\n+\tval = size >> 32;\n+\trte_rawdev_set_attr(dev_id, \"spad14\", val);\n+\tval = size;\n+\trte_rawdev_set_attr(dev_id, \"spad15\", val);\n+\n+\tpkts_send[0] = (struct rte_rawdev_buf *)malloc\n+\t\t\t(sizeof(struct rte_rawdev_buf));\n+\tpkts_send[0]->buf_addr = buff;\n+\n+\tif (rte_rawdev_enqueue_buffers(dev_id, pkts_send, 1,\n+\t\t\t\t       (void *)(size_t)size)) {\n+\t\tprintf(\"Fail to enqueue.\\n\");\n+\t\tgoto clean;\n+\t}\n+\tprintf(\"Done sending file.\\n\");\n+\n+clean:\n+\tfclose(file);\n+\tfree(buff);\n+\tfree(pkts_send[0]);\n+}\n+\n+cmdline_parse_token_string_t cmd_send_file_send =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_sendfile_result, send_string,\n+\t\t\t\t \"send\");\n+cmdline_parse_token_string_t cmd_send_file_filepath =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_sendfile_result, filepath, NULL);\n+\n+\n+cmdline_parse_inst_t cmd_send_file = {\n+\t.f = cmd_sendfile_parsed,\n+\t.data = NULL,\n+\t.help_str = \"send <file_path>\",\n+\t.tokens = {\n+\t\t(void *)&cmd_send_file_send,\n+\t\t(void *)&cmd_send_file_filepath,\n+\t\tNULL,\n+\t},\n+};\n+\n+/* *** RECEIVE FILE PARAMETERS *** */\n+struct cmd_recvfile_result {\n+\tcmdline_fixed_string_t recv_string;\n+\tchar filepath[];\n+};\n+\n+static void\n+cmd_recvfile_parsed(void *parsed_result,\n+\t\t    __attribute__((unused)) struct cmdline *cl,\n+\t\t    __attribute__((unused)) void *data)\n+{\n+\tstruct cmd_sendfile_result *res = parsed_result;\n+\tstruct rte_rawdev_buf *pkts_recv[1];\n+\tuint8_t *buff;\n+\tuint64_t val;\n+\tsize_t size;\n+\tFILE *file;\n+\n+\tif (!rte_rawdevs[dev_id].started) {\n+\t\tprintf(\"Device needs to be up first. Try later.\\n\");\n+\t\treturn;\n+\t}\n+\n+\trte_rawdev_get_attr(dev_id, \"link_status\", &val);\n+\tif (!val) {\n+\t\tprintf(\"Link is not up, cannot receive file.\\n\");\n+\t\treturn;\n+\t}\n+\n+\tfile = fopen(res->filepath, \"w\");\n+\tif (file == NULL) {\n+\t\tprintf(\"Fail to open the file.\\n\");\n+\t\treturn;\n+\t}\n+\n+\trte_rawdev_get_attr(dev_id, \"spad14\", &val);\n+\tsize = val << 32;\n+\trte_rawdev_get_attr(dev_id, \"spad15\", &val);\n+\tsize |= val;\n+\n+\tbuff = (uint8_t *)malloc(size);\n+\tpkts_recv[0] = (struct rte_rawdev_buf *)malloc\n+\t\t\t(sizeof(struct rte_rawdev_buf));\n+\tpkts_recv[0]->buf_addr = buff;\n+\n+\tif (rte_rawdev_dequeue_buffers(dev_id, pkts_recv, 1, (void *)size)) {\n+\t\tprintf(\"Fail to dequeue.\\n\");\n+\t\tgoto clean;\n+\t}\n+\n+\tfwrite(buff, size, 1, file);\n+\tprintf(\"Done receiving to file.\\n\");\n+\n+clean:\n+\tfclose(file);\n+\tfree(buff);\n+\tfree(pkts_recv[0]);\n+}\n+\n+cmdline_parse_token_string_t cmd_recv_file_recv =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_recvfile_result, recv_string,\n+\t\t\t\t \"recv\");\n+cmdline_parse_token_string_t cmd_recv_file_filepath =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_recvfile_result, filepath, NULL);\n+\n+\n+cmdline_parse_inst_t cmd_recv_file = {\n+\t.f = cmd_recvfile_parsed,\n+\t.data = NULL,\n+\t.help_str = \"recv <file_path>\",\n+\t.tokens = {\n+\t\t(void *)&cmd_recv_file_recv,\n+\t\t(void *)&cmd_recv_file_filepath,\n+\t\tNULL,\n+\t},\n+};\n+\n+/* list of instructions */\n+cmdline_parse_ctx_t main_ctx[] = {\n+\t(cmdline_parse_inst_t *)&cmd_help,\n+\t(cmdline_parse_inst_t *)&cmd_send_file,\n+\t(cmdline_parse_inst_t *)&cmd_recv_file,\n+\t(cmdline_parse_inst_t *)&cmd_quit,\n+\tNULL,\n+};\n+\n+/* prompt function, called from main on MASTER lcore */\n+static void\n+prompt(void)\n+{\n+\tstruct cmdline *cl;\n+\n+\tcl = cmdline_stdin_new(main_ctx, \"ntb> \");\n+\tif (cl == NULL)\n+\t\treturn;\n+\n+\tcmdline_interact(cl);\n+\tcmdline_stdin_exit(cl);\n+}\n+\n+static void\n+signal_handler(int signum)\n+{\n+\tif (signum == SIGINT || signum == SIGTERM) {\n+\t\tprintf(\"\\nSignal %d received, preparing to exit...\\n\", signum);\n+\t\tsignal(signum, SIG_DFL);\n+\t\tkill(getpid(), signum);\n+\t}\n+}\n+\n+static void\n+ntb_usage(const char *prgname)\n+{\n+\tprintf(\"%s [EAL options] -- [options]\\n\"\n+\t       \"-i : run in interactive mode (default value is 1)\\n\",\n+\t       prgname);\n+}\n+\n+static int\n+parse_args(int argc, char **argv)\n+{\n+\tchar *prgname = argv[0], **argvopt = argv;\n+\tint opt, ret;\n+\n+\t/* Only support interactive mode to send/recv file first. */\n+\twhile ((opt = getopt(argc, argvopt, \"i\")) != EOF) {\n+\t\tswitch (opt) {\n+\t\tcase 'i':\n+\t\t\tprintf(\"Interactive-mode selected\\n\");\n+\t\t\tinteractive = 1;\n+\t\t\tbreak;\n+\n+\t\tdefault:\n+\t\t\tntb_usage(prgname);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\tif (optind >= 0)\n+\t\targv[optind-1] = prgname;\n+\n+\tret = optind-1;\n+\toptind = 1; /* reset getopt lib */\n+\treturn ret;\n+}\n+\n+int\n+main(int argc, char **argv)\n+{\n+\tint ret, i;\n+\n+\tsignal(SIGINT, signal_handler);\n+\tsignal(SIGTERM, signal_handler);\n+\n+\tret = rte_eal_init(argc, argv);\n+\tif (ret < 0)\n+\t\trte_exit(EXIT_FAILURE, \"Error with EAL initialization.\\n\");\n+\n+\t/* Find 1st ntb rawdev. */\n+\tfor (i = 0; i < RTE_RAWDEV_MAX_DEVS; i++)\n+\t\tif (rte_rawdevs[i].driver_name &&\n+\t\t    (strncmp(rte_rawdevs[i].driver_name, \"raw_ntb\",\n+\t\t    NTB_DRV_NAME_LEN) == 0) && (rte_rawdevs[i].attached == 1))\n+\t\t\tbreak;\n+\n+\tif (i == RTE_RAWDEV_MAX_DEVS)\n+\t\trte_exit(EXIT_FAILURE, \"Cannot find any ntb device.\\n\");\n+\n+\tdev_id = i;\n+\n+\targc -= ret;\n+\targv += ret;\n+\n+\tret = parse_args(argc, argv);\n+\tif (ret < 0)\n+\t\trte_exit(EXIT_FAILURE, \"Invalid arguments\\n\");\n+\n+\trte_rawdev_start(dev_id);\n+\n+\tif (interactive) {\n+\t\tsleep(1);\n+\t\tprompt();\n+\t}\n+\n+\treturn 0;\n+}\n",
    "prefixes": [
        "v5",
        "4/6"
    ]
}