get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 27816,
    "url": "https://patches.dpdk.org/api/patches/27816/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20170823150027.70565-1-sergio.gonzalez.monroy@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": "<20170823150027.70565-1-sergio.gonzalez.monroy@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20170823150027.70565-1-sergio.gonzalez.monroy@intel.com",
    "date": "2017-08-23T15:00:26",
    "name": "[dpdk-dev] eal/x86: implement x86 specific tsc hz",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "704c98e4d2b9ba1ec0325ba6c483d30508c240fb",
    "submitter": {
        "id": 73,
        "url": "https://patches.dpdk.org/api/people/73/?format=api",
        "name": "Sergio Gonzalez Monroy",
        "email": "sergio.gonzalez.monroy@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20170823150027.70565-1-sergio.gonzalez.monroy@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/27816/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/27816/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 [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 66B197D3A;\n\tWed, 23 Aug 2017 17:00:32 +0200 (CEST)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby dpdk.org (Postfix) with ESMTP id CA6ED7D3A\n\tfor <dev@dpdk.org>; Wed, 23 Aug 2017 17:00:30 +0200 (CEST)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t23 Aug 2017 08:00:30 -0700",
            "from silpixa00397517.ir.intel.com (HELO\n\tsilpixa00397517.ger.corp.intel.com) ([10.237.222.54])\n\tby fmsmga001.fm.intel.com with ESMTP; 23 Aug 2017 08:00:28 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos; i=\"5.41,417,1498546800\"; d=\"scan'208\";\n\ta=\"1187349761\"",
        "From": "Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "konstantin.ananyev@intel.com,\n\tbruce.richardson@intel.com",
        "Date": "Wed, 23 Aug 2017 16:00:26 +0100",
        "Message-Id": "<20170823150027.70565-1-sergio.gonzalez.monroy@intel.com>",
        "X-Mailer": "git-send-email 2.9.5",
        "Subject": "[dpdk-dev] [PATCH] eal/x86: implement x86 specific tsc hz",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "First, try to use CPUID Time Stamp Counter and Nominal Core Crystal\nClock Information Leaf to determine the tsc hz on platforms that\nsupports it (does not require priviledge user).\n\nIf the CPUID leaf is not available, then try to determine the tsc hz by\nreading the MSR 0xCE (requires priviledge user).\n\nDefault to the tsc hz estimation if both methods fail.\n\nSigned-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>\n---\n\nDEPENDS on Jerin's patch:\nhttp://dpdk.org/dev/patchwork/patch/27526/\n\n lib/librte_eal/common/arch/x86/rte_cycles.c        | 142 +++++++++++++++++++++\n .../common/include/arch/x86/rte_cycles.h           |   7 +-\n lib/librte_eal/linuxapp/eal/Makefile               |   1 +\n 3 files changed, 145 insertions(+), 5 deletions(-)\n create mode 100644 lib/librte_eal/common/arch/x86/rte_cycles.c",
    "diff": "diff --git a/lib/librte_eal/common/arch/x86/rte_cycles.c b/lib/librte_eal/common/arch/x86/rte_cycles.c\nnew file mode 100644\nindex 0000000..9336947\n--- /dev/null\n+++ b/lib/librte_eal/common/arch/x86/rte_cycles.c\n@@ -0,0 +1,142 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include <fcntl.h>\n+#include <unistd.h>\n+#include <cpuid.h>\n+#include <rte_cycles.h>\n+\n+static unsigned int\n+rte_cpu_get_model(uint32_t fam_mod_step)\n+{\n+\tuint32_t family, model, ext_model;\n+\n+\tfamily = (fam_mod_step >> 8) & 0xf;\n+\tmodel = (fam_mod_step >> 4) & 0xf;\n+\n+\tif (family == 6 || family == 15) {\n+\t\text_model = (fam_mod_step >> 16) & 0xf;\n+\t\tmodel += (ext_model << 4);\n+\t}\n+\n+\treturn model;\n+}\n+\n+static int32_t\n+rdmsr(int msr, uint64_t *val)\n+{\n+\tint fd;\n+\tint ret = 0;\n+\n+\tfd = open(\"/dev/cpu/0/msr\", O_RDONLY);\n+\tif (fd < 0)\n+\t\treturn fd;\n+\n+\tret = pread(fd, val, sizeof(uint64_t), msr);\n+\n+\tclose(fd);\n+\n+\treturn ret;\n+}\n+\n+static uint32_t\n+check_model_wsm_nhm(uint8_t model)\n+{\n+\tswitch (model) {\n+\t/* Westmere */\n+\tcase 0x25:\n+\tcase 0x2C:\n+\tcase 0x2F:\n+\t/* Nehalem */\n+\tcase 0x1E:\n+\tcase 0x1F:\n+\tcase 0x1A:\n+\tcase 0x2E:\n+\t\treturn 1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static uint32_t\n+check_model_gdm_dnv(uint8_t model)\n+{\n+\tswitch (model) {\n+\t/* Goldmont */\n+\tcase 0x5C:\n+\t/* Denverton */\n+\tcase 0x5F:\n+\t\treturn 1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+uint64_t\n+rte_rdtsc_arch_hz(void)\n+{\n+\tuint64_t tsc_hz = 0;\n+\tuint32_t a, b, c, d, maxleaf;\n+\tuint8_t mult, model;\n+\tint32_t ret;\n+\n+\t/*\n+\t * Time Stamp Counter and Nominal Core Crystal Clock\n+\t * Information Leaf\n+\t */\n+\tmaxleaf = __get_cpuid_max(0, NULL);\n+\n+\tif (maxleaf >= 0x15) {\n+\t\t__cpuid(0x15, a, b, c, d);\n+\n+\t\t/* EBX : TSC/Crystal ratio, ECX : Crystal Hz */\n+\t\tif (b && c)\n+\t\t\treturn c * (b / a);\n+\t}\n+\n+\t__cpuid(0x1, a, b, c, d);\n+\tmodel = rte_cpu_get_model(a);\n+\n+\tif (check_model_wsm_nhm(model))\n+\t\tmult = 133;\n+\telse if ((c & bit_AVX) || check_model_gdm_dnv(model))\n+\t\tmult = 100;\n+\telse\n+\t\treturn 0;\n+\n+\tret = rdmsr(0xCE, &tsc_hz);\n+\tif (!(ret < 0))\n+\t\treturn ((tsc_hz >> 8) & 0xff) * mult * 1E6;\n+\n+\treturn 0;\n+}\ndiff --git a/lib/librte_eal/common/include/arch/x86/rte_cycles.h b/lib/librte_eal/common/include/arch/x86/rte_cycles.h\nindex e2661e2..0db89dc 100644\n--- a/lib/librte_eal/common/include/arch/x86/rte_cycles.h\n+++ b/lib/librte_eal/common/include/arch/x86/rte_cycles.h\n@@ -84,11 +84,8 @@ rte_rdtsc(void)\n  *   The number of rdtsc cycles in one second. Return zero if the architecture\n  *   support is not available.\n  */\n-static inline uint64_t\n-rte_rdtsc_arch_hz(void)\n-{\n-\treturn 0;\n-}\n+uint64_t\n+rte_rdtsc_arch_hz(void);\n \n static inline uint64_t\n rte_rdtsc_precise(void)\ndiff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile\nindex 90bca4d..9d44828 100644\n--- a/lib/librte_eal/linuxapp/eal/Makefile\n+++ b/lib/librte_eal/linuxapp/eal/Makefile\n@@ -104,6 +104,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_service.c\n # from arch dir\n SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_cpuflags.c\n SRCS-$(CONFIG_RTE_ARCH_X86) += rte_spinlock.c\n+SRCS-$(CONFIG_RTE_ARCH_X86) += rte_cycles.c\n \n CFLAGS_eal_common_cpuflags.o := $(CPUFLAGS_LIST)\n \n",
    "prefixes": [
        "dpdk-dev"
    ]
}