get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 64542,
    "url": "http://patches.dpdk.org/api/patches/64542/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1578907777-194921-2-git-send-email-orika@mellanox.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": "<1578907777-194921-2-git-send-email-orika@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1578907777-194921-2-git-send-email-orika@mellanox.com",
    "date": "2020-01-13T09:29:35",
    "name": "[1/2] app/testpmd: add dynamic flag support",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "530851ad97ca9c224c1164dc402336625944c612",
    "submitter": {
        "id": 795,
        "url": "http://patches.dpdk.org/api/people/795/?format=api",
        "name": "Ori Kam",
        "email": "orika@mellanox.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/1578907777-194921-2-git-send-email-orika@mellanox.com/mbox/",
    "series": [
        {
            "id": 8077,
            "url": "http://patches.dpdk.org/api/series/8077/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=8077",
            "date": "2020-01-13T09:29:34",
            "name": "net/mlx5: add PMD dynf",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/8077/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/64542/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/64542/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 59D99A04F0;\n\tMon, 13 Jan 2020 10:30:14 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 8A7011D5DB;\n\tMon, 13 Jan 2020 10:30:12 +0100 (CET)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by dpdk.org (Postfix) with ESMTP id 2C3211D5DA\n for <dev@dpdk.org>; Mon, 13 Jan 2020 10:30:10 +0100 (CET)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n orika@mellanox.com)\n with ESMTPS (AES256-SHA encrypted); 13 Jan 2020 11:30:08 +0200",
            "from pegasus03.mtr.labs.mlnx (pegasus03.mtr.labs.mlnx\n [10.210.16.124])\n by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 00D9U3M3000700;\n Mon, 13 Jan 2020 11:30:08 +0200"
        ],
        "From": "Ori Kam <orika@mellanox.com>",
        "To": "Wenzhuo Lu <wenzhuo.lu@intel.com>, Jingjing Wu <jingjing.wu@intel.com>,\n Bernard Iremonger <bernard.iremonger@intel.com>,\n John McNamara <john.mcnamara@intel.com>,\n Marko Kovacevic <marko.kovacevic@intel.com>",
        "Cc": "dev@dpdk.org, orika@mellanox.com, ferruh.yigit@intel.com,\n viacheslavo@mellanox.com, matan@mellanox.com",
        "Date": "Mon, 13 Jan 2020 09:29:35 +0000",
        "Message-Id": "<1578907777-194921-2-git-send-email-orika@mellanox.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1578907777-194921-1-git-send-email-orika@mellanox.com>",
        "References": "<1578907777-194921-1-git-send-email-orika@mellanox.com>",
        "Subject": "[dpdk-dev] [PATCH 1/2] app/testpmd: add dynamic flag support",
        "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": "DPDK now supports registration of dynamic flags (dynf) to the mbuf.\ndynf can be given any name, and can be used with a supporting PMD or\nsupporting application.\n\nDue to the generic concept of the dynf, it is impossible and meaningless,\nto define register set/get function for each flag.\nThis commit introduce a generic way to register and set/clear such flags.\n\nThe basic syntax:\nport config <port id> dynf <name> <set|clear>\n\nThe first step the new flag is registered. Regardless if the action is\nset or clear.\nThere is no way to unregister the flag, after registring it.\n\nThe second step, if the action is set then we set the requested flag.\nIf this is the first flag that is enabled we also register a call back\nfor the Tx. In this call back we set the flag.\nIf the action is clear the requested flag is cleared, and if there\nare no more flags that are set, the call back is removed.\n\nThe reason that the set is only applied in Tx is that in case of Rx\nit is assumed that the value comes from the PMD.\n\nIf log is enabled the name of the flag, and value will be printed\nin the packet info.\nIn order for the log to work correcly the registration of the flag\nmust be done before setting verbose.\n\nSigned-off-by: Ori Kam <orika@mellanox.com>\nAcked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>\n---\n app/test-pmd/cmdline.c                      | 88 +++++++++++++++++++++++++++++\n app/test-pmd/testpmd.h                      | 16 ++++++\n app/test-pmd/util.c                         | 63 +++++++++++++++++++++\n doc/guides/testpmd_app_ug/testpmd_funcs.rst | 10 ++++\n 4 files changed, 177 insertions(+)",
    "diff": "diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c\nindex 2d74df8..46c9291 100644\n--- a/app/test-pmd/cmdline.c\n+++ b/app/test-pmd/cmdline.c\n@@ -40,6 +40,7 @@\n #include <rte_devargs.h>\n #include <rte_flow.h>\n #include <rte_gro.h>\n+#include <rte_mbuf_dyn.h>\n \n #include <cmdline_rdline.h>\n #include <cmdline_parse.h>\n@@ -70,6 +71,8 @@\n #include \"cmdline_tm.h\"\n #include \"bpf_cmd.h\"\n \n+char dynf_names[64][RTE_MBUF_DYN_NAMESIZE];\n+\n static struct cmdline *testpmd_cl;\n \n static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);\n@@ -901,6 +904,11 @@ static void cmd_help_long_parsed(void *parsed_result,\n \t\t\t\"port config (port_id) tx_metadata (value)\\n\"\n \t\t\t\"    Set Tx metadata value per port. Testpmd will add this value\"\n \t\t\t\" to any Tx packet sent from this port\\n\\n\"\n+\n+\t\t\t\"port config (port_id) dynf (name) set|clear\\n\"\n+\t\t\t\"    Register a dynf and Set/clear this flag on Tx. \"\n+\t\t\t\"Testpmd will set this value to any Tx packet \"\n+\t\t\t\"sent from this port\\n\\n\"\n \t\t);\n \t}\n \n@@ -18837,6 +18845,85 @@ struct cmd_config_tx_metadata_specific_result {\n \t},\n };\n \n+/* *** set dynf *** */\n+struct cmd_config_tx_dynf_specific_result {\n+\tcmdline_fixed_string_t port;\n+\tcmdline_fixed_string_t keyword;\n+\tuint16_t port_id;\n+\tcmdline_fixed_string_t item;\n+\tcmdline_fixed_string_t name;\n+\tcmdline_fixed_string_t value;\n+};\n+\n+static void\n+cmd_config_dynf_specific_parsed(void *parsed_result,\n+\t\t\t\t__attribute__((unused)) struct cmdline *cl,\n+\t\t\t\t__attribute__((unused)) void *data)\n+{\n+\tstruct cmd_config_tx_dynf_specific_result *res = parsed_result;\n+\tstruct rte_mbuf_dynflag desc_flag;\n+\tint flag;\n+\tuint64_t old_port_flags;\n+\n+\tif (port_id_is_invalid(res->port_id, ENABLED_WARN))\n+\t\treturn;\n+\tflag = rte_mbuf_dynflag_lookup(res->name, NULL);\n+\tif (flag <= 0) {\n+\t\tstrcpy(desc_flag.name, res->name);\n+\t\tdesc_flag.flags = 0;\n+\t\tflag = rte_mbuf_dynflag_register(&desc_flag);\n+\t\tif (flag < 0) {\n+\t\t\tprintf(\"Can't register flag\");\n+\t\t\treturn;\n+\t\t}\n+\t\tstrcpy(dynf_names[flag], res->name);\n+\t}\n+\told_port_flags = ports[res->port_id].dynf;\n+\tif (!strcmp(res->value, \"set\")) {\n+\t\tports[res->port_id].dynf |= 1UL << flag;\n+\t\tif (old_port_flags == 0)\n+\t\t\tadd_tx_dynf_callback(res->port_id);\n+\t} else {\n+\t\tports[res->port_id].dynf &= ~(1UL << flag);\n+\t\tif (ports[res->port_id].dynf == 0)\n+\t\t\tremove_tx_dynf_callback(res->port_id);\n+\t}\n+}\n+\n+cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,\n+\t\t\tkeyword, \"port\");\n+cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,\n+\t\t\tkeyword, \"config\");\n+cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,\n+\t\t\tport_id, UINT16);\n+cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,\n+\t\t\titem, \"dynf\");\n+cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,\n+\t\t\tname, NULL);\n+cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,\n+\t\t\tvalue, \"set#clear\");\n+\n+cmdline_parse_inst_t cmd_config_tx_dynf_specific = {\n+\t.f = cmd_config_dynf_specific_parsed,\n+\t.data = NULL,\n+\t.help_str = \"port config <port id> dynf <name> set|clear\",\n+\t.tokens = {\n+\t\t(void *)&cmd_config_tx_dynf_specific_port,\n+\t\t(void *)&cmd_config_tx_dynf_specific_keyword,\n+\t\t(void *)&cmd_config_tx_dynf_specific_port_id,\n+\t\t(void *)&cmd_config_tx_dynf_specific_item,\n+\t\t(void *)&cmd_config_tx_dynf_specific_name,\n+\t\t(void *)&cmd_config_tx_dynf_specific_value,\n+\t\tNULL,\n+\t},\n+};\n+\n /* *** display tx_metadata per port configuration *** */\n struct cmd_show_tx_metadata_result {\n \tcmdline_fixed_string_t cmd_show;\n@@ -19520,6 +19607,7 @@ struct cmd_showport_macs_result {\n \t(cmdline_parse_inst_t *)&cmd_set_raw,\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 \tNULL,\n };\n \ndiff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h\nindex 857a11f..49f3e43 100644\n--- a/app/test-pmd/testpmd.h\n+++ b/app/test-pmd/testpmd.h\n@@ -104,6 +104,13 @@ struct rss_type_info {\n extern const struct rss_type_info rss_type_table[];\n \n /**\n+ * Dynf name array.\n+ *\n+ * Array that holds the name for each dynf.\n+ */\n+extern char dynf_names[64][RTE_MBUF_DYN_NAMESIZE];\n+\n+/**\n  * The data structure associated with a forwarding stream between a receive\n  * port/queue and a transmit port/queue.\n  */\n@@ -193,6 +200,9 @@ struct rte_port {\n \t/**< metadata value to insert in Tx packets. */\n \tuint32_t\t\ttx_metadata;\n \tconst struct rte_eth_rxtx_callback *tx_set_md_cb[RTE_MAX_QUEUES_PER_PORT+1];\n+\t/**< dynamic flags. */\n+\tuint64_t\t\tdynf;\n+\tconst struct rte_eth_rxtx_callback *tx_set_dynf_cb[RTE_MAX_QUEUES_PER_PORT+1];\n };\n \n /**\n@@ -884,6 +894,12 @@ uint16_t tx_pkt_set_md(uint16_t port_id, __rte_unused uint16_t queue,\n void add_tx_md_callback(portid_t portid);\n void remove_tx_md_callback(portid_t portid);\n \n+uint16_t tx_pkt_set_dynf(uint16_t port_id, __rte_unused uint16_t queue,\n+\t\t\t struct rte_mbuf *pkts[], uint16_t nb_pkts,\n+\t\t\t __rte_unused void *user_param);\n+void add_tx_dynf_callback(portid_t portid);\n+void remove_tx_dynf_callback(portid_t portid);\n+\n /*\n  * Work-around of a compilation error with ICC on invocations of the\n  * rte_be_to_cpu_16() function.\ndiff --git a/app/test-pmd/util.c b/app/test-pmd/util.c\nindex b514be5..5af3d07 100644\n--- a/app/test-pmd/util.c\n+++ b/app/test-pmd/util.c\n@@ -39,6 +39,7 @@\n \tuint16_t udp_port;\n \tuint32_t vx_vni;\n \tconst char *reason;\n+\tint dynf_index;\n \n \tif (!nb_pkts)\n \t\treturn;\n@@ -88,6 +89,12 @@\n \t\tif (is_rx && (ol_flags & PKT_RX_DYNF_METADATA))\n \t\t\tprintf(\" - Rx metadata: 0x%x\",\n \t\t\t       *RTE_FLOW_DYNF_METADATA(mb));\n+\t\tfor (dynf_index = 0; dynf_index < 64; dynf_index++) {\n+\t\t\tif (dynf_names[dynf_index][0] != '\\0')\n+\t\t\t\tprintf(\" - dynf %s: %d\",\n+\t\t\t\t       dynf_names[dynf_index],\n+\t\t\t\t       !!(ol_flags & (1UL << dynf_index)));\n+\t\t}\n \t\tif (mb->packet_type) {\n \t\t\trte_get_ptype_name(mb->packet_type, buf, sizeof(buf));\n \t\t\tprintf(\" - hw ptype: %s\", buf);\n@@ -241,6 +248,62 @@\n \t\t}\n }\n \n+uint16_t\n+tx_pkt_set_dynf(uint16_t port_id, __rte_unused uint16_t queue,\n+\t\tstruct rte_mbuf *pkts[], uint16_t nb_pkts,\n+\t\t__rte_unused void *user_param)\n+{\n+\tuint16_t i = 0;\n+\n+\tif (ports[port_id].dynf)\n+\t\tfor (i = 0; i < nb_pkts; i++)\n+\t\t\tpkts[i]->ol_flags |= ports[port_id].dynf;\n+\treturn nb_pkts;\n+}\n+\n+void\n+add_tx_dynf_callback(portid_t portid)\n+{\n+\tstruct rte_eth_dev_info dev_info;\n+\tuint16_t queue;\n+\tint ret;\n+\n+\tif (port_id_is_invalid(portid, ENABLED_WARN))\n+\t\treturn;\n+\n+\tret = eth_dev_info_get_print_err(portid, &dev_info);\n+\tif (ret != 0)\n+\t\treturn;\n+\n+\tfor (queue = 0; queue < dev_info.nb_tx_queues; queue++)\n+\t\tif (!ports[portid].tx_set_dynf_cb[queue])\n+\t\t\tports[portid].tx_set_dynf_cb[queue] =\n+\t\t\t\trte_eth_add_tx_callback(portid, queue,\n+\t\t\t\t\t\t\ttx_pkt_set_dynf, NULL);\n+}\n+\n+void\n+remove_tx_dynf_callback(portid_t portid)\n+{\n+\tstruct rte_eth_dev_info dev_info;\n+\tuint16_t queue;\n+\tint ret;\n+\n+\tif (port_id_is_invalid(portid, ENABLED_WARN))\n+\t\treturn;\n+\n+\tret = eth_dev_info_get_print_err(portid, &dev_info);\n+\tif (ret != 0)\n+\t\treturn;\n+\n+\tfor (queue = 0; queue < dev_info.nb_tx_queues; queue++)\n+\t\tif (ports[portid].tx_set_dynf_cb[queue]) {\n+\t\t\trte_eth_remove_tx_callback(portid, queue,\n+\t\t\t\tports[portid].tx_set_dynf_cb[queue]);\n+\t\t\tports[portid].tx_set_dynf_cb[queue] = NULL;\n+\t\t}\n+}\n+\n int\n eth_dev_info_get_print_err(uint16_t port_id,\n \t\t\t\t\tstruct rte_eth_dev_info *dev_info)\ndiff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst\nindex 10aabf5..94327e1 100644\n--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst\n+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst\n@@ -2317,6 +2317,16 @@ testpmd will add this value to any Tx packet sent from this port::\n \n    testpmd> port config (port_id) tx_metadata (value)\n \n+port config dynf\n+~~~~~~~~~~~~~~~~\n+\n+Set/clear dynamic flag per port.\n+testpmd will register this flag in the mbuf (same registration\n+for both Tx and Rx). Then set/clear this flag for each Tx\n+packet sent from this port. The set bit only works for Tx packet::\n+\n+   testpmd> port config (port_id) dynf (name) (set|clear)\n+\n port config mtu\n ~~~~~~~~~~~~~~~\n \n",
    "prefixes": [
        "1/2"
    ]
}