DPDK patches and discussions
 help / color / mirror / Atom feed
From: Qi Zhang <qi.z.zhang@intel.com>
To: qiming.yang@intel.com
Cc: junfeng.guo@intel.com, dev@dpdk.org,
	Qi Zhang <qi.z.zhang@intel.com>,
	Jacob Keller <jacob.e.keller@intel.com>
Subject: [dpdk-dev] [PATCH 11/28] net/ice/base: add support for starting PHY in bypass mode
Date: Tue, 10 Aug 2021 10:51:23 +0800	[thread overview]
Message-ID: <20210810025140.1698163-12-qi.z.zhang@intel.com> (raw)
In-Reply-To: <20210810025140.1698163-1-qi.z.zhang@intel.com>

After starting the timestamping block, hardware begins calculating
precise offsets through a process of vernier calibration. This process
measures the effective phase offset of the various internal clocks used
in the PHY.

Once hardware completes these measurements, the P_REG_TX_OV_STATUS and
P_REG_RX_OV_STATUS registers are updated to indicate that the hardware
offset measurements are done.

This process does not happen immediately, but requires that at least one
packet be sent or received in order for the offset in that direction to
be calculated.

This poses a problem in some setups, because software expects the first
packet sent to be timestamped. This most often occurs if the clock time
is set by an application during startup. This set time command triggers
a PHY restart. Because of this, the timestamping block is reset, and
timestamps are not enabled until vernier calibration is complete. Since
this process won't complete until at least one packet is sent through
the PHY, timestamps of the very first packet sent will not be obtained.

This can result in the application failing due to missing timestamps.

To avoid this, allow starting the PHY in bypass mode. This mode enables
timestamps immediately, and skips adding the precise offset measurement.
This reduces the accuracy of the timestamp slightly, but ensures that we
get a reasonable value for the first packet.

The driver can continue monitoring the P_REG_TX_OV_STATUS and
P_REG_RX_OV_STATUS registers and exit bypass mode once the total
calibration is completed. In this way, once calibration is complete, the
timestamps will have the precise offset, but we do not break
applications which expect to be able to timestamp immediately.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/ice/base/ice_ptp_hw.c | 84 +++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_ptp_hw.h |  1 +
 2 files changed, 85 insertions(+)

diff --git a/drivers/net/ice/base/ice_ptp_hw.c b/drivers/net/ice/base/ice_ptp_hw.c
index bf6889029a..8ea75538fa 100644
--- a/drivers/net/ice/base/ice_ptp_hw.c
+++ b/drivers/net/ice/base/ice_ptp_hw.c
@@ -2572,6 +2572,90 @@ ice_start_phy_timer_e822(struct ice_hw *hw, u8 port, bool bypass)
 	return ICE_SUCCESS;
 }
 
+/**
+ * ice_phy_exit_bypass_e822 - Exit bypass mode, after vernier calculations
+ * @hw: pointer to the HW struct
+ * @port: the PHY port to configure
+ *
+ * After hardware finishes vernier calculations for the Tx and Rx offset, this
+ * function can be used to exit bypass mode by updating the total Tx and Rx
+ * offsets, and then disabling bypass. This will enable hardware to include
+ * the more precise offset calibrations, increasing precision of the generated
+ * timestamps.
+ *
+ * This cannot be done until hardware has measured the offsets, which requires
+ * waiting until at least one packet has been sent and received by the device.
+ */
+enum ice_status ice_phy_exit_bypass_e822(struct ice_hw *hw, u8 port)
+{
+	enum ice_status status;
+	u32 val;
+
+	status = ice_read_phy_reg_e822(hw, port, P_REG_TX_OV_STATUS, &val);
+	if (status) {
+		ice_debug(hw, ICE_DBG_PTP, "Failed to read TX_OV_STATUS for port %u, status %d\n",
+			  port, status);
+		return status;
+	}
+
+	if (!(val & P_REG_TX_OV_STATUS_OV_M)) {
+		ice_debug(hw, ICE_DBG_PTP, "Tx offset is not yet valid for port %u\n",
+			  port);
+		return ICE_ERR_NOT_READY;
+	}
+
+	status = ice_read_phy_reg_e822(hw, port, P_REG_RX_OV_STATUS, &val);
+	if (status) {
+		ice_debug(hw, ICE_DBG_PTP, "Failed to read RX_OV_STATUS for port %u, status %d\n",
+			  port, status);
+		return status;
+	}
+
+	if (!(val & P_REG_TX_OV_STATUS_OV_M)) {
+		ice_debug(hw, ICE_DBG_PTP, "Rx offset is not yet valid for port %u\n",
+			  port);
+		return ICE_ERR_NOT_READY;
+	}
+
+	status = ice_phy_cfg_tx_offset_e822(hw, port);
+	if (status) {
+		ice_debug(hw, ICE_DBG_PTP, "Failed to program total Tx offset for port %u, status %d\n",
+			  port, status);
+		return status;
+	}
+
+	status = ice_phy_cfg_rx_offset_e822(hw, port);
+	if (status) {
+		ice_debug(hw, ICE_DBG_PTP, "Failed to program total Rx offset for port %u, status %d\n",
+			  port, status);
+		return status;
+	}
+
+	/* Exit bypass mode now that the offset has been updated */
+	status = ice_read_phy_reg_e822(hw, port, P_REG_PS, &val);
+	if (status) {
+		ice_debug(hw, ICE_DBG_PTP, "Failed to read P_REG_PS for port %u, status %d\n",
+			  port, status);
+		return status;
+	}
+
+	if (!(val & P_REG_PS_BYPASS_MODE_M))
+		ice_debug(hw, ICE_DBG_PTP, "Port %u not in bypass mode\n",
+			  port);
+
+	val &= ~P_REG_PS_BYPASS_MODE_M;
+	status = ice_write_phy_reg_e822(hw, port, P_REG_PS, val);
+	if (status) {
+		ice_debug(hw, ICE_DBG_PTP, "Failed to disable bypass for port %u, status %d\n",
+			  port, status);
+		return status;
+	}
+
+	ice_info(hw, "Exiting bypass mode on PHY port %u\n", port);
+
+	return ICE_SUCCESS;
+}
+
 /* E810 functions
  *
  * The following functions operate on the E810 series devices which use
diff --git a/drivers/net/ice/base/ice_ptp_hw.h b/drivers/net/ice/base/ice_ptp_hw.h
index f2d87ca1e6..c804085095 100644
--- a/drivers/net/ice/base/ice_ptp_hw.h
+++ b/drivers/net/ice/base/ice_ptp_hw.h
@@ -218,6 +218,7 @@ enum ice_status
 ice_start_phy_timer_e822(struct ice_hw *hw, u8 port, bool bypass);
 enum ice_status ice_phy_cfg_tx_offset_e822(struct ice_hw *hw, u8 port);
 enum ice_status ice_phy_cfg_rx_offset_e822(struct ice_hw *hw, u8 port);
+enum ice_status ice_phy_exit_bypass_e822(struct ice_hw *hw, u8 port);
 
 /* E810 family functions */
 enum ice_status ice_ptp_init_phy_e810(struct ice_hw *hw);
-- 
2.26.2


  parent reply	other threads:[~2021-08-10  2:49 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-10  2:51 [dpdk-dev] [PATCH 00/28] ice: base code update Qi Zhang
2021-08-10  2:51 ` [dpdk-dev] [PATCH 01/28] net/ice/base: add 1588 capability probe Qi Zhang
2021-08-10  4:31   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 02/28] net/ice/base: add low level functions for device clock control Qi Zhang
2021-08-10  4:33   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 03/28] net/ice/base: add ethertype IPv6 check for dummy packet Qi Zhang
2021-08-10  4:34   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 04/28] net/ice/base: change dummy packets with VLAN Qi Zhang
2021-08-10  4:35   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 05/28] net/ice/base: add timestamp masks Qi Zhang
2021-08-10  4:35   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 06/28] net/ice/base: add clock initialization function Qi Zhang
2021-08-10  4:36   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 07/28] net/ice/base: add accessors to get/set the time reference Qi Zhang
2021-08-10  4:37   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 08/28] net/ice/base: print human-friendly PHY types Qi Zhang
2021-08-10  4:37   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 09/28] net/ice/base: implement Vernier calibration logic for E822 devices Qi Zhang
2021-08-10  4:38   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 10/28] net/ice/base: clarify comments on checking PFC mode Qi Zhang
2021-08-10  4:39   ` Guo, Junfeng
2021-08-10  2:51 ` Qi Zhang [this message]
2021-08-10  4:39   ` [dpdk-dev] [PATCH 11/28] net/ice/base: add support for starting PHY in bypass mode Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 12/28] net/ice/base: add E810T check function Qi Zhang
2021-08-10  4:39   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 13/28] net/ice/base: implement firmware debug dump Qi Zhang
2021-08-10  4:40   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 14/28] net/ice/base: add new AQ description Qi Zhang
2021-08-10  4:40   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 15/28] net/ice/base: refine MAC rule adding Qi Zhang
2021-08-10  4:41   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 16/28] net/ice/base: support TC nodes PIR configuration Qi Zhang
2021-08-10  4:41   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 17/28] net/ice/base: support FDIR for GRE tunnel packet Qi Zhang
2021-08-10  4:41   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 18/28] net/ice/base: support RSS " Qi Zhang
2021-08-10  4:42   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 19/28] net/ice/base: support FDIR for GTPU EH inner IPv6 Qi Zhang
2021-08-10  4:43   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 20/28] net/ice/base: support RSS for GTPoGRE Qi Zhang
2021-08-10  4:43   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 21/28] net/ice/base: enable NVM update reset capabilities Qi Zhang
2021-08-10  4:43   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 22/28] net/ice/base: support FDIR for GTPoGRE Qi Zhang
2021-08-10  4:44   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 23/28] net/ice/base: add RSS support for IPv4/L4 checksum Qi Zhang
2021-08-10  4:45   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 24/28] net/ice/base: enable jumbo frame support during HW init Qi Zhang
2021-08-10  4:45   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 25/28] net/ice/base: support FDIR for GTPU UL/DL with QFI fields Qi Zhang
2021-08-10  4:46   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 26/28] net/ice/base: rename and add a setter function Qi Zhang
2021-08-10  4:46   ` Guo, Junfeng
2021-08-10  2:51 ` [dpdk-dev] [PATCH 27/28] net/ice/base: correct spellling of word data Qi Zhang
2021-08-10  4:46   ` Guo, Junfeng
2021-08-13 16:50   ` Ferruh Yigit
2021-08-13 16:53     ` Ferruh Yigit
2021-08-10  2:51 ` [dpdk-dev] [PATCH 28/28] net/ice/base: update Max TCAM/PTG Per Profile Qi Zhang
2021-08-10  4:47   ` Guo, Junfeng
2021-08-11  2:25 ` [dpdk-dev] [PATCH 00/28] ice: base code update Zhang, Qi Z

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210810025140.1698163-12-qi.z.zhang@intel.com \
    --to=qi.z.zhang@intel.com \
    --cc=dev@dpdk.org \
    --cc=jacob.e.keller@intel.com \
    --cc=junfeng.guo@intel.com \
    --cc=qiming.yang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).