From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 4EF061B395 for ; Fri, 13 Oct 2017 02:02:54 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id D757D2168C; Thu, 12 Oct 2017 20:02:53 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Thu, 12 Oct 2017 20:02:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=mesmtp; bh=HRtyhv6f8w7EbC gVuT2S5eA1WmToURNGMDtQMHkDIPs=; b=Sa669rAlMMDI8PMr9jkbmaMeYV5vW6 UUFc0SDg5VK62o5yoDE4ZDAM1HPE1k9ragoOtRbAARAqUSZJN6DabOKsBlqfyfcS gWfD2J73q4eBbkiNErmfxjPGRsvty1fjmsVqNuGdFsK0P3cKYXiHT8GjzGCIDwCW WNYvGVibCsL2A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=HRtyhv6f8w7EbCgVuT2S5eA1WmToURNGMDtQMHkDIPs=; b=gPc9nXSl xTAJEZWaUGkqxXgG3cVzauahOFlm0H47ACAB1jfW80a+4pvr7qvGGYXsCp1XldSx xl8fyzwtnc9HrREIA+jJLE4grDRQ/WPEHBpVOcxlsMRZQ3TcHYrBl2ZJxryF97HY v1Nh3+ZoRWIefHuTuXBTfGRmcp0j73ywoqqssKBJAxWCDH5q5AcqLnPQ5qnjJ+UF EFWzKqaOtizJUsAIoKj9ehkGeQWEhk1PyE6HcuIzmawINQafEmGA+QW8iGL4NkqA ltKbImLU6AfpXZUwWQzW4+QuhJEHSU22v3zrDzpaz3iDPdxyqV7fWGlYrmucObIp 1sbEBDWLIiKl5g== X-ME-Sender: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id CFABC24A6C; Thu, 12 Oct 2017 20:02:52 -0400 (EDT) From: Thomas Monjalon To: gowrishankar.m@linux.vnet.ibm.com, jerin.jacob@caviumnetworks.com, jianbo.liu@linaro.org, sergio.gonzalez.monroy@intel.com, bruce.richardson@intel.com Cc: dev@dpdk.org Date: Fri, 13 Oct 2017 02:02:44 +0200 Message-Id: <20171013000247.4158-2-thomas@monjalon.net> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171013000247.4158-1-thomas@monjalon.net> References: <20171013000247.4158-1-thomas@monjalon.net> Subject: [dpdk-dev] [PATCH 1/4] timer: honor arch-specific TSC frequency query X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Oct 2017 00:02:54 -0000 From: Jerin Jacob When calibrating the TSC frequency, first, probe the architecture specific function. If not available, use the existing calibrate scheme. Signed-off-by: Jerin Jacob Signed-off-by: Thomas Monjalon --- lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/common/arch/arm/rte_cycles.c | 7 +++++++ lib/librte_eal/common/arch/ppc_64/rte_cycles.c | 7 +++++++ lib/librte_eal/common/arch/x86/rte_cycles.c | 7 +++++++ lib/librte_eal/common/eal_common_timer.c | 5 ++++- lib/librte_eal/common/eal_private.h | 11 +++++++++++ lib/librte_eal/linuxapp/eal/Makefile | 1 + 7 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 lib/librte_eal/common/arch/arm/rte_cycles.c create mode 100644 lib/librte_eal/common/arch/ppc_64/rte_cycles.c create mode 100644 lib/librte_eal/common/arch/x86/rte_cycles.c diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile index 317a75ebc..b42306bc3 100644 --- a/lib/librte_eal/bsdapp/eal/Makefile +++ b/lib/librte_eal/bsdapp/eal/Makefile @@ -92,6 +92,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_service.c # from arch dir SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_cpuflags.c SRCS-$(CONFIG_RTE_ARCH_X86) += rte_spinlock.c +SRCS-y += rte_cycles.c CFLAGS_eal_common_cpuflags.o := $(CPUFLAGS_LIST) diff --git a/lib/librte_eal/common/arch/arm/rte_cycles.c b/lib/librte_eal/common/arch/arm/rte_cycles.c new file mode 100644 index 000000000..851fd0255 --- /dev/null +++ b/lib/librte_eal/common/arch/arm/rte_cycles.c @@ -0,0 +1,7 @@ +#include "eal_private.h" + +uint64_t +get_tsc_freq_arch(void) +{ + return 0; +} diff --git a/lib/librte_eal/common/arch/ppc_64/rte_cycles.c b/lib/librte_eal/common/arch/ppc_64/rte_cycles.c new file mode 100644 index 000000000..851fd0255 --- /dev/null +++ b/lib/librte_eal/common/arch/ppc_64/rte_cycles.c @@ -0,0 +1,7 @@ +#include "eal_private.h" + +uint64_t +get_tsc_freq_arch(void) +{ + return 0; +} diff --git a/lib/librte_eal/common/arch/x86/rte_cycles.c b/lib/librte_eal/common/arch/x86/rte_cycles.c new file mode 100644 index 000000000..851fd0255 --- /dev/null +++ b/lib/librte_eal/common/arch/x86/rte_cycles.c @@ -0,0 +1,7 @@ +#include "eal_private.h" + +uint64_t +get_tsc_freq_arch(void) +{ + return 0; +} diff --git a/lib/librte_eal/common/eal_common_timer.c b/lib/librte_eal/common/eal_common_timer.c index ed0b16d05..5980b294e 100644 --- a/lib/librte_eal/common/eal_common_timer.c +++ b/lib/librte_eal/common/eal_common_timer.c @@ -80,8 +80,11 @@ estimate_tsc_freq(void) void set_tsc_freq(void) { - uint64_t freq = get_tsc_freq(); + uint64_t freq; + freq = get_tsc_freq_arch(); + if (!freq) + freq = get_tsc_freq(); if (!freq) freq = estimate_tsc_freq(); diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index 597d82e44..6e0f85def 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -314,6 +314,17 @@ void set_tsc_freq(void); */ uint64_t get_tsc_freq(void); +/** + * Get TSC frequency if the architecture supports. + * + * This function is private to the EAL. + * + * @return + * The number of TSC cycles in one second. + * Returns zero if the architecture support is not available. + */ +uint64_t get_tsc_freq_arch(void); + /** * Prepare physical memory mapping * i.e. hugepages on Linux and diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile index 21e0b4aad..140d1acfa 100644 --- a/lib/librte_eal/linuxapp/eal/Makefile +++ b/lib/librte_eal/linuxapp/eal/Makefile @@ -101,6 +101,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_service.c # from arch dir SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_cpuflags.c SRCS-$(CONFIG_RTE_ARCH_X86) += rte_spinlock.c +SRCS-y += rte_cycles.c CFLAGS_eal_common_cpuflags.o := $(CPUFLAGS_LIST) -- 2.14.1