From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7132B41F50; Wed, 12 Jun 2024 17:20:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 29E5642FA9; Wed, 12 Jun 2024 17:06:18 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by mails.dpdk.org (Postfix) with ESMTP id A7A1E42F97 for ; Wed, 12 Jun 2024 17:06:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718204776; x=1749740776; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hksXOVWNXnH3tH+CKGiZq9LalXwmk4tEPRP89DJjK5M=; b=i7cigjlolzM8/jGrUfuwZIHKZAIcyHUBOVT+DCOxv34Z5U6Mz/m3Yze/ T+/K2avYKPKrSbA4gV7LdMM42NRVZ/li8QDrerBrHgmBT3mbuk6JLp60w 914fquNAlVPezgRw3ylzyt0aJUi7mtbZ+xCtuFg/Lm+Po9g3yJlVNViF4 DBqfkNRuXV0ziQ7sEVFcakEyLKLi0jmwAofOQzJZ8ecspcTkd9tcAxU8x WXc3baytcOlVc5cQrzzb7gRYoj6tp3PcGq58ahLyFpJXhvB0T0q/4iQMN 3K6D1DcHDnpOJskC2sgVIftFcGhIONJRAIoQYQwqeXcIf7POKsUeHGaj3 g==; X-CSE-ConnectionGUID: pSp2aQ2HQ0qOGCAV7dKlFA== X-CSE-MsgGUID: MpJIqKjtT5WkWoi4bqEc2A== X-IronPort-AV: E=McAfee;i="6700,10204,11101"; a="32459905" X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="32459905" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2024 08:06:15 -0700 X-CSE-ConnectionGUID: qwAY7BcTTb+LFipz0FltIA== X-CSE-MsgGUID: N1RenJ6nSdm0pV7Iryp+Nw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="39925849" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by orviesa009.jf.intel.com with ESMTP; 12 Jun 2024 08:06:14 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Ian Stokes , bruce.richardson@intel.com, Jacob Keller Subject: [PATCH v2 108/148] net/ice/base: add function to read Tx timestamp status register Date: Wed, 12 Jun 2024 16:01:42 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: <20240430154014.1026-1-ian.stokes@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Ian Stokes Both e822 and eth56g based hardware have a register indicating the status of timestamps in the Tx timestamp memory bank. This register is used to indicate which timestamps are currently valid. This is important because the interrupt logic for these devices assumes that software will only read registers with the valid bit set. If software does not follow this practice, it can potentially cause hardware to stop reporting timestamp interrupts. Use of the status register value also allows software to avoid unnecessarily reading timestamps which haven't yet been captured. Add a helper function which reads the timestamp memory status registers for these devices. For e810, it is not clear if the hardware has an equivalent register. Instead, implement a stub which just reports that all timestamps are valid. This allows the timestamp tracking logic to use the same function for all current device variants. Signed-off-by: Jacob Keller Signed-off-by: Ian Stokes --- drivers/net/ice/base/ice_ptp_hw.c | 113 ++++++++++++++++++++++++++++++ drivers/net/ice/base/ice_ptp_hw.h | 6 ++ 2 files changed, 119 insertions(+) diff --git a/drivers/net/ice/base/ice_ptp_hw.c b/drivers/net/ice/base/ice_ptp_hw.c index 938707afdf..7b1f462eee 100644 --- a/drivers/net/ice/base/ice_ptp_hw.c +++ b/drivers/net/ice/base/ice_ptp_hw.c @@ -2374,6 +2374,33 @@ ice_ptp_read_tx_hwtstamp_status_eth56g(struct ice_hw *hw, u32 *ts_status) return 0; } +/** + * ice_get_phy_tx_tstamp_ready_eth56g - Read the Tx memory status register + * @hw: pointer to the HW struct + * @port: the PHY port to read from + * @tstamp_ready: contents of the Tx memory status register + * + * Read the PHY_REG_TX_MEMORY_STATUS register indicating which timestamps in + * the PHY are ready. A set bit means the corresponding timestamp is valid and + * ready to be captured from the PHY timestamp block. + */ +static int +ice_get_phy_tx_tstamp_ready_eth56g(struct ice_hw *hw, u8 port, + u64 *tstamp_ready) +{ + int err; + + err = ice_read_64b_phy_reg_eth56g(hw, port, PHY_REG_TX_MEMORY_STATUS_L, + tstamp_ready); + if (err) { + ice_debug(hw, ICE_DBG_PTP, "Failed to read TX_MEMORY_STATUS for port %u, err %d\n", + port, err); + return err; + } + + return 0; +} + #define ICE_DEVID_MASK 0xFFF8 /** @@ -4630,6 +4657,41 @@ ice_start_phy_timer_e822(struct ice_hw *hw, u8 port, bool bypass) return 0; } +/** + * ice_get_phy_tx_tstamp_ready_e822 - Read Tx memory status register + * @hw: pointer to the HW struct + * @quad: the timestamp quad to read from + * @tstamp_ready: contents of the Tx memory status register + * + * Read the Q_REG_TX_MEMORY_STATUS register indicating which timestamps in + * the PHY are ready. A set bit means the corresponding timestamp is valid and + * ready to be captured from the PHY timestamp block. + */ +static int +ice_get_phy_tx_tstamp_ready_e822(struct ice_hw *hw, u8 quad, u64 *tstamp_ready) +{ + u32 hi, lo; + int err; + + err = ice_read_quad_reg_e822(hw, quad, Q_REG_TX_MEMORY_STATUS_U, &hi); + if (err) { + ice_debug(hw, ICE_DBG_PTP, "Failed to read TX_MEMORY_STATUS_U for quad %u, err %d\n", + quad, err); + return err; + } + + err = ice_read_quad_reg_e822(hw, quad, Q_REG_TX_MEMORY_STATUS_L, &lo); + if (err) { + ice_debug(hw, ICE_DBG_PTP, "Failed to read TX_MEMORY_STATUS_L for quad %u, err %d\n", + quad, err); + return err; + } + + *tstamp_ready = (u64)hi << 32 | (u64)lo; + + return 0; +} + /** * ice_phy_exit_bypass_e822 - Exit bypass mode, after vernier calculations * @hw: pointer to the HW struct @@ -5168,6 +5230,22 @@ int ice_ptp_port_cmd_e810(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd, return 0; } +/** + * ice_get_phy_tx_tstamp_ready_e810 - Read Tx memory status register + * @hw: pointer to the HW struct + * @port: the PHY port to read + * @tstamp_ready: contents of the Tx memory status register + * + * E810 devices do not use a Tx memory status register. Instead simply + * indicate that all timestamps are currently ready. + */ +static int +ice_get_phy_tx_tstamp_ready_e810(struct ice_hw *hw, u8 port, u64 *tstamp_ready) +{ + *tstamp_ready = 0xFFFFFFFFFFFFFFFF; + return 0; +} + /* E810T SMA functions * * The following functions operate specifically on E810T hardware and are used @@ -6167,6 +6245,41 @@ int ice_ptp_init_phc(struct ice_hw *hw) return err; } +/** + * ice_get_phy_tx_tstamp_ready - Read PHY Tx memory status indication + * @hw: pointer to the HW struct + * @block: the timestamp block to check + * @tstamp_ready: storage for the PHY Tx memory status information + * + * Check the PHY for Tx timestamp memory status. This reports a 64 bit value + * which indicates which timestamps in the block may be captured. A set bit + * means the timestamp can be read. An unset bit means the timestamp is not + * ready and software should avoid reading the register. + */ +int ice_get_phy_tx_tstamp_ready(struct ice_hw *hw, u8 block, u64 *tstamp_ready) +{ + int err; + + switch (hw->phy_model) { + case ICE_PHY_ETH56G: + err = ice_get_phy_tx_tstamp_ready_eth56g(hw, block, + tstamp_ready); + break; + case ICE_PHY_E810: + err = ice_get_phy_tx_tstamp_ready_e810(hw, block, + tstamp_ready); + break; + case ICE_PHY_E822: + err = ice_get_phy_tx_tstamp_ready_e822(hw, block, + tstamp_ready); + break; + default: + err = ICE_ERR_NOT_SUPPORTED; + } + + return err; +} + /** * refsync_pin_id_valid * @hw: pointer to the HW struct diff --git a/drivers/net/ice/base/ice_ptp_hw.h b/drivers/net/ice/base/ice_ptp_hw.h index f20ce8cb0d..e11b47c528 100644 --- a/drivers/net/ice/base/ice_ptp_hw.h +++ b/drivers/net/ice/base/ice_ptp_hw.h @@ -146,8 +146,14 @@ void ice_ptp_reset_ts_memory(struct ice_hw *hw); int ice_ptp_init_phc(struct ice_hw *hw); bool refsync_pin_id_valid(struct ice_hw *hw, u8 id); int +ice_get_phy_tx_tstamp_ready(struct ice_hw *hw, u8 block, u64 *tstamp_ready); +int ice_ptp_one_port_cmd(struct ice_hw *hw, u8 configured_port, enum ice_ptp_tmr_cmd configured_cmd, bool lock_sbq); +int +ice_ptp_read_port_capture(struct ice_hw *hw, u8 port, u64 *tx_ts, u64 *rx_ts); +int +ice_ptp_read_phy_incval(struct ice_hw *hw, u8 port, u64 *incval); /* E822 family functions */ int -- 2.43.0