get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2207,
    "url": "https://patches.dpdk.org/api/patches/2207/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1420565213-17429-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": "<1420565213-17429-5-git-send-email-rkerur@gmail.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1420565213-17429-5-git-send-email-rkerur@gmail.com",
    "date": "2015-01-06T17:26:51",
    "name": "[dpdk-dev,v4,5/7] Move common functions in eal_timer.c",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "fe72f4723b1f8ee5c0cc513c1ae9ff9d9a2dda5b",
    "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/1420565213-17429-5-git-send-email-rkerur@gmail.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/2207/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/2207/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 BEBCE5A70;\n\tTue,  6 Jan 2015 18:27:24 +0100 (CET)",
            "from mail-pa0-f52.google.com (mail-pa0-f52.google.com\n\t[209.85.220.52]) by dpdk.org (Postfix) with ESMTP id 69780590C\n\tfor <dev@dpdk.org>; Tue,  6 Jan 2015 18:27:18 +0100 (CET)",
            "by mail-pa0-f52.google.com with SMTP id eu11so31390516pac.11\n\tfor <dev@dpdk.org>; Tue, 06 Jan 2015 09:27:17 -0800 (PST)",
            "from iaas-l305162.englab.brocade.com ([144.49.130.148])\n\tby mx.google.com with ESMTPSA id\n\tnl14sm46887340pdb.81.2015.01.06.09.27.17\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tTue, 06 Jan 2015 09:27:17 -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=8sRl6/BrRymPZkuELnbzbs92byM7jbHY3Ox2YvCMGjI=;\n\tb=ah30zoWPiqtsqSAIBsWinUqOVwxIWH1LRUM8J7cu9/DZ+1ITIuq/8S4I7AEHEjsFJ+\n\t8ZCBQ3aiNdOB7O2N6F1+re+OJ4GD4K1+hLRwmgzKfw6bZU3ti9HRqmaZLIBkuAkdsjqb\n\tbS+qpIarPWUgKjzBkZU4ok2Fsr/rjwjophXe/bpE3BHY0R3Ing0GY1GB6/P10HqMvMy1\n\tJnOapXG+NPck5PYVMoTUIuBSqffJ0Dy9VoKWUNdulvcTSGyJSlLFRZMahz65M1sdtgCr\n\twcmtaW4eUvhpf9ReZvv9RHMXfsHAnYDAPSKS1qstkP3H/y+lgP4aaEzkjQe3skGghGvh\n\tiC/A==",
        "X-Received": "by 10.68.189.71 with SMTP id gg7mr155600519pbc.21.1420565237793; \n\tTue, 06 Jan 2015 09:27:17 -0800 (PST)",
        "From": "Ravi Kerur <rkerur@gmail.com>",
        "To": "dev@dpdk.org",
        "Date": "Tue,  6 Jan 2015 12:26:51 -0500",
        "Message-Id": "<1420565213-17429-5-git-send-email-rkerur@gmail.com>",
        "X-Mailer": "git-send-email 1.9.1",
        "In-Reply-To": "<1420565213-17429-1-git-send-email-rkerur@gmail.com>",
        "References": "<1420565170-17365-1-git-send-email-rkerur@gmail.com>\n\t<1420565213-17429-1-git-send-email-rkerur@gmail.com>",
        "Subject": "[dpdk-dev] [PATCH v4 5/7] Move common functions in eal_timer.c",
        "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 v4\nRemoved extern declaration of eal_tsc_resolution_hz,\ninstead provided _set_ API.\nMake set_tsc_freq_from_clock as wrapper function for BSD.\n\nChanges in v3\nChanged subject to be more explicit on file name inclusion.\n\nChanges in v2\nUse common function name set_tsc_freq_from_sysctl for BSD and Linux.\nUpdate comments about its actuality in function declaration.\n\nChanges in v1\nMove common functions in eal_timer.c to librte_eal/common/\neal_common_timer.c file.\n\nFollowing functions are  moved to eal_common_timer.c file\n\nvoid rte_delay_us(unsigned us);\nuint64_t rte_get_tsc_hz(void);\nstatic void set_tsc_freq_fallback(void);\nvoid set_tsc_freq(void);\n\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    |  54 +++--------------\n lib/librte_eal/common/eal_common_timer.c | 101 +++++++++++++++++++++++++++++++\n lib/librte_eal/common/eal_private.h      |  24 ++++++++\n lib/librte_eal/linuxapp/eal/Makefile     |   1 +\n lib/librte_eal/linuxapp/eal/eal_timer.c  |  55 ++---------------\n 6 files changed, 140 insertions(+), 96 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 e01b5f3..a86123c 100644\n--- a/lib/librte_eal/bsdapp/eal/Makefile\n+++ b/lib/librte_eal/bsdapp/eal/Makefile\n@@ -76,6 +76,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..bbcc69d 100644\n--- a/lib/librte_eal/bsdapp/eal/eal_timer.c\n+++ b/lib/librte_eal/bsdapp/eal/eal_timer.c\n@@ -56,29 +56,12 @@\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+static inline int\n set_tsc_freq_from_sysctl(void)\n {\n \tsize_t sz;\n \tint tmp;\n+\tuint64_t tsc_hz;\n \n \tsz = sizeof(tmp);\n \ttmp = 0;\n@@ -95,42 +78,23 @@ set_tsc_freq_from_sysctl(void)\n \telse if (tmp != 1)\n \t\tRTE_LOG(WARNING, EAL, \"TSC is not invariant\\n\");\n \n-\tsz = sizeof(eal_tsc_resolution_hz);\n-\tif (sysctlbyname(\"machdep.tsc_freq\", &eal_tsc_resolution_hz, &sz, NULL, 0)) {\n+\tsz = sizeof(tsc_hz);\n+\tif (sysctlbyname(\"machdep.tsc_freq\", &tsc_hz, &sz, NULL, 0)) {\n \t\tRTE_LOG(WARNING, EAL, \"%s\\n\", strerror(errno));\n \t\treturn -1;\n \t}\n+\trte_set_tsc_hz(tsc_hz);\n \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+ * Wrapper function to get TSC frequency from sysctl.\n  */\n-static void\n-set_tsc_freq(void)\n+int\n+set_tsc_freq_from_clock(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+\treturn set_tsc_freq_from_sysctl();\n }\n \n int\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..2a511d0\n--- /dev/null\n+++ b/lib/librte_eal/common/eal_common_timer.c\n@@ -0,0 +1,101 @@\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+void\n+rte_set_tsc_hz(uint64_t tsc_hz)\n+{\n+\teal_tsc_resolution_hz = tsc_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_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+}\ndiff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h\nindex 855d033..f907e79 100644\n--- a/lib/librte_eal/common/eal_private.h\n+++ b/lib/librte_eal/common/eal_private.h\n@@ -302,4 +302,28 @@ unsigned cpu_core_id(unsigned lcore_id);\n  */\n int cpu_detected(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+ * Is a wrapper function for BSD which will\n+ * internally call set_tsc_freq_from_sysctl.\n+ *\n+ * This function is private to the EAL.\n+ */\n+int set_tsc_freq_from_clock(void);\n+\n+/**\n+ * This function sets TSC frequency\n+ *\n+ * This function is private to the EAL.\n+ */\n+void rte_set_tsc_hz(uint64_t tsc_hz);\n+\n #endif /* _EAL_PRIVATE_H_ */\ndiff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile\nindex 0fc997d..3453f31 100644\n--- a/lib/librte_eal/linuxapp/eal/Makefile\n+++ b/lib/librte_eal/linuxapp/eal/Makefile\n@@ -88,6 +88,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..bc176db 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_timer.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_timer.c\n@@ -58,9 +58,6 @@\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 +158,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,7 +256,7 @@ check_tsc_flags(void)\n \tfclose(stream);\n }\n \n-static int\n+int\n set_tsc_freq_from_clock(void)\n {\n #ifdef CLOCK_MONOTONIC_RAW\n@@ -285,6 +265,7 @@ set_tsc_freq_from_clock(void)\n \tstruct timespec sleeptime = {.tv_nsec = 5E8 }; /* 1/2 second */\n \n \tstruct timespec t_start, t_end;\n+\tuint64_t tsc_hz;\n \n \tif (clock_gettime(CLOCK_MONOTONIC_RAW, &t_start) == 0) {\n \t\tuint64_t ns, end, start = rte_rdtsc();\n@@ -295,42 +276,14 @@ set_tsc_freq_from_clock(void)\n \t\tns += (t_end.tv_nsec - t_start.tv_nsec);\n \n \t\tdouble secs = (double)ns/NS_PER_SEC;\n-\t\teal_tsc_resolution_hz = (uint64_t)((end - start)/secs);\n+\t\ttsc_hz = (uint64_t)((end - start)/secs);\n+\t\trte_set_tsc_hz(tsc_hz);\n \t\treturn 0;\n \t}\n #endif\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",
        "v4",
        "5/7"
    ]
}