Skip to content

Commit

Permalink
net: gptp: Allow user to tweak priority1 and priority2 values
Browse files Browse the repository at this point in the history
Instead of hardcoding the priority1 and priority2 values used
in BMCA, let the user tweak the values via Kconfig.

Fixes zephyrproject-rtos#28151

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information
jukkar committed Sep 8, 2020
1 parent e79835e commit 079d80a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
5 changes: 5 additions & 0 deletions include/net/gptp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
25 changes: 25 additions & 0 deletions subsys/net/l2/ethernet/gptp/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion subsys/net/l2/ethernet/gptp/gptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 079d80a

Please sign in to comment.