On 10/18/2022 8:08 AM, Maciek Machnikowski wrote:
> LSTAB_UNKNOWN is too generic, add LSTAB_EXPIRED result to return the latest
> lstab correction and indicate that the tab used to resolve it is expired.
>
> This is useful for more precise reporting of lstab file state and will enable
> an
> override of expired table.
>
> Signed-off-by: Maciek Machnikowski <mac...@machnikowski.net>
Reviewed-by: Jacob Keller <jacob.e.kel...@intel.com>
> ---
> lstab.c | 9 +++++----
> lstab.h | 6 ++++++
> ts2phc_nmea_pps_source.c | 7 ++++---
> 3 files changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/lstab.c b/lstab.c
> index 8971aaf..a44aead 100644
> --- a/lstab.c
> +++ b/lstab.c
> @@ -182,10 +182,6 @@ enum lstab_result lstab_utc2tai(struct lstab *lstab,
> uint64_t utctime,
> {
> int epoch = -1, index, next;
>
> - if (utctime > lstab->expiration_utc) {
> - return LSTAB_UNKNOWN;
> - }
> -
Ok, so now we no longer immediately fail, but instead...
> for (index = lstab->length - 1; index > -1; index--) {
> if (utctime >= lstab->lstab[index].utc) {
> epoch = index;
> @@ -203,5 +199,10 @@ enum lstab_result lstab_utc2tai(struct lstab *lstab,
> uint64_t utctime,
> if (next < lstab->length && utctime == lstab->lstab[next].utc - 1) {
> return LSTAB_AMBIGUOUS;
> }
> +
> + if (utctime > lstab->expiration_utc) {
> + return LSTAB_EXPIRED;
> + }
> +
We still update the lstab but now we reported it as experted instead of
ok. Makes sense.
> return LSTAB_OK;
> }
> diff --git a/lstab.h b/lstab.h
> index d2393b4..3811aed 100644
> --- a/lstab.h
> +++ b/lstab.h
> @@ -41,6 +41,12 @@ enum lstab_result {
> */
> LSTAB_UNKNOWN,
>
> + /**
> + * The given lstab is past its expiry date and the tai_offset return
> + * value may not be correct.
> + */
> + LSTAB_EXPIRED,
> +
> /**
> * The given UTC value is ambiguous. The corresponding TAI time is
> either
> *
> diff --git a/ts2phc_nmea_pps_source.c b/ts2phc_nmea_pps_source.c
> index db8b5c6..8ea26bf 100644
> --- a/ts2phc_nmea_pps_source.c
> +++ b/ts2phc_nmea_pps_source.c
> @@ -188,7 +188,7 @@ static int ts2phc_nmea_pps_source_getppstime(struct
> ts2phc_pps_source *src,
> struct ts2phc_nmea_pps_source *m =
> container_of(src, struct ts2phc_nmea_pps_source, pps_source);
> tmv_t delay_t1, delay_t2, duration_since_rmc, local_t1, local_t2, rmc;
> - int lstab_error = 0, tai_offset = 0;
> + int lstab_error = -1, tai_offset = 0;
> enum lstab_result result;
> struct timespec now;
> int64_t utc_time;
> @@ -237,11 +237,12 @@ static int ts2phc_nmea_pps_source_getppstime(struct
> ts2phc_pps_source *src,
> break;
> case LSTAB_UNKNOWN:
> pr_err("nmea: unable to find utc time in leap second table");
> - lstab_error = -1;
> + break;
> + case LSTAB_EXPIRED:
> + pr_err("nmea: utc time is past leap second table expiry date");
> break;
Much nicer error message!
> case LSTAB_AMBIGUOUS:
> pr_err("nmea: utc time stamp is ambiguous");
> - lstab_error = -1;
> break;
> }
> ts->tv_sec += tai_offset;
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel