From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id B8D1BA00E6 for ; Thu, 13 Jun 2019 07:55:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 061FE1CE55; Thu, 13 Jun 2019 07:55:50 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 0C0881CE4F for ; Thu, 13 Jun 2019 07:55:49 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 24C362203C; Thu, 13 Jun 2019 01:55:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 13 Jun 2019 01:55:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=mesmtp; bh=VbQgD61nIivBtqgJxW3XH+8J738lYwbXD0m79jo8MMU=; b=g4ZUQedjKMTp CmFZ+6hLzQJLFA5zaAQ7V2nWavjur4kIadoOC9kEZ23/uBV39Mye1lx2PZqFs862 pjgI3Xs9Emwu1jUDAS3JGktZRp6MTrKPg/NtPBFu/KFf3X3iRLSDaEe0yIZgJp+Q SnOxF+LSG8dwoitZhpKs6MPZrzBbJ9M= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=VbQgD61nIivBtqgJxW3XH+8J738lYwbXD0m79jo8M MU=; b=P3syQwsuZb1p1RrOyuHua16nOcrk6nAfQ17maumZ4jXKunW6KLpUqJUvR 8/42IO3KTp+QQe8CMkDL/OJukr9Cxy47TDRtGtyw49aQ4KyKlk0FOISp/A7qKAcH PSJoLZjQtL1DSkeqSp/vUri28lyo9sdzCMtvCbQ+7RP1Z2lMxqNQON+ACcpPjgLv cfopUySHf/NO0+TMed9BMJV9yik+8BsfG25TitC6zxNyBZva3C8lNk+DMMsKJ7NL BUU/Zd9sTUO/g8UUPZC1Mxu7ybbJ6NtJh0c/4lZna3ujJ3jm0e8AGlDCSKzHaUYJ AjLfrO4hhGhYZzIz/sTkv2ErN3iDQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehkedguddtudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkjghfggfgtgesthfuredttddtvdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc fkphepuddviedrvdduuddruddvjedrleeinecurfgrrhgrmhepmhgrihhlfhhrohhmpeht hhhomhgrshesmhhonhhjrghlohhnrdhnvghtnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from xps.localnet (om126211127096.13.openmobile.ne.jp [126.211.127.96]) by mail.messagingengine.com (Postfix) with ESMTPA id 68EA338008B; Thu, 13 Jun 2019 01:55:41 -0400 (EDT) From: Thomas Monjalon To: Tom Barbette Cc: dev@dpdk.org, bruce.richardson@intel.com, john.mcnamara@intel.com, Ferruh Yigit , Andrew Rybchenko , Shahaf Shuler , Yongseok Koh , olivier.matz@6wind.com Date: Thu, 13 Jun 2019 14:55:37 +0900 Message-ID: <4877681.EENiiDfvPL@xps> In-Reply-To: <20190502121135.18775-4-barbette@kth.se> References: <20190502121135.18775-1-barbette@kth.se> <20190502121135.18775-4-barbette@kth.se> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v4 3/3] rxtx_callbacks: Add support for HW timestamp 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 02/05/2019 21:11, Tom Barbette: > + if (hw_timestamping && ticks_per_cycle_mult == 0) { > + uint64_t cycles_base = rte_rdtsc(); > + uint64_t ticks_base; > + retval = rte_eth_read_clock(port, &ticks_base); > + if (retval != 0) > + return retval; > + rte_delay_ms(100); > + uint64_t cycles = rte_rdtsc(); > + uint64_t ticks; > + rte_eth_read_clock(port, &ticks); > + uint64_t c_freq = cycles - cycles_base; > + uint64_t t_freq = ticks - ticks_base; > + double freq_mult = (double)c_freq / t_freq; > + printf("TSC Freq ~= %lu\nHW Freq ~= %lu\nRatio : %f\n", > + c_freq * 10, t_freq * 10, freq_mult); > + /* TSC will be faster than internal ticks so freq_mult is > 0 > + * We convert the multiplication to an integer shift & mult > + */ > + ticks_per_cycle_mult = (1 << TICKS_PER_CYCLE_SHIFT) / freq_mult; > + } I see two issues in this code: 1/ statements are mixed with variable declarations 2/ %lu is used for 64-bit variables, which does not work on 32-bit system. I am fixing item 2 when merging. I hope item 1 won't be an issue for some old compilers.