clock: Create a slave event monitor.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2020-04-14 18:13:11 -07:00
parent d3a519e26d
commit 6f95c2e92c
2 changed files with 21 additions and 0 deletions

13
clock.c
View File

@ -131,6 +131,7 @@ struct clock {
struct clockcheck *sanity_check;
struct interface *udsif;
LIST_HEAD(clock_subscribers_head, clock_subscriber) subscribers;
struct monitor *slave_event_monitor;
};
struct clock the_clock;
@ -271,6 +272,7 @@ void clock_destroy(struct clock *c)
LIST_FOREACH_SAFE(p, &c->ports, list, tmp) {
clock_remove_port(c, p);
}
monitor_destroy(c->slave_event_monitor);
port_close(c->uds_port);
free(c->pollfd);
if (c->clkid != CLOCK_REALTIME) {
@ -1185,6 +1187,12 @@ struct clock *clock_create(enum clock_type type, struct config *config,
}
clock_fda_changed(c);
c->slave_event_monitor = monitor_create(config, c->uds_port);
if (!c->slave_event_monitor) {
pr_err("failed to create slave event monitor");
return NULL;
}
/* Create the ports. */
STAILQ_FOREACH(iface, &config->interfaces, list) {
if (clock_add_port(c, phc_device, phc_index, timestamping, iface)) {
@ -1626,6 +1634,11 @@ void clock_peer_delay(struct clock *c, tmv_t ppd, tmv_t req, tmv_t rx,
stats_add_value(c->stats.delay, tmv_dbl(ppd));
}
struct monitor *clock_slave_monitor(struct clock *c)
{
return c->slave_event_monitor;
}
int clock_slave_only(struct clock *c)
{
return c->dds.flags & DDS_SLAVE_ONLY;

View File

@ -23,6 +23,7 @@
#include "dm.h"
#include "ds.h"
#include "config.h"
#include "monitor.h"
#include "notification.h"
#include "servo.h"
#include "tlv.h"
@ -267,6 +268,13 @@ struct servo *clock_servo(struct clock *c);
*/
enum servo_state clock_servo_state(struct clock *c);
/**
* Obtain the slave monitor instance from a clock.
* @param c The clock instance.
* @return The slave monitor associated with the clock.
*/
struct monitor *clock_slave_monitor(struct clock *c);
/**
* Obtain the slave-only flag from a clock's default data set.
* @param c The clock instance.