dcavalca / rpms / linuxptp

Forked from rpms/linuxptp 2 years ago
Clone
3b72dd
commit 1a2dfe9b00b79a59acf905476bbc33c74d5770a3
3b72dd
Author: Jacob Keller <jacob.e.keller@intel.com>
3b72dd
Date:   Thu Jul 8 12:59:30 2021 -0700
3b72dd
3b72dd
    Increase the default tx_timestamp_timeout to 10
3b72dd
    
3b72dd
    The tx_timestamp_timeout configuration defines the number of
3b72dd
    milliseconds to wait for a Tx timestamp from the kernel stack. This
3b72dd
    delay is necessary as Tx timestamps are captured after a packet is sent
3b72dd
    and reported back via the socket error queue.
3b72dd
    
3b72dd
    The current default is to poll for up to 1 millisecond. In practice, it
3b72dd
    turns out that this is not always enough time for hardware and software
3b72dd
    to capture the timestamp and report it back. Some hardware designs
3b72dd
    require reading timestamps over registers or other slow mechanisms.
3b72dd
    
3b72dd
    This extra delay results in the timestamp not being sent back to
3b72dd
    userspace within the default 1 millisecond polling time. If that occurs
3b72dd
    the following can be seen from ptp4l:
3b72dd
    
3b72dd
      ptp4l[4756.840]: timed out while polling for tx timestamp
3b72dd
      ptp4l[4756.840]: increasing tx_timestamp_timeout may correct this issue,
3b72dd
                       but it is likely caused by a driver bug
3b72dd
      ptp4l[4756.840]: port 1 (p2p1): send sync failed
3b72dd
      ptp4l[4756.840]: port 1 (p2p1): MASTER to FAULTY on FAULT_DETECTED
3b72dd
                       (FT_UNSPECIFIED)
3b72dd
    
3b72dd
    This can confuse users because it implies this is a bug, when the
3b72dd
    correct solution in many cases is to just increase the timeout to
3b72dd
    a slightly higher value.
3b72dd
    
3b72dd
    Since we know this is a problem for many drivers and hardware designs,
3b72dd
    lets increase the default timeout.
3b72dd
    
3b72dd
    Note that a longer timeout should not affect setups which return the
3b72dd
    timestamp quickly. On modern kernels, the poll() call will return once
3b72dd
    the timestamp is reported back to the socket error queue. (On old
3b72dd
    kernels around the 3.x era the poll will sleep for the full duration
3b72dd
    before reporting the timestamp, but this is now quite an old kernel
3b72dd
    release).
3b72dd
    
3b72dd
    Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
3b72dd
3b72dd
diff --git a/config.c b/config.c
3b72dd
index 760b395..03d981e 100644
3b72dd
--- a/config.c
3b72dd
+++ b/config.c
3b72dd
@@ -324,7 +324,7 @@ struct config_item config_tab[] = {
3b72dd
 	GLOB_ITEM_INT("ts2phc.pulsewidth", 500000000, 1000000, 999000000),
3b72dd
 	PORT_ITEM_ENU("tsproc_mode", TSPROC_FILTER, tsproc_enu),
3b72dd
 	GLOB_ITEM_INT("twoStepFlag", 1, 0, 1),
3b72dd
-	GLOB_ITEM_INT("tx_timestamp_timeout", 1, 1, INT_MAX),
3b72dd
+	GLOB_ITEM_INT("tx_timestamp_timeout", 10, 1, INT_MAX),
3b72dd
 	PORT_ITEM_INT("udp_ttl", 1, 1, 255),
3b72dd
 	PORT_ITEM_INT("udp6_scope", 0x0E, 0x00, 0x0F),
3b72dd
 	GLOB_ITEM_STR("uds_address", "/var/run/ptp4l"),
3b72dd
diff --git a/configs/default.cfg b/configs/default.cfg
3b72dd
index 64ef3bd..d615610 100644
3b72dd
--- a/configs/default.cfg
3b72dd
+++ b/configs/default.cfg
3b72dd
@@ -51,7 +51,7 @@ hybrid_e2e		0
3b72dd
 inhibit_multicast_service	0
3b72dd
 net_sync_monitor	0
3b72dd
 tc_spanning_tree	0
3b72dd
-tx_timestamp_timeout	1
3b72dd
+tx_timestamp_timeout	10
3b72dd
 unicast_listen		0
3b72dd
 unicast_master_table	0
3b72dd
 unicast_req_duration	3600
3b72dd
diff --git a/ptp4l.8 b/ptp4l.8
3b72dd
index fe9e150..7ca3474 100644
3b72dd
--- a/ptp4l.8
3b72dd
+++ b/ptp4l.8
3b72dd
@@ -496,7 +496,7 @@ switches all implement this option together with the BMCA.
3b72dd
 .B tx_timestamp_timeout
3b72dd
 The number of milliseconds to poll waiting for the tx time stamp from the kernel
3b72dd
 when a message has recently been sent.
3b72dd
-The default is 1.
3b72dd
+The default is 10.
3b72dd
 .TP
3b72dd
 .B check_fup_sync
3b72dd
 Because of packet reordering that can occur in the network, in the