get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 47510,
    "url": "https://patches.dpdk.org/api/patches/47510/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20181027091750.17254-2-harry.van.haaren@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": "<20181027091750.17254-2-harry.van.haaren@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20181027091750.17254-2-harry.van.haaren@intel.com",
    "date": "2018-10-27T09:17:39",
    "name": "[v10,01/12] eal: add option register infrastructure",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "311fe285ae209fa786bf89a98ff18398ae658e93",
    "submitter": {
        "id": 317,
        "url": "https://patches.dpdk.org/api/people/317/?format=api",
        "name": "Van Haaren, Harry",
        "email": "harry.van.haaren@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20181027091750.17254-2-harry.van.haaren@intel.com/mbox/",
    "series": [
        {
            "id": 2132,
            "url": "https://patches.dpdk.org/api/series/2132/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=2132",
            "date": "2018-10-27T09:17:38",
            "name": "Introduce Telemetry Library",
            "version": 10,
            "mbox": "https://patches.dpdk.org/series/2132/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/47510/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/47510/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 513C24CA5;\n\tSat, 27 Oct 2018 11:19:39 +0200 (CEST)",
            "from mga18.intel.com (mga18.intel.com [134.134.136.126])\n\tby dpdk.org (Postfix) with ESMTP id 845FA293B\n\tfor <dev@dpdk.org>; Sat, 27 Oct 2018 11:19:26 +0200 (CEST)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n\tby orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t27 Oct 2018 02:19:25 -0700",
            "from silpixa00399779.ir.intel.com (HELO\n\tsilpixa00399779.ger.corp.intel.com) ([10.237.223.188])\n\tby orsmga008.jf.intel.com with ESMTP; 27 Oct 2018 02:19:23 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.54,431,1534834800\"; d=\"scan'208\";a=\"84903866\"",
        "From": "Harry van Haaren <harry.van.haaren@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "thomas@monjalon.net, bruce.richardson@intel.com,\n\tstephen@networkplumber.org, gaetan.rivet@6wind.com,\n\tshreyansh.jain@nxp.com, \n\tmattias.ronnblom@ericsson.com, Kevin Laatz <kevin.laatz@intel.com>",
        "Date": "Sat, 27 Oct 2018 10:17:39 +0100",
        "Message-Id": "<20181027091750.17254-2-harry.van.haaren@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20181027091750.17254-1-harry.van.haaren@intel.com>",
        "References": "<20181026235933.79779-1-harry.van.haaren@intel.com>\n\t<20181027091750.17254-1-harry.van.haaren@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v10 01/12] eal: add option register infrastructure",
        "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\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Kevin Laatz <kevin.laatz@intel.com>\n\nThis commit adds infrastructure to EAL that allows an application to\nregister it's init function with EAL. This allows libraries to be\ninitialized at the end of EAL init.\n\nThis infrastructure allows libraries that depend on EAL to be initialized\nas part of EAL init, removing circular dependency issues.\n\nSigned-off-by: Kevin Laatz <kevin.laatz@intel.com>\nAcked-by: Harry van Haaren <harry.van.haaren@intel.com>\nAcked-by: Gaetan Rivet <gaetan.rivet@6wind.com>\n---\n lib/librte_eal/bsdapp/eal/Makefile         |  1 +\n lib/librte_eal/bsdapp/eal/eal.c            | 14 ++++-\n lib/librte_eal/common/Makefile             |  1 +\n lib/librte_eal/common/eal_private.h        | 21 ++++++++\n lib/librte_eal/common/include/rte_option.h | 63 ++++++++++++++++++++++\n lib/librte_eal/common/meson.build          |  2 +\n lib/librte_eal/common/rte_option.c         | 54 +++++++++++++++++++\n lib/librte_eal/linuxapp/eal/Makefile       |  1 +\n lib/librte_eal/linuxapp/eal/eal.c          | 14 ++++-\n lib/librte_eal/rte_eal_version.map         |  1 +\n 10 files changed, 170 insertions(+), 2 deletions(-)\n create mode 100644 lib/librte_eal/common/include/rte_option.h\n create mode 100644 lib/librte_eal/common/rte_option.c",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile\nindex d19f53c1e..bfeddaadc 100644\n--- a/lib/librte_eal/bsdapp/eal/Makefile\n+++ b/lib/librte_eal/bsdapp/eal/Makefile\n@@ -67,6 +67,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += malloc_elem.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += malloc_heap.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += malloc_mp.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_keepalive.c\n+SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_option.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_service.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_reciprocal.c\n \ndiff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c\nindex f94c5c5f4..11cbda964 100644\n--- a/lib/librte_eal/bsdapp/eal/eal.c\n+++ b/lib/librte_eal/bsdapp/eal/eal.c\n@@ -42,6 +42,7 @@\n #include <rte_devargs.h>\n #include <rte_version.h>\n #include <rte_vfio.h>\n+#include <rte_option.h>\n #include <rte_atomic.h>\n #include <malloc_heap.h>\n \n@@ -414,12 +415,20 @@ eal_parse_args(int argc, char **argv)\n \targvopt = argv;\n \toptind = 1;\n \toptreset = 1;\n+\topterr = 0;\n \n \twhile ((opt = getopt_long(argc, argvopt, eal_short_options,\n \t\t\t\t  eal_long_options, &option_index)) != EOF) {\n \n-\t\t/* getopt is not happy, stop right now */\n+\t\t/*\n+\t\t * getopt didn't recognise the option, lets parse the\n+\t\t * registered options to see if the flag is valid\n+\t\t */\n \t\tif (opt == '?') {\n+\t\t\tret = rte_option_parse(argv[optind-1]);\n+\t\t\tif (ret == 0)\n+\t\t\t\tcontinue;\n+\n \t\t\teal_usage(prgname);\n \t\t\tret = -1;\n \t\t\tgoto out;\n@@ -791,6 +800,9 @@ rte_eal_init(int argc, char **argv)\n \n \trte_eal_mcfg_complete();\n \n+\t/* Call each registered callback, if enabled */\n+\trte_option_init();\n+\n \treturn fctret;\n }\n \ndiff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile\nindex cca68826f..87d8c455d 100644\n--- a/lib/librte_eal/common/Makefile\n+++ b/lib/librte_eal/common/Makefile\n@@ -12,6 +12,7 @@ INC += rte_tailq.h rte_interrupts.h rte_alarm.h\n INC += rte_string_fns.h rte_version.h\n INC += rte_eal_memconfig.h rte_malloc_heap.h\n INC += rte_hexdump.h rte_devargs.h rte_bus.h rte_dev.h rte_class.h\n+INC += rte_option.h\n INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h\n INC += rte_malloc.h rte_keepalive.h rte_time.h\n INC += rte_service.h rte_service_component.h\ndiff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h\nindex b189d675d..442c6dc48 100644\n--- a/lib/librte_eal/common/eal_private.h\n+++ b/lib/librte_eal/common/eal_private.h\n@@ -349,4 +349,25 @@ dev_sigbus_handler_register(void);\n int\n dev_sigbus_handler_unregister(void);\n \n+/**\n+ * Check if the option is registered.\n+ *\n+ * @param option\n+ *  The option to be parsed.\n+ *\n+ * @return\n+ *  0 on success\n+ * @return\n+ *  -1 on fail\n+ */\n+int\n+rte_option_parse(const char *opt);\n+\n+/**\n+ * Iterate through the registered options and execute the associated\n+ * callback if enabled.\n+ */\n+void\n+rte_option_init(void);\n+\n #endif /* _EAL_PRIVATE_H_ */\ndiff --git a/lib/librte_eal/common/include/rte_option.h b/lib/librte_eal/common/include/rte_option.h\nnew file mode 100644\nindex 000000000..8957b970c\n--- /dev/null\n+++ b/lib/librte_eal/common/include/rte_option.h\n@@ -0,0 +1,63 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018 Intel Corporation.\n+ */\n+\n+#ifndef __INCLUDE_RTE_OPTION_H__\n+#define __INCLUDE_RTE_OPTION_H__\n+\n+/**\n+ * @file\n+ *\n+ * This API offers the ability to register options to the EAL command line and\n+ * map those options to functions that will be executed at the end of EAL\n+ * initialization. These options will be available as part of the EAL command\n+ * line of applications and are dynamically managed.\n+ *\n+ * This is used primarily by DPDK libraries offering command line options.\n+ * Currently, this API is limited to registering options without argument.\n+ *\n+ * The register API can be used to resolve circular dependency issues\n+ * between EAL and the library. The library uses EAL, but is also initialized\n+ * by EAL. Hence, EAL depends on the init function of the library. The API\n+ * introduced in rte_option allows us to register the library init with EAL\n+ * (passing a function pointer) and avoid the circular dependency.\n+ */\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+typedef int (*rte_option_cb)(void);\n+\n+/*\n+ * Structure describing the EAL command line option being registered.\n+ */\n+struct rte_option {\n+\tTAILQ_ENTRY(rte_option) next; /**< Next entry in the list. */\n+\tchar *opt_str;             /**< The option name. */\n+\trte_option_cb cb;          /**< Function called when option is used. */\n+\tint enabled;               /**< Set when the option is used. */\n+};\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * Register an option to the EAL command line.\n+ * When recognized, the associated function will be executed at the end of EAL\n+ * initialization.\n+ *\n+ * The associated structure must be available the whole time this option is\n+ * registered (i.e. not stack memory).\n+ *\n+ * @param opt\n+ *  Structure describing the option to parse.\n+ */\n+void __rte_experimental\n+rte_option_register(struct rte_option *opt);\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif\ndiff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build\nindex 04c414356..2a10d57d8 100644\n--- a/lib/librte_eal/common/meson.build\n+++ b/lib/librte_eal/common/meson.build\n@@ -34,6 +34,7 @@ common_sources = files(\n \t'malloc_mp.c',\n \t'rte_keepalive.c',\n \t'rte_malloc.c',\n+\t'rte_option.c',\n \t'rte_reciprocal.c',\n \t'rte_service.c'\n )\n@@ -71,6 +72,7 @@ common_headers = files(\n \t'include/rte_malloc_heap.h',\n \t'include/rte_memory.h',\n \t'include/rte_memzone.h',\n+\t'include/rte_option.h',\n \t'include/rte_pci_dev_feature_defs.h',\n \t'include/rte_pci_dev_features.h',\n \t'include/rte_per_lcore.h',\ndiff --git a/lib/librte_eal/common/rte_option.c b/lib/librte_eal/common/rte_option.c\nnew file mode 100644\nindex 000000000..02d59a869\n--- /dev/null\n+++ b/lib/librte_eal/common/rte_option.c\n@@ -0,0 +1,54 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018 Intel Corporation.\n+ */\n+\n+#include <unistd.h>\n+#include <string.h>\n+\n+#include <rte_eal.h>\n+#include <rte_option.h>\n+\n+#include \"eal_private.h\"\n+\n+TAILQ_HEAD(rte_option_list, rte_option);\n+\n+struct rte_option_list rte_option_list =\n+\tTAILQ_HEAD_INITIALIZER(rte_option_list);\n+\n+static struct rte_option *option;\n+\n+int\n+rte_option_parse(const char *opt)\n+{\n+\t/* Check if the option is registered */\n+\tTAILQ_FOREACH(option, &rte_option_list, next) {\n+\t\tif (strcmp(opt, option->opt_str) == 0) {\n+\t\t\toption->enabled = 1;\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\n+\treturn -1;\n+}\n+\n+void __rte_experimental\n+rte_option_register(struct rte_option *opt)\n+{\n+\tTAILQ_FOREACH(option, &rte_option_list, next) {\n+\t\tif (strcmp(opt->opt_str, option->opt_str) == 0)\n+\t\t\tRTE_LOG(INFO, EAL, \"Option %s has already been registered.\",\n+\t\t\t\t\topt->opt_str);\n+\t\t\treturn;\n+\t}\n+\n+\tTAILQ_INSERT_HEAD(&rte_option_list, opt, next);\n+}\n+\n+void\n+rte_option_init(void)\n+{\n+\tTAILQ_FOREACH(option, &rte_option_list, next) {\n+\t\tif (option->enabled)\n+\t\t\toption->cb();\n+\t}\n+}\ndiff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile\nindex 728088594..51deb5797 100644\n--- a/lib/librte_eal/linuxapp/eal/Makefile\n+++ b/lib/librte_eal/linuxapp/eal/Makefile\n@@ -75,6 +75,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += malloc_elem.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += malloc_heap.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += malloc_mp.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_keepalive.c\n+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_option.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_service.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_reciprocal.c\n \ndiff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c\nindex 76536bae2..930070e43 100644\n--- a/lib/librte_eal/linuxapp/eal/eal.c\n+++ b/lib/librte_eal/linuxapp/eal/eal.c\n@@ -48,6 +48,7 @@\n #include <rte_atomic.h>\n #include <malloc_heap.h>\n #include <rte_vfio.h>\n+#include <rte_option.h>\n \n #include \"eal_private.h\"\n #include \"eal_thread.h\"\n@@ -600,12 +601,20 @@ eal_parse_args(int argc, char **argv)\n \n \targvopt = argv;\n \toptind = 1;\n+\topterr = 0;\n \n \twhile ((opt = getopt_long(argc, argvopt, eal_short_options,\n \t\t\t\t  eal_long_options, &option_index)) != EOF) {\n \n-\t\t/* getopt is not happy, stop right now */\n+\t\t/*\n+\t\t * getopt didn't recognise the option, lets parse the\n+\t\t * registered options to see if the flag is valid\n+\t\t */\n \t\tif (opt == '?') {\n+\t\t\tret = rte_option_parse(argv[optind-1]);\n+\t\t\tif (ret == 0)\n+\t\t\t\tcontinue;\n+\n \t\t\teal_usage(prgname);\n \t\t\tret = -1;\n \t\t\tgoto out;\n@@ -1080,6 +1089,9 @@ rte_eal_init(int argc, char **argv)\n \n \trte_eal_mcfg_complete();\n \n+\t/* Call each registered callback, if enabled */\n+\trte_option_init();\n+\n \treturn fctret;\n }\n \ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex f4a2b38fd..5b6d91ffd 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -350,6 +350,7 @@ EXPERIMENTAL {\n \trte_mp_request_sync;\n \trte_mp_request_async;\n \trte_mp_sendmsg;\n+\trte_option_register;\n \trte_service_lcore_attr_get;\n \trte_service_lcore_attr_reset_all;\n \trte_service_may_be_active;\n",
    "prefixes": [
        "v10",
        "01/12"
    ]
}