get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 76820,
    "url": "http://patches.dpdk.org/api/patches/76820/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1599534347-20430-4-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": "<1599534347-20430-4-git-send-email-humin29@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1599534347-20430-4-git-send-email-humin29@huawei.com",
    "date": "2020-09-08T03:05:47",
    "name": "[3/3] app/testpmd: add FEC command",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "cced08ea3af51f7aa78788b89326c63b8a361ab6",
    "submitter": {
        "id": 1944,
        "url": "http://patches.dpdk.org/api/people/1944/?format=api",
        "name": "humin (Q)",
        "email": "humin29@huawei.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1599534347-20430-4-git-send-email-humin29@huawei.com/mbox/",
    "series": [
        {
            "id": 12003,
            "url": "http://patches.dpdk.org/api/series/12003/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=12003",
            "date": "2020-09-08T03:05:44",
            "name": "add FEC support",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/12003/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/76820/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/76820/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 0C820A04AA;\n\tTue,  8 Sep 2020 05:08:30 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 5C1941C190;\n\tTue,  8 Sep 2020 05:08:20 +0200 (CEST)",
            "from huawei.com (szxga05-in.huawei.com [45.249.212.191])\n by dpdk.org (Postfix) with ESMTP id 152B21C13B\n for <dev@dpdk.org>; Tue,  8 Sep 2020 05:08:18 +0200 (CEST)",
            "from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59])\n by Forcepoint Email with ESMTP id 12E603ECA5EBA5D25259;\n Tue,  8 Sep 2020 11:08:16 +0800 (CST)",
            "from localhost.localdomain (10.69.192.56) by\n DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id\n 14.3.487.0; Tue, 8 Sep 2020 11:08:06 +0800"
        ],
        "From": "\"Min Hu (Connor)\" <humin29@huawei.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<thomas@monjalon.net>, <arybchenko@solarflare.com>,\n <ferruh.yigit@intel.com>, <linuxarm@huawei.com>",
        "Date": "Tue, 8 Sep 2020 11:05:47 +0800",
        "Message-ID": "<1599534347-20430-4-git-send-email-humin29@huawei.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1599534347-20430-1-git-send-email-humin29@huawei.com>",
        "References": "<1598614332-48508-1-git-send-email-humin29@huawei.com>\n <1599534347-20430-1-git-send-email-humin29@huawei.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.69.192.56]",
        "X-CFilter-Loop": "Reflected",
        "Subject": "[dpdk-dev] [PATCH 3/3] app/testpmd: add FEC command",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This commit adds testpmd capability to query and config FEC\nfunction of device. This includes:\n- show FEC capabilities, example:\n\ttestpmd> show port 0 fec capabilities\n- show FEC mode, example:\n\ttestpmd> show port 0 fec_mode\n- config FEC mode, example:\n\ttestpmd> set port <port_id> 0 <auto|off|rs|baser>\n\n\twhere:\n\n\tauto|off|rs|baser are four kinds of FEC mode which dev\n\tsupport according to MAC link speed.\n\nSigned-off-by: Min Hu (Connor) <humin29@huawei.com>\nReviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>\nReviewed-by: Chengwen Feng <fengchengwen@huawei.com>\nReviewed-by: Chengchang Tang <tangchengchang@huawei.com>\n---\n app/test-pmd/cmdline.c | 206 +++++++++++++++++++++++++++++++++++++++++++++++++\n app/test-pmd/config.c  |  54 +++++++++++++\n app/test-pmd/testpmd.h |   2 +\n 3 files changed, 262 insertions(+)",
    "diff": "diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c\nindex 0a6ed85..71b2711 100644\n--- a/app/test-pmd/cmdline.c\n+++ b/app/test-pmd/cmdline.c\n@@ -19054,6 +19054,209 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {\n \t},\n };\n \n+/* *** show fec capability per port configuration *** */\n+struct cmd_show_fec_capability_result {\n+\tcmdline_fixed_string_t cmd_show;\n+\tcmdline_fixed_string_t cmd_port;\n+\tcmdline_fixed_string_t cmd_fec;\n+\tcmdline_fixed_string_t cmd_keyword;\n+\tportid_t cmd_pid;\n+};\n+\n+static void\n+cmd_show_fec_capability_parsed(void *parsed_result,\n+\t\t__rte_unused struct cmdline *cl,\n+\t\t__rte_unused void *data)\n+{\n+\tstruct cmd_show_fec_capability_result *res = parsed_result;\n+\tuint8_t fec_cap;\n+\tint ret;\n+\n+\tif (!rte_eth_dev_is_valid_port(res->cmd_pid)) {\n+\t\tprintf(\"invalid port id %u\\n\", res->cmd_pid);\n+\t\treturn;\n+\t}\n+\n+\tret = rte_eth_fec_get_capability(res->cmd_pid, &fec_cap);\n+\tif (ret < 0)\n+\t\treturn;\n+\n+\tshow_fec_capability(fec_cap);\n+}\n+\n+cmdline_parse_token_string_t cmd_show_fec_capability_show =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,\n+\t\t\tcmd_show, \"show\");\n+cmdline_parse_token_string_t cmd_show_fec_capability_port =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,\n+\t\t\tcmd_port, \"port\");\n+cmdline_parse_token_num_t cmd_show_fec_capability_pid =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,\n+\t\t\tcmd_pid, UINT16);\n+cmdline_parse_token_string_t cmd_show_fec_capability_fec =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,\n+\t\t\tcmd_fec, \"fec\");\n+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,\n+\t\t\tcmd_keyword, \"capabilities\");\n+\n+cmdline_parse_inst_t cmd_show_capability = {\n+\t.f = cmd_show_fec_capability_parsed,\n+\t.data = NULL,\n+\t.help_str = \"show port <port_id> fec capabilities\",\n+\t.tokens = {\n+\t\t(void *)&cmd_show_fec_capability_show,\n+\t\t(void *)&cmd_show_fec_capability_port,\n+\t\t(void *)&cmd_show_fec_capability_pid,\n+\t\t(void *)&cmd_show_fec_capability_fec,\n+\t\t(void *)&cmd_show_fec_capability_keyword,\n+\t\tNULL,\n+\t},\n+};\n+\n+/* *** show fec mode per port configuration *** */\n+struct cmd_show_fec_metadata_result {\n+\tcmdline_fixed_string_t cmd_show;\n+\tcmdline_fixed_string_t cmd_port;\n+\tcmdline_fixed_string_t cmd_keyword;\n+\tportid_t cmd_pid;\n+};\n+\n+static void\n+cmd_show_fec_mode_parsed(void *parsed_result,\n+\t\t__rte_unused struct cmdline *cl,\n+\t\t__rte_unused void *data)\n+{\n+#define FEC_NAME_SIZE 16\n+\tstruct cmd_show_fec_metadata_result *res = parsed_result;\n+\tenum rte_fec_mode mode;\n+\tchar buf[FEC_NAME_SIZE];\n+\tint ret;\n+\n+\tif (!rte_eth_dev_is_valid_port(res->cmd_pid)) {\n+\t\tprintf(\"invalid port id %u\\n\", res->cmd_pid);\n+\t\treturn;\n+\t}\n+\tret = rte_eth_fec_get(res->cmd_pid, &mode);\n+\tif (ret < 0)\n+\t\treturn;\n+\n+\tswitch (mode) {\n+\tcase ETH_FEC_NOFEC:\n+\t\tstrlcpy(buf, \"off\", sizeof(buf));\n+\t\tbreak;\n+\tcase ETH_FEC_BASER:\n+\t\tstrlcpy(buf, \"baser\", sizeof(buf));\n+\t\tbreak;\n+\tcase ETH_FEC_RS:\n+\t\tstrlcpy(buf, \"rs\", sizeof(buf));\n+\t\tbreak;\n+\tcase ETH_FEC_AUTO:\n+\t\tstrlcpy(buf, \"auto\", sizeof(buf));\n+\t\tbreak;\n+\tdefault:\n+\t\treturn;\n+\t}\n+\n+\tprintf(\"%s\\n\", buf);\n+}\n+\n+cmdline_parse_token_string_t cmd_show_fec_mode_show =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,\n+\t\t\tcmd_show, \"show\");\n+cmdline_parse_token_string_t cmd_show_fec_mode_port =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,\n+\t\t\tcmd_port, \"port\");\n+cmdline_parse_token_num_t cmd_show_fec_mode_pid =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,\n+\t\t\tcmd_pid, UINT16);\n+cmdline_parse_token_string_t cmd_show_fec_mode_keyword =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,\n+\t\t\tcmd_keyword, \"fec_mode\");\n+\n+cmdline_parse_inst_t cmd_show_fec_mode = {\n+\t.f = cmd_show_fec_mode_parsed,\n+\t.data = NULL,\n+\t.help_str = \"show port <port_id> fec_mode\",\n+\t.tokens = {\n+\t\t(void *)&cmd_show_fec_mode_show,\n+\t\t(void *)&cmd_show_fec_mode_port,\n+\t\t(void *)&cmd_show_fec_mode_pid,\n+\t\t(void *)&cmd_show_fec_mode_keyword,\n+\t\tNULL,\n+\t},\n+};\n+\n+/* *** set fec mode per port configuration *** */\n+struct cmd_set_port_fec_mode {\n+\tcmdline_fixed_string_t set;\n+\tcmdline_fixed_string_t port;\n+\tportid_t port_id;\n+\tcmdline_fixed_string_t fec_mode;\n+\tcmdline_fixed_string_t fec_value;\n+};\n+\n+/* Common CLI fields for set fec mode */\n+cmdline_parse_token_string_t cmd_set_port_fec_mode_set =\n+\tTOKEN_STRING_INITIALIZER\n+\t\t(struct cmd_set_port_fec_mode,\n+\t\t set, \"set\");\n+cmdline_parse_token_string_t cmd_set_port_fec_mode_port =\n+\tTOKEN_STRING_INITIALIZER\n+\t\t(struct cmd_set_port_fec_mode,\n+\t\t port, \"port\");\n+cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =\n+\tTOKEN_NUM_INITIALIZER\n+\t\t(struct cmd_set_port_fec_mode,\n+\t\t port_id, UINT16);\n+cmdline_parse_token_string_t cmd_set_port_fec_mode_str =\n+\tTOKEN_STRING_INITIALIZER\n+\t\t(struct cmd_set_port_fec_mode,\n+\t\t fec_mode, \"fec_mode\");\n+cmdline_parse_token_string_t cmd_set_port_fec_mode_value =\n+\tTOKEN_STRING_INITIALIZER\n+\t\t(struct cmd_set_port_fec_mode,\n+\t\t fec_value, NULL);\n+\n+static void\n+cmd_set_port_fec_mode_parsed(\n+\tvoid *parsed_result,\n+\t__rte_unused struct cmdline *cl,\n+\t__rte_unused void *data)\n+{\n+\tstruct cmd_set_port_fec_mode *res = parsed_result;\n+\tuint16_t port_id = res->port_id;\n+\tenum rte_fec_mode mode;\n+\tint ret;\n+\n+\tret = parse_fec_mode(res->fec_value, &mode);\n+\tif (ret < 0) {\n+\t\tprintf(\"Unknown fec mode: %s for Port %d\", res->fec_value,\n+\t\t\tport_id);\n+\t\treturn;\n+\t}\n+\n+\tret = rte_eth_fec_set(port_id, mode);\n+\tif (ret < 0) {\n+\t\tprintf(\"Set fec mode for Port %d failed\\n\", port_id);\n+\t\treturn;\n+\t}\n+}\n+\n+cmdline_parse_inst_t cmd_set_fec_mode = {\n+\t.f = cmd_set_port_fec_mode_parsed,\n+\t.data = NULL,\n+\t.help_str = \"set port <port_id> fec_mode <auto|off|rs|baser>\",\n+\t.tokens = {\n+\t\t(void *)&cmd_set_port_fec_mode_set,\n+\t\t(void *)&cmd_set_port_fec_mode_port,\n+\t\t(void *)&cmd_set_port_fec_mode_port_id,\n+\t\t(void *)&cmd_set_port_fec_mode_str,\n+\t\t(void *)&cmd_set_port_fec_mode_value,\n+\t\tNULL,\n+\t},\n+};\n+\n /* show port supported ptypes */\n \n /* Common result structure for show port ptypes */\n@@ -19685,6 +19888,9 @@ cmdline_parse_ctx_t main_ctx[] = {\n \t(cmdline_parse_inst_t *)&cmd_show_set_raw,\n \t(cmdline_parse_inst_t *)&cmd_show_set_raw_all,\n \t(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,\n+\t(cmdline_parse_inst_t *)&cmd_show_fec_mode,\n+\t(cmdline_parse_inst_t *)&cmd_set_fec_mode,\n+\t(cmdline_parse_inst_t *)&cmd_show_capability,\n \tNULL,\n };\n \ndiff --git a/app/test-pmd/config.c b/app/test-pmd/config.c\nindex 30bee33..8f996af 100644\n--- a/app/test-pmd/config.c\n+++ b/app/test-pmd/config.c\n@@ -138,6 +138,28 @@ const struct rss_type_info rss_type_table[] = {\n \t{ NULL, 0 },\n };\n \n+static const struct {\n+\tenum rte_fec_mode mode;\n+\tconst char *name;\n+} fec_mode_name[] = {\n+\t{\n+\t\t.mode = ETH_FEC_NOFEC,\n+\t\t.name = \"off\",\n+\t},\n+\t{\n+\t\t.mode = ETH_FEC_BASER,\n+\t\t.name = \"baser\",\n+\t},\n+\t{\n+\t\t.mode = ETH_FEC_RS,\n+\t\t.name = \"rs\",\n+\t},\n+\t{\n+\t\t.mode = ETH_FEC_AUTO,\n+\t\t.name = \"auto\",\n+\t},\n+};\n+\n static void\n print_ethaddr(const char *name, struct rte_ether_addr *eth_addr)\n {\n@@ -2967,6 +2989,38 @@ set_tx_pkt_split(const char *name)\n \tprintf(\"unknown value: \\\"%s\\\"\\n\", name);\n }\n \n+int\n+parse_fec_mode(const char *name, enum rte_fec_mode *mode)\n+{\n+\tuint8_t i;\n+\n+\tfor (i = 0; i < RTE_DIM(fec_mode_name); i++) {\n+\t\tif (strcmp(fec_mode_name[i].name, name) == 0) {\n+\t\t\t*mode = fec_mode_name[i].mode;\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\treturn -1;\n+}\n+\n+void\n+show_fec_capability(uint8_t fec_cap)\n+{\n+\tuint8_t i;\n+\n+\tif (fec_cap == 0) {\n+\t\tprintf(\"FEC is not supported\\n\");\n+\t\treturn;\n+\t}\n+\n+\tprintf(\"FEC capabilities:\\n\");\n+\tfor (i = ETH_FEC_BASER; i <= ETH_FEC_AUTO; i++) {\n+\t\tif (fec_cap & 1U << i)\n+\t\t\tprintf(\"%s \", fec_mode_name[i].name);\n+\t}\n+\tprintf(\"\\n\");\n+}\n+\n void\n show_tx_pkt_segments(void)\n {\ndiff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h\nindex 25a12b1..7ab91ad 100644\n--- a/app/test-pmd/testpmd.h\n+++ b/app/test-pmd/testpmd.h\n@@ -778,6 +778,8 @@ void show_tx_pkt_segments(void);\n void set_tx_pkt_times(unsigned int *tx_times);\n void show_tx_pkt_times(void);\n void set_tx_pkt_split(const char *name);\n+int parse_fec_mode(const char *name, enum rte_fec_mode *mode);\n+void show_fec_capability(uint8_t fec_cap);\n void set_nb_pkt_per_burst(uint16_t pkt_burst);\n char *list_pkt_forwarding_modes(void);\n char *list_pkt_forwarding_retry_modes(void);\n",
    "prefixes": [
        "3/3"
    ]
}