Currently, PMC agents can only subscribe to port state change events. However, it may be useful to also create push subscriptions to the non-portable ptp4l TIME_STATUS management messages. These tell a PTP management client information such as the offset to the master.
Extend the pmc_agent_subscribe() API by adding two boolean arguments, one for subscribing to port events and the other to time status events. Convert all users to pass true to the first and false to the latter. Signed-off-by: Vladimir Oltean <olte...@gmail.com> --- phc2sys.c | 2 +- pmc_agent.c | 14 ++++++++++++-- pmc_agent.h | 10 ++++++++-- ts2phc.c | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/phc2sys.c b/phc2sys.c index 6815c3dee8a0..1c02e2b605b0 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -871,7 +871,7 @@ static int auto_init_ports(struct phc2sys_private *priv, int add_rt) return -1; } - err = pmc_agent_subscribe(priv->agent, 1000); + err = pmc_agent_subscribe(priv->agent, 1000, true, false); if (err) { pr_err("failed to subscribe"); return -1; diff --git a/pmc_agent.c b/pmc_agent.c index 86350d8e6fd1..77334e381b6e 100644 --- a/pmc_agent.c +++ b/pmc_agent.c @@ -38,6 +38,9 @@ struct pmc_agent { struct pmc *pmc; uint64_t pmc_last_update; + bool notify_port_state; + bool notify_time_sync; + struct defaultDS dds; bool dds_valid; int leap; @@ -57,7 +60,10 @@ static void send_subscription(struct pmc_agent *node) memset(&sen, 0, sizeof(sen)); sen.duration = PMC_SUBSCRIBE_DURATION; - event_bitmask_set(sen.bitmask, NOTIFY_PORT_STATE, TRUE); + event_bitmask_set(sen.bitmask, NOTIFY_PORT_STATE, + node->notify_port_state); + event_bitmask_set(sen.bitmask, NOTIFY_TIME_SYNC, + node->notify_time_sync); pmc_send_set_action(node->pmc, MID_SUBSCRIBE_EVENTS_NP, &sen, sizeof(sen)); } @@ -375,8 +381,12 @@ void pmc_agent_set_sync_offset(struct pmc_agent *agent, int offset) agent->sync_offset = offset; } -int pmc_agent_subscribe(struct pmc_agent *node, int timeout) +int pmc_agent_subscribe(struct pmc_agent *node, int timeout, + bool notify_port_state, + bool notify_time_sync) { + node->notify_port_state = notify_port_state; + node->notify_time_sync = notify_time_sync; node->stay_subscribed = true; return renew_subscription(node, timeout); } diff --git a/pmc_agent.h b/pmc_agent.h index 11b93479fb0b..ea5788d79606 100644 --- a/pmc_agent.h +++ b/pmc_agent.h @@ -132,12 +132,18 @@ int pmc_agent_query_utc_offset(struct pmc_agent *agent, int timeout); void pmc_agent_set_sync_offset(struct pmc_agent *agent, int offset); /** - * Subscribes to push notifications of changes in port state. + * Subscribes to push notifications. * @param agent Pointer to a PMC instance obtained via @ref pmc_agent_create(). * @param timeout Transmit and receive timeout in milliseconds. + * @param notify_port_state Receive MID_PORT_DATA_SET management messages + * for changes in port state. + * @param notify_time_sync Receive MID_TIME_STATUS_NP management messages + * for clock synchronization updates. * @return Zero on success, negative error code otherwise. */ -int pmc_agent_subscribe(struct pmc_agent *agent, int timeout); +int pmc_agent_subscribe(struct pmc_agent *agent, int timeout, + bool notify_port_state, + bool notify_time_sync); /** * Polls for push notifications from the local ptp4l service. diff --git a/ts2phc.c b/ts2phc.c index 1301b6c6795b..dd6b7ec1b7c9 100644 --- a/ts2phc.c +++ b/ts2phc.c @@ -293,7 +293,7 @@ static int auto_init_ports(struct ts2phc_private *priv) return -1; } - err = pmc_agent_subscribe(priv->agent, 1000); + err = pmc_agent_subscribe(priv->agent, 1000, true, false); if (err) { pr_err("failed to subscribe"); return -1; -- 2.25.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel