- 19 Sep, 2013 7 commits
-
-
Alessandro Rubini authored
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
Suggested by Aurelio and Maciej Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Grzegorz Daniluk authored
-
Alessandro Rubini authored
set to -1 all unused sockets, so FS_SET won't crash if, for example, we request UDP on a port with no IPV4 address, after the message: unix_open_ch: ioctl(SIOCGIFADDR): Cannot assign requested address While at it, I factorized some common code. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
- 18 Sep, 2013 9 commits
-
-
Alessandro Rubini authored
This commit factorizes some code in lib/conf.c from the two hosted startup files, but the aim is passing "-f <filename>" on the command line, to test with unconventional setups without touching the "real" filesystem. Now ppsi looks for the configuration file is from threee places, in this order: - command line, if any - architecture-specific, if any (e.g. "/wr/etc/ppsi.conf") - compile-time default ("/etc/ppsi.conf") Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
The next commit makes a little order in startup files, and config file parsing ends up after all allocations, so we can't reply on ppg->nlinks to be properly set. In hosted environments we have no issues with a few kilobytes more, so allocate the max number of instances even if less are used. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
If we run both Ethernet and UDP services in a 18-port switch, we need 36 logical links. Thus, increase the previous limit of 32 to 64, knowing we have no serious memory constraints in hosted environments. The definition is moved to <ppsi/constants.h> as implementation-specific. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
When running a WR device as non-WR slave, we adjust the clock instead of the phase. When adjusting the counters, timestamps are reported as invalid until two increments of the "seconds" register. So, when T3 is not valid (tx stamp of delay_request), avoid running the non-WR servo. A later iteration of the slave FSM will work. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
When setting time, set Unix time as well. And when asking for the time, return Unix time if the WR inter process communication fails. Currently (and in all past history) the IPC call to get the time is not implemented, so we are sure we fail. But I keep it in place nonetheless in case we'll have it working in the future. Such time_get calls are mainly for timestamping the diagnostic messages anyways. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
- 16 Sep, 2013 3 commits
-
-
Alessandro Rubini authored
-
Alessandro Rubini authored
This function allows a servo to initialize its hardware and return the current "observed drift" value that is in charge. In unix-time this is used to return the current value for frequency correction -- being consistent with current naming and use of values, which unfortunately is not really correct. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
In my opinion, it makes no sense to make calculations with a well-filtered OWD and the instantaneous OFM, which is subject to the same oscillations. Thus, this commit filters OFM with the same rules used for OWD. However, the detection of outliers is more difficult because OFM can have either sign, and OFM is really changing while we are not yet synchronized. So the code does the following: - if we are at PP_ADJ_FREQ_MAX it means we are bridging a gap as fast as possible. In that case, don't average OFM. - if we receive a bigger-than-expected OFM value, trim it, but relax the expectation so we can track a real change if futher samples confirm it or push it farther. - if the averaged OFM changed sign, start averaging from scratch. The second item works by keeping the average of ofm magnitude, and we accept a change no bigger than the averaged magnitude. So, if we are synced in the millisecond range we accept changes of the order of milliseconds (this usually applies while syncing, and OFM is expected to change in that case); if we are in the microsecond range outliers move us by a few microseconds, but such trimming is then relaxed so we increase our ability to move exponentially. The last item prevents oscillations: this OFM is fed to a PI controller, so if we are late in responding to changes in sign, both P and I continue pushing in the wrong direction. So, combining the average and the PI we have an almost inversion in phase of the error, and the servo oscillates a lot while converging. Unfortunately, while working on this I realized there's a bug when dealing with very short and consistent timestamps. For example, a current average of 20ns, will never reach 40ns even if all further samples request 40ns, due to integer truncation. We need to either move to floating point or count fractional bits as the magnitudes permit. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
- 15 Sep, 2013 21 commits
-
-
Alessandro Rubini authored
This commit almost ignores long owd values. They happen when there are software delays; for example I sometimes see 7ms RTT values every now and then, which destroy synchronization by a few hundred microseconds. I "almost" ignore them, by using an OWD value twice as the current average. This is meant to gradually recover if the real OWD is bigger than what we initially measured (e.g., initially the slave clock was too slow during a recovery). The commit also slightly reorders some calculation to be safer in dealing with errors in initial values. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
This commit makes the servo engine discard events where "one way delay" is over one second (this will be documented). The management was never tested and likely wrong anyways. It also ignores events where the trip time appears to be negative. In this case the calculation is brought forward with the current value for one way delay (the current average). This happens when the slave is running a faster clock than the master during recovery. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
This moves the currenct checks for bad events into a specific function. Some duplication is removed in that function and log messages are slightly different, but no technical change is in charge. I'm going to use pp_servo_bad_event() in later commits. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
The "Use the average between current value and previous one" in the "one way delay" calculation was actually a running-average of two samples. This happened before the real (and properly implemented) running average of the value. By removing the first one we better respect the configured width of the filter. As a side effect the default (64 samples) is now effective, while earlier it behaved like a 128-sample running average. It converges faster. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
The "offset from master" filter was "a simple two-sample average" as documented in the header, and the result of such average is used only in the PI controller. Thus, by averaging we have no effect at all in the I component and only a spread over two samples of the P component for each sample. In practice, it has no effect at all. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
This trivial change makes the code more readable, and more symmetric in the two filtering sections. Unrelated, it also moves a temporary variable to the only block where it is used. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
This rename is for consistency: the filter is called owd_fltr but the data it acts upon were called a meaningless "mean path delay". Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
This reports more information about the servo, to help me trace some misbehaviour. At level 2 it also reports T1..T4 and at level 3 it reports the correction fields (currently always 0 in my setup). The big hunk in this diff is just a reindentation to remove a goto introduced a few commits ago; it is now an else stanza. Try "git show -pw" if in doubt. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
The code was using "mean path delay" before calculating it. Which means that is used wrong values (likely 0) the first time and the previous value at each successive iteration. This commit moves calculation of "mpd" before code that uses it. The calculation itself is not changed. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
This moves the first check for "max_delay" into the calculation function. As a side effect we got rid of the field "t1_t2_valid" in the servo structure. While nothing is changed in the calculations (and I see the same (mis)behaviour in my network) we now have a sane servo.c, where pp_servo_got_sync only takes care of the correction factor for the sync/follow-up message and then everything is done in pp_servo_got_resp. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
This simplifies slightly the code. and has no technical effects. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
When we only have t1/t2 we can't do all the corrections, as we miss t3/t4. This moves all the calculations from the first servo entry point (sync/follow-up) to the second one (delay-response). Diagnostic prints are moved at the end as well. Nothing else is changed by this commit: the code is just moved. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
"delay_ms" and "m_to_s_delay" were duplicates. This removes one of them (and the same for s_to_m) and a long-standing "TODO check". The original code was unclear about correction factor, that sometimes was removed and sometimes not. Since the value is an overhead figure added by any transparent clocks in the path, this commit counts it immediately, to forget about it as soon as possible. This also makes the code more symmetric (t1,t2 code is similar to t3,t4 code). Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
This renames "ofst_first_updated" (wrongly a runtime option) into "t1_t2_valid" as a servo field. This makes thing more readable and is a fix in that it allows more than one servo to coexist in the future. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
This commit is another step in simplifying the servo. It makes the following changes: - format_TimeInternal is just moved (no effect) - pp_update_offset() and __pp_update_clock() are squashed together. They were called in sequence anyways, as two halves of a single thing. This changes the error return paths, because the whole procedure is aborted in case of error. I've never seen such errors, but I think if something is "aborted" it should not proceed. One non-error return from the first half is turned into a goto, to avoid changing indentation (that appears in the commit diff). - the meaning of "ofst_first_updated" is slightly changed. If we get an error in the sync phase the bit is cleared so delay-resp won't use the tuple. The field is then renamed in the next commit. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
The servo implementation we brought forward from ptpd was strange and difficult to understand. This commit is the first step in trying to make some order, but it doesn't actually change anything but names. The entry points for the servo are now called pp_servo_init(), pp_servo_got_sync() and pp_servo_got_resp(). A two-step protocol calls got_sync after getting the follow-up message. Also, the hook for response messages is called handle_resp with a name similar to the hooks for sync and follow-up. The servo itself is not changed, but I reordered the functions so the calculations appear in the real order in which they happen. Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-
Alessandro Rubini authored
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
-