On Tue, 2022-12-13 at 17:27 +0100, Erez Geva wrote: On Tue, 2022-12-13 at 10:56 +0530, Devasish Dey wrote: > + /* Megabits per secon converted to attoseconds per bit. */ > + return 1000000000000ULL/ iface->if_info.speed; Performing division in running is not a very good idea. It is better to perform the division when updating the speed and store it in if_info.
I agree with Miroslav, calculation is better, I did not suggest using hard coded values, so not need to defend. I simply suggest to move the calculation to where you set "if_info.speed". So instead of calculate it every cycle, we only calculate when speed is changed. Division is expensive (unless it is a left shift). I usually compare new speed with old speed before calculate, if the speed is the same, so is the bit time :-) Are you sure we need attoseconds (10^-18), we usually uses nanoseconds (10^-9). I would except a better resolution, but that much? Please explain your choosing. > +} [Devasish]: The initial changes were with hardcoded values for the speed to avoid the calculation. Miroslav suggested this way to have clean code. Yes the calculation is based on attoseconds and not nanoseconds This is as per standard G.8275.2 From G.8275.2 (06/2021) The linuxptp is mainly implement IEEE. That does not means we can not support or use ITU standards, but if you do, please add a comment with reference. This applies as well as to choosing attoseconds. This comment is also valid for the 'Uinteger64' type, as it is not currently used by IEEE, please add a comment it is used for ITU standard parameters. If future IEEE will use the Uinteger64 too, we can remove the comment. " interfaceBitPeriod (Uinteger64) The period of 1-bit of the transmitting PTP timestamp interface, excluding line encoding. The value is encoded as an unsigned integer in units of attoseconds (10–18 s) to accommodate interface bit periods less than 1 ns." Thanks, Devasish. Erez
_______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel