Skip to content

Commit e238dce

Browse files
ainguraXmarquieguidleach02
authored andcommitted
net: gptp: gptp port role disabled on link down
Set GPTP port role to disabled if port link is down. Signed-off-by: Xabier Marquiegui <[email protected]>
1 parent 270b7c8 commit e238dce

File tree

1 file changed

+17
-12
lines changed
  • subsys/net/l2/ethernet/gptp

1 file changed

+17
-12
lines changed

subsys/net/l2/ethernet/gptp/gptp.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -521,18 +521,23 @@ static void gptp_state_machine(void)
521521
for (port = GPTP_PORT_START; port < GPTP_PORT_END; port++) {
522522
struct gptp_port_ds *port_ds = GPTP_PORT_DS(port);
523523

524-
switch (GPTP_GLOBAL_DS()->selected_role[port]) {
525-
case GPTP_PORT_DISABLED:
526-
case GPTP_PORT_MASTER:
527-
case GPTP_PORT_PASSIVE:
528-
case GPTP_PORT_SLAVE:
529-
gptp_md_state_machines(port);
530-
gptp_mi_port_sync_state_machines(port);
531-
gptp_mi_port_bmca_state_machines(port);
532-
break;
533-
default:
534-
NET_DBG("%s: Unknown port state", __func__);
535-
break;
524+
/* If interface is down, don't move foward */
525+
if (net_if_flag_is_set(GPTP_PORT_IFACE(port), NET_IF_UP)) {
526+
switch (GPTP_GLOBAL_DS()->selected_role[port]) {
527+
case GPTP_PORT_DISABLED:
528+
case GPTP_PORT_MASTER:
529+
case GPTP_PORT_PASSIVE:
530+
case GPTP_PORT_SLAVE:
531+
gptp_md_state_machines(port);
532+
gptp_mi_port_sync_state_machines(port);
533+
gptp_mi_port_bmca_state_machines(port);
534+
break;
535+
default:
536+
NET_DBG("%s: Unknown port state", __func__);
537+
break;
538+
}
539+
} else {
540+
GPTP_GLOBAL_DS()->selected_role[port] = GPTP_PORT_DISABLED;
536541
}
537542

538543
port_ds->prev_ptt_port_enabled = port_ds->ptt_port_enabled;

0 commit comments

Comments
 (0)