get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1258,
    "url": "https://patches.dpdk.org/api/patches/1258/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1415773476-31004-7-git-send-email-cunming.liang@intel.com/",
    "project": {
        "id": 1,
        "url": "https://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": "<1415773476-31004-7-git-send-email-cunming.liang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1415773476-31004-7-git-send-email-cunming.liang@intel.com",
    "date": "2014-11-12T06:24:35",
    "name": "[dpdk-dev,v7,6/7] app/test: measure the cost of rx/tx routines by cycle number",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "94490dc65e7747f913ceb45076ef8ca21ee9f328",
    "submitter": {
        "id": 46,
        "url": "https://patches.dpdk.org/api/people/46/?format=api",
        "name": "Cunming Liang",
        "email": "cunming.liang@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1415773476-31004-7-git-send-email-cunming.liang@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/1258/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/1258/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 0AB9F7F99;\n\tWed, 12 Nov 2014 07:15:26 +0100 (CET)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id 7FD3A7F6D\n\tfor <dev@dpdk.org>; Wed, 12 Nov 2014 07:15:22 +0100 (CET)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga102.fm.intel.com with ESMTP; 11 Nov 2014 22:25:14 -0800",
            "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby fmsmga002.fm.intel.com with ESMTP; 11 Nov 2014 22:25:12 -0800",
            "from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com\n\t[10.239.29.89])\n\tby shvmail01.sh.intel.com with ESMTP id sAC6P98Y020480;\n\tWed, 12 Nov 2014 14:25:09 +0800",
            "from shecgisg004.sh.intel.com (localhost [127.0.0.1])\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP\n\tid sAC6P7AC031226; Wed, 12 Nov 2014 14:25:09 +0800",
            "(from cliang18@localhost)\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id sAC6P7ta031222; \n\tWed, 12 Nov 2014 14:25:07 +0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.07,367,1413270000\"; d=\"scan'208\";a=\"630587866\"",
        "From": "Cunming Liang <cunming.liang@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Wed, 12 Nov 2014 14:24:35 +0800",
        "Message-Id": "<1415773476-31004-7-git-send-email-cunming.liang@intel.com>",
        "X-Mailer": "git-send-email 1.7.4.1",
        "In-Reply-To": "<1415773476-31004-1-git-send-email-cunming.liang@intel.com>",
        "References": "<1414372809-14044-1-git-send-email-cunming.liang@intel.com>\n\t<1415773476-31004-1-git-send-email-cunming.liang@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v7 6/7] app/test: measure the cost of rx/tx\n\troutines by cycle number",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "The unit test can be used to measure cycles per packet in different rx/tx rouines.\nThe NIC works in loopback mode. So it doesn't require test equipment to measure throughput.\nAs result, the unit test shows the average cycles per packet consuming.\nWhen doing the test, make sure the link is UP.\n\nUsage Example:\n1. Run unit test app in interactive mode\n    app/test -c f -n 4 -- -i\n2. Run and wait for the result\n    pmd_perf_autotest\n\nThere's option to choose rx/tx pair, default is vector.\n    set_rxtx_mode [vector|scalar|full|hybrid]\nNote: To get acurate scalar fast, please choose 'vector' or 'hybrid' without INC_VEC=y in config\n\nIt supports to measure standalone rx or tx.\nUsage Example:\nChoose rx or tx standalone, default is both\n    set_rxtx_anchor [rxtx|rxonly|txonly]\n\nIt also supports to measure standalone RX burst cycles.\nIn this way, it won't repeat re-send recevied packets.\nNow it measures two situations, poll before/after xmit(w or w/o desc. cache conflict)\nUsage Example:\nSet stream control mode, by default is continuous\n    set_rxtx_sc [continuous|poll_before_xmit|poll_after_xmit]\n\nSigned-off-by: Cunming Liang <cunming.liang@intel.com>\n---\n app/test/Makefile        |    1 +\n app/test/commands.c      |  111 ++++++\n app/test/test.h          |    6 +\n app/test/test_pmd_perf.c |  922 ++++++++++++++++++++++++++++++++++++++++++++++\n 4 files changed, 1040 insertions(+), 0 deletions(-)\n create mode 100644 app/test/test_pmd_perf.c",
    "diff": "diff --git a/app/test/Makefile b/app/test/Makefile\nindex 6af6d76..ebfa0ba 100644\n--- a/app/test/Makefile\n+++ b/app/test/Makefile\n@@ -56,6 +56,7 @@ SRCS-y += test_memzone.c\n \n SRCS-y += test_ring.c\n SRCS-y += test_ring_perf.c\n+SRCS-y += test_pmd_perf.c\n \n ifeq ($(CONFIG_RTE_LIBRTE_TABLE),y)\n SRCS-y += test_table.c\ndiff --git a/app/test/commands.c b/app/test/commands.c\nindex a9e36b1..92a17ed 100644\n--- a/app/test/commands.c\n+++ b/app/test/commands.c\n@@ -310,12 +310,123 @@ cmdline_parse_inst_t cmd_quit = {\n \n /****************/\n \n+struct cmd_set_rxtx_result {\n+\tcmdline_fixed_string_t set;\n+\tcmdline_fixed_string_t mode;\n+};\n+\n+static void cmd_set_rxtx_parsed(void *parsed_result, struct cmdline *cl,\n+\t\t\t\t__attribute__((unused)) void *data)\n+{\n+\tstruct cmd_set_rxtx_result *res = parsed_result;\n+\tif (test_set_rxtx_conf(res->mode) < 0)\n+\t\tcmdline_printf(cl, \"Cannot find such mode\\n\");\n+}\n+\n+cmdline_parse_token_string_t cmd_set_rxtx_set =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_set_rxtx_result, set,\n+\t\t\t\t \"set_rxtx_mode\");\n+\n+cmdline_parse_token_string_t cmd_set_rxtx_mode =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_set_rxtx_result, mode, NULL);\n+\n+cmdline_parse_inst_t cmd_set_rxtx = {\n+\t.f = cmd_set_rxtx_parsed,  /* function to call */\n+\t.data = NULL,      /* 2nd arg of func */\n+\t.help_str = \"set rxtx routine: \"\n+\t\t\t\"set_rxtx <mode>\",\n+\t.tokens = {        /* token list, NULL terminated */\n+\t\t(void *)&cmd_set_rxtx_set,\n+\t\t(void *)&cmd_set_rxtx_mode,\n+\t\tNULL,\n+\t},\n+};\n+\n+/****************/\n+\n+struct cmd_set_rxtx_anchor {\n+\tcmdline_fixed_string_t set;\n+\tcmdline_fixed_string_t type;\n+};\n+\n+static void\n+cmd_set_rxtx_anchor_parsed(void *parsed_result,\n+\t\t\t   struct cmdline *cl,\n+\t\t\t   __attribute__((unused)) void *data)\n+{\n+\tstruct cmd_set_rxtx_anchor *res = parsed_result;\n+\tif (test_set_rxtx_anchor(res->type) < 0)\n+\t\tcmdline_printf(cl, \"Cannot find such anchor\\n\");\n+}\n+\n+cmdline_parse_token_string_t cmd_set_rxtx_anchor_set =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_set_rxtx_anchor, set,\n+\t\t\t\t \"set_rxtx_anchor\");\n+\n+cmdline_parse_token_string_t cmd_set_rxtx_anchor_type =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_set_rxtx_anchor, type, NULL);\n+\n+cmdline_parse_inst_t cmd_set_rxtx_anchor = {\n+\t.f = cmd_set_rxtx_anchor_parsed,  /* function to call */\n+\t.data = NULL,      /* 2nd arg of func */\n+\t.help_str = \"set rxtx anchor: \"\n+\t\t\t\"set_rxtx_anchor <type>\",\n+\t.tokens = {        /* token list, NULL terminated */\n+\t\t(void *)&cmd_set_rxtx_anchor_set,\n+\t\t(void *)&cmd_set_rxtx_anchor_type,\n+\t\tNULL,\n+\t},\n+};\n+\n+/****************/\n+\n+/* for stream control */\n+struct cmd_set_rxtx_sc {\n+\tcmdline_fixed_string_t set;\n+\tcmdline_fixed_string_t type;\n+};\n+\n+static void\n+cmd_set_rxtx_sc_parsed(void *parsed_result,\n+\t\t\t   struct cmdline *cl,\n+\t\t\t   __attribute__((unused)) void *data)\n+{\n+\tstruct cmd_set_rxtx_sc *res = parsed_result;\n+\tif (test_set_rxtx_sc(res->type) < 0)\n+\t\tcmdline_printf(cl, \"Cannot find such stream control\\n\");\n+}\n+\n+cmdline_parse_token_string_t cmd_set_rxtx_sc_set =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_set_rxtx_sc, set,\n+\t\t\t\t \"set_rxtx_sc\");\n+\n+cmdline_parse_token_string_t cmd_set_rxtx_sc_type =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_set_rxtx_sc, type, NULL);\n+\n+cmdline_parse_inst_t cmd_set_rxtx_sc = {\n+\t.f = cmd_set_rxtx_sc_parsed,  /* function to call */\n+\t.data = NULL,      /* 2nd arg of func */\n+\t.help_str = \"set rxtx stream control: \"\n+\t\t\t\"set_rxtx_sc <type>\",\n+\t.tokens = {        /* token list, NULL terminated */\n+\t\t(void *)&cmd_set_rxtx_sc_set,\n+\t\t(void *)&cmd_set_rxtx_sc_type,\n+\t\tNULL,\n+\t},\n+};\n+\n+/****************/\n+\n+\n cmdline_parse_ctx_t main_ctx[] = {\n \t(cmdline_parse_inst_t *)&cmd_autotest,\n \t(cmdline_parse_inst_t *)&cmd_dump,\n \t(cmdline_parse_inst_t *)&cmd_dump_one,\n \t(cmdline_parse_inst_t *)&cmd_set_ring,\n \t(cmdline_parse_inst_t *)&cmd_quit,\n+\t(cmdline_parse_inst_t *)&cmd_set_rxtx,\n+\t(cmdline_parse_inst_t *)&cmd_set_rxtx_anchor,\n+\t(cmdline_parse_inst_t *)&cmd_set_rxtx_sc,\n \tNULL,\n };\n \ndiff --git a/app/test/test.h b/app/test/test.h\nindex 98ab804..bd44a7f 100644\n--- a/app/test/test.h\n+++ b/app/test/test.h\n@@ -125,6 +125,9 @@ int unit_test_suite_runner(struct unit_test_suite *suite);\n \n #define RECURSIVE_ENV_VAR \"RTE_TEST_RECURSIVE\"\n \n+#include <cmdline_parse.h>\n+#include <cmdline_parse_string.h>\n+\n extern const char *prgname;\n \n int commands_init(void);\n@@ -137,6 +140,9 @@ int test_pci_run;\n int test_mp_secondary(void);\n \n int test_ivshmem(void);\n+int test_set_rxtx_conf(cmdline_fixed_string_t mode);\n+int test_set_rxtx_anchor(cmdline_fixed_string_t type);\n+int test_set_rxtx_sc(cmdline_fixed_string_t type);\n \n typedef int (test_callback)(void);\n TAILQ_HEAD(test_commands_list, test_command);\ndiff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c\nnew file mode 100644\nindex 0000000..1c1f236\n--- /dev/null\n+++ b/app/test/test_pmd_perf.c\n@@ -0,0 +1,922 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+\n+#include <stdio.h>\n+#include <inttypes.h>\n+#include <signal.h>\n+#include <unistd.h>\n+#include <rte_cycles.h>\n+#include <rte_ethdev.h>\n+#include <rte_byteorder.h>\n+#include <rte_atomic.h>\n+#include <rte_malloc.h>\n+#include \"packet_burst_generator.h\"\n+#include \"test.h\"\n+\n+#define NB_ETHPORTS_USED                (1)\n+#define NB_SOCKETS                      (2)\n+#define MEMPOOL_CACHE_SIZE 250\n+#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)\n+#define MAX_PKT_BURST                   (32)\n+#define RTE_TEST_RX_DESC_DEFAULT        (128)\n+#define RTE_TEST_TX_DESC_DEFAULT        (512)\n+#define RTE_PORT_ALL            (~(uint8_t)0x0)\n+\n+/* how long test would take at full line rate */\n+#define RTE_TEST_DURATION                (2)\n+\n+/*\n+ * RX and TX Prefetch, Host, and Write-back threshold values should be\n+ * carefully set for optimal performance. Consult the network\n+ * controller's datasheet and supporting DPDK documentation for guidance\n+ * on how these parameters should be set.\n+ */\n+#define RX_PTHRESH 8 /**< Default values of RX prefetch threshold reg. */\n+#define RX_HTHRESH 8 /**< Default values of RX host threshold reg. */\n+#define RX_WTHRESH 0 /**< Default values of RX write-back threshold reg. */\n+\n+/*\n+ * These default values are optimized for use with the Intel(R) 82599 10 GbE\n+ * Controller and the DPDK ixgbe PMD. Consider using other values for other\n+ * network controllers and/or network drivers.\n+ */\n+#define TX_PTHRESH 32 /**< Default values of TX prefetch threshold reg. */\n+#define TX_HTHRESH 0  /**< Default values of TX host threshold reg. */\n+#define TX_WTHRESH 0  /**< Default values of TX write-back threshold reg. */\n+\n+#define MAX_TRAFFIC_BURST              2048\n+\n+#define NB_MBUF RTE_MAX(\t\t\t\t\t\t\\\n+\t\t(unsigned)(nb_ports*nb_rx_queue*nb_rxd +\t\t\\\n+\t\t\t   nb_ports*nb_lcores*MAX_PKT_BURST +\t\t\\\n+\t\t\t   nb_ports*nb_tx_queue*nb_txd +\t\t\\\n+\t\t\t   nb_lcores*MEMPOOL_CACHE_SIZE +\t\t\\\n+\t\t\t   nb_ports*MAX_TRAFFIC_BURST),\t\t\t\\\n+\t\t\t(unsigned)8192)\n+\n+\n+static struct rte_mempool *mbufpool[NB_SOCKETS];\n+/* ethernet addresses of ports */\n+static struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];\n+\n+static struct rte_eth_conf port_conf = {\n+\t.rxmode = {\n+\t\t.mq_mode = ETH_MQ_RX_NONE,\n+\t\t.max_rx_pkt_len = ETHER_MAX_LEN,\n+\t\t.split_hdr_size = 0,\n+\t\t.header_split   = 0, /**< Header Split disabled */\n+\t\t.hw_ip_checksum = 0, /**< IP checksum offload enabled */\n+\t\t.hw_vlan_filter = 0, /**< VLAN filtering disabled */\n+\t\t.hw_vlan_strip  = 0, /**< VLAN strip enabled. */\n+\t\t.hw_vlan_extend = 0, /**< Extended VLAN disabled. */\n+\t\t.jumbo_frame    = 0, /**< Jumbo Frame Support disabled */\n+\t\t.hw_strip_crc   = 0, /**< CRC stripped by hardware */\n+\t\t.enable_scatter = 0, /**< scatter rx disabled */\n+\t},\n+\t.txmode = {\n+\t\t.mq_mode = ETH_MQ_TX_NONE,\n+\t},\n+\t.lpbk_mode = 1,  /* enable loopback */\n+};\n+\n+static struct rte_eth_rxconf rx_conf = {\n+\t.rx_thresh = {\n+\t\t.pthresh = RX_PTHRESH,\n+\t\t.hthresh = RX_HTHRESH,\n+\t\t.wthresh = RX_WTHRESH,\n+\t},\n+\t.rx_free_thresh = 32,\n+};\n+\n+static struct rte_eth_txconf tx_conf = {\n+\t.tx_thresh = {\n+\t\t.pthresh = TX_PTHRESH,\n+\t\t.hthresh = TX_HTHRESH,\n+\t\t.wthresh = TX_WTHRESH,\n+\t},\n+\t.tx_free_thresh = 32, /* Use PMD default values */\n+\t.tx_rs_thresh = 32, /* Use PMD default values */\n+\t.txq_flags = (ETH_TXQ_FLAGS_NOMULTSEGS |\n+\t\t      ETH_TXQ_FLAGS_NOVLANOFFL |\n+\t\t      ETH_TXQ_FLAGS_NOXSUMSCTP |\n+\t\t      ETH_TXQ_FLAGS_NOXSUMUDP |\n+\t\t      ETH_TXQ_FLAGS_NOXSUMTCP)\n+};\n+\n+enum {\n+\tLCORE_INVALID = 0,\n+\tLCORE_AVAIL,\n+\tLCORE_USED,\n+};\n+\n+struct lcore_conf {\n+\tuint8_t status;\n+\tuint8_t socketid;\n+\tuint16_t nb_ports;\n+\tuint8_t portlist[RTE_MAX_ETHPORTS];\n+} __rte_cache_aligned;\n+\n+struct lcore_conf lcore_conf[RTE_MAX_LCORE];\n+\n+static uint64_t link_mbps;\n+\n+enum {\n+\tSC_CONTINUOUS = 0,\n+\tSC_BURST_POLL_FIRST,\n+\tSC_BURST_XMIT_FIRST,\n+};\n+\n+static uint32_t sc_flag;\n+\n+/* Check the link status of all ports in up to 3s, and print them finally */\n+static void\n+check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)\n+{\n+#define CHECK_INTERVAL 100 /* 100ms */\n+#define MAX_CHECK_TIME 30 /* 3s (30 * 100ms) in total */\n+\tuint8_t portid, count, all_ports_up, print_flag = 0;\n+\tstruct rte_eth_link link;\n+\n+\tprintf(\"Checking link statuses...\\n\");\n+\tfflush(stdout);\n+\tfor (count = 0; count <= MAX_CHECK_TIME; count++) {\n+\t\tall_ports_up = 1;\n+\t\tfor (portid = 0; portid < port_num; portid++) {\n+\t\t\tif ((port_mask & (1 << portid)) == 0)\n+\t\t\t\tcontinue;\n+\t\t\tmemset(&link, 0, sizeof(link));\n+\t\t\trte_eth_link_get_nowait(portid, &link);\n+\t\t\t/* print link status if flag set */\n+\t\t\tif (print_flag == 1) {\n+\t\t\t\tif (link.link_status) {\n+\t\t\t\t\tprintf(\"Port %d Link Up - speed %u \"\n+\t\t\t\t\t\t\"Mbps - %s\\n\", (uint8_t)portid,\n+\t\t\t\t\t\t(unsigned)link.link_speed,\n+\t\t\t\t(link.link_duplex == ETH_LINK_FULL_DUPLEX) ?\n+\t\t\t\t\t(\"full-duplex\") : (\"half-duplex\\n\"));\n+\t\t\t\t\tif (link_mbps == 0)\n+\t\t\t\t\t\tlink_mbps = link.link_speed;\n+\t\t\t\t} else\n+\t\t\t\t\tprintf(\"Port %d Link Down\\n\",\n+\t\t\t\t\t\t(uint8_t)portid);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t\t/* clear all_ports_up flag if any link down */\n+\t\t\tif (link.link_status == 0) {\n+\t\t\t\tall_ports_up = 0;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\t\t/* after finally printing all link status, get out */\n+\t\tif (print_flag == 1)\n+\t\t\tbreak;\n+\n+\t\tif (all_ports_up == 0) {\n+\t\t\tfflush(stdout);\n+\t\t\trte_delay_ms(CHECK_INTERVAL);\n+\t\t}\n+\n+\t\t/* set the print_flag if all ports up or timeout */\n+\t\tif (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1))\n+\t\t\tprint_flag = 1;\n+\t}\n+}\n+\n+static void\n+print_ethaddr(const char *name, const struct ether_addr *eth_addr)\n+{\n+\tchar buf[ETHER_ADDR_FMT_SIZE];\n+\tether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);\n+\tprintf(\"%s%s\", name, buf);\n+}\n+\n+static int\n+init_traffic(struct rte_mempool *mp,\n+\t     struct rte_mbuf **pkts_burst, uint32_t burst_size)\n+{\n+\tstruct ether_hdr pkt_eth_hdr;\n+\tstruct ipv4_hdr pkt_ipv4_hdr;\n+\tstruct udp_hdr pkt_udp_hdr;\n+\tuint32_t pktlen;\n+\tstatic uint8_t src_mac[] = { 0x00, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF };\n+\tstatic uint8_t dst_mac[] = { 0x00, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA };\n+\n+\n+\tinitialize_eth_header(&pkt_eth_hdr,\n+\t\t(struct ether_addr *)src_mac,\n+\t\t(struct ether_addr *)dst_mac, 0, 0);\n+\tpkt_eth_hdr.ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);\n+\n+\tpktlen = initialize_ipv4_header(&pkt_ipv4_hdr,\n+\t\t\t\t\tIPV4_ADDR(10, 0, 0, 1),\n+\t\t\t\t\tIPV4_ADDR(10, 0, 0, 2), 26);\n+\tprintf(\"IPv4 pktlen %u\\n\", pktlen);\n+\n+\tpktlen = initialize_udp_header(&pkt_udp_hdr, 0, 0, 18);\n+\n+\tprintf(\"UDP pktlen %u\\n\", pktlen);\n+\n+\treturn generate_packet_burst(mp, pkts_burst, &pkt_eth_hdr,\n+\t\t\t\t     0, &pkt_ipv4_hdr, 1,\n+\t\t\t\t     &pkt_udp_hdr, burst_size,\n+\t\t\t\t     PACKET_BURST_GEN_PKT_LEN, 1);\n+}\n+\n+static int\n+init_lcores(void)\n+{\n+\tunsigned lcore_id;\n+\n+\tfor (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {\n+\t\tlcore_conf[lcore_id].socketid =\n+\t\t\trte_lcore_to_socket_id(lcore_id);\n+\t\tif (rte_lcore_is_enabled(lcore_id) == 0) {\n+\t\t\tlcore_conf[lcore_id].status = LCORE_INVALID;\n+\t\t\tcontinue;\n+\t\t} else\n+\t\t\tlcore_conf[lcore_id].status = LCORE_AVAIL;\n+\t}\n+\treturn 0;\n+}\n+\n+static int\n+init_mbufpool(unsigned nb_mbuf)\n+{\n+\tint socketid;\n+\tunsigned lcore_id;\n+\tchar s[64];\n+\n+\tfor (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {\n+\t\tif (rte_lcore_is_enabled(lcore_id) == 0)\n+\t\t\tcontinue;\n+\n+\t\tsocketid = rte_lcore_to_socket_id(lcore_id);\n+\t\tif (socketid >= NB_SOCKETS) {\n+\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\"Socket %d of lcore %u is out of range %d\\n\",\n+\t\t\t\tsocketid, lcore_id, NB_SOCKETS);\n+\t\t}\n+\t\tif (mbufpool[socketid] == NULL) {\n+\t\t\tsnprintf(s, sizeof(s), \"mbuf_pool_%d\", socketid);\n+\t\t\tmbufpool[socketid] =\n+\t\t\t\trte_mempool_create(s, nb_mbuf, MBUF_SIZE,\n+\t\t\t\t\tMEMPOOL_CACHE_SIZE,\n+\t\t\t\t\tsizeof(struct rte_pktmbuf_pool_private),\n+\t\t\t\t\trte_pktmbuf_pool_init, NULL,\n+\t\t\t\t\trte_pktmbuf_init, NULL,\n+\t\t\t\t\tsocketid, 0);\n+\t\t\tif (mbufpool[socketid] == NULL)\n+\t\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\t\"Cannot init mbuf pool on socket %d\\n\",\n+\t\t\t\t\tsocketid);\n+\t\t\telse\n+\t\t\t\tprintf(\"Allocated mbuf pool on socket %d\\n\",\n+\t\t\t\t\tsocketid);\n+\t\t}\n+\t}\n+\treturn 0;\n+}\n+\n+static uint16_t\n+alloc_lcore(uint16_t socketid)\n+{\n+\tunsigned lcore_id;\n+\n+\tfor (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {\n+\t\tif (LCORE_AVAIL != lcore_conf[lcore_id].status ||\n+\t\t    lcore_conf[lcore_id].socketid != socketid ||\n+\t\t    lcore_id == rte_get_master_lcore())\n+\t\t\tcontinue;\n+\t\tlcore_conf[lcore_id].status = LCORE_USED;\n+\t\tlcore_conf[lcore_id].nb_ports = 0;\n+\t\treturn lcore_id;\n+\t}\n+\n+\treturn (uint16_t)-1;\n+}\n+\n+volatile uint64_t stop;\n+uint64_t count;\n+uint64_t drop;\n+uint64_t idle;\n+\n+static void\n+reset_count(void)\n+{\n+\tcount = 0;\n+\tdrop = 0;\n+\tidle = 0;\n+}\n+\n+static void\n+stats_display(uint8_t port_id)\n+{\n+\tstruct rte_eth_stats stats;\n+\trte_eth_stats_get(port_id, &stats);\n+\n+\tprintf(\"  RX-packets: %-10\"PRIu64\" RX-missed: %-10\"PRIu64\" RX-bytes:  \"\n+\t       \"%-\"PRIu64\"\\n\",\n+\t       stats.ipackets, stats.imissed, stats.ibytes);\n+\tprintf(\"  RX-badcrc:  %-10\"PRIu64\" RX-badlen: %-10\"PRIu64\" RX-errors: \"\n+\t       \"%-\"PRIu64\"\\n\",\n+\t       stats.ibadcrc, stats.ibadlen, stats.ierrors);\n+\tprintf(\"  RX-nombuf:  %-10\"PRIu64\"\\n\",\n+\t       stats.rx_nombuf);\n+\tprintf(\"  TX-packets: %-10\"PRIu64\" TX-errors: %-10\"PRIu64\" TX-bytes:  \"\n+\t       \"%-\"PRIu64\"\\n\",\n+\t       stats.opackets, stats.oerrors, stats.obytes);\n+}\n+\n+static void\n+signal_handler(int signum)\n+{\n+\t/*  USR1 signal, stop testing */\n+\tif (signum == SIGUSR1) {\n+\t\tprintf(\"Force Stop!\\n\");\n+\t\tstop = 1;\n+\t}\n+\n+\t/*  USR2 signal, print stats */\n+\tif (signum == SIGUSR2)\n+\t\tstats_display(0);\n+}\n+\n+struct rte_mbuf **tx_burst;\n+\n+uint64_t (*do_measure)(struct lcore_conf *conf,\n+\t\t       struct rte_mbuf *pkts_burst[],\n+\t\t       uint64_t total_pkts);\n+\n+static uint64_t\n+measure_rxtx(struct lcore_conf *conf,\n+\t     struct rte_mbuf *pkts_burst[],\n+\t     uint64_t total_pkts)\n+{\n+\tunsigned i, portid, nb_rx, nb_tx;\n+\tuint64_t prev_tsc, cur_tsc;\n+\n+\tprev_tsc = rte_rdtsc();\n+\n+\twhile (likely(!stop)) {\n+\t\tfor (i = 0; i < conf->nb_ports; i++) {\n+\t\t\tportid = conf->portlist[i];\n+\t\t\tnb_rx = rte_eth_rx_burst((uint8_t) portid, 0,\n+\t\t\t\t\t\t pkts_burst, MAX_PKT_BURST);\n+\t\t\tif (unlikely(nb_rx == 0)) {\n+\t\t\t\tidle++;\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\tcount += nb_rx;\n+\t\t\tnb_tx = rte_eth_tx_burst(portid, 0, pkts_burst, nb_rx);\n+\t\t\tif (unlikely(nb_tx < nb_rx)) {\n+\t\t\t\tdrop += (nb_rx - nb_tx);\n+\t\t\t\tdo {\n+\t\t\t\t\trte_pktmbuf_free(pkts_burst[nb_tx]);\n+\t\t\t\t} while (++nb_tx < nb_rx);\n+\t\t\t}\n+\t\t}\n+\t\tif (unlikely(count >= total_pkts))\n+\t\t\tbreak;\n+\t}\n+\n+\tcur_tsc = rte_rdtsc();\n+\n+\treturn cur_tsc - prev_tsc;\n+}\n+\n+static uint64_t\n+measure_rxonly(struct lcore_conf *conf,\n+\t       struct rte_mbuf *pkts_burst[],\n+\t       uint64_t total_pkts)\n+{\n+\tunsigned i, portid, nb_rx, nb_tx;\n+\tuint64_t diff_tsc, cur_tsc;\n+\n+\tdiff_tsc = 0;\n+\twhile (likely(!stop)) {\n+\t\tfor (i = 0; i < conf->nb_ports; i++) {\n+\t\t\tportid = conf->portlist[i];\n+\n+\t\t\tcur_tsc = rte_rdtsc();\n+\t\t\tnb_rx = rte_eth_rx_burst((uint8_t) portid, 0,\n+\t\t\t\t\t\t pkts_burst, MAX_PKT_BURST);\n+\t\t\tif (unlikely(nb_rx == 0)) {\n+\t\t\t\tidle++;\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t\tdiff_tsc += rte_rdtsc() - cur_tsc;\n+\n+\t\t\tcount += nb_rx;\n+\t\t\tnb_tx = rte_eth_tx_burst(portid, 0, pkts_burst, nb_rx);\n+\t\t\tif (unlikely(nb_tx < nb_rx)) {\n+\t\t\t\tdrop += (nb_rx - nb_tx);\n+\t\t\t\tdo {\n+\t\t\t\t\trte_pktmbuf_free(pkts_burst[nb_tx]);\n+\t\t\t\t} while (++nb_tx < nb_rx);\n+\t\t\t}\n+\t\t}\n+\t\tif (unlikely(count >= total_pkts))\n+\t\t\tbreak;\n+\t}\n+\n+\treturn diff_tsc;\n+}\n+\n+static uint64_t\n+measure_txonly(struct lcore_conf *conf,\n+\t       struct rte_mbuf *pkts_burst[],\n+\t       uint64_t total_pkts)\n+{\n+\tunsigned i, portid, nb_rx, nb_tx;\n+\tuint64_t diff_tsc, cur_tsc;\n+\n+\tprintf(\"do tx measure\\n\");\n+\tdiff_tsc = 0;\n+\twhile (likely(!stop)) {\n+\t\tfor (i = 0; i < conf->nb_ports; i++) {\n+\t\t\tportid = conf->portlist[i];\n+\t\t\tnb_rx = rte_eth_rx_burst((uint8_t) portid, 0,\n+\t\t\t\t\t\t pkts_burst, MAX_PKT_BURST);\n+\t\t\tif (unlikely(nb_rx == 0)) {\n+\t\t\t\tidle++;\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\tcount += nb_rx;\n+\n+\t\t\tcur_tsc = rte_rdtsc();\n+\t\t\tnb_tx = rte_eth_tx_burst(portid, 0, pkts_burst, nb_rx);\n+\t\t\tif (unlikely(nb_tx < nb_rx)) {\n+\t\t\t\tdrop += (nb_rx - nb_tx);\n+\t\t\t\tdo {\n+\t\t\t\t\trte_pktmbuf_free(pkts_burst[nb_tx]);\n+\t\t\t\t} while (++nb_tx < nb_rx);\n+\t\t\t}\n+\t\t\tdiff_tsc += rte_rdtsc() - cur_tsc;\n+\t\t}\n+\t\tif (unlikely(count >= total_pkts))\n+\t\t\tbreak;\n+\t}\n+\n+\treturn diff_tsc;\n+}\n+\n+/* main processing loop */\n+static int\n+main_loop(__rte_unused void *args)\n+{\n+#define PACKET_SIZE 64\n+#define FRAME_GAP 12\n+#define MAC_PREAMBLE 8\n+\tstruct rte_mbuf *pkts_burst[MAX_PKT_BURST];\n+\tunsigned lcore_id;\n+\tunsigned i, portid, nb_rx = 0, nb_tx = 0;\n+\tstruct lcore_conf *conf;\n+\tint pkt_per_port;\n+\tuint64_t diff_tsc;\n+\tuint64_t packets_per_second, total_packets;\n+\n+\tlcore_id = rte_lcore_id();\n+\tconf = &lcore_conf[lcore_id];\n+\tif (conf->status != LCORE_USED)\n+\t\treturn 0;\n+\n+\tpkt_per_port = MAX_TRAFFIC_BURST;\n+\n+\tint idx = 0;\n+\tfor (i = 0; i < conf->nb_ports; i++) {\n+\t\tint num = pkt_per_port;\n+\t\tportid = conf->portlist[i];\n+\t\tprintf(\"inject %d packet to port %d\\n\", num, portid);\n+\t\twhile (num) {\n+\t\t\tnb_tx = RTE_MIN(MAX_PKT_BURST, num);\n+\t\t\tnb_tx = rte_eth_tx_burst(portid, 0,\n+\t\t\t\t\t\t&tx_burst[idx], nb_tx);\n+\t\t\tnum -= nb_tx;\n+\t\t\tidx += nb_tx;\n+\t\t}\n+\t}\n+\tprintf(\"Total packets inject to prime ports = %u\\n\", idx);\n+\n+\tpackets_per_second = (link_mbps * 1000 * 1000) /\n+\t\t((PACKET_SIZE + FRAME_GAP + MAC_PREAMBLE) * CHAR_BIT);\n+\tprintf(\"Each port will do %\"PRIu64\" packets per second\\n\",\n+\t       packets_per_second);\n+\n+\ttotal_packets = RTE_TEST_DURATION * conf->nb_ports * packets_per_second;\n+\tprintf(\"Test will stop after at least %\"PRIu64\" packets received\\n\",\n+\t\t+ total_packets);\n+\n+\tdiff_tsc = do_measure(conf, pkts_burst, total_packets);\n+\n+\tfor (i = 0; i < conf->nb_ports; i++) {\n+\t\tportid = conf->portlist[i];\n+\t\tint nb_free = pkt_per_port;\n+\t\tdo { /* dry out */\n+\t\t\tnb_rx = rte_eth_rx_burst((uint8_t) portid, 0,\n+\t\t\t\t\t\t pkts_burst, MAX_PKT_BURST);\n+\t\t\tnb_tx = 0;\n+\t\t\twhile (nb_tx < nb_rx)\n+\t\t\t\trte_pktmbuf_free(pkts_burst[nb_tx++]);\n+\t\t\tnb_free -= nb_rx;\n+\t\t} while (nb_free != 0);\n+\t\tprintf(\"free %d mbuf left in port %u\\n\", pkt_per_port, portid);\n+\t}\n+\n+\tif (count == 0)\n+\t\treturn -1;\n+\n+\tprintf(\"%\"PRIu64\" packet, %\"PRIu64\" drop, %\"PRIu64\" idle\\n\",\n+\t       count, drop, idle);\n+\tprintf(\"Result: %\"PRIu64\" cycles per packet\\n\", diff_tsc / count);\n+\n+\treturn 0;\n+}\n+\n+rte_atomic64_t start;\n+\n+static inline int\n+poll_burst(void *args)\n+{\n+#define MAX_IDLE           (10000)\n+\tunsigned lcore_id;\n+\tstruct rte_mbuf **pkts_burst;\n+\tuint64_t diff_tsc, cur_tsc;\n+\tuint16_t next[RTE_MAX_ETHPORTS];\n+\tstruct lcore_conf *conf;\n+\tuint32_t pkt_per_port = *((uint32_t *)args);\n+\tunsigned i, portid, nb_rx = 0;\n+\tuint64_t total;\n+\tuint64_t timeout = MAX_IDLE;\n+\n+\tlcore_id = rte_lcore_id();\n+\tconf = &lcore_conf[lcore_id];\n+\tif (conf->status != LCORE_USED)\n+\t\treturn 0;\n+\n+\ttotal = pkt_per_port * conf->nb_ports;\n+\tprintf(\"start to receive total expect %\"PRIu64\"\\n\", total);\n+\n+\tpkts_burst = (struct rte_mbuf **)\n+\t\trte_calloc_socket(\"poll_burst\",\n+\t\t\t\t  total, sizeof(void *),\n+\t\t\t\t  CACHE_LINE_SIZE, conf->socketid);\n+\tif (!pkts_burst)\n+\t\treturn -1;\n+\n+\tfor (i = 0; i < conf->nb_ports; i++) {\n+\t\tportid = conf->portlist[i];\n+\t\tnext[portid] = i * pkt_per_port;\n+\t}\n+\n+\twhile (!rte_atomic64_read(&start))\n+\t\t;\n+\n+\tcur_tsc = rte_rdtsc();\n+\twhile (total) {\n+\t\tfor (i = 0; i < conf->nb_ports; i++) {\n+\t\t\tportid = conf->portlist[i];\n+\t\t\tnb_rx = rte_eth_rx_burst((uint8_t) portid, 0,\n+\t\t\t\t\t\t &pkts_burst[next[portid]],\n+\t\t\t\t\t\t MAX_PKT_BURST);\n+\t\t\tif (unlikely(nb_rx == 0)) {\n+\t\t\t\ttimeout--;\n+\t\t\t\tif (unlikely(timeout == 0))\n+\t\t\t\t\tgoto timeout;\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t\tnext[portid] += nb_rx;\n+\t\t\ttotal -= nb_rx;\n+\t\t}\n+\t}\n+timeout:\n+\tdiff_tsc = rte_rdtsc() - cur_tsc;\n+\n+\tprintf(\"%\"PRIu64\" packets lost, IDLE %\"PRIu64\" times\\n\",\n+\t       total, MAX_IDLE - timeout);\n+\n+\t/* clean up */\n+\ttotal = pkt_per_port * conf->nb_ports - total;\n+\tfor (i = 0; i < total; i++)\n+\t\trte_pktmbuf_free(pkts_burst[i]);\n+\n+\trte_free(pkts_burst);\n+\n+\treturn diff_tsc / total;\n+}\n+\n+static int\n+exec_burst(uint32_t flags, int lcore)\n+{\n+\tunsigned i, portid, nb_tx = 0;\n+\tstruct lcore_conf *conf;\n+\tuint32_t pkt_per_port;\n+\tint num, idx = 0;\n+\tint diff_tsc;\n+\n+\tconf = &lcore_conf[lcore];\n+\n+\tpkt_per_port = MAX_TRAFFIC_BURST;\n+\tnum = pkt_per_port;\n+\n+\trte_atomic64_init(&start);\n+\n+\t/* start polling thread, but not actually poll yet */\n+\trte_eal_remote_launch(poll_burst,\n+\t\t\t      (void *)&pkt_per_port, lcore);\n+\n+\t/* Only when polling first */\n+\tif (flags == SC_BURST_POLL_FIRST)\n+\t\trte_atomic64_set(&start, 1);\n+\n+\t/* start xmit */\n+\twhile (num) {\n+\t\tnb_tx = RTE_MIN(MAX_PKT_BURST, num);\n+\t\tfor (i = 0; i < conf->nb_ports; i++) {\n+\t\t\tportid = conf->portlist[i];\n+\t\t\trte_eth_tx_burst(portid, 0,\n+\t\t\t\t\t &tx_burst[idx], nb_tx);\n+\t\t\tidx += nb_tx;\n+\t\t}\n+\t\tnum -= nb_tx;\n+\t}\n+\n+\tsleep(5);\n+\n+\t/* only when polling second  */\n+\tif (flags == SC_BURST_XMIT_FIRST)\n+\t\trte_atomic64_set(&start, 1);\n+\n+\t/* wait for polling finished */\n+\tdiff_tsc = rte_eal_wait_lcore(lcore);\n+\tif (diff_tsc < 0)\n+\t\treturn -1;\n+\n+\tprintf(\"Result: %d cycles per packet\\n\", diff_tsc);\n+\n+\treturn 0;\n+}\n+\n+static int\n+test_pmd_perf(void)\n+{\n+\tuint16_t nb_ports, num, nb_lcores, slave_id = (uint16_t)-1;\n+\tuint16_t nb_rxd = MAX_TRAFFIC_BURST;\n+\tuint16_t nb_txd = MAX_TRAFFIC_BURST;\n+\tuint16_t portid;\n+\tuint16_t nb_rx_queue = 1, nb_tx_queue = 1;\n+\tint socketid = -1;\n+\tint ret;\n+\n+\tprintf(\"Start PMD RXTX cycles cost test.\\n\");\n+\n+\tsignal(SIGUSR1, signal_handler);\n+\tsignal(SIGUSR2, signal_handler);\n+\n+\tnb_ports = rte_eth_dev_count();\n+\tif (nb_ports < NB_ETHPORTS_USED) {\n+\t\tprintf(\"At least %u port(s) used for perf. test\\n\",\n+\t\t       NB_ETHPORTS_USED);\n+\t\treturn -1;\n+\t}\n+\n+\tif (nb_ports > RTE_MAX_ETHPORTS)\n+\t\tnb_ports = RTE_MAX_ETHPORTS;\n+\n+\tnb_lcores = rte_lcore_count();\n+\n+\tmemset(lcore_conf, 0, sizeof(lcore_conf));\n+\tinit_lcores();\n+\n+\tinit_mbufpool(NB_MBUF);\n+\n+\tif (sc_flag == SC_CONTINUOUS) {\n+\t\tnb_rxd = RTE_TEST_RX_DESC_DEFAULT;\n+\t\tnb_txd = RTE_TEST_TX_DESC_DEFAULT;\n+\t}\n+\tprintf(\"CONFIG RXD=%d TXD=%d\\n\", nb_rxd, nb_txd);\n+\n+\treset_count();\n+\tnum = 0;\n+\tfor (portid = 0; portid < nb_ports; portid++) {\n+\t\tif (socketid == -1) {\n+\t\t\tsocketid = rte_eth_dev_socket_id(portid);\n+\t\t\tslave_id = alloc_lcore(socketid);\n+\t\t\tif (slave_id == (uint16_t)-1) {\n+\t\t\t\tprintf(\"No avail lcore to run test\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tprintf(\"Performance test runs on lcore %u socket %u\\n\",\n+\t\t\t       slave_id, socketid);\n+\t\t}\n+\n+\t\tif (socketid != rte_eth_dev_socket_id(portid)) {\n+\t\t\tprintf(\"Skip port %d\\n\", portid);\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\t/* port configure */\n+\t\tret = rte_eth_dev_configure(portid, nb_rx_queue,\n+\t\t\t\t\t    nb_tx_queue, &port_conf);\n+\t\tif (ret < 0)\n+\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\"Cannot configure device: err=%d, port=%d\\n\",\n+\t\t\t\t ret, portid);\n+\n+\t\trte_eth_macaddr_get(portid, &ports_eth_addr[portid]);\n+\t\tprintf(\"Port %u \", portid);\n+\t\tprint_ethaddr(\"Address:\", &ports_eth_addr[portid]);\n+\t\tprintf(\"\\n\");\n+\n+\t\t/* tx queue setup */\n+\t\tret = rte_eth_tx_queue_setup(portid, 0, nb_txd,\n+\t\t\t\t\t     socketid, &tx_conf);\n+\t\tif (ret < 0)\n+\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\"rte_eth_tx_queue_setup: err=%d, \"\n+\t\t\t\t\"port=%d\\n\", ret, portid);\n+\n+\t\t/* rx queue steup */\n+\t\tret = rte_eth_rx_queue_setup(portid, 0, nb_rxd,\n+\t\t\t\t\t\tsocketid, &rx_conf,\n+\t\t\t\t\t\tmbufpool[socketid]);\n+\t\tif (ret < 0)\n+\t\t\trte_exit(EXIT_FAILURE, \"rte_eth_rx_queue_setup: err=%d,\"\n+\t\t\t\t \"port=%d\\n\", ret, portid);\n+\n+\t\t/* Start device */\n+\t\tstop = 0;\n+\t\tret = rte_eth_dev_start(portid);\n+\t\tif (ret < 0)\n+\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\"rte_eth_dev_start: err=%d, port=%d\\n\",\n+\t\t\t\tret, portid);\n+\n+\t\t/* always eanble promiscuous */\n+\t\trte_eth_promiscuous_enable(portid);\n+\n+\t\tlcore_conf[slave_id].portlist[num++] = portid;\n+\t\tlcore_conf[slave_id].nb_ports++;\n+\t}\n+\tcheck_all_ports_link_status(nb_ports, RTE_PORT_ALL);\n+\n+\tif (tx_burst == NULL) {\n+\t\ttx_burst = (struct rte_mbuf **)\n+\t\t\trte_calloc_socket(\"tx_buff\",\n+\t\t\t\t\t  MAX_TRAFFIC_BURST * nb_ports,\n+\t\t\t\t\t  sizeof(void *),\n+\t\t\t\t\t  CACHE_LINE_SIZE, socketid);\n+\t\tif (!tx_burst)\n+\t\t\treturn -1;\n+\t}\n+\n+\tinit_traffic(mbufpool[socketid],\n+\t\t     tx_burst, MAX_TRAFFIC_BURST * nb_ports);\n+\n+\tprintf(\"Generate %d packets @socket %d\\n\",\n+\t       MAX_TRAFFIC_BURST * nb_ports, socketid);\n+\n+\tif (sc_flag == SC_CONTINUOUS) {\n+\t\t/* do both rxtx by default */\n+\t\tif (NULL == do_measure)\n+\t\t\tdo_measure = measure_rxtx;\n+\n+\t\trte_eal_remote_launch(main_loop, NULL, slave_id);\n+\n+\t\tif (rte_eal_wait_lcore(slave_id) < 0)\n+\t\t\treturn -1;\n+\t} else if (sc_flag == SC_BURST_POLL_FIRST ||\n+\t\t   sc_flag == SC_BURST_XMIT_FIRST)\n+\t\texec_burst(sc_flag, slave_id);\n+\n+\t/* port tear down */\n+\tfor (portid = 0; portid < nb_ports; portid++) {\n+\t\tif (socketid != rte_eth_dev_socket_id(portid))\n+\t\t\tcontinue;\n+\n+\t\trte_eth_dev_stop(portid);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int\n+test_set_rxtx_conf(cmdline_fixed_string_t mode)\n+{\n+\tprintf(\"mode switch to %s\\n\", mode);\n+\n+\tif (!strcmp(mode, \"vector\")) {\n+\t\t/* vector rx, tx */\n+\t\ttx_conf.txq_flags = 0xf01;\n+\t\ttx_conf.tx_rs_thresh = 32;\n+\t\ttx_conf.tx_free_thresh = 32;\n+\t\tport_conf.rxmode.hw_ip_checksum = 0;\n+\t\tport_conf.rxmode.enable_scatter = 0;\n+\t\treturn 0;\n+\t} else if (!strcmp(mode, \"scalar\")) {\n+\t\t/* bulk alloc rx, simple tx */\n+\t\ttx_conf.txq_flags = 0xf01;\n+\t\ttx_conf.tx_rs_thresh = 128;\n+\t\ttx_conf.tx_free_thresh = 128;\n+\t\tport_conf.rxmode.hw_ip_checksum = 1;\n+\t\tport_conf.rxmode.enable_scatter = 0;\n+\t\treturn 0;\n+\t} else if (!strcmp(mode, \"hybrid\")) {\n+\t\t/* bulk alloc rx, vector tx\n+\t\t * when vec macro not define,\n+\t\t * using the same rx/tx as scalar\n+\t\t */\n+\t\ttx_conf.txq_flags = 0xf01;\n+\t\ttx_conf.tx_rs_thresh = 32;\n+\t\ttx_conf.tx_free_thresh = 32;\n+\t\tport_conf.rxmode.hw_ip_checksum = 1;\n+\t\tport_conf.rxmode.enable_scatter = 0;\n+\t\treturn 0;\n+\t} else if (!strcmp(mode, \"full\")) {\n+\t\t/* full feature rx,tx pair */\n+\t\ttx_conf.txq_flags = 0x0;   /* must condition */\n+\t\ttx_conf.tx_rs_thresh = 32;\n+\t\ttx_conf.tx_free_thresh = 32;\n+\t\tport_conf.rxmode.hw_ip_checksum = 0;\n+\t\tport_conf.rxmode.enable_scatter = 1; /* must condition */\n+\t\treturn 0;\n+\t}\n+\n+\treturn -1;\n+}\n+\n+int\n+test_set_rxtx_anchor(cmdline_fixed_string_t type)\n+{\n+\tprintf(\"type switch to %s\\n\", type);\n+\n+\tif (!strcmp(type, \"rxtx\")) {\n+\t\tdo_measure = measure_rxtx;\n+\t\treturn 0;\n+\t} else if (!strcmp(type, \"rxonly\")) {\n+\t\tdo_measure = measure_rxonly;\n+\t\treturn 0;\n+\t} else if (!strcmp(type, \"txonly\")) {\n+\t\tdo_measure = measure_txonly;\n+\t\treturn 0;\n+\t}\n+\n+\treturn -1;\n+}\n+\n+int\n+test_set_rxtx_sc(cmdline_fixed_string_t type)\n+{\n+\tprintf(\"stream control switch to %s\\n\", type);\n+\n+\tif (!strcmp(type, \"continuous\")) {\n+\t\tsc_flag = SC_CONTINUOUS;\n+\t\treturn 0;\n+\t} else if (!strcmp(type, \"poll_before_xmit\")) {\n+\t\tsc_flag = SC_BURST_POLL_FIRST;\n+\t\treturn 0;\n+\t} else if (!strcmp(type, \"poll_after_xmit\")) {\n+\t\tsc_flag = SC_BURST_XMIT_FIRST;\n+\t\treturn 0;\n+\t}\n+\n+\treturn -1;\n+}\n+\n+static struct test_command pmd_perf_cmd = {\n+\t.command = \"pmd_perf_autotest\",\n+\t.callback = test_pmd_perf,\n+};\n+REGISTER_TEST_COMMAND(pmd_perf_cmd);\n",
    "prefixes": [
        "dpdk-dev",
        "v7",
        "6/7"
    ]
}