net: gptp: Allow user to tweak priority1 and priority2 values

Instead of hardcoding the priority1 and priority2 values used
in BMCA, let the user tweak the values via Kconfig.

Fixes #28151

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2020-09-08 14:06:21 +03:00 committed by Anas Nashif
parent b22c95b746
commit 744fadc998
3 changed files with 39 additions and 1 deletions

View File

@ -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 */

View File

@ -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

View File

@ -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;
}