[v2,140/148] net/ice/base: enable CGU error reporting

Message ID a0b1da1d5e8e58a932026c3a1c790ad37ea0efdc.1718204529.git.anatoly.burakov@intel.com (mailing list archive)
State Superseded
Delegated to: Bruce Richardson
Headers
Series Update net/ice base driver to latest upstream snapshot |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Anatoly Burakov June 12, 2024, 3:02 p.m. UTC
  From: Ian Stokes <ian.stokes@intel.com>

Enable CGU error reporting for SyncE and TimeSync issues. Process TimeSync loss
of lock event by trying to acquire lock with the default config.

Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
---
 drivers/net/ice/base/ice_ptp_hw.c | 49 ++++++++++++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)
  

Comments

Bruce Richardson June 21, 2024, 3:08 p.m. UTC | #1
On Wed, Jun 12, 2024 at 04:02:14PM +0100, Anatoly Burakov wrote:
> From: Ian Stokes <ian.stokes@intel.com>
> 
> Enable CGU error reporting for SyncE and TimeSync issues. Process TimeSync loss
> of lock event by trying to acquire lock with the default config.
> 
> Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
> Signed-off-by: Ian Stokes <ian.stokes@intel.com>
> ---
>  drivers/net/ice/base/ice_ptp_hw.c | 49 ++++++++++++++++++++++++++++++-
>  1 file changed, 48 insertions(+), 1 deletion(-)
> 

Possible candidate for merge with patch 136?

/Bruce
  

Patch

diff --git a/drivers/net/ice/base/ice_ptp_hw.c b/drivers/net/ice/base/ice_ptp_hw.c
index bca9e75744..cfcbdddee8 100644
--- a/drivers/net/ice/base/ice_ptp_hw.c
+++ b/drivers/net/ice/base/ice_ptp_hw.c
@@ -787,7 +787,49 @@  static int ice_init_cgu_e82x(struct ice_hw *hw)
 }
 
 /**
- * @ice_ptp_tmr_cmd_to_src_reg - Convert to source timer command value
+ * ice_ptp_cgu_err_reporting - Enable/disable error reporting for CGU
+ * @hw: pointer to HW struct
+ * @enable: true if reporting should be enabled
+ *
+ * Enable or disable error events to be reported through Admin Queue.
+ *
+ * Return: 0 on success, error code otherwise
+ */
+static int ice_ptp_cgu_err_reporting(struct ice_hw *hw, bool enable)
+{
+	int err;
+
+	err = ice_aq_cfg_cgu_err(hw, enable, enable, NULL);
+	if (err) {
+		ice_debug(hw, ICE_DBG_PTP,
+			  "Failed to %s CGU error reporting, err %d\n",
+			  enable ? "enable" : "disable", err);
+		return err;
+	}
+
+	return 0;
+}
+
+/**
+ * ice_ptp_process_cgu_err - Handle reported CGU error
+ * @hw: pointer to HW struct
+ * @event: reported CGU error descriptor
+ */
+void ice_ptp_process_cgu_err(struct ice_hw *hw, struct ice_rq_event_info *event)
+{
+	u8 err_type = event->desc.params.cgu_err.err_type;
+
+	if (err_type & ICE_AQC_CGU_ERR_TIMESYNC_LOCK_LOSS) {
+		ice_warn(hw, "TimeSync PLL lock lost. Retrying to acquire lock with default PLL configuration.\n");
+		ice_init_cgu_e82x(hw);
+	}
+
+	/* Reenable CGU error reporting */
+	ice_ptp_cgu_err_reporting(hw, true);
+}
+
+/**
+ * ice_ptp_tmr_cmd_to_src_reg - Convert to source timer command value
  * @hw: pointer to HW struct
  * @cmd: Timer command
  *
@@ -3014,6 +3056,11 @@  static int ice_ptp_init_phc_e822(struct ice_hw *hw)
 	if (err)
 		return err;
 
+	/* Enable CGU error reporting */
+	err = ice_ptp_cgu_err_reporting(hw, true);
+	if (err)
+		return err;
+
 	/* Set window length for all the ports */
 	return ice_ptp_set_vernier_wl(hw);
 }