DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Soumyadeep Hore <soumyadeep.hore@intel.com>
Cc: <aman.deep.singh@intel.com>, <dev@dpdk.org>,
	<shaiq.wani@intel.com>, <stable@dpdk.org>
Subject: Re: [PATCH v3] net/ice: fix incorrect reading of PHY timestamp
Date: Fri, 25 Oct 2024 09:55:24 +0100	[thread overview]
Message-ID: <Zxtc_OSUVP4fjEW5@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <20241025073211.681268-1-soumyadeep.hore@intel.com>

On Fri, Oct 25, 2024 at 07:32:11AM +0000, Soumyadeep Hore wrote:
> In ICE PMD, previously the ready bitmap checking before reading
> PHY timestamp was not present. This caused incorrect Tx
> timestamping.
> 
> The ready bitmap checking is enabled and PHY timestamp is read once
> the ready bitmap gives positive value.
> 
> Fixes: 881169950d80 ("net/ice/base: implement initial PTP support for E830")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Soumyadeep Hore <soumyadeep.hore@intel.com>
> ---
>  drivers/net/ice/ice_ethdev.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
> index 7b1bd163a2..e0db47cf28 100644
> --- a/drivers/net/ice/ice_ethdev.c
> +++ b/drivers/net/ice/ice_ethdev.c
> @@ -6517,12 +6517,28 @@ ice_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
>  	struct ice_adapter *ad =
>  			ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
>  	uint8_t lport;
> -	uint64_t ts_ns, ns, tstamp;
> +	uint64_t ts_ns, ns, tstamp, tstamp_ready = 0;
> +	uint64_t start_time, curr_time;
>  	const uint64_t mask = 0xFFFFFFFF;
>  	int ret;
>  
>  	lport = hw->port_info->lport;
>  
> +	start_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);

Why all the division by 1000?

> +
> +	while (!(tstamp_ready & BIT_ULL(0))) {
> +		ret = ice_get_phy_tx_tstamp_ready(hw, lport, &tstamp_ready);
> +		if (ret) {
> +			PMD_DRV_LOG(ERR, "Failed to get phy ready for timestamp");
> +			return -1;
> +		}
> +		curr_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
> +		if (curr_time - start_time > 1000) {

Is 1 second not a very long time to wait for this? Surely even milliseconds
is a very long delay in this case.

In terms of the logic, rather than constantly comparing vs the start time
and doing lots of division, I think it would be simpler to just set a max
end-time. For example, to keep the current 1s limit:

	uint64_t end_time = rte_get_timer_cycles?() + rte_get_timer_hz()
	...
	if (rte_get_timer_cycles() > end_time) {
	     ...
	}

> +			PMD_DRV_LOG(ERR, "Timeout to get phy ready for timestamp");
> +			return -1;
> +		}
> +	}
> +
>  	ret = ice_read_phy_tstamp(hw, lport, 0, &tstamp);
>  	if (ret) {
>  		PMD_DRV_LOG(ERR, "Failed to read phy timestamp");
> -- 
> 2.43.0
> 

  reply	other threads:[~2024-10-25  8:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-11 13:00 [PATCH v1] " Soumyadeep Hore
2024-10-25  5:14 ` [PATCH v2] " Soumyadeep Hore
2024-10-25  7:32   ` [PATCH v3] " Soumyadeep Hore
2024-10-25  8:55     ` Bruce Richardson [this message]
2024-10-25  7:50   ` [PATCH v4] " Soumyadeep Hore
2024-10-25  9:02     ` Bruce Richardson

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=Zxtc_OSUVP4fjEW5@bricha3-mobl1.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=aman.deep.singh@intel.com \
    --cc=dev@dpdk.org \
    --cc=shaiq.wani@intel.com \
    --cc=soumyadeep.hore@intel.com \
    --cc=stable@dpdk.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).