get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 91976,
    "url": "http://patches.dpdk.org/api/patches/91976/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1619054288-17556-1-git-send-email-humin29@huawei.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": "<1619054288-17556-1-git-send-email-humin29@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1619054288-17556-1-git-send-email-humin29@huawei.com",
    "date": "2021-04-22T01:18:08",
    "name": "[v13] app/testpmd: support multi-process",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "66c2cbe2f425bc6986f2763470513dc2fec301ac",
    "submitter": {
        "id": 1944,
        "url": "http://patches.dpdk.org/api/people/1944/?format=api",
        "name": "humin (Q)",
        "email": "humin29@huawei.com"
    },
    "delegate": {
        "id": 3961,
        "url": "http://patches.dpdk.org/api/users/3961/?format=api",
        "username": "arybchenko",
        "first_name": "Andrew",
        "last_name": "Rybchenko",
        "email": "andrew.rybchenko@oktetlabs.ru"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1619054288-17556-1-git-send-email-humin29@huawei.com/mbox/",
    "series": [
        {
            "id": 16581,
            "url": "http://patches.dpdk.org/api/series/16581/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=16581",
            "date": "2021-04-22T01:18:08",
            "name": "[v13] app/testpmd: support multi-process",
            "version": 13,
            "mbox": "http://patches.dpdk.org/series/16581/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/91976/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/91976/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 mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 4AC9CA0547;\n\tThu, 22 Apr 2021 03:18:04 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 00C8740692;\n\tThu, 22 Apr 2021 03:18:04 +0200 (CEST)",
            "from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35])\n by mails.dpdk.org (Postfix) with ESMTP id EB79E40150\n for <dev@dpdk.org>; Thu, 22 Apr 2021 03:18:01 +0200 (CEST)",
            "from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60])\n by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FQfcQ4JKkzCqk9;\n Thu, 22 Apr 2021 09:15:34 +0800 (CST)",
            "from localhost.localdomain (10.69.192.56) by\n DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id\n 14.3.498.0; Thu, 22 Apr 2021 09:17:55 +0800"
        ],
        "From": "\"Min Hu (Connor)\" <humin29@huawei.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<ferruh.yigit@intel.com>, <thomas@monjalon.net>,\n <aman.deep.singh@intel.com>",
        "Date": "Thu, 22 Apr 2021 09:18:08 +0800",
        "Message-ID": "<1619054288-17556-1-git-send-email-humin29@huawei.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1614906276-34293-1-git-send-email-oulijun@huawei.com>",
        "References": "<1614906276-34293-1-git-send-email-oulijun@huawei.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"UTF-8\"",
        "Content-Transfer-Encoding": "8bit",
        "X-Originating-IP": "[10.69.192.56]",
        "X-CFilter-Loop": "Reflected",
        "Subject": "[dpdk-dev] [PATCH v13] app/testpmd: support multi-process",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "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": "This patch adds multi-process support for testpmd.\nThe test cmd example as follows:\nthe primary cmd:\n./dpdk-testpmd -a xxx --proc-type=auto -l 0-1 -- -i \\\n--rxq=4 --txq=4 --num-procs=2 --proc-id=0\n\nthe secondary cmd:\n./dpdk-testpmd -a xxx --proc-type=auto -l 2-3 -- -i \\\n--rxq=4 --txq=4 --num-procs=2 --proc-id=1\n\nSigned-off-by: Min Hu (Connor) <humin29@huawei.com>\nSigned-off-by: Lijun Ou <oulijun@huawei.com>\nAcked-by: Xiaoyun Li <xiaoyun.li@intel.com>\nAcked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>\nReviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>\n---\nv13:\n* Modified the doc syntax.\n\nv12:\n* Updated doc info.\n\nv11:\n* Fixed some minor syntax.\n\nv10:\n* Hid process type checks behind new functions.\n* Added comments.\n\nv9:\n* Updated release notes and rst doc.\n* Deleted deprecated codes.\n* move macro and variable.\n\nv8:\n* Added warning info about queue numbers and process numbers.\n\nv7:\n* Fixed compiling error for unexpected unindent.\n\nv6:\n* Add rte flow description for multiple process.\n\nv5:\n* Fixed run_app.rst for multiple process description.\n* Fix compiling error.\n\nv4:\n* Fixed minimum vlaue of Rxq or Txq in doc.\n\nv3:\n* Fixed compiling error using gcc10.0.\n\nv2:\n* Added document for this patch.\n---\n app/test-pmd/cmdline.c                 |   6 ++\n app/test-pmd/config.c                  |  21 +++++-\n app/test-pmd/parameters.c              |  11 +++\n app/test-pmd/testpmd.c                 | 129 ++++++++++++++++++++++++++-------\n app/test-pmd/testpmd.h                 |   9 +++\n doc/guides/rel_notes/release_21_05.rst |   1 +\n doc/guides/testpmd_app_ug/run_app.rst  |  70 ++++++++++++++++++\n 7 files changed, 220 insertions(+), 27 deletions(-)",
    "diff": "diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c\nindex 12efbc0..f0fa6e8 100644\n--- a/app/test-pmd/cmdline.c\n+++ b/app/test-pmd/cmdline.c\n@@ -5450,6 +5450,12 @@ cmd_set_flush_rx_parsed(void *parsed_result,\n \t\t__rte_unused void *data)\n {\n \tstruct cmd_set_flush_rx *res = parsed_result;\n+\n+\tif (num_procs > 1 && (strcmp(res->mode, \"on\") == 0)) {\n+\t\tprintf(\"multi-process doesn't support to flush rx queues.\\n\");\n+\t\treturn;\n+\t}\n+\n \tno_flush_rx = (uint8_t)((strcmp(res->mode, \"on\") == 0) ? 0 : 1);\n }\n \ndiff --git a/app/test-pmd/config.c b/app/test-pmd/config.c\nindex e189062..9eb1fa7 100644\n--- a/app/test-pmd/config.c\n+++ b/app/test-pmd/config.c\n@@ -2971,6 +2971,8 @@ rss_fwd_config_setup(void)\n \tqueueid_t  rxq;\n \tqueueid_t  nb_q;\n \tstreamid_t  sm_id;\n+\tint start;\n+\tint end;\n \n \tnb_q = nb_rxq;\n \tif (nb_q > nb_txq)\n@@ -2988,7 +2990,22 @@ rss_fwd_config_setup(void)\n \tinit_fwd_streams();\n \n \tsetup_fwd_config_of_each_lcore(&cur_fwd_config);\n-\trxp = 0; rxq = 0;\n+\n+\tif (proc_id > 0 && nb_q % num_procs)\n+\t\tprintf(\"Warning! queue numbers should be multiple of \"\n+\t\t\t\"processes, or packet loss will happen.\\n\");\n+\n+\t/**\n+\t * In multi-process, All queues are allocated to different\n+\t * processes based on num_procs and proc_id. For example:\n+\t * if supports 4 queues(nb_q), 2 processes(num_procs),\n+\t * the 0~1 queue for primary process.\n+\t * the 2~3 queue for secondary process.\n+\t */\n+\tstart = proc_id * nb_q / num_procs;\n+\tend = start + nb_q / num_procs;\n+\trxp = 0;\n+\trxq = start;\n \tfor (sm_id = 0; sm_id < cur_fwd_config.nb_fwd_streams; sm_id++) {\n \t\tstruct fwd_stream *fs;\n \n@@ -3005,6 +3022,8 @@ rss_fwd_config_setup(void)\n \t\t\tcontinue;\n \t\trxp = 0;\n \t\trxq++;\n+\t\tif (rxq >= end)\n+\t\t\trxq = start;\n \t}\n }\n \ndiff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c\nindex f3954c1..ece05c1 100644\n--- a/app/test-pmd/parameters.c\n+++ b/app/test-pmd/parameters.c\n@@ -508,6 +508,9 @@ parse_link_speed(int n)\n void\n launch_args_parse(int argc, char** argv)\n {\n+#define PARAM_PROC_ID \"proc-id\"\n+#define PARAM_NUM_PROCS \"num-procs\"\n+\n \tint n, opt;\n \tchar **argvopt;\n \tint opt_idx;\n@@ -625,6 +628,8 @@ launch_args_parse(int argc, char** argv)\n \t\t{ \"rx-mq-mode\",                 1, 0, 0 },\n \t\t{ \"record-core-cycles\",         0, 0, 0 },\n \t\t{ \"record-burst-stats\",         0, 0, 0 },\n+\t\t{ PARAM_NUM_PROCS,              1, 0, 0 },\n+\t\t{ PARAM_PROC_ID,                1, 0, 0 },\n \t\t{ 0, 0, 0, 0 },\n \t};\n \n@@ -1391,6 +1396,12 @@ launch_args_parse(int argc, char** argv)\n \t\t\t\trecord_core_cycles = 1;\n \t\t\tif (!strcmp(lgopts[opt_idx].name, \"record-burst-stats\"))\n \t\t\t\trecord_burst_stats = 1;\n+\t\t\tif (strncmp(lgopts[opt_idx].name,\n+\t\t\t\t    PARAM_NUM_PROCS, 9) == 0)\n+\t\t\t\tnum_procs = atoi(optarg);\n+\t\t\tif (strncmp(lgopts[opt_idx].name,\n+\t\t\t\t    PARAM_PROC_ID, 7) == 0)\n+\t\t\t\tproc_id = atoi(optarg);\n \t\t\tbreak;\n \t\tcase 'h':\n \t\t\tusage(argv[0]);\ndiff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c\nindex d4be23f..afa2a6b 100644\n--- a/app/test-pmd/testpmd.c\n+++ b/app/test-pmd/testpmd.c\n@@ -518,6 +518,62 @@ enum rte_eth_rx_mq_mode rx_mq_mode = ETH_MQ_RX_VMDQ_DCB_RSS;\n  */\n uint32_t eth_link_speed;\n \n+/*\n+ * Id of the current process in multi-process, used to\n+ * configure the queues to be polled.\n+ */\n+int proc_id;\n+\n+/*\n+ * Number of processes in multi-process, used to\n+ * configure the queues to be polled.\n+ */\n+unsigned int num_procs = 1;\n+\n+static int\n+eth_dev_configure_mp(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,\n+\t\t      const struct rte_eth_conf *dev_conf)\n+{\n+\tif (is_proc_primary())\n+\t\treturn rte_eth_dev_configure(port_id, nb_rx_q, nb_tx_q,\n+\t\t\t\t\tdev_conf);\n+\treturn 0;\n+}\n+\n+static int\n+eth_dev_start_mp(uint16_t port_id)\n+{\n+\tif (is_proc_primary())\n+\t\treturn rte_eth_dev_start(port_id);\n+\n+\treturn 0;\n+}\n+\n+static int\n+eth_dev_stop_mp(uint16_t port_id)\n+{\n+\tif (is_proc_primary())\n+\t\treturn rte_eth_dev_stop(port_id);\n+\n+\treturn 0;\n+}\n+\n+static void\n+mempool_free_mp(struct rte_mempool *mp)\n+{\n+\tif (is_proc_primary())\n+\t\treturn rte_mempool_free(mp);\n+}\n+\n+static int\n+eth_dev_set_mtu_mp(uint16_t port_id, uint16_t mtu)\n+{\n+\tif (is_proc_primary())\n+\t\treturn rte_eth_dev_set_mtu(port_id, mtu);\n+\n+\treturn 0;\n+}\n+\n /* Forward function declarations */\n static void setup_attached_port(portid_t pi);\n static void check_all_ports_link_status(uint32_t port_mask);\n@@ -977,6 +1033,11 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,\n \tmb_size = sizeof(struct rte_mbuf) + mbuf_seg_size;\n \tmbuf_poolname_build(socket_id, pool_name, sizeof(pool_name), size_idx);\n \n+\tif (!is_proc_primary()) {\n+\t\trte_mp = rte_mempool_lookup(pool_name);\n+\t\tgoto err;\n+\t}\n+\n \tTESTPMD_LOG(INFO,\n \t\t\"create a new mbuf pool <%s>: n=%u, size=%u, socket=%u\\n\",\n \t\tpool_name, nb_mbuf, mbuf_seg_size, socket_id);\n@@ -1059,9 +1120,14 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,\n \n err:\n \tif (rte_mp == NULL) {\n-\t\trte_exit(EXIT_FAILURE,\n-\t\t\t\"Creation of mbuf pool for socket %u failed: %s\\n\",\n-\t\t\tsocket_id, rte_strerror(rte_errno));\n+\t\tif (is_proc_primary())\n+\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\"Creation of mbuf pool for socket %u failed: %s\\n\",\n+\t\t\t\tsocket_id, rte_strerror(rte_errno));\n+\t\telse\n+\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\"Get mbuf pool for socket %u failed: %s\\n\",\n+\t\t\t\tsocket_id, rte_strerror(rte_errno));\n \t} else if (verbose_level > 0) {\n \t\trte_mempool_dump(stdout, rte_mp);\n \t}\n@@ -2002,6 +2068,12 @@ flush_fwd_rx_queues(void)\n \tuint64_t prev_tsc = 0, diff_tsc, cur_tsc, timer_tsc = 0;\n \tuint64_t timer_period;\n \n+\tif (num_procs > 1) {\n+\t\tprintf(\"multi-process not support for flushing fwd rx \"\n+\t\t       \"queues, skip the below lines and return.\\n\");\n+\t\treturn;\n+\t}\n+\n \t/* convert to number of cycles */\n \ttimer_period = rte_get_timer_hz(); /* 1 second timeout */\n \n@@ -2511,21 +2583,24 @@ start_port(portid_t pid)\n \t\t\t\treturn -1;\n \t\t\t}\n \t\t\t/* configure port */\n-\t\t\tdiag = rte_eth_dev_configure(pi, nb_rxq + nb_hairpinq,\n-\t\t\t\t\t\t     nb_txq + nb_hairpinq,\n-\t\t\t\t\t\t     &(port->dev_conf));\n+\t\t\tdiag = eth_dev_configure_mp(pi,\n+\t\t\t\t\t     nb_rxq + nb_hairpinq,\n+\t\t\t\t\t     nb_txq + nb_hairpinq,\n+\t\t\t\t\t     &(port->dev_conf));\n \t\t\tif (diag != 0) {\n-\t\t\t\tif (rte_atomic16_cmpset(&(port->port_status),\n-\t\t\t\tRTE_PORT_HANDLING, RTE_PORT_STOPPED) == 0)\n-\t\t\t\t\tprintf(\"Port %d can not be set back \"\n-\t\t\t\t\t\t\t\"to stopped\\n\", pi);\n+\t\t\t\tif (rte_atomic16_cmpset(\n+\t\t\t\t\t\t&(port->port_status),\n+\t\t\t\t\t\tRTE_PORT_HANDLING,\n+\t\t\t\t\t\tRTE_PORT_STOPPED) == 0)\n+\t\t\t\t\tprintf(\"Port %d can not be set back to stopped\\n\",\n+\t\t\t\t\t\tpi);\n \t\t\t\tprintf(\"Fail to configure port %d\\n\", pi);\n \t\t\t\t/* try to reconfigure port next time */\n \t\t\t\tport->need_reconfig = 1;\n \t\t\t\treturn -1;\n \t\t\t}\n \t\t}\n-\t\tif (port->need_reconfig_queues > 0) {\n+\t\tif (port->need_reconfig_queues > 0 && is_proc_primary()) {\n \t\t\tport->need_reconfig_queues = 0;\n \t\t\t/* setup tx queues */\n \t\t\tfor (qi = 0; qi < nb_txq; qi++) {\n@@ -2548,8 +2623,8 @@ start_port(portid_t pid)\n \t\t\t\tif (rte_atomic16_cmpset(&(port->port_status),\n \t\t\t\t\t\t\tRTE_PORT_HANDLING,\n \t\t\t\t\t\t\tRTE_PORT_STOPPED) == 0)\n-\t\t\t\t\tprintf(\"Port %d can not be set back \"\n-\t\t\t\t\t\t\t\"to stopped\\n\", pi);\n+\t\t\t\t\tprintf(\"Port %d can not be set back to stopped\\n\",\n+\t\t\t\t\t\tpi);\n \t\t\t\tprintf(\"Fail to configure port %d tx queues\\n\",\n \t\t\t\t       pi);\n \t\t\t\t/* try to reconfigure queues next time */\n@@ -2626,16 +2701,16 @@ start_port(portid_t pid)\n \t\tcnt_pi++;\n \n \t\t/* start port */\n-\t\tdiag = rte_eth_dev_start(pi);\n+\t\tdiag = eth_dev_start_mp(pi);\n \t\tif (diag < 0) {\n \t\t\tprintf(\"Fail to start port %d: %s\\n\", pi,\n \t\t\t       rte_strerror(-diag));\n \n \t\t\t/* Fail to setup rx queue, return */\n \t\t\tif (rte_atomic16_cmpset(&(port->port_status),\n-\t\t\t\tRTE_PORT_HANDLING, RTE_PORT_STOPPED) == 0)\n-\t\t\t\tprintf(\"Port %d can not be set back to \"\n-\t\t\t\t\t\t\t\"stopped\\n\", pi);\n+\t\t\tRTE_PORT_HANDLING, RTE_PORT_STOPPED) == 0)\n+\t\t\t\tprintf(\"Port %d can not be set back to stopped\\n\",\n+\t\t\t\t       pi);\n \t\t\tcontinue;\n \t\t}\n \n@@ -2765,7 +2840,7 @@ stop_port(portid_t pid)\n \t\tif (port->flow_list)\n \t\t\tport_flow_flush(pi);\n \n-\t\tif (rte_eth_dev_stop(pi) != 0)\n+\t\tif (eth_dev_stop_mp(pi) != 0)\n \t\t\tRTE_LOG(ERR, EAL, \"rte_eth_dev_stop failed for port %u\\n\",\n \t\t\t\tpi);\n \n@@ -2834,8 +2909,10 @@ close_port(portid_t pid)\n \t\t\tcontinue;\n \t\t}\n \n-\t\tport_flow_flush(pi);\n-\t\trte_eth_dev_close(pi);\n+\t\tif (is_proc_primary()) {\n+\t\t\tport_flow_flush(pi);\n+\t\t\trte_eth_dev_close(pi);\n+\t\t}\n \t}\n \n \tremove_invalid_ports();\n@@ -3101,7 +3178,7 @@ pmd_test_exit(void)\n \t}\n \tfor (i = 0 ; i < RTE_DIM(mempools) ; i++) {\n \t\tif (mempools[i])\n-\t\t\trte_mempool_free(mempools[i]);\n+\t\t\tmempool_free_mp(mempools[i]);\n \t}\n \n \tprintf(\"\\nBye...\\n\");\n@@ -3432,7 +3509,7 @@ update_jumbo_frame_offload(portid_t portid)\n \t * if unset do it here\n \t */\n \tif ((rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) == 0) {\n-\t\tret = rte_eth_dev_set_mtu(portid,\n+\t\tret = eth_dev_set_mtu_mp(portid,\n \t\t\t\tport->dev_conf.rxmode.max_rx_pkt_len - eth_overhead);\n \t\tif (ret)\n \t\t\tprintf(\"Failed to set MTU to %u for port %u\\n\",\n@@ -3622,6 +3699,10 @@ init_port_dcb_config(portid_t pid,\n \tint retval;\n \tuint16_t i;\n \n+\tif (num_procs > 1) {\n+\t\tprintf(\"The multi-process feature doesn't support dcb.\\n\");\n+\t\treturn -ENOTSUP;\n+\t}\n \trte_port = &ports[pid];\n \n \tmemset(&port_conf, 0, sizeof(struct rte_eth_conf));\n@@ -3787,10 +3868,6 @@ main(int argc, char** argv)\n \t\trte_exit(EXIT_FAILURE, \"Cannot init EAL: %s\\n\",\n \t\t\t rte_strerror(rte_errno));\n \n-\tif (rte_eal_process_type() == RTE_PROC_SECONDARY)\n-\t\trte_exit(EXIT_FAILURE,\n-\t\t\t \"Secondary process type not supported.\\n\");\n-\n \tret = register_eth_event_callback();\n \tif (ret != 0)\n \t\trte_exit(EXIT_FAILURE, \"Cannot register for ethdev events\");\ndiff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h\nindex 6ca872d..3318e8f 100644\n--- a/app/test-pmd/testpmd.h\n+++ b/app/test-pmd/testpmd.h\n@@ -632,6 +632,15 @@ extern enum rte_eth_rx_mq_mode rx_mq_mode;\n \n extern struct rte_flow_action_conntrack conntrack_context;\n \n+extern int proc_id;\n+extern unsigned int num_procs;\n+\n+static inline bool\n+is_proc_primary(void)\n+{\n+\treturn rte_eal_process_type() == RTE_PROC_PRIMARY;\n+}\n+\n static inline unsigned int\n lcore_num(void)\n {\ndiff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst\nindex b36c120..9361332 100644\n--- a/doc/guides/rel_notes/release_21_05.rst\n+++ b/doc/guides/rel_notes/release_21_05.rst\n@@ -235,6 +235,7 @@ New Features\n     ``port cleanup (port_id) txq (queue_id) (free_cnt)``\n   * Added command to show link flow control info.\n     ``show port (port_id) flow_ctrl``\n+  * Added support multi-process for testpmd.\n \n * **Updated ipsec-secgw sample application.**\n \ndiff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst\nindex d062165..74efa4f 100644\n--- a/doc/guides/testpmd_app_ug/run_app.rst\n+++ b/doc/guides/testpmd_app_ug/run_app.rst\n@@ -543,3 +543,73 @@ The command line options are:\n     bit 1 - two hairpin ports paired\n     bit 0 - two hairpin ports loop\n     The default value is 0. Hairpin will use single port mode and implicit Tx flow mode.\n+\n+Testpmd Multi-Process Command-line Options\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n+\n+The following are the command-line options for testpmd multi-process support:\n+\n+.. code-block:: console\n+\n+\tprimary process:\n+\tsudo ./dpdk-testpmd -a xxx --proc-type=auto -l 0-1 -- -i --rxq=4 --txq=4 \\\n+        --num-procs=2 --proc-id=0\n+\n+\tsecondary process:\n+\tsudo ./dpdk-testpmd -a xxx --proc-type=auto -l 2-3 -- -i --rxq=4 --txq=4 \\\n+        --num-procs=2 --proc-id=1\n+\n+The command line options are:\n+\n+*   ``--num-procs=N``\n+\n+    The number of processes which will be used.\n+\n+*   ``--proc-id=id``\n+\n+    The id of the current process (id < num-procs). id should be different in primary\n+    process and secondary process, which starts from '0'.\n+\n+Calculation rule for queue:\n+All queues are allocated to different processes based on ``proc_num`` and ``proc_id``.\n+Calculation rule for the testpmd to allocate queues to each process:\n+start(queue start id) = proc_id * nb_q / num_procs;\n+end(queue end id) = start + nb_q / num_procs;\n+\n+For example, if testpmd supports 4 Tx and Rx queues\n+the 0~1 for primary process\n+the 2~3 for secondary process\n+\n+The number of rings should be a multiple of the number of processes. If not,\n+redundant queues will exist after queues are allocated to processes. After RSS is\n+enabled, packet loss occurs when traffic is sent to all processes at the same time.\n+Some traffic enters redundant queues and cannot be forwarded.\n+\n+All the dev ops is supported in primary process. While secondary process is not permitted\n+to allocate or release shared memory, so some ops are not supported as follows::\n+``dev_configure``\n+``dev_start``\n+``dev_stop``\n+``rx_queue_setup``\n+``tx_queue_setup``\n+``rx_queue_release``\n+``tx_queue_release``\n+\n+So, any command from testpmd which calls those APIs will not be supported in secondary\n+process, like::\n+``port config all rxq|txq|rxd|txd <value>``\n+``port config <port_id> rx_offload xxx on/off ``\n+``port config <port_id> tx_offload xxx on/off``\n+etc.\n+\n+Flow API is supported, it applies only on its own process on SW side, but all on HW side.\n+\n+Stats is supported, stats will not change when one quit and start, as they share the same\n+buffer to store the stats. Flow rules are maintained in process level: primary and secondary\n+has its own flow list (but one flow list in HW). The two can see all the queues, so setting\n+the flow rules for the other is OK. But in the testpmd primary process receiving or transmitting\n+packets from the queue allocated for secondary process is not permitted, and same for\n+secondary process.\n+\n+RSS is supported, primary process and secondary process has separate queues to use, RSS\n+will work in their own queues whether primary or secondary process.\n",
    "prefixes": [
        "v13"
    ]
}