get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2172,
    "url": "https://patches.dpdk.org/api/patches/2172/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1419694402-2215-5-git-send-email-rkerur@gmail.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": "<1419694402-2215-5-git-send-email-rkerur@gmail.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1419694402-2215-5-git-send-email-rkerur@gmail.com",
    "date": "2014-12-27T15:33:21",
    "name": "[dpdk-dev,v2,5/6] Move EAL common functions",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "90c85d952e4c1aecd65bb3127f692524921c9115",
    "submitter": {
        "id": 134,
        "url": "https://patches.dpdk.org/api/people/134/?format=api",
        "name": "Ravi Kerur",
        "email": "rkerur@gmail.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1419694402-2215-5-git-send-email-rkerur@gmail.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/2172/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/2172/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 CF732568E;\n\tSat, 27 Dec 2014 16:33:43 +0100 (CET)",
            "from mail-pa0-f54.google.com (mail-pa0-f54.google.com\n\t[209.85.220.54]) by dpdk.org (Postfix) with ESMTP id 1D0815691\n\tfor <dev@dpdk.org>; Sat, 27 Dec 2014 16:33:36 +0100 (CET)",
            "by mail-pa0-f54.google.com with SMTP id fb1so14596856pad.41\n\tfor <dev@dpdk.org>; Sat, 27 Dec 2014 07:33:35 -0800 (PST)",
            "from iaas-l305162.englab.brocade.com ([144.49.130.148])\n\tby mx.google.com with ESMTPSA id\n\tzk9sm31325490pac.1.2014.12.27.07.33.34\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tSat, 27 Dec 2014 07:33:34 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=LkEz3XoPqVjWpnmWc0YR9nrMpNncoGWZ9qv5wF1V1gw=;\n\tb=Jh8mW1I3KcUow2emXt6F0fY41F6EQAtcczAd7Avcp4QsUupLiHN+mGnjuCekaxA9X+\n\tDey0RnApV8HG3w3d9EwUXmMe2/HIEAXqgNcW7Rc5EKhICRqEqNWK9TCLNbnWmVo9S2jt\n\tswaVxpXuXhm8TlzLWLHHUM0K366dYIJmXYYB5iyD3w8sS0fKb8uabW6gxH/FcHxZ5VrJ\n\tgxbHaxe3l/AICqfcdDH3Mb5BEz7DsI34ILikK7e/5WR1tlKAhyNbxBI6/TQqdqGMMXSP\n\t14kDggbr5QNriQ5sj2Klixd6IlOdYg+6bwW0asTPavSjpK5X/D3TvXJFzTYI/6yvjCsp\n\tHMrg==",
        "X-Received": "by 10.66.66.203 with SMTP id h11mr25741860pat.131.1419694415392; \n\tSat, 27 Dec 2014 07:33:35 -0800 (PST)",
        "From": "Ravi Kerur <rkerur@gmail.com>",
        "To": "dev@dpdk.org",
        "Date": "Sat, 27 Dec 2014 10:33:21 -0500",
        "Message-Id": "<1419694402-2215-5-git-send-email-rkerur@gmail.com>",
        "X-Mailer": "git-send-email 1.9.1",
        "In-Reply-To": "<1419694402-2215-1-git-send-email-rkerur@gmail.com>",
        "References": "<1419694322-2114-1-git-send-email-rkerur@gmail.com>\n\t<1419694402-2215-1-git-send-email-rkerur@gmail.com>",
        "Subject": "[dpdk-dev] [PATCH v2 5/6] Move EAL common functions",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <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": "Changes in v2\n1. Use common function name set_tsc_freq_from_sysctl for BSD and Linux.\n   Update comments about its actuality in function declaration.\n\nMove common functions in eal_timer.c to librte_eal/common\ndirectory.\nMakefile changes to reflect new file added.\nFix checkpatch warnings and errors.\n\nSigned-off-by: Ravi Kerur <rkerur@gmail.com>\n---\n lib/librte_eal/bsdapp/eal/Makefile       |  1 +\n lib/librte_eal/bsdapp/eal/eal_timer.c    | 50 +----------------\n lib/librte_eal/common/eal_common_timer.c | 95 ++++++++++++++++++++++++++++++++\n lib/librte_eal/common/eal_externs.h      |  3 +\n lib/librte_eal/common/eal_private.h      | 15 +++++\n lib/librte_eal/linuxapp/eal/Makefile     |  1 +\n lib/librte_eal/linuxapp/eal/eal_timer.c  | 54 +-----------------\n 7 files changed, 120 insertions(+), 99 deletions(-)\n create mode 100644 lib/librte_eal/common/eal_common_timer.c",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile\nindex 560b7a3..fb1faa3 100644\n--- a/lib/librte_eal/bsdapp/eal/Makefile\n+++ b/lib/librte_eal/bsdapp/eal/Makefile\n@@ -75,6 +75,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_options.c\n SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_debug.c\n SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_thread.c\n SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_lcore.c\n+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_timer.c\n \n CFLAGS_eal.o := -D_GNU_SOURCE\n #CFLAGS_eal_common_thread.o := -D_GNU_SOURCE\ndiff --git a/lib/librte_eal/bsdapp/eal/eal_timer.c b/lib/librte_eal/bsdapp/eal/eal_timer.c\nindex 3163496..4341d3c 100644\n--- a/lib/librte_eal/bsdapp/eal/eal_timer.c\n+++ b/lib/librte_eal/bsdapp/eal/eal_timer.c\n@@ -49,6 +49,7 @@\n \n #include \"eal_private.h\"\n #include \"eal_internal_cfg.h\"\n+#include \"eal_externs.h\"\n \n #ifdef RTE_LIBEAL_USE_HPET\n #warning HPET is not supported in FreeBSD\n@@ -56,25 +57,7 @@\n \n enum timer_source eal_timer_source = EAL_TIMER_TSC;\n \n-/* The frequency of the RDTSC timer resolution */\n-static uint64_t eal_tsc_resolution_hz = 0;\n-\n-void\n-rte_delay_us(unsigned us)\n-{\n-\tconst uint64_t start = rte_get_timer_cycles();\n-\tconst uint64_t ticks = (uint64_t)us * rte_get_timer_hz() / 1E6;\n-\twhile ((rte_get_timer_cycles() - start) < ticks)\n-\t\trte_pause();\n-}\n-\n-uint64_t\n-rte_get_tsc_hz(void)\n-{\n-\treturn eal_tsc_resolution_hz;\n-}\n-\n-static int\n+int\n set_tsc_freq_from_sysctl(void)\n {\n \tsize_t sz;\n@@ -104,35 +87,6 @@ set_tsc_freq_from_sysctl(void)\n \treturn 0;\n }\n \n-static void\n-set_tsc_freq_fallback(void)\n-{\n-\tRTE_LOG(WARNING, EAL, \"WARNING: clock_gettime cannot use \"\n-\t\t\t\"CLOCK_MONOTONIC_RAW and HPET is not available\"\n-\t\t\t\" - clock timings may be less accurate.\\n\");\n-\t/* assume that the sleep(1) will sleep for 1 second */\n-\tuint64_t start = rte_rdtsc();\n-\tsleep(1);\n-\teal_tsc_resolution_hz = rte_rdtsc() - start;\n-}\n-\n-/*\n- * This function measures the TSC frequency. It uses a variety of approaches.\n- *\n- * 1. Read the TSC frequency value provided by the kernel\n- * 2. If above does not work, just sleep for 1 second and tune off that,\n- *    printing a warning about inaccuracy of timing\n- */\n-static void\n-set_tsc_freq(void)\n-{\n-\tif (set_tsc_freq_from_sysctl() < 0)\n-\t\tset_tsc_freq_fallback();\n-\n-\tRTE_LOG(INFO, EAL, \"TSC frequency is ~%\"PRIu64\" KHz\\n\",\n-\t\t\teal_tsc_resolution_hz/1000);\n-}\n-\n int\n rte_eal_timer_init(void)\n {\ndiff --git a/lib/librte_eal/common/eal_common_timer.c b/lib/librte_eal/common/eal_common_timer.c\nnew file mode 100644\nindex 0000000..cc4515f\n--- /dev/null\n+++ b/lib/librte_eal/common/eal_common_timer.c\n@@ -0,0 +1,95 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2010-2014 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+#include <string.h>\n+#include <stdio.h>\n+#include <unistd.h>\n+#include <inttypes.h>\n+#include <sys/types.h>\n+#include <sys/sysctl.h>\n+#include <errno.h>\n+\n+#include <rte_common.h>\n+#include <rte_log.h>\n+#include <rte_cycles.h>\n+\n+#include \"eal_private.h\"\n+#include \"eal_internal_cfg.h\"\n+\n+/* The frequency of the RDTSC timer resolution */\n+uint64_t eal_tsc_resolution_hz = 0;\n+\n+void\n+rte_delay_us(unsigned us)\n+{\n+\tconst uint64_t start = rte_get_timer_cycles();\n+\tconst uint64_t ticks = (uint64_t)us * rte_get_timer_hz() / 1E6;\n+\n+\twhile ((rte_get_timer_cycles() - start) < ticks)\n+\t\trte_pause();\n+}\n+\n+uint64_t\n+rte_get_tsc_hz(void)\n+{\n+\treturn eal_tsc_resolution_hz;\n+}\n+\n+static void\n+set_tsc_freq_fallback(void)\n+{\n+\tRTE_LOG(WARNING, EAL, \"WARNING: clock_gettime cannot use \"\n+\t\t\"CLOCK_MONOTONIC_RAW and HPET is not available\"\n+\t\t\" - clock timings may be less accurate.\\n\");\n+\t/* assume that the sleep(1) will sleep for 1 second */\n+\tuint64_t start = rte_rdtsc();\n+\n+\tsleep(1);\n+\teal_tsc_resolution_hz = rte_rdtsc() - start;\n+}\n+\n+/*\n+ * This function measures the TSC frequency. It uses a variety of approaches.\n+ *\n+ * 1. Read the TSC frequency value provided by the kernel\n+ * 2. If above does not work, just sleep for 1 second and tune off that,\n+ *    printing a warning about inaccuracy of timing\n+ */\n+void\n+set_tsc_freq(void)\n+{\n+\tif (set_tsc_freq_from_sysctl() < 0)\n+\t\tset_tsc_freq_fallback();\n+\n+\tRTE_LOG(INFO, EAL, \"TSC frequency is ~%\"PRIu64\" KHz\\n\",\n+\t\t\teal_tsc_resolution_hz/1000);\n+}\ndiff --git a/lib/librte_eal/common/eal_externs.h b/lib/librte_eal/common/eal_externs.h\nindex b19bea6..124ab65 100644\n--- a/lib/librte_eal/common/eal_externs.h\n+++ b/lib/librte_eal/common/eal_externs.h\n@@ -39,4 +39,7 @@ extern struct rte_config rte_config;\n extern int mem_cfg_fd;\n extern rte_usage_hook_t\trte_application_usage_hook;\n \n+/* Extern declarations defined in eal_common_timer.c */\n+extern uint64_t eal_tsc_resolution_hz;\n+\n #endif\ndiff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h\nindex 9fe91b3..98a08f0 100644\n--- a/lib/librte_eal/common/eal_private.h\n+++ b/lib/librte_eal/common/eal_private.h\n@@ -264,6 +264,21 @@ unsigned cpu_socket_id(unsigned lcore_id);\n  */\n unsigned cpu_core_id(unsigned lcore_id);\n \n+/**\n+ * This function measures TSC frequency\n+ *\n+ * This function is private to the EAL.\n+ */\n+void set_tsc_freq(void);\n+\n+/**\n+ * This function sets TSC frequency from sysctl\n+ * for BSD and from clock for Linux.\n+ *\n+ * This function is private to the EAL.\n+ */\n+int set_tsc_freq_from_sysctl(void);\n+\n #ifdef RTE_EXEC_ENV_BSDAPP\n /**\n  * This function gets no. of cpus\ndiff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile\nindex ff185fd..2404423 100644\n--- a/lib/librte_eal/linuxapp/eal/Makefile\n+++ b/lib/librte_eal/linuxapp/eal/Makefile\n@@ -87,6 +87,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_options.c\n SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_debug.c\n SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_thread.c\n SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_lcore.c\n+SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_timer.c\n \n CFLAGS_eal.o := -D_GNU_SOURCE\n CFLAGS_eal_common_thread.o := -D_GNU_SOURCE\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_timer.c b/lib/librte_eal/linuxapp/eal/eal_timer.c\nindex ca57916..0d5416b 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_timer.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_timer.c\n@@ -55,12 +55,10 @@\n \n #include \"eal_private.h\"\n #include \"eal_internal_cfg.h\"\n+#include \"eal_externs.h\"\n \n enum timer_source eal_timer_source = EAL_TIMER_HPET;\n \n-/* The frequency of the RDTSC timer resolution */\n-static uint64_t eal_tsc_resolution_hz = 0;\n-\n #ifdef RTE_LIBEAL_USE_HPET\n \n #define DEV_HPET \"/dev/hpet\"\n@@ -161,23 +159,6 @@ rte_get_hpet_cycles(void)\n \n #endif\n \n-\n-void\n-rte_delay_us(unsigned us)\n-{\n-\tconst uint64_t start = rte_get_timer_cycles();\n-\tconst uint64_t ticks = (uint64_t)us * rte_get_timer_hz() / 1E6;\n-\twhile ((rte_get_timer_cycles() - start) < ticks)\n-\t\trte_pause();\n-}\n-\n-uint64_t\n-rte_get_tsc_hz(void)\n-{\n-\treturn eal_tsc_resolution_hz;\n-}\n-\n-\n #ifdef RTE_LIBEAL_USE_HPET\n /*\n  * Open and mmap /dev/hpet (high precision event timer) that will\n@@ -276,8 +257,8 @@ check_tsc_flags(void)\n \tfclose(stream);\n }\n \n-static int\n-set_tsc_freq_from_clock(void)\n+int\n+set_tsc_freq_from_sysctl(void)\n {\n #ifdef CLOCK_MONOTONIC_RAW\n #define NS_PER_SEC 1E9\n@@ -302,35 +283,6 @@ set_tsc_freq_from_clock(void)\n \treturn -1;\n }\n \n-static void\n-set_tsc_freq_fallback(void)\n-{\n-\tRTE_LOG(WARNING, EAL, \"WARNING: clock_gettime cannot use \"\n-\t\t\t\"CLOCK_MONOTONIC_RAW and HPET is not available\"\n-\t\t\t\" - clock timings may be less accurate.\\n\");\n-\t/* assume that the sleep(1) will sleep for 1 second */\n-\tuint64_t start = rte_rdtsc();\n-\tsleep(1);\n-\teal_tsc_resolution_hz = rte_rdtsc() - start;\n-}\n-/*\n- * This function measures the TSC frequency. It uses a variety of approaches.\n- *\n- * 1. If kernel provides CLOCK_MONOTONIC_RAW we use that to tune the TSC value\n- * 2. If kernel does not provide that, and we have HPET support, tune using HPET\n- * 3. Lastly, if neither of the above can be used, just sleep for 1 second and\n- * tune off that, printing a warning about inaccuracy of timing\n- */\n-static void\n-set_tsc_freq(void)\n-{\n-\tif (set_tsc_freq_from_clock() < 0)\n-\t\tset_tsc_freq_fallback();\n-\n-\tRTE_LOG(INFO, EAL, \"TSC frequency is ~%\"PRIu64\" KHz\\n\",\n-\t\t\teal_tsc_resolution_hz/1000);\n-}\n-\n int\n rte_eal_timer_init(void)\n {\n",
    "prefixes": [
        "dpdk-dev",
        "v2",
        "5/6"
    ]
}