net: gptp: Always use GM PRIO root system id for announce messages

A problem occurred while running PTP on a multi-port target
(RENESAS RZT2M) with two ports enabled. Announce messages on the
switched devices master port always contained local clock information
instead information from received on the slave port from the better
GM clock. Depending on the BMCA config this turned into having more
than one GM in the system.

Sending always the locally stored GM information helped to overcome
this issue.

Signed-off-by: Manuel Schappacher <manuel.schappacher@hs-offenburg.de>
This commit is contained in:
Manuel Schappacher 2023-12-20 15:19:03 +01:00 committed by Carles Cufí
parent 0a8d03b95f
commit bff6054cb8

View file

@ -489,6 +489,7 @@ struct net_pkt *gptp_prepare_announce(int port)
struct net_if *iface;
struct net_pkt *pkt;
struct gptp_hdr *hdr;
struct gptp_priority_vector *gm_prio;
NET_ASSERT((port >= GPTP_PORT_START) && (port <= GPTP_PORT_END));
global_ds = GPTP_GLOBAL_DS();
@ -538,25 +539,12 @@ struct net_pkt *gptp_prepare_announce(int port)
ann->cur_utc_offset = htons(global_ds->current_utc_offset);
ann->time_source = global_ds->time_source;
gm_prio = &global_ds->gm_priority;
switch (GPTP_PORT_BMCA_DATA(port)->info_is) {
case GPTP_INFO_IS_MINE:
ann->root_system_id.grand_master_prio1 = default_ds->priority1;
ann->root_system_id.grand_master_prio2 = default_ds->priority2;
ann->root_system_id.clk_quality.clock_accuracy =
default_ds->clk_quality.clock_accuracy;
ann->root_system_id.clk_quality.clock_class = default_ds->clk_quality.clock_class;
ann->root_system_id.clk_quality.offset_scaled_log_var =
htons(default_ds->clk_quality.offset_scaled_log_var);
memcpy(&ann->root_system_id.grand_master_id,
default_ds->clk_id,
GPTP_CLOCK_ID_LEN);
break;
case GPTP_INFO_IS_RECEIVED:
memcpy(&ann->root_system_id,
&GPTP_PORT_BMCA_DATA(port)->
master_priority.root_system_id,
&gm_prio->root_system_id,
sizeof(struct gptp_root_system_identity));
break;
default: