> -----Original Message-----
> From: Frantisek Rysanek <frantisek.rysa...@post.cz>
> Sent: Friday, May 26, 2023 9:01 AM
> To: linuxptp-devel@lists.sourceforge.net
> Subject: [Linuxptp-devel] Side note: i225 / igc time sync and TSN 
> capabilities...
> 
> Dear gents,
> 
> this is just a slightly off topic gratuitous side note.
> 
> In the context of fumbling in the "igb" driver in the other thread, I
> also took a look inside driver "igc" for comparison = to see what the
> i225 had to offer.
> Unsurprisingly, the register map related to time sync features seems
> quite similar to that of the i210. The source code of igc_ptp.c is
> pretty clean. The datasheet for the i225 is not public yet and I
> don't have it, so I cannot comment further.
> 
> Interestingly to me, the TIMADJ register is now mentioned, but only
> to set some novel flag/bit in that register during port init/reset...
> For stepwise time adjustment, the SYSTIM registers get written
> directly :-)
> 

Hi,

I didn't work directly on the i350 code, but I recall historically that the 
TIMADJ registers were poorly designed and didn't map very well onto the actual 
adjtime callback.

Assuming the i350 is anything like i210, here's the description of TIMADJ from 
i210's datasheet:

Dynamic update of SYSTIM registers can be done by using the TIMADJ registers by 
the following
flow. It can also be done by adjusting the INC_TIME as described later in this 
section. Adjusting the
time by TIMADJ are meant to be used only when the time difference between the 
master and the
slave are small enough (at least smaller than one 8th of the time between 
consecutive SYNC
cycles). If this assumption is incorrect, than this process might take longer 
time than the SYNC
cycle to take effect. If this is an issue, software might need to set the 
SYSTIM by direct access as
described in the “Initial Setting” phase:
— Write the Tadjust value and its Sign to the TIMADJ register (the Sign bit 
indicates if the Tadjust
value should be added or subtracted)
— Following the write access to the TIMADJ register, the hardware repeats the 
following two steps
at each 8 nsec clock as long as the Tadjust > zero.
• SYSTIM = SYSTIM + INC_TIME +/- 1 nsec. Add or subtract 1 nsec is defined by
TIMADJ.Sign (while 0bmeans Add and 1b means Subtract)
• Tadjust = Tadjust - 1 nsec
• Note that the SYSTIM timer is incremented monotonically at all times. When 
updating the
SYSTIM by the TIMADJ and concurrent non-zero TIMINCA, the SYSTIM is incremented 
each
clock by steps in the range of 6.5ns up to 9.5ns units.
— As shown above, the time adjustment might take multiple clocks. Software 
might write a new
value to the TIMADJ register before the hardware completed the previous 
adjustment. In such
a case, the new value written by software, overrides the above equation. If 
such a race is not
desired, the software could check that the previous adjustment is completed by 
one of the
following methods:
• Wait enough time before accessing the TIMADJ register which guarantees that 
the previous
update procedure is completed.
• Poll the matched TSICR.TADJ flag which is set by the hardware each time the 
update
procedure is completed.
• Enable the TADJ interrupt by setting the TADJ flag in the TSIM register and 
enable timesync
interrupts by setting the Time_Sync flag in the IMS register. The TADJ 
interrupt indicates
that the hardware completed the adjustment procedure. This method is unlikely 
to be used
in nominal operation since the expected adjustments are in the sub s range.

TL;DR; the TIMADJ basically just amounts to a +1 or -1 to the increment value 
beyond the range of the INC_TIME register. It doesn't actually do an immediate 
atomic adjustment. The delay makes it not as useful, and the fact that you 
can't enable it "permanently" makes it not useful for performing frequency 
adjustment as we'd have to keep re-applying the value in order to keep the +1 
for longer periods.

We could apply the adjustment and then poll until it completes which might take 
time and delay the adjtime operation, or we could set a timer and block new 
adjtime operations until the thing completes...

Thanks,
Jake


_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to