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 0360445501; Wed, 26 Jun 2024 14:02:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B212C4336F; Wed, 26 Jun 2024 13:56:24 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mails.dpdk.org (Postfix) with ESMTP id 016BF42E95 for ; Wed, 26 Jun 2024 13:44:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719402293; x=1750938293; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JMzPRpCDiI44Qn1ns0D+3qRGAlDltHBmxCqDaonStEw=; b=PXdCFaVy4bCQ6xaGKRkD4DC40Rzypw7oXRAr3I7anndjCC5tzYgUgcp/ 93ba5DIkyVk3O3fVLmfv5ev16Gh4MnhTZd6TA7/c17XgtHpI2f+yBR/eA ZUDYVVcoAWsX2mqxdfBXNUnixWEr5OJf5ivA4JxIxJQNakpg2jlqwoY9f ivX22OLOUHcegtzZ6ew2k4ORUazedvLnWogOjDk8x4JKJPan3yAqMw/o+ R72H8GcytlqhTNgQiLmy733bhImI+aIUvwjylE2S8nZ5TIFnHrZ9ZYieg oX5kxaxxOp81qYd0vQi6UMmycd593IUqtpejU+uVcH/RSb8LZHTQZOt2M A==; X-CSE-ConnectionGUID: 65kzJEtYTiyGdNiqSmwYgA== X-CSE-MsgGUID: vDDxjB6UTeaRkBr7YvO3aQ== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="38979472" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="38979472" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 04:44:52 -0700 X-CSE-ConnectionGUID: 8JK+GwnrQcmCXIsbNEVt7g== X-CSE-MsgGUID: gWqQQ4yeTAuyl0i4mV0oWA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="43874098" Received: from unknown (HELO silpixa00401119.ir.intel.com) ([10.55.129.167]) by orviesa010.jf.intel.com with ESMTP; 26 Jun 2024 04:44:51 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Jacob Keller , ian.stokes@intel.com, bruce.richardson@intel.com Subject: [PATCH v4 067/103] net/ice/base: return high address for multi-read eth56g registers Date: Wed, 26 Jun 2024 12:41:55 +0100 Message-ID: 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: Jacob Keller The eth56g register checks for 40b and 64b registers do not return the high address offset. Instead it is expected that all offsets are exactly 4 bytes apart in the expected order. The e822 implementations explicitly return the address in the lookup function. This form is better because it allows for the potential of registers which may not have a static offset. Match the e822 style by refactoring these functions to return the high address in a function parameter. Signed-off-by: Jacob Keller Signed-off-by: Ian Stokes --- drivers/net/ice/base/ice_ptp_hw.c | 43 ++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/drivers/net/ice/base/ice_ptp_hw.c b/drivers/net/ice/base/ice_ptp_hw.c index ac01de3e37..01c2f95d5d 100644 --- a/drivers/net/ice/base/ice_ptp_hw.c +++ b/drivers/net/ice/base/ice_ptp_hw.c @@ -1209,19 +1209,35 @@ ice_phy_port_mem_write_eth56g(struct ice_hw *hw, u8 port, u16 offset, u32 val) /** * ice_is_64b_phy_reg_eth56g - Check if this is a 64bit PHY register * @low_addr: the low address to check + * @high_addr: on return, contains the high address of the 64bit register * * Checks if the provided low address is one of the known 64bit PHY values - * represented as two 32bit registers. + * represented as two 32bit registers. If it is, return the appropriate high + * register offset to use. */ -static bool ice_is_64b_phy_reg_eth56g(u16 low_addr) +static bool ice_is_64b_phy_reg_eth56g(u16 low_addr, u16 *high_addr) { switch (low_addr) { case PHY_REG_TX_TIMER_INC_PRE_L: + *high_addr = PHY_REG_TX_TIMER_INC_PRE_U; + return true; case PHY_REG_RX_TIMER_INC_PRE_L: + *high_addr = PHY_REG_RX_TIMER_INC_PRE_U; + return true; case PHY_REG_TX_CAPTURE_L: + *high_addr = PHY_REG_TX_CAPTURE_U; + return true; case PHY_REG_RX_CAPTURE_L: + *high_addr = PHY_REG_RX_CAPTURE_U; + return true; case PHY_REG_TOTAL_TX_OFFSET_L: + *high_addr = PHY_REG_TOTAL_TX_OFFSET_U; + return true; case PHY_REG_TOTAL_RX_OFFSET_L: + *high_addr = PHY_REG_TOTAL_RX_OFFSET_U; + return true; + case PHY_REG_TX_MEMORY_STATUS_L: + *high_addr = PHY_REG_TX_MEMORY_STATUS_U; return true; default: return false; @@ -1231,15 +1247,18 @@ static bool ice_is_64b_phy_reg_eth56g(u16 low_addr) /** * ice_is_40b_phy_reg_eth56g - Check if this is a 40bit PHY register * @low_addr: the low address to check + * @high_addr: on return, contains the high address of the 40bit value * * Checks if the provided low address is one of the known 40bit PHY values * split into two registers with the lower 8 bits in the low register and the - * upper 32 bits in the high register. + * upper 32 bits in the high register. If it is, return the high register + * offset to use. */ -static bool ice_is_40b_phy_reg_eth56g(u16 low_addr) +static bool ice_is_40b_phy_reg_eth56g(u16 low_addr, u16 *high_addr) { switch (low_addr) { case PHY_REG_TIMETUS_L: + *high_addr = PHY_REG_TIMETUS_U; return true; default: return false; @@ -1261,11 +1280,11 @@ static bool ice_is_40b_phy_reg_eth56g(u16 low_addr) static int ice_read_40b_phy_reg_eth56g(struct ice_hw *hw, u8 port, u16 low_addr, u64 *val) { - u16 high_addr = low_addr + sizeof(u32); int err; + u16 high_addr; u32 lo, hi; - if (!ice_is_40b_phy_reg_eth56g(low_addr)) + if (!ice_is_40b_phy_reg_eth56g(low_addr, &high_addr)) return ICE_ERR_PARAM; err = ice_read_phy_reg_eth56g(hw, port, low_addr, &lo); @@ -1302,11 +1321,11 @@ ice_read_40b_phy_reg_eth56g(struct ice_hw *hw, u8 port, u16 low_addr, u64 *val) static int ice_read_64b_phy_reg_eth56g(struct ice_hw *hw, u8 port, u16 low_addr, u64 *val) { - u16 high_addr = low_addr + sizeof(u32); int err; + u16 high_addr; u32 lo, hi; - if (!ice_is_64b_phy_reg_eth56g(low_addr)) + if (!ice_is_64b_phy_reg_eth56g(low_addr, &high_addr)) return ICE_ERR_PARAM; err = ice_read_phy_reg_eth56g(hw, port, low_addr, &lo); @@ -1343,11 +1362,11 @@ ice_read_64b_phy_reg_eth56g(struct ice_hw *hw, u8 port, u16 low_addr, u64 *val) static int ice_write_40b_phy_reg_eth56g(struct ice_hw *hw, u8 port, u16 low_addr, u64 val) { - u16 high_addr = low_addr + sizeof(u32); int err; + u16 high_addr; u32 lo, hi; - if (!ice_is_40b_phy_reg_eth56g(low_addr)) + if (!ice_is_40b_phy_reg_eth56g(low_addr, &high_addr)) return ICE_ERR_PARAM; lo = (u32)(val & P_REG_40B_LOW_M); @@ -1384,11 +1403,11 @@ ice_write_40b_phy_reg_eth56g(struct ice_hw *hw, u8 port, u16 low_addr, u64 val) static int ice_write_64b_phy_reg_eth56g(struct ice_hw *hw, u8 port, u16 low_addr, u64 val) { - u16 high_addr = low_addr + sizeof(u32); int err; + u16 high_addr; u32 lo, hi; - if (!ice_is_64b_phy_reg_eth56g(low_addr)) + if (!ice_is_64b_phy_reg_eth56g(low_addr, &high_addr)) return ICE_ERR_PARAM; lo = ICE_LO_DWORD(val); -- 2.43.0