[Linuxptp-devel] [PATCH v3 0/6] Use precise frequency for TX SYNC messages

2023-03-29 Thread Luigi Mantellini
The actual ptp4l implementation rearms timers after the expiration. This approach doesn't permit to have a precise TX SYNC message scheduling. During my test the TX SYNC frequency is slightly lower the expectation (eg 15.99Hz vs 16Hz). The following patchset uses non blocking timers and only for

[Linuxptp-devel] [PATCH v3 4/6] Split announce/sync_rx timer rearm on expiration.

2023-03-29 Thread Luigi Mantellini
During a timer handling we should avoid to call timerfd_settime() on a different timer because this call will invalidate the file descriptor, resulting in a EGAIN when the other timer code will performe the read(). The ANNOUNCE and RX SYNC timer code just doesn't follow this rule. The solution is

[Linuxptp-devel] [PATCH v3 2/6] Rearrange the fdarray in order to serve timers before sockets fds.

2023-03-29 Thread Luigi Mantellini
This change ensure that all timers timeouts are handled just before the PTP message handling. The PTP message hanlding code can performe timerfd_settime() calls that invalidate the status of timer descriptors. This side effect is not noticed until now because we never read from the timer descriptor

[Linuxptp-devel] [PATCH v3 1/6] Use FD_EVENT and FD_GENERAL instead numeric values.

2023-03-29 Thread Luigi Mantellini
Change fd[0] with FD_EVENT and fd[1] with FD_GENERAL. Signed-off-by: Luigi Mantellini --- raw.c | 4 ++-- udp.c | 4 ++-- udp6.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/raw.c b/raw.c index a76fab6..f73e895 100644 --- a/raw.c +++ b/raw.c @@ -193,8 +193,8 @@ stat

[Linuxptp-devel] [PATCH v3 5/6] Use Non-blocking timer file descriptors.

2023-03-29 Thread Luigi Mantellini
This patch avoid to block on a timer fd read. We already protect with poll(). Signed-off-by: Luigi Mantellini --- port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/port.c b/port.c index 7609f2c..03f388b 100644 --- a/port.c +++ b/port.c @@ -1939,7 +1939,7 @@ int port_

[Linuxptp-devel] [PATCH v3 3/6] Flush timer file descriptors after expiration.

2023-03-29 Thread Luigi Mantellini
After the timer expiration, just after the poll(), we can read fron the timer file descriptor a 64bit value that represents the number of expirations that have occured. This value is useful for debug. In addition, when we use a periodic timer the timer will be locked until the read of this value.

[Linuxptp-devel] [PATCH v3 6/6] Use periodic timer for TX SYNC timeout.

2023-03-29 Thread Luigi Mantellini
In order to obtain a precise TX SYNC frequency we need to use a periodic timer facility instead to reconfigure the timer on every expiration. The solution consists to configure the it_interval field of the itimerspec structure (see timerfd_create(2) man page) only when the port goes into Master ro

Re: [Linuxptp-devel] Bug caused by commit afeabf3 "ptp4l: add VLAN over bond support" on kernel 4.9

2023-03-29 Thread Hangbin Liu
On Thu, Mar 30, 2023 at 03:03:44AM +0200, Martin Pecka wrote: > I have a suspicion regarding the code in sk.c: > > ```c++ >     cfg.flags = HWTSTAMP_FLAG_BONDED_PHC_INDEX; >     /* Fall back without flag if user run new build on old kernel */ >     if (ioctl(fd, SIOCGHWTSTAMP, &ifreq) == -EINVAL)

Re: [Linuxptp-devel] Bug caused by commit afeabf3 "ptp4l: add VLAN over bond support" on kernel 4.9

2023-03-29 Thread Martin Pecka
The kernel is 1 year and 3 month old, it should work. You mean this device: https://developer.nvidia.com/embedded/jetson-tx2 Yes. NVidia Jetson TX2. The device's NIC uses eqos driver and reports all the timestamping capabilities required for ptp4l: I do not find any 'eqos' driver i

Re: [Linuxptp-devel] [PATCH] Fix power profile config option range to UINT32_MAX

2023-03-29 Thread Erez
On Wed, 29 Mar 2023 at 20:36, Jacob Keller wrote: > The power profile configuration options added in commit 7059a05a3fb2 > ("Introduce the power profile.") specify their maximum range as INT_MAX. > The values are stored in UInteger32 values, and the default 0x is > outside the range of a

[Linuxptp-devel] [PATCH] Fix power profile config option range to UINT32_MAX

2023-03-29 Thread Jacob Keller
The power profile configuration options added in commit 7059a05a3fb2 ("Introduce the power profile.") specify their maximum range as INT_MAX. The values are stored in UInteger32 values, and the default 0x is outside the range of a 32-bit integer. Because of this, on platforms which have 32-

[Linuxptp-devel] bugs when reading ptp4l configuration files

2023-03-29 Thread Jacob Keller
Hi, I recently discovered a couple of bugs with ptp4l's config reading code: First, the default configuration specifies values for two of the power profile options which are out of INT_MAX range: power_profile.2011.grandmasterTimeInaccuracy and power_profile.2017.totalTimeInaccuracy On systems

[Linuxptp-devel] [PATCH 6/6] Use periodic timer for TX SYNC timeout.

2023-03-29 Thread Luigi 'Comio' Mantellini
Thanks... i will produce a v3 after some feedback > Sorry I forgot another hint. Please use the 'git format-patch' with the patch > seria iteration flag '-v '. So we can differentiate the mails as newer :-) > This will change the subject to something like "Subject: [PATCH v2 0/6] " ___

Re: [Linuxptp-devel] [PATCH 6/6] Use periodic timer for TX SYNC timeout.

2023-03-29 Thread Erez
Sorry I forgot another hint. Please use the 'git format-patch' with the patch seria iteration flag '-v '. So we can differentiate the mails as newer :-) This will change the subject to something like "Subject: [PATCH *v2* 0/6] " Erez On Wed, 29 Mar 2023 at 17:17, Erez wrote: > You add a

Re: [Linuxptp-devel] [PATCH 6/6] Use periodic timer for TX SYNC timeout.

2023-03-29 Thread Erez
You add a nice cover letter and good explanations on your patches. Now we wait for other developers' feedback. Just one last hint. We usually check the patch format with the kernel check patch tool. https://docs.kernel.org/dev-tools/checkpatch.html But you can do that after you get more feedbacks

Re: [Linuxptp-devel] Use periodic timer for TX SYNC timeout

2023-03-29 Thread Erez
On Wed, 29 Mar 2023 at 14:37, Luigi 'Comio' Mantellini < luigi.mantell...@gmail.com> wrote: > Hi Erez, > > sorry, I usually use pull requests. > Me too :-) But using patch seria is cool too. > > > Il giorno mer 29 mar 2023 alle ore 14:29 Erez ha > scritto: > >> >> >> On Wed, 29 Mar 2023 at 11:

[Linuxptp-devel] [PATCH 2/6] Rearrange the fdarray in order to serve timers before sockets fds.

2023-03-29 Thread Luigi Mantellini
This change ensure that all timers timeouts are handled just before the PTP message handling. The PTP message hanlding code can performe timerfd_settime() calls that invalidate the status of timer descriptors. This side effect is not noticed until now because we never read from the timer descriptor

[Linuxptp-devel] [PATCH 4/6] Split announce/sync_rx timer rearm on expiration.

2023-03-29 Thread Luigi Mantellini
During a timer handling we should avoid to call timerfd_settime() on a different timer because this call will invalidate the file descriptor, resulting in a EGAIN when the other timer code will performe the read(). The ANNOUNCE and RX SYNC timer code just doesn't follow this rule. The solution is

[Linuxptp-devel] [PATCH 1/6] Use FD_EVENT and FD_GENERAL instead numeric values.

2023-03-29 Thread Luigi Mantellini
--- raw.c | 4 ++-- udp.c | 4 ++-- udp6.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/raw.c b/raw.c index a76fab6..f73e895 100644 --- a/raw.c +++ b/raw.c @@ -193,8 +193,8 @@ static int raw_configure(int fd, int event, int index, static int raw_close(struct transp

[Linuxptp-devel] [PATCH 6/6] Use periodic timer for TX SYNC timeout.

2023-03-29 Thread Luigi Mantellini
In order to obtain a precise TX SYNC frequency we need to use a periodic timer facility instead to reconfigure the timer on every expiration. The solution consists to configure the it_interval field of the itimerspec structure (see timerfd_create(2) man page) only when the port goes into Master ro

[Linuxptp-devel] [PATCH 6/6] Use periodic timer for TX SYNC timeout.

2023-03-29 Thread Luigi Mantellini
In order to obtain a precise TX SYNC frequency we need to use a periodic timer facility instead to reconfigure the timer on every expiration. The solution consists to configure the it_interval field of the itimerspec structure (see timerfd_create(2) man page) only when the port goes into Master ro

[Linuxptp-devel] [PATCH 0/6] Use precise frequency for TX SYNC messages

2023-03-29 Thread Luigi Mantellini
The actual ptp4l implementation rearms timers after the expiration. This approach doesn't permit to have a precise TX SYNC message scheduling. During my test the TX SYNC frequency is slightly lower the expectation (eg 15.99Hz vs 16Hz). The following patchset uses non blocking timers and only for

[Linuxptp-devel] [PATCH 4/6] Split announce/sync_rx timer rearm on expiration.

2023-03-29 Thread Luigi Mantellini
During a timer handling we should avoid to call timerfd_settime() on a different timer because this call will invalidate the file descriptor, resulting in a EGAIN when the other timer code will performe the read(). The ANNOUNCE and RX SYNC timer code just doesn't follow this rule. The solution is

[Linuxptp-devel] [PATCH 1/6] Use FD_EVENT and FD_GENERAL instead numeric values.

2023-03-29 Thread Luigi Mantellini
--- raw.c | 4 ++-- udp.c | 4 ++-- udp6.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/raw.c b/raw.c index a76fab6..f73e895 100644 --- a/raw.c +++ b/raw.c @@ -193,8 +193,8 @@ static int raw_configure(int fd, int event, int index, static int raw_close(struct transp

[Linuxptp-devel] [PATCH 5/6] Use Non-blocking timer file descriptors.

2023-03-29 Thread Luigi Mantellini
This patch avoid to block on a timer fd read. We already protect with poll(). --- port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/port.c b/port.c index cc558eb..29b6870 100644 --- a/port.c +++ b/port.c @@ -1939,7 +1939,7 @@ int port_initialize(struct port *p)

[Linuxptp-devel] [PATCH 2/6] Rearrange the fdarray in order to serve timers before sockets fds.

2023-03-29 Thread Luigi Mantellini
This change ensure that all timers timeouts are handled just before the PTP message handling. The PTP message hanlding code can performe timerfd_settime() calls that invalidate the status of timer descriptors. This side effect is not noticed until now because we never read from the timer descriptor

[Linuxptp-devel] [PATCH 3/6] Flush timer file descriptors after expiration.

2023-03-29 Thread Luigi Mantellini
After the timer expiration, just after the poll(), we can read fron the timer file descriptor a 64bit value that represents the number of expirations that have occured. This value is useful for debug. In addition, when we use a periodic timer the timer will be locked until the read of this value. -

[Linuxptp-devel] [PATCH 5/6] Use Non-blocking timer file descriptors.

2023-03-29 Thread Luigi Mantellini
This patch avoid to block on a timer fd read. We already protect with poll(). --- port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/port.c b/port.c index cc558eb..29b6870 100644 --- a/port.c +++ b/port.c @@ -1939,7 +1939,7 @@ int port_initialize(struct port *p)

[Linuxptp-devel] [PATCH 3/6] Flush timer file descriptors after expiration.

2023-03-29 Thread Luigi Mantellini
After the timer expiration, just after the poll(), we can read fron the timer file descriptor a 64bit value that represents the number of expirations that have occured. This value is useful for debug. In addition, when we use a periodic timer the timer will be locked until the read of this value. -

Re: [Linuxptp-devel] Use periodic timer for TX SYNC timeout

2023-03-29 Thread Luigi 'Comio' Mantellini
Hi Erez, sorry, I usually use pull requests. Il giorno mer 29 mar 2023 alle ore 14:29 Erez ha scritto: > > > On Wed, 29 Mar 2023 at 11:28, Luigi Mantellini > wrote: > >> The actual ptp4l implementation rearms timers on timeut. This doesn't >> permit to have a precise TX SYNC > > > Did you mis

Re: [Linuxptp-devel] Use periodic timer for TX SYNC timeout

2023-03-29 Thread Erez
On Wed, 29 Mar 2023 at 11:28, Luigi Mantellini wrote: > The actual ptp4l implementation rearms timers on timeut. This doesn't > permit to have a precise TX SYNC Did you misspell "timeout"? > message scheduling. > The following patchset uses non blocking timers and only for TX SYNC timer > a p

Re: [Linuxptp-devel] Bug caused by commit afeabf3 "ptp4l: add VLAN over bond support" on kernel 4.9

2023-03-29 Thread Erez
On Wed, 29 Mar 2023 at 11:27, Martin Pecka wrote: > Hello, > > I'm using linuxptp from master branch on a Jetson TX2 device, where > unfortunately only kernel 4.9.299 is available from the manufacturer. > commit 224d99f50f25ec3234b99556c0076a7130e230c6 (tag: v4.9.299) Author: Greg Kroah-Hartman

[Linuxptp-devel] [PATCH 3/6] Flush timer fd after expiration

2023-03-29 Thread Luigi Mantellini
--- e2e_tc.c | 4 p2p_tc.c | 4 port.c | 25 + port.h | 10 ++ 4 files changed, 43 insertions(+) diff --git a/e2e_tc.c b/e2e_tc.c index 2f8e821..43c69e9 100644 --- a/e2e_tc.c +++ b/e2e_tc.c @@ -85,6 +85,7 @@ enum fsm_event e2e_event(struct port *p,

[Linuxptp-devel] [PATCH 4/6] Split announce/sync_rx timer rearm on expiration fd

2023-03-29 Thread Luigi Mantellini
--- e2e_tc.c | 26 p2p_tc.c | 26 port.c | 60 3 files changed, 70 insertions(+), 42 deletions(-) diff --git a/e2e_tc.c b/e2e_tc.c index 43c69e9..c7cfd9e 100644 --- a/e2e_tc.c +++ b/e2e_tc

[Linuxptp-devel] [PATCH 5/6] Use Non-blocking timer file descriptors

2023-03-29 Thread Luigi Mantellini
--- port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/port.c b/port.c index cc558eb..29b6870 100644 --- a/port.c +++ b/port.c @@ -1939,7 +1939,7 @@ int port_initialize(struct port *p) fd[i] = -1; } for (i = 0; i < N_TIMER_FDS; i++) { -

[Linuxptp-devel] Use periodic timer for TX SYNC timeout

2023-03-29 Thread Luigi Mantellini
The actual ptp4l implementation rearms timers on timeut. This doesn't permit to have a precise TX SYNC message scheduling. The following patchset uses non blocking timers and only for TX SYNC timer a periodic timer is used. In addition, a periodic timer requires to read (and flush) the file descr

[Linuxptp-devel] [PATCH 2/6] Rearrange the fdarray in order to serve timers before sockets fds

2023-03-29 Thread Luigi Mantellini
--- fd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fd.h b/fd.h index 16420d7..038d156 100644 --- a/fd.h +++ b/fd.h @@ -29,8 +29,6 @@ * same call to poll(). */ enum { - FD_EVENT, - FD_GENERAL, FD_DELAY_TIMER, FD_ANNOUNCE_TIMER,

[Linuxptp-devel] [PATCH 1/6] Use constant FD_EVENT and FD_GENERAL instead numeric values

2023-03-29 Thread Luigi Mantellini
--- raw.c | 4 ++-- udp.c | 4 ++-- udp6.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/raw.c b/raw.c index a76fab6..f73e895 100644 --- a/raw.c +++ b/raw.c @@ -193,8 +193,8 @@ static int raw_configure(int fd, int event, int index, static int raw_close(struct transp

[Linuxptp-devel] [PATCH 6/6] Use periodic timer for TX SYNC timeout

2023-03-29 Thread Luigi Mantellini
--- port.c | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/port.c b/port.c index 29b6870..3c7df6b 100644 --- a/port.c +++ b/port.c @@ -231,7 +231,7 @@ struct fdarray *port_fda(struct port *port) return &port->fda; } -int set_tmo_log(int fd, unsigned

[Linuxptp-devel] Bug caused by commit afeabf3 "ptp4l: add VLAN over bond support" on kernel 4.9

2023-03-29 Thread Martin Pecka
Hello, I'm using linuxptp from master branch on a Jetson TX2 device, where unfortunately only kernel 4.9.299 is available from the manufacturer. The device's NIC uses eqos driver and reports all the timestamping capabilities required for ptp4l: $ ethtool -T eth0 Time stamping parameters for