[Linuxptp-devel] [PATCH] unicast: Update announce timer when renew

2022-06-14 Thread Vadim Fedorenko via Linuxptp-devel
After first timeout of Announce message ptp4l will send Announce
requests messages to all of configured non-master clock peers
without updating timeout on approval packet making huge unneeded
workload on servers. Fix it by updating announce timeout correctly.

Signed-off-by: Vadim Fedorenko 
---
 unicast_client.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/unicast_client.c b/unicast_client.c
index 8ebe06f..ba49757 100644
--- a/unicast_client.c
+++ b/unicast_client.c
@@ -467,6 +467,7 @@ void unicast_client_grant(struct port *p, struct 
ptp_message *m,
ucma->granted |= 1 << mtype;
 
switch (ucma->state) {
+   case UC_HAVE_ANN:
case UC_WAIT:
if (mtype == ANNOUNCE) {
ucma->state = unicast_fsm(ucma->state, UC_EV_GRANT_ANN);
@@ -474,8 +475,6 @@ void unicast_client_grant(struct port *p, struct 
ptp_message *m,
unicast_client_set_renewal(p, ucma, g->durationField);
}
break;
-   case UC_HAVE_ANN:
-   break;
case UC_NEED_SYDY:
switch (mtype) {
case DELAY_RESP:
-- 
2.30.2



___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH v5 09/13] ts2phc_slave: print offset to the source clock

2022-06-14 Thread Richard Cochran
On Tue, Nov 23, 2021 at 02:14:17AM +0200, Vladimir Oltean wrote:
> Make this information more visible by default, since it is the key
> output of this program.

ok


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH v5 08/13] ts2phc: instantiate a pmc agent

2022-06-14 Thread Richard Cochran
On Tue, Nov 23, 2021 at 02:14:16AM +0200, Vladimir Oltean wrote:

> +static enum port_state ts2phc_normalize_state(enum port_state state)
> +{
> + if (state != PS_MASTER && state != PS_SLAVE &&
> + state != PS_PRE_MASTER && state != PS_UNCALIBRATED) {
> + /* treat any other state as "not a master nor a slave" */
> + state = PS_DISABLED;
> + }
> + return state;
> +}

Please make this explicit by using switch/case over all the enumerated values.

> +static int auto_init_ports(struct ts2phc_private *priv)
> +{
> + int number_ports, timestamping, err;
> + struct ts2phc_clock *clock;
> + struct ts2phc_port *port;
> + enum port_state state;
> + char iface[IFNAMSIZ];
> + unsigned int i;
> +
> + while (1) {
> + if (!is_running())
> + return -1;
> + err = pmc_agent_query_dds(priv->agent, 1000);
> + if (!err)
> + break;
> + if (err == -ETIMEDOUT)
> + pr_notice("Waiting for ptp4l...");
> + else
> + return -1;
> + }
> +
> + number_ports = pmc_agent_get_number_ports(priv->agent);
> + if (number_ports <= 0) {
> + pr_err("failed to get number of ports");
> + return -1;
> + }
> +
> + err = pmc_agent_subscribe(priv->agent, 1000);
> + if (err) {
> + pr_err("failed to subscribe");
> + return -1;
> + }
> +
> + for (i = 1; i <= number_ports; i++) {
> + err = pmc_agent_query_port_properties(priv->agent, 1000, i,
> +   , ,
> +   iface);
> + if (err == -ENODEV) {
> + /* port does not exist, ignore the port */
> + continue;
> + }
> + if (err) {
> + pr_err("failed to get port properties");
> + return -1;
> + }
> + if (timestamping == TS_SOFTWARE) {
> + /* ignore ports with software time stamping */
> + continue;
> + }
> + port = ts2phc_port_add(priv, i, iface);
> + if (!port)
> + return -1;
> + port->state = ts2phc_normalize_state(state);
> + }
> + if (LIST_EMPTY(>clocks)) {
> + pr_err("no suitable ports available");
> + return -1;
> + }
> + LIST_FOREACH(clock, >clocks, list) {
> + clock->new_state = ts2phc_clock_compute_state(priv, clock);
> + }
> +
> + return 0;
> +}

This is very similar to the code in phc2sys.  Can't you refactor to
share that logic?

Thanks,
Richard


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel