Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/133873/?format=api
http://patches.dpdk.org/api/patches/133873/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20231105054539.22303-2-fengchengwen@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": "<20231105054539.22303-2-fengchengwen@huawei.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20231105054539.22303-2-fengchengwen@huawei.com", "date": "2023-11-05T05:45:35", "name": "[v4,1/5] kvargs: add one new process API", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "609f6f6eb854bb83f31fa68e751159fbd4eba47d", "submitter": { "id": 2146, "url": "http://patches.dpdk.org/api/people/2146/?format=api", "name": "fengchengwen", "email": "fengchengwen@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/20231105054539.22303-2-fengchengwen@huawei.com/mbox/", "series": [ { "id": 30160, "url": "http://patches.dpdk.org/api/series/30160/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=30160", "date": "2023-11-05T05:45:35", "name": "fix segment fault when parse args", "version": 4, "mbox": "http://patches.dpdk.org/series/30160/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/133873/comments/", "check": "warning", "checks": "http://patches.dpdk.org/api/patches/133873/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 7F2FA43249;\n\tSun, 5 Nov 2023 06:48:47 +0100 (CET)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 6F4F1402D8;\n\tSun, 5 Nov 2023 06:48:47 +0100 (CET)", "from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189])\n by mails.dpdk.org (Postfix) with ESMTP id EE0C6402CE\n for <dev@dpdk.org>; Sun, 5 Nov 2023 06:48:44 +0100 (CET)", "from dggpeml100024.china.huawei.com (unknown [172.30.72.53])\n by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SNNhd6sQ9zMmMX;\n Sun, 5 Nov 2023 13:44:17 +0800 (CST)", "from localhost.localdomain (10.50.165.33) by\n dggpeml100024.china.huawei.com (7.185.36.115) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id\n 15.1.2507.31; Sun, 5 Nov 2023 13:48:42 +0800" ], "From": "Chengwen Feng <fengchengwen@huawei.com>", "To": "<thomas@monjalon.net>, <ferruh.yigit@amd.com>", "CC": "<dev@dpdk.org>, <stephen@networkplumber.org>", "Subject": "[PATCH v4 1/5] kvargs: add one new process API", "Date": "Sun, 5 Nov 2023 05:45:35 +0000", "Message-ID": "<20231105054539.22303-2-fengchengwen@huawei.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20231105054539.22303-1-fengchengwen@huawei.com>", "References": "<20230314124813.39521-1-fengchengwen@huawei.com>\n <20231105054539.22303-1-fengchengwen@huawei.com>", "MIME-Version": "1.0", "Content-Type": "text/plain", "X-Originating-IP": "[10.50.165.33]", "X-ClientProxiedBy": "dggems701-chm.china.huawei.com (10.3.19.178) To\n dggpeml100024.china.huawei.com (7.185.36.115)", "X-CFilter-Loop": "Reflected", "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" }, "content": "The rte_kvargs_process() was used to handle key=value (e.g.\nsocket_id=0), it also supports to handle only-key (e.g. socket_id).\nBut many drivers's callback can only handle key=value, it will segment\nfault if handles only-key. so the patchset [1] was introduced.\n\nBecause the patchset [1] modified too much drivers, therefore:\n1) A new API rte_kvargs_process_opt() was introduced, it inherits the\nfunction of rte_kvargs_process() which could handle both key=value and\nonly-key cases.\n2) Constraint the rte_kvargs_process() can only handle key=value cases,\nit will return -1 when handle only-key case (that is the matched key's\nvalue is NULL).\n\nThis patch also make sure the rte_kvargs_process_opt() and\nrte_kvargs_process() API both return -1 when the kvlist parameter is\nNULL.\n\n[1] https://patches.dpdk.org/project/dpdk/patch/20230320092110.37295-1-fengchengwen@huawei.com/\n\nSigned-off-by: Chengwen Feng <fengchengwen@huawei.com>\n---\n doc/guides/rel_notes/release_23_11.rst | 13 ++++++++\n lib/kvargs/rte_kvargs.c | 43 ++++++++++++++++++++------\n lib/kvargs/rte_kvargs.h | 37 ++++++++++++++++++++--\n lib/kvargs/version.map | 3 ++\n 4 files changed, 84 insertions(+), 12 deletions(-)", "diff": "diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst\nindex 249e5939e1..ea7b758b20 100644\n--- a/doc/guides/rel_notes/release_23_11.rst\n+++ b/doc/guides/rel_notes/release_23_11.rst\n@@ -137,6 +137,19 @@ New Features\n a group's miss actions, which are the actions to be performed on packets\n that didn't match any of the flow rules in the group.\n \n+* **Updated kvargs process API.**\n+\n+ * Introduced rte_kvargs_process_opt() API, which inherits the function\n+ of rte_kvargs_process() and could handle both key=value and only-key\n+ cases.\n+\n+ * Constraint rte_kvargs_process() API can only handle key=value cases,\n+ it will return -1 when handle only-key case (that is the matched key's\n+ value is NULL).\n+\n+ * Make sure rte_kvargs_process_opt() and rte_kvargs_process() API both\n+ return -1 when the kvlist parameter is NULL.\n+\n * **Updated Amazon ena (Elastic Network Adapter) net driver.**\n \n * Upgraded ENA HAL to latest version.\ndiff --git a/lib/kvargs/rte_kvargs.c b/lib/kvargs/rte_kvargs.c\nindex c77bb82feb..adc47f8898 100644\n--- a/lib/kvargs/rte_kvargs.c\n+++ b/lib/kvargs/rte_kvargs.c\n@@ -167,31 +167,56 @@ rte_kvargs_count(const struct rte_kvargs *kvlist, const char *key_match)\n \treturn ret;\n }\n \n-/*\n- * For each matching key, call the given handler function.\n- */\n-int\n-rte_kvargs_process(const struct rte_kvargs *kvlist,\n-\t\tconst char *key_match,\n-\t\targ_handler_t handler,\n-\t\tvoid *opaque_arg)\n+static int\n+kvargs_process_common(const struct rte_kvargs *kvlist,\n+\t\t const char *key_match,\n+\t\t arg_handler_t handler,\n+\t\t void *opaque_arg,\n+\t\t bool support_only_key)\n {\n \tconst struct rte_kvargs_pair *pair;\n \tunsigned i;\n \n \tif (kvlist == NULL)\n-\t\treturn 0;\n+\t\treturn -1;\n \n \tfor (i = 0; i < kvlist->count; i++) {\n \t\tpair = &kvlist->pairs[i];\n \t\tif (key_match == NULL || strcmp(pair->key, key_match) == 0) {\n+\t\t\tif (!support_only_key && pair->value == NULL)\n+\t\t\t\treturn -1;\n \t\t\tif ((*handler)(pair->key, pair->value, opaque_arg) < 0)\n \t\t\t\treturn -1;\n \t\t}\n \t}\n+\n \treturn 0;\n }\n \n+/*\n+ * For each matching key in key/value, call the given handler function.\n+ */\n+int\n+rte_kvargs_process(const struct rte_kvargs *kvlist,\n+\t\t const char *key_match,\n+\t\t arg_handler_t handler,\n+\t\t void *opaque_arg)\n+{\n+\treturn kvargs_process_common(kvlist, key_match, handler, opaque_arg, false);\n+}\n+\n+/*\n+ * For each matching key in key/value or only-key, call the given handler function.\n+ */\n+int\n+rte_kvargs_process_opt(const struct rte_kvargs *kvlist,\n+\t\t const char *key_match,\n+\t\t arg_handler_t handler,\n+\t\t void *opaque_arg)\n+{\n+\treturn kvargs_process_common(kvlist, key_match, handler, opaque_arg, true);\n+}\n+\n /* free the rte_kvargs structure */\n void\n rte_kvargs_free(struct rte_kvargs *kvlist)\ndiff --git a/lib/kvargs/rte_kvargs.h b/lib/kvargs/rte_kvargs.h\nindex 4900b750bc..ad0b609ad7 100644\n--- a/lib/kvargs/rte_kvargs.h\n+++ b/lib/kvargs/rte_kvargs.h\n@@ -172,14 +172,17 @@ const char *rte_kvargs_get_with_value(const struct rte_kvargs *kvlist,\n \t\t\t\t const char *key, const char *value);\n \n /**\n- * Call a handler function for each key/value matching the key\n+ * Call a handler function for each key=value matching the key\n *\n- * For each key/value association that matches the given key, calls the\n+ * For each key=value association that matches the given key, calls the\n * handler function with the for a given arg_name passing the value on the\n * dictionary for that key and a given extra argument.\n *\n+ * @note Compared to @see rte_kvargs_process_opt, this API will return -1\n+ * when handle only-key case (that is the matched key's value is NULL).\n+ *\n * @param kvlist\n- * The rte_kvargs structure. No error if NULL.\n+ * The rte_kvargs structure.\n * @param key_match\n * The key on which the handler should be called, or NULL to process handler\n * on all associations\n@@ -195,6 +198,34 @@ const char *rte_kvargs_get_with_value(const struct rte_kvargs *kvlist,\n int rte_kvargs_process(const struct rte_kvargs *kvlist,\n \tconst char *key_match, arg_handler_t handler, void *opaque_arg);\n \n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Call a handler function for each key=value or only-key matching the key\n+ *\n+ * For each key=value or only-key association that matches the given key, calls\n+ * the handler function with the for a given arg_name passing the value on the\n+ * dictionary for that key and a given extra argument.\n+ *\n+ * @param kvlist\n+ * The rte_kvargs structure.\n+ * @param key_match\n+ * The key on which the handler should be called, or NULL to process handler\n+ * on all associations\n+ * @param handler\n+ * The function to call for each matching key\n+ * @param opaque_arg\n+ * A pointer passed unchanged to the handler\n+ *\n+ * @return\n+ * - 0 on success\n+ * - Negative on error\n+ */\n+__rte_experimental\n+int rte_kvargs_process_opt(const struct rte_kvargs *kvlist,\n+\tconst char *key_match, arg_handler_t handler, void *opaque_arg);\n+\n /**\n * Count the number of associations matching the given key\n *\ndiff --git a/lib/kvargs/version.map b/lib/kvargs/version.map\nindex 387a94e725..15d482e9b3 100644\n--- a/lib/kvargs/version.map\n+++ b/lib/kvargs/version.map\n@@ -16,4 +16,7 @@ EXPERIMENTAL {\n \n \t# added in 21.11\n \trte_kvargs_get_with_value;\n+\n+\t# added in 23.11\n+\trte_kvargs_process_opt;\n };\n", "prefixes": [ "v4", "1/5" ] }{ "id": 133873, "url": "