All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: Tom Barbette <barbette@kth.se>
Cc: dev@dpdk.org, bruce.richardson@intel.com,
	john.mcnamara@intel.com, Ferruh Yigit <ferruh.yigit@intel.com>,
	Andrew Rybchenko <arybchenko@solarflare.com>,
	Shahaf Shuler <shahafs@mellanox.com>,
	Yongseok Koh <yskoh@mellanox.com>,
	olivier.matz@6wind.com
Subject: Re: [dpdk-dev] [PATCH v4 3/3] rxtx_callbacks: Add support for HW timestamp
Date: Thu, 13 Jun 2019 14:55:37 +0900	[thread overview]
Message-ID: <4877681.EENiiDfvPL@xps> (raw)
In-Reply-To: <20190502121135.18775-4-barbette@kth.se>

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.



  parent reply	other threads:[~2019-06-13  5:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-02 12:11 [dpdk-dev] [PATCH v4 0/3] Add rte_eth_read_clock API Tom Barbette
2019-05-02 12:11 ` [dpdk-dev] [PATCH v4 1/3] rte_ethdev: Add API function to read dev clock Tom Barbette
2019-05-08  7:54   ` Andrew Rybchenko
2019-06-04 13:57   ` Ferruh Yigit
2019-05-02 12:11 ` [dpdk-dev] [PATCH v4 2/3] mlx5: Implement support for read_clock Tom Barbette
2019-05-02 12:11 ` [dpdk-dev] [PATCH v4 3/3] rxtx_callbacks: Add support for HW timestamp Tom Barbette
2019-05-31  7:46   ` Ferruh Yigit
2019-06-13  5:55   ` Thomas Monjalon [this message]
2019-05-08  7:49 ` [dpdk-dev] [PATCH v4 0/3] Add rte_eth_read_clock API Tom Barbette
2019-05-31  7:46 ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4877681.EENiiDfvPL@xps \
    --to=thomas@monjalon.net \
    --cc=arybchenko@solarflare.com \
    --cc=barbette@kth.se \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=john.mcnamara@intel.com \
    --cc=olivier.matz@6wind.com \
    --cc=shahafs@mellanox.com \
    --cc=yskoh@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.