get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 43857,
    "url": "http://patches.dpdk.org/api/patches/43857/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1535115087-2442-5-git-send-email-naga.sureshx.somarowthu@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": "<1535115087-2442-5-git-send-email-naga.sureshx.somarowthu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1535115087-2442-5-git-send-email-naga.sureshx.somarowthu@intel.com",
    "date": "2018-08-24T12:51:27",
    "name": "[v13,4/4] test: add unit test for pdump library",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "19e4f55631d63fbda0c70c4cf43971757bad0681",
    "submitter": {
        "id": 1053,
        "url": "http://patches.dpdk.org/api/people/1053/?format=api",
        "name": "Naga Suresh Somarowthu",
        "email": "naga.sureshx.somarowthu@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/1535115087-2442-5-git-send-email-naga.sureshx.somarowthu@intel.com/mbox/",
    "series": [
        {
            "id": 1045,
            "url": "http://patches.dpdk.org/api/series/1045/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1045",
            "date": "2018-08-24T12:51:23",
            "name": "add unit tests for bitrate, latency and pdump libraries",
            "version": 13,
            "mbox": "http://patches.dpdk.org/series/1045/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/43857/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/43857/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "X-Amp-File-Uploaded": "False",
        "Subject": "[dpdk-dev] [PATCH v13 4/4] test: add unit test for pdump library",
        "List-Post": "<mailto:dev@dpdk.org>",
        "X-Mailer": "git-send-email 1.7.12.2",
        "X-Original-To": "patchwork@dpdk.org",
        "Cc": "reshma.pattan@intel.com,\n\tNaga Suresh Somarowthu <naga.sureshx.somarowthu@intel.com>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "From": "Naga Suresh Somarowthu <naga.sureshx.somarowthu@intel.com>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-BeenThere": "dev@dpdk.org",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Date": "Fri, 24 Aug 2018 13:51:27 +0100",
        "Precedence": "list",
        "In-Reply-To": "<1535115087-2442-1-git-send-email-naga.sureshx.somarowthu@intel.com>",
        "Message-Id": "<1535115087-2442-5-git-send-email-naga.sureshx.somarowthu@intel.com>",
        "X-Mailman-Version": "2.1.15",
        "Errors-To": "dev-bounces@dpdk.org",
        "References": "<1533299698-20950-1-git-send-email-naga.sureshx.somarowthu@intel.com>\n\t<1535115087-2442-1-git-send-email-naga.sureshx.somarowthu@intel.com>",
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "Delivered-To": "patchwork@dpdk.org",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id E4FDA4CE4;\n\tFri, 24 Aug 2018 14:51:52 +0200 (CEST)",
            "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n\tby dpdk.org (Postfix) with ESMTP id 9D2E54CBB\n\tfor <dev@dpdk.org>; Fri, 24 Aug 2018 14:51:50 +0200 (CEST)",
            "from orsmga005.jf.intel.com ([10.7.209.41])\n\tby fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t24 Aug 2018 05:51:49 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby orsmga005.jf.intel.com with ESMTP; 24 Aug 2018 05:51:43 -0700",
            "from wgcvswdev001.ir.intel.com (wgcvswdev001.ir.intel.com\n\t[10.102.246.100])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\tw7OCphE7031751; Fri, 24 Aug 2018 13:51:43 +0100",
            "from wgcvswdev001.ir.intel.com (localhost [127.0.0.1])\n\tby wgcvswdev001.ir.intel.com with ESMTP id w7OCpatH002561;\n\tFri, 24 Aug 2018 13:51:36 +0100",
            "(from jmparthx@localhost)\n\tby wgcvswdev001.ir.intel.com with ? id w7OCpaP5002557;\n\tFri, 24 Aug 2018 13:51:36 +0100"
        ],
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "X-ExtLoop1": "1",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "To": "dev@dpdk.org",
        "X-IronPort-AV": "E=Sophos;i=\"5.53,281,1531810800\"; d=\"scan'208\";a=\"251612459\""
    },
    "content": "Unit test cases are added for pdump library.\nPrimary process will act as server, forks a child secondary process.\nSecondary process acts as client.\nServer will do pdump init to serve any pdump client requests.\nServer will create a vdev, send/receive packets continuously\nin a separate thread.\nClient will create virtual rings to receive the packet dump.\nClient sends pdump enable/disable requests using either port/device id.\nPacket flow direction can be tx/rx/tx&rx.\nIn Server, appropriate pdump callbacks are triggered,\nwhen packets are transmitted/received.\nPdump packet is copied to client rings.\n\nSigned-off-by: Naga Suresh Somarowthu <naga.sureshx.somarowthu@intel.com>\nReviewed-by: Reshma Pattan <reshma.pattan@intel.com>\n---\n MAINTAINERS                |   3 +-\n test/test/Makefile         |   6 ++\n test/test/autotest_data.py |   6 ++\n test/test/meson.build      |   2 +\n test/test/process.h        |  13 +++\n test/test/test.c           |   2 +\n test/test/test_pdump.c     | 219 +++++++++++++++++++++++++++++++++++++++++++++\n test/test/test_pdump.h     |  31 +++++++\n 8 files changed, 281 insertions(+), 1 deletion(-)\n create mode 100644 test/test/test_pdump.c\n create mode 100644 test/test/test_pdump.h",
    "diff": "diff --git a/MAINTAINERS b/MAINTAINERS\nindex 886646fd1..7999f2d24 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -1018,7 +1018,8 @@ F: lib/librte_pdump/\n F: doc/guides/prog_guide/pdump_lib.rst\n F: app/pdump/\n F: doc/guides/tools/pdump.rst\n-\n+F: test/test/test_pdump.c\n+F: test/test/test_pdump.h\n \n Packet Framework\n ----------------\ndiff --git a/test/test/Makefile b/test/test/Makefile\nindex bba3be1be..3e7baef76 100644\n--- a/test/test/Makefile\n+++ b/test/test/Makefile\n@@ -185,6 +185,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c\n SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_asym.c\n SRCS-$(CONFIG_RTE_LIBRTE_BITRATE) += test_bitratestats.c\n SRCS-$(CONFIG_RTE_LIBRTE_LATENCY_STATS) += test_latencystats.c\n+SRCS-$(CONFIG_RTE_LIBRTE_PDUMP) += test_pdump.c\n \n ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)\n SRCS-$(CONFIG_RTE_LIBRTE_COMPRESSDEV) += test_compressdev.c\n@@ -214,6 +215,11 @@ CFLAGS += $(WERROR_FLAGS)\n CFLAGS += -D_GNU_SOURCE\n \n LDLIBS += -lm\n+\n+ifeq ($(CONFIG_RTE_LIBRTE_PDUMP),y)\n+LDLIBS += -lpthread\n+endif\n+\n ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)\n ifeq ($(CONFIG_RTE_LIBRTE_COMPRESSDEV),y)\n LDLIBS += -lz\ndiff --git a/test/test/autotest_data.py b/test/test/autotest_data.py\nindex f44e31d33..9a54d0c04 100644\n--- a/test/test/autotest_data.py\n+++ b/test/test/autotest_data.py\n@@ -494,6 +494,12 @@\n         \"Func\":    default_autotest,\n         \"Report\":  None,\n     },\n+    {\n+        \"Name\":    \"Pdump autotest\",\n+        \"Comamnd\": \"pdump_autotest\",\n+        \"Func\":    default_autotest,\n+        \"Report\":  None,\n+    },\n     #\n     #Please always keep all dump tests at the end and together!\n     #\ndiff --git a/test/test/meson.build b/test/test/meson.build\nindex d3385a3e2..1f9707da7 100644\n--- a/test/test/meson.build\n+++ b/test/test/meson.build\n@@ -67,6 +67,7 @@ test_sources = files('commands.c',\n \t'test_memzone.c',\n \t'test_meter.c',\n \t'test_mp_secondary.c',\n+\t'test_pdump.c',\n \t'test_per_lcore.c',\n \t'test_pmd_perf.c',\n \t'test_pmd_ring.c',\n@@ -192,6 +193,7 @@ test_names = [\n \t'memzone_autotest',\n \t'meter_autotest',\n \t'multiprocess_autotest',\n+\t'pdump_autotest',\n \t'per_lcore_autotest',\n \t'pmd_perf_autotest',\n \t'power_acpi_cpufreq_autotest',\ndiff --git a/test/test/process.h b/test/test/process.h\nindex ba3a18502..7f62f644f 100644\n--- a/test/test/process.h\n+++ b/test/test/process.h\n@@ -9,6 +9,7 @@\n #include <libgen.h> /* basename et al */\n #include <stdlib.h> /* NULL */\n #include <unistd.h> /* readlink */\n+#include <sys/wait.h>\n \n #ifdef RTE_EXEC_ENV_BSDAPP\n #define self \"curproc\"\n@@ -18,6 +19,10 @@\n #define exe \"exe\"\n #endif\n \n+#include <pthread.h>\n+extern void *send_pkts(void *empty);\n+extern uint16_t flag_for_send_pkts;\n+\n /*\n  * launches a second copy of the test process using the given argv parameters,\n  * which should include argv[0] as the process name. To identify in the\n@@ -31,6 +36,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)\n \tchar *argv_cpy[numargs + 1];\n \tint i, fd, status;\n \tchar path[32];\n+\tpthread_t thread;\n \n \tpid_t pid = fork();\n \tif (pid < 0)\n@@ -61,8 +67,15 @@ process_dup(const char *const argv[], int numargs, const char *env_value)\n \t\t\trte_panic(\"Cannot exec\\n\");\n \t}\n \t/* parent process does a wait */\n+\tif ((strcmp(env_value, \"run_pdump_server_tests\") == 0))\n+\t\tpthread_create(&thread, NULL, &send_pkts, NULL);\n+\n \twhile (wait(&status) != pid)\n \t\t;\n+\tif ((strcmp(env_value, \"run_pdump_server_tests\") == 0)) {\n+\t\tflag_for_send_pkts = 0;\n+\t\tpthread_join(thread, NULL);\n+\t}\n \treturn status;\n }\n \ndiff --git a/test/test/test.c b/test/test/test.c\nindex 44dfe20ef..a54b0d142 100644\n--- a/test/test/test.c\n+++ b/test/test/test.c\n@@ -30,6 +30,7 @@ extern cmdline_parse_ctx_t main_ctx[];\n #endif\n \n #include \"test.h\"\n+#include \"test_pdump.h\"\n \n #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1\n \n@@ -49,6 +50,7 @@ do_recursive_call(void)\n \t\tint (*action_fn)(void);\n \t} actions[] =  {\n \t\t\t{ \"run_secondary_instances\", test_mp_secondary },\n+\t\t\t{ \"run_pdump_server_tests\", test_pdump },\n \t\t\t{ \"test_missing_c_flag\", no_action },\n \t\t\t{ \"test_master_lcore_flag\", no_action },\n \t\t\t{ \"test_invalid_n_flag\", no_action },\ndiff --git a/test/test/test_pdump.c b/test/test/test_pdump.c\nnew file mode 100644\nindex 000000000..ec962f08f\n--- /dev/null\n+++ b/test/test/test_pdump.c\n@@ -0,0 +1,219 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018 Intel Corporation\n+ */\n+#include <stdio.h>\n+#include <unistd.h>\n+#include <stdint.h>\n+#include <limits.h>\n+\n+#include <rte_ethdev_driver.h>\n+#include <rte_pdump.h>\n+#include \"rte_eal.h\"\n+#include \"rte_lcore.h\"\n+#include \"rte_mempool.h\"\n+#include \"rte_ring.h\"\n+\n+#include \"sample_packet_forward.h\"\n+#include \"test.h\"\n+#include \"process.h\"\n+#include \"test_pdump.h\"\n+\n+#define launch_p(ARGV) process_dup(ARGV, \\\n+\t\tsizeof(ARGV)/(sizeof(ARGV[0])), __func__)\n+\n+struct rte_ring *ring_server;\n+uint16_t portid;\n+uint16_t flag_for_send_pkts = 1;\n+\n+int\n+test_pdump_init(void)\n+{\n+\tint ret = 0;\n+\n+\tret = rte_pdump_init(NULL);\n+\tif (ret < 0) {\n+\t\tprintf(\"rte_pdump_init failed\\n\");\n+\t\treturn -1;\n+\t}\n+\tret = test_ring_setup(&ring_server, &portid);\n+\tif (ret < 0) {\n+\t\tprintf(\"test_ring_setup failed\\n\");\n+\t\treturn -1;\n+\t}\n+\tprintf(\"pdump_init success\\n\");\n+\treturn ret;\n+}\n+\n+int\n+run_pdump_client_tests(void)\n+{\n+\tint flags = RTE_PDUMP_FLAG_TX, ret = 0, itr;\n+\tchar deviceid[] = \"net_ring_net_ringa\";\n+\tstruct rte_ring *ring_client;\n+\tstruct rte_mempool *mp = NULL;\n+\tstruct rte_eth_dev *eth_dev = NULL;\n+\tchar poolname[] = \"mbuf_pool_client\";\n+\n+\tret = test_get_mempool(&mp, poolname);\n+\tif (ret < 0)\n+\t\treturn -1;\n+\tmp->flags = 0x0000;\n+\tring_client = rte_ring_create(\"SR0\", RING_SIZE, rte_socket_id(),\n+\t\t\t\t      RING_F_SP_ENQ | RING_F_SC_DEQ);\n+\tif (ring_client == NULL) {\n+\t\tprintf(\"rte_ring_create SR0 failed\");\n+\t\treturn -1;\n+\t}\n+\n+\teth_dev = rte_eth_dev_attach_secondary(deviceid);\n+\tif (!eth_dev) {\n+\t\tprintf(\"Failed to probe %s\", deviceid);\n+\t\treturn -1;\n+\t}\n+\trte_eth_dev_probing_finish(eth_dev);\n+\n+\tring_client->prod.single = 0;\n+\tring_client->cons.single = 0;\n+\n+\tprintf(\"\\n***** flags = RTE_PDUMP_FLAG_TX *****\\n\");\n+\n+\tfor (itr = 0; itr < NUM_ITR; itr++) {\n+\t\tret = rte_pdump_enable(portid, QUEUE_ID, flags, ring_client,\n+\t\t\t\t       mp, NULL);\n+\t\tif (ret < 0) {\n+\t\t\tprintf(\"rte_pdump_enable failed\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\tprintf(\"pdump_enable success\\n\");\n+\n+\t\tret = rte_pdump_disable(portid, QUEUE_ID, flags);\n+\t\tif (ret < 0) {\n+\t\t\tprintf(\"rte_pdump_disable failed\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\tprintf(\"pdump_disable success\\n\");\n+\n+\t\tret = rte_pdump_enable_by_deviceid(deviceid, QUEUE_ID, flags,\n+\t\t\t\t\t\t   ring_client, mp, NULL);\n+\t\tif (ret < 0) {\n+\t\t\tprintf(\"rte_pdump_enable_by_deviceid failed\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\tprintf(\"pdump_enable_by_deviceid success\\n\");\n+\n+\t\tret = rte_pdump_disable_by_deviceid(deviceid, QUEUE_ID, flags);\n+\t\tif (ret < 0) {\n+\t\t\tprintf(\"rte_pdump_disable_by_deviceid failed\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\tprintf(\"pdump_disable_by_deviceid success\\n\");\n+\n+\t\tif (itr == 0) {\n+\t\t\tflags = RTE_PDUMP_FLAG_RX;\n+\t\t\tprintf(\"\\n***** flags = RTE_PDUMP_FLAG_RX *****\\n\");\n+\t\t} else if (itr == 1) {\n+\t\t\tflags = RTE_PDUMP_FLAG_RXTX;\n+\t\t\tprintf(\"\\n***** flags = RTE_PDUMP_FLAG_RXTX *****\\n\");\n+\t\t}\n+\t}\n+\tif (ring_client != NULL)\n+\t\ttest_ring_free(ring_client);\n+\tif (mp != NULL)\n+\t\ttest_mp_free(mp);\n+\n+\treturn ret;\n+}\n+\n+int\n+test_pdump_uninit(void)\n+{\n+\tint ret = 0;\n+\n+\tret = rte_pdump_uninit();\n+\tif (ret < 0) {\n+\t\tprintf(\"rte_pdump_uninit failed\\n\");\n+\t\treturn -1;\n+\t}\n+\tif (ring_server != NULL)\n+\t\ttest_ring_free(ring_server);\n+\tprintf(\"pdump_uninit success\\n\");\n+\ttest_vdev_uninit(\"net_ring_net_ringa\");\n+\treturn ret;\n+}\n+\n+void *\n+send_pkts(void *empty)\n+{\n+\tint ret = 0;\n+\tstruct rte_mbuf *pbuf[NUM_PACKETS] = { };\n+\tstruct rte_mempool *mp;\n+\tchar poolname[] = \"mbuf_pool_server\";\n+\n+\tret = test_get_mbuf_from_pool(&mp, pbuf, poolname);\n+\tif (ret < 0)\n+\t\tprintf(\"get_mbuf_from_pool failed\\n\");\n+\tdo {\n+\t\tret = test_packet_forward(pbuf, portid, QUEUE_ID);\n+\t\tif (ret < 0)\n+\t\t\tprintf(\"send pkts Failed\\n\");\n+\t} while (flag_for_send_pkts);\n+\ttest_put_mbuf_to_pool(mp, pbuf);\n+\treturn empty;\n+}\n+\n+/*\n+ * This function is called in the primary i.e. main test, to spawn off secondary\n+ * processes to run actual mp tests. Uses fork() and exec pair\n+ */\n+\n+int\n+run_pdump_server_tests(void)\n+{\n+\tint ret = 0;\n+\tchar coremask[10];\n+\n+#ifdef RTE_EXEC_ENV_LINUXAPP\n+\tchar tmp[PATH_MAX] = { 0 };\n+\tchar prefix[PATH_MAX] = { 0 };\n+\n+\tget_current_prefix(tmp, sizeof(tmp));\n+\tsnprintf(prefix, sizeof(prefix), \"--file-prefix=%s\", tmp);\n+#else\n+\tconst char *prefix = \"\";\n+#endif\n+\n+\t/* good case, using secondary */\n+\tconst char *const argv1[] = {\n+\t\tprgname, \"-c\", coremask, \"--proc-type=secondary\",\n+\t\tprefix\n+\t};\n+\n+\tsnprintf(coremask, sizeof(coremask), \"%x\",\n+\t\t (1 << rte_get_master_lcore()));\n+\n+\tret = test_pdump_init();\n+\tret |= launch_p(argv1);\n+\tret |= test_pdump_uninit();\n+\treturn ret;\n+}\n+\n+int\n+test_pdump(void)\n+{\n+\tint ret = 0;\n+\tif (rte_eal_process_type() == RTE_PROC_PRIMARY) {\n+\t\tprintf(\"IN PRIMARY PROCESS\\n\");\n+\t\tret = run_pdump_server_tests();\n+\t\tif (ret < 0)\n+\t\t\treturn TEST_FAILED;\n+\t} else if (rte_eal_process_type() == RTE_PROC_SECONDARY) {\n+\t\tprintf(\"IN SECONDARY PROCESS\\n\");\n+\t\tsleep(5);\n+\t\tret = run_pdump_client_tests();\n+\t\tif (ret < 0)\n+\t\t\treturn TEST_FAILED;\n+\t}\n+\treturn TEST_SUCCESS;\n+}\n+\n+REGISTER_TEST_COMMAND(pdump_autotest, test_pdump);\ndiff --git a/test/test/test_pdump.h b/test/test/test_pdump.h\nnew file mode 100644\nindex 000000000..abef9a85e\n--- /dev/null\n+++ b/test/test/test_pdump.h\n@@ -0,0 +1,31 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018 Intel Corporation\n+ */\n+\n+#ifndef _TEST_PDUMP_H_\n+#define _TEST_PDUMP_H_\n+\n+#define QUEUE_ID 0\n+#define NUM_ITR 3\n+\n+/* sample test to send packets to the pdump client recursively */\n+void *send_pkts(void *port);\n+\n+/* Sample test to create setup for the pdump server tests */\n+int test_pdump_init(void);\n+\n+/* Sample test to teardown the pdump server setup */\n+int test_pdump_uninit(void);\n+\n+/* Sample test to run the pdump client tests */\n+int run_pdump_client_tests(void);\n+\n+/* Sample test to run the pdump server tests */\n+int run_pdump_server_tests(void);\n+\n+/* Sample test to run the pdump client and server tests based on\n+ * the process type\n+ */\n+int test_pdump(void);\n+\n+#endif /* _TEST_PDUMP_H_ */\n",
    "prefixes": [
        "v13",
        "4/4"
    ]
}