lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <067101db67df$422cecd0$c686c670$@trustnetic.com>
Date: Thu, 16 Jan 2025 14:24:12 +0800
From: Jiawen Wu <jiawenwu@...stnetic.com>
To: "'Richard Cochran'" <richardcochran@...il.com>
Cc: <andrew+netdev@...n.ch>,
	<davem@...emloft.net>,
	<edumazet@...gle.com>,
	<kuba@...nel.org>,
	<pabeni@...hat.com>,
	<linux@...linux.org.uk>,
	<horms@...nel.org>,
	<jacob.e.keller@...el.com>,
	<netdev@...r.kernel.org>,
	<vadim.fedorenko@...ux.dev>,
	<mengyuanlou@...-swift.com>
Subject: RE: [PATCH net-next v4 4/4] net: ngbe: Add support for 1PPS and TOD

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;
+       }



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ