From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ferruh Yigit Subject: Re: [PATCH 1/3] rte_ethdev: Add API function to read dev clock Date: Thu, 20 Dec 2018 19:55:11 +0000 Message-ID: <491a4e29-83dd-ad0c-8904-d1e2ccca1f68@intel.com> References: <20181219134934.24693-1-barbette@kth.se> <20181219134934.24693-2-barbette@kth.se> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: bruce.richardson@intel.com, john.mcnamara@intel.com, Thomas Monjalon , Andrew Rybchenko , Shahaf Shuler , Yongseok Koh To: Tom Barbette , dev@dpdk.org Return-path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 957804C88 for ; Thu, 20 Dec 2018 20:55:15 +0100 (CET) In-Reply-To: <20181219134934.24693-2-barbette@kth.se> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 12/19/2018 1:49 PM, Tom Barbette wrote: > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice. > + * > + * Read the current clock counter of an Ethernet device > + * > + * This returns the current raw clock value of an Ethernet device. > + * The value returned here is from the same clock than the one > + * filling timestamp field of RX packets. Therefore it can be used > + * to compute a precise conversion of the device clock to the real time. > + * > + * E.g, a simple heuristic to derivate the frequency would be: > + * uint64_t start, end; > + * rte_eth_read_clock(port, start); > + * rte_delay_ms(100); > + * rte_eth_read_clock(port, end); > + * double freq = (end - start) * 10; > + * > + * Compute a common reference with: > + * uint64_t base_time_sec = current_time(); > + * uint64_t base_clock; > + * rte_eth_read_clock(port, base_clock); > + * > + * Then, convert the raw mbuf timestamp with: > + * base_time_sec + (double)(mbuf->timestamp - base_clock) / freq; > + * > + * This simple example will not provide a very good accuracy. One must > + * at least measure multiple times the frequency and do a regression. > + * To avoid deviation from the system time, the common reference can > + * be repeated from time to time. The integer division can also be > + * converted by a multiplication and a shift for better performance. > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @param time > + * Pointer to the uint64_t that holds the raw clock value. > + * > + * @return > + * - 0: Success. > + * - -ENODEV: The port ID is invalid. > + * - -ENOTSUP: The function is not supported by the Ethernet driver. > + */ > +int __rte_experimental rte_eth_read_clock(uint16_t port_id, uint64_t *time); Is this a common enough feature to include into ethdev abstraction layer? Or a feature for a single vendor? I would like to get more input from other vendors if this is something they can benefit from?