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 13D67454EF; Tue, 25 Jun 2024 13:23:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A865C42F91; Tue, 25 Jun 2024 13:18:13 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mails.dpdk.org (Postfix) with ESMTP id D006442D8C for ; Tue, 25 Jun 2024 13:16:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719314216; x=1750850216; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/FDTbgY8UyNZhMNsq4S4N+M8nt5B0f/0qcY6ehWxWwE=; b=OMqj6jaEHL8uJc3JHAdgQpy4nQft0K3jSydgTOVlAqRwsf2ApJo+tmbg QlbMWZGoO3yuUk+u3FMrwgyTOMrLQSZPIc5UvloJRAh3DmWsJfLI748q9 waP7lJefMbTOAft6O7oyatYpirR9dt7EIF4vb1tCNJzOdOdiJem+0GAz3 AKORhXZb9tloKzTjk1IVcBERwRm3Q5oV+1dT/yjVY4K64ID9PidkNvMDM iQV/KU7coOn0iSkIjuAFwHMzBAdY/jfldlLkTrf3oaWOg8scphY8l7iZK hG2xy1NiH94CYD0AaJzapiNtQapmuEZ6E0fEBPSDIqvOcLJMBbzvj2Uu5 w==; X-CSE-ConnectionGUID: rYxjlZVsTMqTllqaufslOA== X-CSE-MsgGUID: 5G0GxRLmREewKIV42yZx+Q== X-IronPort-AV: E=McAfee;i="6700,10204,11113"; a="16080314" X-IronPort-AV: E=Sophos;i="6.08,263,1712646000"; d="scan'208";a="16080314" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2024 04:16:46 -0700 X-CSE-ConnectionGUID: 8ZDq1NefS5qi5PrNHtfvHQ== X-CSE-MsgGUID: 7ZRdLKj0SKm3McAXjRRGiQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,263,1712646000"; d="scan'208";a="43719372" Received: from unknown (HELO silpixa00401119.ir.intel.com) ([10.55.129.167]) by orviesa009.jf.intel.com with ESMTP; 25 Jun 2024 04:16:46 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Tomaszx Wakula , bruce.richardson@intel.com, ian.stokes@intel.com Subject: [PATCH v3 066/129] net/ice/base: add function to read SDP section from NVM Date: Tue, 25 Jun 2024 12:13:11 +0100 Message-ID: <253dd9e2a44d4558bb01a84e1b38f7f9513f8e12.1719313663.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: 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: Tomaszx Wakula Add API and definitions related to reading Software Definable Pin section from NVM, related to PTP pins assignment. Signed-off-by: Tomaszx Wakula Signed-off-by: Ian Stokes --- drivers/net/ice/base/ice_adminq_cmd.h | 23 +++++++ drivers/net/ice/base/ice_ptp_hw.c | 87 +++++++++++++++++++++++++++ drivers/net/ice/base/ice_ptp_hw.h | 3 + 3 files changed, 113 insertions(+) diff --git a/drivers/net/ice/base/ice_adminq_cmd.h b/drivers/net/ice/base/ice_adminq_cmd.h index 4a20a7ac35..d828731a5b 100644 --- a/drivers/net/ice/base/ice_adminq_cmd.h +++ b/drivers/net/ice/base/ice_adminq_cmd.h @@ -1976,6 +1976,29 @@ struct ice_aqc_nvm { #define ICE_AQC_NVM_LLDP_STATUS_M_LEN 4 /* In Bits */ #define ICE_AQC_NVM_LLDP_STATUS_RD_LEN 4 /* In Bytes */ +#define ICE_AQC_NVM_SDP_CFG_PTR_OFFSET 0xD8 +#define ICE_AQC_NVM_SDP_CFG_PTR_RD_LEN 2 /* In Bytes */ +#define ICE_AQC_NVM_SDP_CFG_PTR_M MAKEMASK(0x7FFF, 0) +#define ICE_AQC_NVM_SDP_CFG_PTR_TYPE_M BIT(15) +#define ICE_AQC_NVM_SDP_CFG_HEADER_LEN 2 /* In Bytes */ +#define ICE_AQC_NVM_SDP_CFG_SEC_LEN_LEN 2 /* In Bytes */ +#define ICE_AQC_NVM_SDP_CFG_DATA_LEN 14 /* In Bytes */ +#define ICE_AQC_NVM_SDP_CFG_MAX_SECTION_SIZE 7 +#define ICE_AQC_NVM_SDP_CFG_PIN_SIZE 10 +#define ICE_AQC_NVM_SDP_CFG_PIN_OFFSET 6 +#define ICE_AQC_NVM_SDP_CFG_PIN_MASK MAKEMASK(0x3FF, \ + ICE_AQC_NVM_SDP_CFG_PIN_OFFSET) +#define ICE_AQC_NVM_SDP_CFG_CHAN_OFFSET 4 +#define ICE_AQC_NVM_SDP_CFG_CHAN_MASK MAKEMASK(0x3, \ + ICE_AQC_NVM_SDP_CFG_CHAN_OFFSET) +#define ICE_AQC_NVM_SDP_CFG_DIR_OFFSET 3 +#define ICE_AQC_NVM_SDP_CFG_DIR_MASK MAKEMASK(0x1, \ + ICE_AQC_NVM_SDP_CFG_DIR_OFFSET) +#define ICE_AQC_NVM_SDP_CFG_SDP_NUM_OFFSET 0 +#define ICE_AQC_NVM_SDP_CFG_SDP_NUM_MASK MAKEMASK(0x7, \ + ICE_AQC_NVM_SDP_CFG_SDP_NUM_OFFSET) +#define ICE_AQC_NVM_SDP_CFG_NA_PIN_MASK MAKEMASK(0x1, 15) + #define ICE_AQC_NVM_TX_TOPO_MOD_ID 0x14B #define ICE_AQC_NVM_CMPO_MOD_ID 0x153 diff --git a/drivers/net/ice/base/ice_ptp_hw.c b/drivers/net/ice/base/ice_ptp_hw.c index 850cc2a57c..c1c3c77469 100644 --- a/drivers/net/ice/base/ice_ptp_hw.c +++ b/drivers/net/ice/base/ice_ptp_hw.c @@ -5151,6 +5151,93 @@ bool ice_is_pca9575_present(struct ice_hw *hw) return false; } +/** + * ice_ptp_read_sdp_section_from_nvm - reads SDP section from NVM + * @hw: pointer to the HW struct + * @section_exist: on return, returns true if section exist + * @pin_desc_num: on return, returns the number of ice_ptp_pin_desc entries + * @pin_config_num: on return, returns the number of pin that should be + * exposed on pin_config I/F + * @sdp_entries: on return, returns the SDP connection section from NVM + * @nvm_entries: on return, returns the number of valid entries in sdp_entries + * + * Reads SDP connection section from NVM + * Returns -1 if NVM read failed or section corrupted, otherwise 0 + */ +int ice_ptp_read_sdp_section_from_nvm(struct ice_hw *hw, bool *section_exist, + u8 *pin_desc_num, u8 *pin_config_num, + u16 *sdp_entries, u8 *nvm_entries) +{ + __le16 loc_raw_data, raw_nvm_entries; + u32 loc_data, i, all_pin_bitmap = 0; + int err; + + *section_exist = false; + *pin_desc_num = 0; + *pin_config_num = 0; + + err = ice_acquire_nvm(hw, ICE_RES_READ); + if (err) + goto exit; + + /* Read the offset of EMP_SR_PTR */ + err = ice_aq_read_nvm(hw, ICE_AQC_NVM_START_POINT, + ICE_AQC_NVM_SDP_CFG_PTR_OFFSET, + ICE_AQC_NVM_SDP_CFG_PTR_RD_LEN, + &loc_raw_data, false, true, NULL); + if (err) + goto exit; + + /* check if section exist */ + loc_data = LE16_TO_CPU(loc_raw_data); + if ((loc_data & ICE_AQC_NVM_SDP_CFG_PTR_M) == ICE_AQC_NVM_SDP_CFG_PTR_M) + goto exit; + + if (loc_data & ICE_AQC_NVM_SDP_CFG_PTR_TYPE_M) { + loc_data &= ICE_AQC_NVM_SDP_CFG_PTR_M; + loc_data *= ICE_AQC_NVM_SECTOR_UNIT; + } else { + loc_data *= ICE_AQC_NVM_WORD_UNIT; + } + + /* Skip SDP configuration section length (2 bytes) */ + loc_data += ICE_AQC_NVM_SDP_CFG_HEADER_LEN; + + /* read number of valid entries */ + err = ice_aq_read_nvm(hw, ICE_AQC_NVM_START_POINT, loc_data, + ICE_AQC_NVM_SDP_CFG_SEC_LEN_LEN, &raw_nvm_entries, + false, true, NULL); + if (err) + goto exit; + *nvm_entries = (u8)LE16_TO_CPU(raw_nvm_entries); + + /* Read entire SDP configuration section */ + loc_data += ICE_AQC_NVM_SDP_CFG_SEC_LEN_LEN; + err = ice_aq_read_nvm(hw, ICE_AQC_NVM_START_POINT, loc_data, + ICE_AQC_NVM_SDP_CFG_DATA_LEN, sdp_entries, + false, true, NULL); + if (err) + goto exit; + + /* get number of existing pin/connector */ + for (i = 0; i < *nvm_entries; i++) { + all_pin_bitmap |= (sdp_entries[i] & + ICE_AQC_NVM_SDP_CFG_PIN_MASK) >> + ICE_AQC_NVM_SDP_CFG_PIN_OFFSET; + if (sdp_entries[i] & ICE_AQC_NVM_SDP_CFG_NA_PIN_MASK) + *pin_desc_num += 1; + } + + for (i = 0; i < ICE_AQC_NVM_SDP_CFG_PIN_SIZE - 1; i++) + *pin_config_num += (all_pin_bitmap & (1 << i)) != 0; + *pin_desc_num += *pin_config_num; + + *section_exist = true; +exit: + ice_release_nvm(hw); + return err; +} + /** * ice_ptp_write_direct_incval_e830 - Prep PHY port increment value change * @hw: pointer to HW struct diff --git a/drivers/net/ice/base/ice_ptp_hw.h b/drivers/net/ice/base/ice_ptp_hw.h index 11535044a8..468507382d 100644 --- a/drivers/net/ice/base/ice_ptp_hw.h +++ b/drivers/net/ice/base/ice_ptp_hw.h @@ -264,6 +264,9 @@ ice_write_pca9575_reg_e810t(struct ice_hw *hw, u8 offset, u8 data); int ice_read_sma_ctrl_e810t(struct ice_hw *hw, u8 *data); int ice_write_sma_ctrl_e810t(struct ice_hw *hw, u8 data); bool ice_is_pca9575_present(struct ice_hw *hw); +int ice_ptp_read_sdp_section_from_nvm(struct ice_hw *hw, bool *section_exist, + u8 *pin_desc_num, u8 *pin_config_num, + u16 *sdp_entries, u8 *nvm_entries); void ice_ptp_process_cgu_err(struct ice_hw *hw, struct ice_rq_event_info *event); -- 2.43.0