[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <f387de62-6a61-4c21-97a0-ac0da9e99c58@intel.com>
Date: Thu, 16 Jan 2025 09:23:10 -0800
From: Jacob Keller <jacob.e.keller@...el.com>
To: Jiawen Wu <jiawenwu@...stnetic.com>, '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>, <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 1/15/2025 10:24 PM, Jiawen Wu wrote:
> On Wed, Jan 15, 2025 12:25 AM, Richard Cochran wrote:
>> 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.
>
The sysfs interface doesn't expose the full support for the
PTP_PEROUT_REQUEST ioctl.
It only supports setting the period and the start time. The other
features were added later, and the sysfs interface was never extended.
To use the full support, you need to issue the PTP_PEROUT_REQUEST2
ioctl, for example from a C program. Something like the following might
help you on the right path:
> #include <linux/ptp_clock.h>
> #include <sys/ioctl.h>
> #include <time.h>
>
> int main(void)
> {
> struct ptp_perout_request perout_request = {};
> int fd, err;
>
> /* use the appropriate device for your clock */
> fd = open("/dev/ptp0", O_RDWR);
>
> /* fill in perout_request as desired */
>
> err = ioctl(fd, PTP_PEROUT_REQUEST2, &perout_request);
> if (err) {
> ...
> }
> }
Thanks,
Jake
Powered by blists - more mailing lists