diff --git a/include/net/gptp.h b/include/net/gptp.h index 4b82d356424..d57fecb5367 100644 --- a/include/net/gptp.h +++ b/include/net/gptp.h @@ -34,7 +34,12 @@ extern "C" { #define GPTP_PRIORITY1_NON_GM_CAPABLE 255 #define GPTP_PRIORITY1_GM_CAPABLE 248 + +#if defined(CONFIG_NET_GPTP_BMCA_PRIORITY2) +#define GPTP_PRIORITY2_DEFAULT CONFIG_NET_GPTP_BMCA_PRIORITY2 +#else #define GPTP_PRIORITY2_DEFAULT 248 +#endif /** @endcond */ diff --git a/subsys/net/l2/ethernet/gptp/Kconfig b/subsys/net/l2/ethernet/gptp/Kconfig index e756bae5f6c..6784e81b9ac 100644 --- a/subsys/net/l2/ethernet/gptp/Kconfig +++ b/subsys/net/l2/ethernet/gptp/Kconfig @@ -198,6 +198,31 @@ config NET_GPTP_PATH_TRACE_ELEMENTS Announce message. Each array element takes 8 bytes. If this value is set to 8, then 8 * 8 = 64 bytes of memory is used. +config NET_GPTP_BMCA_PRIORITY1 + int "BMCA priority1 value" + default 248 if NET_GPTP_GM_CAPABLE + default 255 + range 0 255 + help + The priority1 attribute of the local clock. It is used in the + Best Master Clock selection Algorithm (BMCA), lower values take + precedence. The default value is 255 if the device is non grand + master capable, and 248 if it is GM capable. + See Chapter 8.6.2.1 of IEEE 802.1AS for a more detailed description + of priority1. Note that if the system is non GM capable, then the + value 255 is used always and this setting is ignored. + +config NET_GPTP_BMCA_PRIORITY2 + int "BMCA priority2 value" + default 248 + range 0 255 + help + The priority2 attribute of the local clock. It is used in the BMCA + (Best Master Clock selection Algorithm), lower values take + precedence. The default value is 248. + See Chapter 8.6.2.5 of IEEE 802.1AS for a more detailed description + of priority2. + config NET_GPTP_STATISTICS bool "Collect gPTP statistics" help diff --git a/subsys/net/l2/ethernet/gptp/gptp.c b/subsys/net/l2/ethernet/gptp/gptp.c index bea3a87ee9f..e38bca01523 100644 --- a/subsys/net/l2/ethernet/gptp/gptp.c +++ b/subsys/net/l2/ethernet/gptp/gptp.c @@ -383,7 +383,15 @@ static void gptp_init_clock_ds(void) GPTP_OFFSET_SCALED_LOG_VAR_UNKNOWN; if (default_ds->gm_capable) { - default_ds->priority1 = GPTP_PRIORITY1_GM_CAPABLE; + /* The priority1 value cannot be 255 for GM capable + * system. + */ + if (CONFIG_NET_GPTP_BMCA_PRIORITY1 == + GPTP_PRIORITY1_NON_GM_CAPABLE) { + default_ds->priority1 = GPTP_PRIORITY1_GM_CAPABLE; + } else { + default_ds->priority1 = CONFIG_NET_GPTP_BMCA_PRIORITY1; + } } else { default_ds->priority1 = GPTP_PRIORITY1_NON_GM_CAPABLE; }