Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/53825/?format=api
http://patches.dpdk.org/api/patches/53825/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190529154132.49955-4-bruce.richardson@intel.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": "<20190529154132.49955-4-bruce.richardson@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20190529154132.49955-4-bruce.richardson@intel.com", "date": "2019-05-29T15:41:31", "name": "[3/4] eal: allow checking CPU flags by name", "commit_ref": null, "pull_url": null, "state": "rejected", "archived": true, "hash": "90c1424278f4c006996ed94e79bbddd1ae8d47e8", "submitter": { "id": 20, "url": "http://patches.dpdk.org/api/people/20/?format=api", "name": "Bruce Richardson", "email": "bruce.richardson@intel.com" }, "delegate": { "id": 1, "url": "http://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20190529154132.49955-4-bruce.richardson@intel.com/mbox/", "series": [ { "id": 4811, "url": "http://patches.dpdk.org/api/series/4811/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=4811", "date": "2019-05-29T15:41:28", "name": "Enhance CPU flag support", "version": 1, "mbox": "http://patches.dpdk.org/series/4811/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/53825/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/53825/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 81CE21B9BC;\n\tWed, 29 May 2019 17:41:50 +0200 (CEST)", "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n\tby dpdk.org (Postfix) with ESMTP id 9EA991B9B1\n\tfor <dev@dpdk.org>; Wed, 29 May 2019 17:41:48 +0200 (CEST)", "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t29 May 2019 08:41:47 -0700", "from silpixa00399126.ir.intel.com (HELO\n\tsilpixa00399126.ger.corp.intel.com) ([10.237.223.2])\n\tby FMSMGA003.fm.intel.com with ESMTP; 29 May 2019 08:41:47 -0700" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "From": "Bruce Richardson <bruce.richardson@intel.com>", "To": "dev@dpdk.org", "Cc": "Bruce Richardson <bruce.richardson@intel.com>", "Date": "Wed, 29 May 2019 16:41:31 +0100", "Message-Id": "<20190529154132.49955-4-bruce.richardson@intel.com>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190529154132.49955-1-bruce.richardson@intel.com>", "References": "<20190529154132.49955-1-bruce.richardson@intel.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] [PATCH 3/4] eal: allow checking CPU flags by name", "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": "Rather than using enum values for CPU flags, which means the symbols don't\nexist on other architectures, provide a flag lookup by name, allowing us to\nunconditionally check for a CPU flag.\n\nSigned-off-by: Bruce Richardson <bruce.richardson@intel.com>\n---\n lib/librte_eal/common/eal_common_cpuflags.c | 41 +++++++++++++++++\n .../common/include/generic/rte_cpuflags.h | 44 ++++++++++++++++++-\n lib/librte_eal/rte_eal_version.map | 3 ++\n 3 files changed, 87 insertions(+), 1 deletion(-)", "diff": "diff --git a/lib/librte_eal/common/eal_common_cpuflags.c b/lib/librte_eal/common/eal_common_cpuflags.c\nindex 3a055f7c7..5084a3e7a 100644\n--- a/lib/librte_eal/common/eal_common_cpuflags.c\n+++ b/lib/librte_eal/common/eal_common_cpuflags.c\n@@ -3,6 +3,7 @@\n */\n \n #include <stdio.h>\n+#include <string.h>\n \n #include <rte_common.h>\n #include <rte_cpuflags.h>\n@@ -48,3 +49,43 @@ rte_cpu_is_supported(void)\n \n \treturn 1;\n }\n+\n+static enum rte_cpu_flag_t\n+rte_cpu_get_flag(const char *flagname)\n+{\n+\tint i;\n+\n+\tif (flagname == NULL)\n+\t\treturn RTE_CPUFLAG_NUMFLAGS;\n+\n+\tfor (i = 0; i < RTE_CPUFLAG_NUMFLAGS; i++)\n+\t\tif (strcmp(flagname, rte_cpu_get_flag_name(i)) == 0)\n+\t\t\tbreak;\n+\treturn i;\n+}\n+\n+static int\n+rte_cpu_is_architecture(enum rte_cpu_arch arch)\n+{\n+\tswitch (arch) {\n+\tcase rte_cpu_arch_arm:\n+\t\treturn strcmp(RTE_ARCH, \"arm\") == 0 ||\n+\t\t\t\tstrcmp(RTE_ARCH, \"arm64\") == 0;\n+\tcase rte_cpu_arch_ppc:\n+\t\treturn strcmp(RTE_ARCH, \"ppc_64\") == 0;\n+\tcase rte_cpu_arch_x86:\n+\t\treturn strcmp(RTE_ARCH, \"x86_64\") == 0 ||\n+\t\t\t\tstrcmp(RTE_ARCH, \"i686\") == 0;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+}\n+\n+int\n+rte_cpu_get_flagname_enabled(enum rte_cpu_arch arch, const char *flagname)\n+{\n+\tif (!rte_cpu_is_architecture(arch))\n+\t\treturn 0;\n+\n+\treturn rte_cpu_get_flag_enabled(rte_cpu_get_flag(flagname)) == 1;\n+}\ndiff --git a/lib/librte_eal/common/include/generic/rte_cpuflags.h b/lib/librte_eal/common/include/generic/rte_cpuflags.h\nindex 156ea0029..a53551eba 100644\n--- a/lib/librte_eal/common/include/generic/rte_cpuflags.h\n+++ b/lib/librte_eal/common/include/generic/rte_cpuflags.h\n@@ -10,7 +10,8 @@\n * Architecture specific API to determine available CPU features at runtime.\n */\n \n-#include \"rte_common.h\"\n+#include <rte_common.h>\n+#include <rte_compat.h>\n #include <errno.h>\n \n /**\n@@ -46,6 +47,47 @@ __extension__\n int\n rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature);\n \n+/**\n+ * Enumeration of the various CPU architectures supported by DPDK.\n+ *\n+ * When checking for CPU flags by name, it's possible that multiple\n+ * architectures have flags with the same name e.g. AES is defined in\n+ * both arm and x86 feature lists. Therefore we need to pass in at runtime\n+ * the architecture we are checking for as well as the CPU flag. This enum\n+ * defines the various supported architectures to be used for that checking.\n+ */\n+enum rte_cpu_arch {\n+\trte_cpu_arch_arm = 0,\n+\trte_cpu_arch_ppc,\n+\trte_cpu_arch_x86,\n+\n+\trte_cpu_num_arch /* must always be the last */\n+};\n+\n+/**\n+ * Function for checking if a named CPU flag is enabled\n+ *\n+ * Wrapper around the rte_cpu_get_flag() and rte_cpu_get_flag_enabled()\n+ * calls, which is safe to use even if the flag doesn't exist on target\n+ * architecture. The function also verifies the target architecture so that\n+ * we can distinguish e.g. AES support for arm vs x86 platforms.\n+ *\n+ * Note: This function uses multiple string compares in its operation and\n+ * so is not recommended for data-path use. It should be called once, and\n+ * the return value cached for later use.\n+ *\n+ * @param arch\n+ * The architecture on which we need to check the flag, since multiple\n+ * architectures could have flags with the same name.\n+ * @param flagname\n+ * The name of the flag to query\n+ * @return\n+ * 1 if flag is available\n+ * 0 if flag is not unavailable or invalid\n+ */\n+__rte_experimental int\n+rte_cpu_get_flagname_enabled(enum rte_cpu_arch arch, const char *flagname);\n+\n /**\n * This function checks that the currently used CPU supports the CPU features\n * that were specified at compile time. It is called automatically within the\ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex 245493461..5ca5584a5 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -378,4 +378,7 @@ EXPERIMENTAL {\n \trte_service_lcore_attr_get;\n \trte_service_lcore_attr_reset_all;\n \trte_service_may_be_active;\n+\n+\t# added in 19.08\n+\trte_cpu_get_flagname_enabled;\n };\n", "prefixes": [ "3/4" ] }{ "id": 53825, "url": "