Re: [Linuxptp-devel] [PATCH pm 04/12] stats: Added copy and combine help funktions

2018-04-16 Thread Richard Cochran
On Mon, Apr 16, 2018 at 07:20:05AM +, Anders Selhammer wrote:
> On Friday after I went for weekend, I got this from one of the authors of 
> Annex M:
> "In the present standard, it is SNMP or NETCONF that is supposed to be used 
> to retrieve PM data."
> When I read Annex M again, this is mentioned in M.4.

It only says:

(e.g. SNMP, NETCONF)

e.g. = "for example"

That language is not at all definitive.  So my instinct is to wait and
see.

> I will go on with the updates based on the comments I got last week and send 
> in a new patch set. 

Let's talk about supporting SNMP first.  I have some ideas on this.

Here is a plan:

1. Decide how to support SNMP from the architectural point of view.

2. Implement SNMP to support the data we already have.

3. Support the published MIBs:

   - 802.1AS Chapter 15
   - the substation profile
   - Yang model

4. When PM MIBs are published, implement the counters and the new
   MIBs.

Thanks,
Richard



--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH pm 04/12] stats: Added copy and combine help funktions

2018-04-16 Thread Anders Selhammer
Friday, April 13, 2018 4:33 PM

> I'd like to have a plan.  It would be a shame to invent our own TLVs
> if the standard turns out to say that reporting should go over
> SNMP/Yang model/whatever.

> Do you have insight into what the authors of Annex M are thinking?

On Friday after I went for weekend, I got this from one of the authors of Annex 
M:
"In the present standard, it is SNMP or NETCONF that is supposed to be used to 
retrieve PM data."
When I read Annex M again, this is mentioned in M.4.

I will go on with the updates based on the comments I got last week and send in 
a new patch set. 


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH pm 04/12] stats: Added copy and combine help funktions

2018-04-13 Thread Richard Cochran
On Fri, Apr 13, 2018 at 07:38:57AM +, Anders Selhammer wrote:
> I believe that the reporting issue will be solved. Otherwise we maybe could 
> introduce
> some linuxptp TLVs for this purpose and update these later when the standard 
> describe them ?

I'd like to have a plan.  It would be a shame to invent our own TLVs
if the standard turns out to say that reporting should go over
SNMP/Yang model/whatever.

Do you have insight into what the authors of Annex M are thinking?

Thanks,
Richard

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH pm 04/12] stats: Added copy and combine help funktions

2018-04-13 Thread Anders Selhammer
Friday, April 13, 2018 8:16 AM

> Let me suggest an easier way.

I agree. It became way to complex then I first believed. I wanted to have some 
input on it before
I did a rework on it. I will look into your suggestion and update accordingly.

I believe that the reporting issue will be solved. Otherwise we maybe could 
introduce
some linuxptp TLVs for this purpose and update these later when the standard 
describe them ?

/Anders

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH pm 04/12] stats: Added copy and combine help funktions

2018-04-13 Thread Richard Cochran
On Fri, Apr 06, 2018 at 12:34:35PM +0200, Anders Selhammer wrote:
> +void stats_combine(struct stats *to, struct stats *from)
> +{
> + if (!from->num) {
> + return;
> + }
> + to->min = (to->num && to->min < from->min) ? to->min : from->min;
> + to->max = (to->num && to->max > from->max) ? to->max : from->max;
> + to->mean = (to->mean * to->num + from->mean * from->num) /
> +(to->num + from->num);
> + to->num  += from->num;
> + to->sum_sqr  += from->sum_sqr;
> + to->sum_diff_sqr += from->sum_diff_sqr;
> +}

This is going to require more work than the straightforward approach
of just feeding the current sample value into two sets of statistics,
one for the current 15 minute period and one for the current 24 hour
period.

Looking at Annex M, it is pretty specific about the intervals:

- moving 24 hour window of 15 minute non-overlapping sub-windows
- current and previous 24 hour non-overlapping intervals

Your implementation, with its lists of statistics, malloc'ed and
freed, inserted and deleted, is way too complicated.  All of the list
management and allocation error handling simply does a lot of work for
no benefit.  Let me suggest an easier way.

Introduce a moving window of sets of statistics:

struct stats_series {
int length;
int index;
int count;
struct stats *stats;
};

with methods like:

struct stats_series *quarter_hour, *daily;

quarter_hour = stats_series_create(96);
daily = stats_series_create(2);

stats_series_add_value(s, value)
{
stats_add_value(s->stats[s->index], value);
}

stats_series_advance(s)
{
s->index = (1 + s->index) % s->length;
stats_reset(s->stats[s->index]);
if (s->count < s->length) {
s->count++;
}
}

Then your main code is as simple as:

void clock_path_delay(struct clock *c, tmv_t req, tmv_t rx)
{
tsproc_up_ts(c->tsproc, req, rx);
if (c->performance_monitoring) {
x = tmv_dbl(tmv_sub(rx, req));
stats_series_add_value(c->qhour[SLAVE_MASTER_DELAY], x);
stats_series_add_value(c->daily[SLAVE_MASTER_DELAY], x);
}
...
}

static void clock_pm_event(struct clock *c)
{
for (i = 0; i < N_SERIES; i++) {
stats_series_advance(c->qhour[i]);
}
counter++;
if (counter == 96) {
for (i = 0; i < N_SERIES; i++) {
stats_series_advance(c->daily[i]);
}
counter = 0;
}
}

No more lists to manage.
No more malloc/free. (well, only once at the start)

See?

Anyhow, we can talk more about the design, but I really want to know
how these statistics are going to be reported before getting too far
along.

Thanks,
Richard


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH pm 04/12] stats: Added copy and combine help funktions

2018-04-06 Thread Anders Selhammer
Methods for copy and combine stats structs is needed for PM

Signed-off-by: Anders Selhammer 
---
 stats.c | 19 +++
 stats.h | 14 ++
 2 files changed, 33 insertions(+)

diff --git a/stats.c b/stats.c
index 41136f0..1ec88d5 100644
--- a/stats.c
+++ b/stats.c
@@ -59,6 +59,25 @@ void stats_add_value(struct stats *stats, double value)
stats->sum_diff_sqr += (value - old_mean) * (value - stats->mean);
 }
 
+void stats_copy(struct stats *to, struct stats *from)
+{
+   memcpy(to, from, sizeof(*to));
+}
+
+void stats_combine(struct stats *to, struct stats *from)
+{
+   if (!from->num) {
+   return;
+   }
+   to->min = (to->num && to->min < from->min) ? to->min : from->min;
+   to->max = (to->num && to->max > from->max) ? to->max : from->max;
+   to->mean = (to->mean * to->num + from->mean * from->num) /
+  (to->num + from->num);
+   to->num  += from->num;
+   to->sum_sqr  += from->sum_sqr;
+   to->sum_diff_sqr += from->sum_diff_sqr;
+}
+
 unsigned int stats_get_num_values(struct stats *stats)
 {
return stats->num;
diff --git a/stats.h b/stats.h
index 541a376..6e09f7b 100644
--- a/stats.h
+++ b/stats.h
@@ -43,6 +43,20 @@ void stats_destroy(struct stats *stats);
 void stats_add_value(struct stats *stats, double value);
 
 /**
+ * Copy from one stats struct to another.
+ * @param to   Pointer to stats obtained via @ref stats_create().
+ * @param from Pointer to stats obtained via @ref stats_create().
+ */
+void stats_copy(struct stats *to, struct stats *from);
+
+/**
+ * Combine from one stats struct into another.
+ * @param to   Pointer to stats obtained via @ref stats_create().
+ * @param from Pointer to stats obtained via @ref stats_create().
+ */
+void stats_combine(struct stats *to, struct stats *from);
+
+/**
  * Get the number of values collected in the stats so far.
  * @param stats Pointer to stats obtained via @ref stats_create().
  * @return  The number of values.
-- 
1.8.3.1


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel