All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jiawen Wu" <jiawenwu@trustnetic.com>
To: "'Richard Cochran'" <richardcochran@gmail.com>
Cc: <andrew+netdev@lunn.ch>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<linux@armlinux.org.uk>, <horms@kernel.org>,
	<jacob.e.keller@intel.com>, <netdev@vger.kernel.org>,
	<vadim.fedorenko@linux.dev>, <mengyuanlou@net-swift.com>
Subject: RE: [PATCH net-next v4 4/4] net: ngbe: Add support for 1PPS and TOD
Date: Thu, 16 Jan 2025 14:24:12 +0800	[thread overview]
Message-ID: <067101db67df$422cecd0$c686c670$@trustnetic.com> (raw)
In-Reply-To: <Z4aPzfa_ngf98t3F@hoboy.vegasvil.org>

On Wed, Jan 15, 2025 12:25 AM, Richard Cochran wrote:
> On Tue, Jan 14, 2025 at 04:44:25PM +0800, Jiawen Wu wrote:
> > +static int wx_ptp_feature_enable(struct ptp_clock_info *ptp,
> > +				 struct ptp_clock_request *rq, int on)
> > +{
> > +	struct wx *wx = container_of(ptp, struct wx, ptp_caps);
> > +
> > +	/**
> > +	 * When PPS is enabled, unmask the interrupt for the ClockOut
> > +	 * feature, so that the interrupt handler can send the PPS
> > +	 * event when the clock SDP triggers. Clear mask when PPS is
> > +	 * disabled
> > +	 */
> > +	if (rq->type != PTP_CLK_REQ_PEROUT || !wx->ptp_setup_sdp)
> > +		return -EOPNOTSUPP;
> > +
> > +	/* Reject requests with unsupported flags */
> > +	if (rq->perout.flags & ~PTP_PEROUT_PHASE)
> > +		return -EOPNOTSUPP;
> > +
> > +	if (rq->perout.phase.sec || rq->perout.phase.nsec) {
> > +		wx_err(wx, "Absolute start time not supported.\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	if (on)
> > +		set_bit(WX_FLAG_PTP_PPS_ENABLED, wx->flags);
> > +	else
> > +		clear_bit(WX_FLAG_PTP_PPS_ENABLED, wx->flags);
> > +
> > +	wx->pps_width = rq->perout.period.nsec;
> 
> This is still wrong.
> 
> perout.period specifies the *period* not the pulse width.

Thanks for the guidance. But what I'm really confused about is how
do I get the duty cycle ("on" in struct ptp_perout_request).
I try this:
	echo "0 0 0 1 0" > /sys/class/ptp/ptp0/period
to pass the period 1s for 1pps. Then where should the duty cycle
values put? Seems "rq->perout.flags & PTP_PEROUT_DUTY_CYCLE"
always be false.

+       /* Reject requests with unsupported flags */
+       if (rq->perout.flags & ~(PTP_PEROUT_DUTY_CYCLE |
+                                PTP_PEROUT_PHASE))
+               return -EOPNOTSUPP;
+
+       if (rq->perout.phase.sec || rq->perout.phase.nsec) {
+               wx_err(wx, "Absolute start time not supported.\n");
+               return -EINVAL;
+       }
+
+       if (rq->perout.period.sec != 1 || rq->perout.period.nsec) {
+               wx_err(wx, "Only 1pps is supported.\n");
+               return -EINVAL;
+       }
+
+       if (rq->perout.flags & PTP_PEROUT_DUTY_CYCLE) {
+               struct timespec64 ts_on;
+
+               ts_on.tv_sec = rq->perout.on.sec;
+               ts_on.tv_nsec = rq->perout.on.nsec;
+               wx->pps_width = timespec64_to_ns(&ts_on);
+       } else {
+               wx->pps_width = 120000000;
+       }



  reply	other threads:[~2025-01-16  6:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-14  8:44 [PATCH net-next v4 0/4] Support PTP clock for Wangxun NICs Jiawen Wu
2025-01-14  8:44 ` [PATCH net-next v4 1/4] net: wangxun: Add support for PTP clock Jiawen Wu
2025-01-14  9:27   ` Vadim Fedorenko
2025-01-14 10:28   ` Vadim Fedorenko
2025-01-14  8:44 ` [PATCH net-next v4 2/4] net: wangxun: Support to get ts info Jiawen Wu
2025-01-14  8:44 ` [PATCH net-next v4 3/4] net: wangxun: Implement do_aux_work of ptp_clock_info Jiawen Wu
2025-01-14  9:31   ` Vadim Fedorenko
2025-01-14  8:44 ` [PATCH net-next v4 4/4] net: ngbe: Add support for 1PPS and TOD Jiawen Wu
2025-01-14 16:24   ` Richard Cochran
2025-01-16  6:24     ` Jiawen Wu [this message]
2025-01-16 17:23       ` Jacob Keller
2025-01-17  6:36         ` Richard Cochran

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='067101db67df$422cecd0$c686c670$@trustnetic.com' \
    --to=jiawenwu@trustnetic.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mengyuanlou@net-swift.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=vadim.fedorenko@linux.dev \
    /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.