Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions include/netutils/ptpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
* Included Files
****************************************************************************/

#include <sys/types.h>

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
Expand All @@ -35,6 +37,17 @@
* Public Types
****************************************************************************/

struct ptpd_config_s
{
FAR const char *interface;
FAR const char *clock;
bool client_only;
bool hardware_ts;
bool delay_e2e;
bool bmca;
sa_family_t af;
};

/* PTPD status information structure */

struct ptpd_status_s
Expand Down Expand Up @@ -115,18 +128,18 @@ extern "C"
* Name: ptpd_start
*
* Description:
* Start the PTP daemon and bind it to specified interface.
* Start the PTP daemon and bind it to specified config.
*
* Input Parameters:
* interface - Name of the network interface to bind to, e.g. "eth0"
* config - The configs of PTP daemon, includes interface, af and clock...
*
* Returned Value:
* On success, the non-negative task ID of the PTP daemon is returned;
* On failure, a negated errno value is returned.
*
****************************************************************************/

int ptpd_start(FAR const char *interface);
int ptpd_start(FAR const struct ptpd_config_s *config);

/****************************************************************************
* Name: ptpd_status
Expand Down
23 changes: 23 additions & 0 deletions netutils/ptpd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# ##############################################################################
# apps/netutils/ptpd/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################

if(CONFIG_NETUTILS_PTPD)
target_sources(apps PRIVATE ptpd.c)
endif()
54 changes: 9 additions & 45 deletions netutils/ptpd/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ config NETUTILS_PTPD
default n
depends on NET_IPv4
depends on NET_IGMP
depends on NET_UDP
depends on NET_UDP || NET_PKT
---help---
Build a minimal implementation of IEEE-1588 precision time protocol.
Uses system gettimeofday() and adjtime() calls to synchronize clock
Expand All @@ -17,31 +17,6 @@ config NETUTILS_PTPD

if NETUTILS_PTPD

config NETUTILS_PTPD_DEBUG
bool "Enable PTP debug messages"
default n
depends on DEBUG_INFO
---help---
Enable PTP debug messages even if CONFIG_DEBUG_NET_INFO is not enabled.

config NETUTILS_PTPD_CLIENT
bool "Enable client support"
default y
---help---
Act as a PTP client, synchronizing the NuttX clock to a remote master
clock.

config NETUTILS_PTPD_SERVER
bool "Enable server support"
default n
---help---
Act as a PTP server, providing NuttX clock time to other systems.

Both server and client can be simultaneously enabled. NuttX will then
synchronize to a higher priority master clock, or act as a master
clock itself if it has the highest priority.
Refer to Best Master Clock algorithm in IEEE-1588 for details.

config NETUTILS_PTPD_STACKSIZE
int "PTP daemon stack stack size"
default DEFAULT_TASK_STACKSIZE
Expand All @@ -58,8 +33,6 @@ config NETUTILS_PTPD_DOMAIN
Set PTP domain to participate in. Default domain is 0, other domains
can be used to isolate reference clocks from each other.

if NETUTILS_PTPD_SERVER

config NETUTILS_PTPD_PRIORITY1
int "PTP server priority1"
default 128
Expand Down Expand Up @@ -161,10 +134,6 @@ config NETUTILS_PTPD_DELAYRESP_INTERVAL

Default value 4 results in 16 second interval.

endif # NETUTILS_PTPD_SERVER

if NETUTILS_PTPD_CLIENT

config NETUTILS_PTPD_TIMEOUT_MS
int "PTP client timeout for changing clock source (ms)"
default 60000
Expand All @@ -180,6 +149,14 @@ config NETUTILS_PTPD_SETTIME_THRESHOLD_MS
time is reset with settimeofday() instead of changing the rate with
adjtime().

config NETUTILS_PTPD_ADJTIME_THRESHOLD_NS
int "PTP client threshold for using accumulated ppb to adjust system time (ns)"
default 500
---help---
If difference between local and remote clock exceeds this threshold,
the PTP client can utilize current ppb instead of accumulated ppb to
accelerate system time adjustment.

config NETUTILS_PTPD_MULTICAST_TIMEOUT_MS
int "PTP client timeout to rejoin multicast group (ms)"
default 30000
Expand All @@ -198,15 +175,6 @@ config NETUTILS_PTPD_DRIFT_AVERAGE_S
gives more stable estimate but reacts slower to crystal oscillator speed
changes (such as caused by temperature changes).

config NETUTILS_PTPD_SEND_DELAYREQ
bool "PTP client enable delay requests"
default n
---help---
If enabled, sends delay request messages to measure the network delay
to server. If disabled, assumes zero delay.

if NETUTILS_PTPD_SEND_DELAYREQ

config NETUTILS_PTPD_MAX_PATH_DELAY_NS
int "PTP client maximum path delay (ns)"
default 100000
Expand All @@ -221,8 +189,4 @@ config NETUTILS_PTPD_DELAYREQ_AVGCOUNT
---help---
Measured path delay is averaged over this many samples.

endif # NETUTILS_PTPD_SEND_DELAYREQ

endif # NETUTILS_PTPD_CLIENT

endif # NETUTILS_PTPD
Loading
Loading