Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Cochran <richardcochran@gmail.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH v8] i40e: add support for PTP external synchronization clock
Date: Tue, 8 Dec 2020 04:35:23 -0800	[thread overview]
Message-ID: <20201208123523.GA17489@hoboy.vegasvil.org> (raw)
In-Reply-To: <20201208154119.106511-1-piotr.kwapulinski@intel.com>

On Tue, Dec 08, 2020 at 03:41:19PM +0000, Piotr Kwapulinski wrote:

> @@ -145,14 +398,35 @@ static int i40e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
>  static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
>  {
>  	struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps);
> -	struct timespec64 now, then;
> +	struct i40e_hw *hw = &pf->hw;
>  
> -	then = ns_to_timespec64(delta);
>  	mutex_lock(&pf->tmreg_lock);
>  
> -	i40e_ptp_read(pf, &now, NULL);
> -	now = timespec64_add(now, then);
> -	i40e_ptp_write(pf, (const struct timespec64 *)&now);
> +	if (delta > -999999900LL && delta < 999999900LL) {
> +		int neg_adj = 0;
> +		u32 timadj;
> +		u64 tohw;
> +
> +		if (delta < 0) {
> +			neg_adj = 1;
> +			tohw = -delta;
> +		} else {
> +			tohw = delta;
> +		}
> +
> +		timadj = tohw & 0x3FFFFFFF;
> +		if (neg_adj)
> +			timadj |= I40E_ISGN;
> +		wr32(hw, I40E_PRTTSYN_ADJ, timadj);
> +	} else {
> +		struct timespec64 then, now;
> +
> +		then = ns_to_timespec64(delta);
> +		i40e_ptp_read(pf, &now, NULL);
> +		now = timespec64_add(now, then);
> +		i40e_ptp_write(pf, (const struct timespec64 *)&now);
> +		i40e_ptp_set_1pps_signal_hw(pf);

This enables a 1-PPS hardware output unconditionally?

> +	}
>  
>  	mutex_unlock(&pf->tmreg_lock);
>  

> @@ -839,6 +1492,8 @@ void i40e_ptp_init(struct i40e_pf *pf)
>  		/* Restore the clock time based on last known value */
>  		i40e_ptp_restore_hw_time(pf);
>  	}
> +
> +	i40e_ptp_set_1pps_signal_hw(pf);
>  }

Here again the 1-PPS is enabled unconditionally.

Instead, why not allow the user to enable/disable this?

There is a new ioctl variant designed for periodic outputs like a PPS.

Bits of the ptp_perout_request.flags field can contain:

 PTP_PEROUT_DUTY_CYCLE
 PTP_PEROUT_PHASE

You can enable the PPS when they are present in the request.

Thanks,
Richard

  parent reply	other threads:[~2020-12-08 12:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07 21:47 [Intel-wired-lan] [PATCH v7] i40e: add support for PTP external synchronization clock Piotr Kwapulinski
2020-12-07 21:10 ` Paul Menzel
2020-12-08  9:57   ` Kwapulinski, Piotr
2020-12-08 15:41   ` [Intel-wired-lan] [PATCH v8] " Piotr Kwapulinski
2020-12-08 10:51     ` Paul Menzel
2020-12-08 11:13       ` Kwapulinski, Piotr
2020-12-08 12:35     ` Richard Cochran [this message]
2021-01-07 11:35       ` Kwapulinski, Piotr
2020-12-08 11:01 ` [Intel-wired-lan] [PATCH v7] " Maciej Fijalkowski

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=20201208123523.GA17489@hoboy.vegasvil.org \
    --to=richardcochran@gmail.com \
    --cc=intel-wired-lan@osuosl.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