When pm timer expires, the collected data should be stored in recordlist.
Signed-off-by: Anders Selhammer <[email protected]>
---
clock.c | 15 ++++++++++++++-
port.c | 19 +++++++++++++++++++
port.h | 18 +++++++++++++++++-
port_private.h | 1 +
4 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/clock.c b/clock.c
index 6575130..37959e7 100644
--- a/clock.c
+++ b/clock.c
@@ -173,20 +173,33 @@ static void clock_set_pmtime(struct clock *c)
static void clock_handle_pm_err(struct clock *c)
{
+ struct port *p;
+
clock_clr_tmo(c->pm_fd);
pm_free_clock_recordlist(&c->pm_recordlist);
+ LIST_FOREACH(p, &c->ports, list) {
+ port_free_pm_recordlist(p);
+ }
c->performance_monitoring = 0;
}
static void clock_pm_event(struct clock *c)
{
- clock_set_pm_tmo(c);
+ struct port *p;
+ clock_set_pm_tmo(c);
if (pm_update_clock_stats_recordlist(&c->pm_stats_record,
&c->pm_recordlist)) {
pr_err("update of pm recordlist for clock failed");
goto err;
}
+ LIST_FOREACH(p, &c->ports, list) {
+ if (port_update_pm_recordlist(p,
c->pm_stats_record.cycle_index)) {
+ pr_err("update of pm recordlist for port: %d failed",
+ port_number(p));
+ goto err;
+ }
+ }
clock_set_pmtime(c);
return;
diff --git a/port.c b/port.c
index f46c1ae..da3305a 100644
--- a/port.c
+++ b/port.c
@@ -62,6 +62,24 @@ void port_set_pmtime(struct port *p, PMTimestamp pmtime)
p->pm_counter_record.head.PMTime = pmtime;
}
+void port_free_pm_recordlist(struct port *p)
+{
+ pm_free_port_recordlist(&p->pm_recordlist);
+}
+
+int port_update_pm_recordlist(struct port *p, int ci)
+{
+ if (pm_update_port_stats_recordlist(&p->pm_stats_record,
+ &p->pm_recordlist, ci)) {
+ return -1;
+ }
+ if (pm_update_port_counters_recordlist(&p->pm_counter_record,
+ &p->pm_recordlist, ci)) {
+ return -1;
+ }
+ return 0;
+}
+
static int announce_compare(struct ptp_message *m1, struct ptp_message *m2)
{
struct announce_msg *a = &m1->announce, *b = &m2->announce;
@@ -2228,6 +2246,7 @@ void port_close(struct port *p)
close(p->fault_fd);
}
pm_destroy_port_stats(&p->pm_stats_record);
+ pm_free_port_recordlist(&p->pm_recordlist);
free(p);
}
diff --git a/port.h b/port.h
index 6af0ecf..edd66f1 100644
--- a/port.h
+++ b/port.h
@@ -37,12 +37,28 @@ struct port;
/**
* Set the pm timestamp for the current port pm data.
*
- * @param port A port instance.
+ * @param p A port instance.
* @param pmtime Current pm timestamp.
*/
void port_set_pmtime(struct port *p, PMTimestamp pmtime);
/**
+ * Free all memory in the recordlist for the port.
+ *
+ * @param p A port instance.
+ */
+void port_free_pm_recordlist(struct port *p);
+
+/**
+ * Updates the recordlist for the port.
+ *
+ * @param p A port instance.
+ * @param ci Cycle index for the pm.
+ * @return Zero on success, non-zero otherwise.
+ */
+int port_update_pm_recordlist(struct port *p, int ci);
+
+/**
* Returns the dataset from a port's best foreign clock record, if any
* has yet been discovered. This function does not bring the returned
* dataset up to date, so the caller should invoke port_compute_best()
diff --git a/port_private.h b/port_private.h
index ae03509..d61c676 100644
--- a/port_private.h
+++ b/port_private.h
@@ -124,6 +124,7 @@ struct port {
/* performance monitoring */
struct pm_port_stats pm_stats_record;
struct pm_port_counters pm_counter_record;
+ struct pm_port_recordlist pm_recordlist;
};
#define portnum(p) (p->portIdentity.portNumber)
--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel