dcavalca / rpms / linuxptp

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