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 3168D454EF; Tue, 25 Jun 2024 13:26:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6B56A432CC; Tue, 25 Jun 2024 13:18:54 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mails.dpdk.org (Postfix) with ESMTP id 3F47042D7D for ; Tue, 25 Jun 2024 13:17:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719314258; x=1750850258; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8mG1xeg/fPIwEefaYcKwKfSGNAblGbSP+q5NGEK+XIA=; b=dKqTqOZrY2WuyDb7FyeiunaK05nIPgOHY7/A0JF7DSVvK9qJjOpZcO2+ gd41qGFGz5hF8b65WIkVza5m7PzvMzDDzlSwfL5g/YxU64Am1cUzmKoze Z8OntJMUhiAwfWY9OG/wzID3IZVzInWJNzTBW/OfTHg+kauIuvO1CGid6 WRA/9E3DXOkNeB17Tc2iD28X4GLE0fRLfOJQ//PvdgJAMUT0rIObV4QaH vk8oYxRZu8Lj9WgdbgXhX+x7q1ZEa1KTOdKEmSfebwmXGq+RN1kdHeRSG VJYNkveHhWRH1liElzCQZOjzEGCwtjEqaxBLE0zM4vbZVF/wSUB3c+8BE A==; X-CSE-ConnectionGUID: bxnmt6g5SCioXGIrxDiN5g== X-CSE-MsgGUID: eLNIZO5UQ3K7rdmWJPjKuw== X-IronPort-AV: E=McAfee;i="6700,10204,11113"; a="16080510" X-IronPort-AV: E=Sophos;i="6.08,263,1712646000"; d="scan'208";a="16080510" 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:17:37 -0700 X-CSE-ConnectionGUID: S6/tPAS1SuiP2m34zgPAcA== X-CSE-MsgGUID: cfTV+IciRfWFp2gnAmG/mQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,263,1712646000"; d="scan'208";a="43719631" Received: from unknown (HELO silpixa00401119.ir.intel.com) ([10.55.129.167]) by orviesa009.jf.intel.com with ESMTP; 25 Jun 2024 04:17:37 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Jesse Brandeburg , bruce.richardson@intel.com, ian.stokes@intel.com Subject: [PATCH v3 097/129] net/ice/base: switch speed conversions to static lookups Date: Tue, 25 Jun 2024 12:13:42 +0100 Message-ID: <9829493e4100653fa4ee4df2e87b0284b8a3e5e0.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: Jesse Brandeburg Refactor to use a constant time lookup in a table for speed conversions from ICE_AQ_LINK_SPEED values to speeds defined in firmware. Also, make sure 200000MBPS is defined when needed. Signed-off-by: Jesse Brandeburg Signed-off-by: Anatoly Burakov --- drivers/net/ice/base/ice_common.c | 40 ++++++++++++++++++++++++++-- drivers/net/ice/base/ice_common.h | 1 + drivers/net/ice/base/ice_lan_tx_rx.h | 2 +- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/drivers/net/ice/base/ice_common.c b/drivers/net/ice/base/ice_common.c index e0aa001390..06b6451393 100644 --- a/drivers/net/ice/base/ice_common.c +++ b/drivers/net/ice/base/ice_common.c @@ -3393,8 +3393,8 @@ bool ice_is_100m_speed_supported(struct ice_hw *hw) * Note: In the structure of [phy_type_low, phy_type_high], there should * be one bit set, as this function will convert one PHY type to its * speed. - * If no bit gets set, ICE_LINK_SPEED_UNKNOWN will be returned - * If more than one bit gets set, ICE_LINK_SPEED_UNKNOWN will be returned + * If no bit gets set, ICE_AQ_LINK_SPEED_UNKNOWN will be returned + * If more than one bit gets set, ICE_AQ_LINK_SPEED_UNKNOWN will be returned */ static u16 ice_get_link_speed_based_on_phy_type(u64 phy_type_low, u64 phy_type_high) @@ -6407,6 +6407,42 @@ bool ice_fw_supports_report_dflt_cfg(struct ice_hw *hw) ICE_FW_API_REPORT_DFLT_CFG_PATCH); } +/* each of the indexes into the following array match the speed of a return + * value from the list of AQ returned speeds like the range: + * ICE_AQ_LINK_SPEED_10MB .. ICE_AQ_LINK_SPEED_100GB excluding + * ICE_AQ_LINK_SPEED_UNKNOWN which is BIT(15) The array is defined as 15 + * elements long because the link_speed returned by the firmware is a 16 bit + * value, but is indexed by [fls(speed) - 1] + */ +static const u32 ice_aq_to_link_speed[] = { + ICE_LINK_SPEED_10MBPS, /* BIT(0) */ + ICE_LINK_SPEED_100MBPS, + ICE_LINK_SPEED_1000MBPS, + ICE_LINK_SPEED_2500MBPS, + ICE_LINK_SPEED_5000MBPS, + ICE_LINK_SPEED_10000MBPS, + ICE_LINK_SPEED_20000MBPS, + ICE_LINK_SPEED_25000MBPS, + ICE_LINK_SPEED_40000MBPS, + ICE_LINK_SPEED_50000MBPS, + ICE_LINK_SPEED_100000MBPS, /* BIT(10) */ + ICE_LINK_SPEED_200000MBPS, +}; + +/** + * ice_get_link_speed - get integer speed from table + * @index: array index from fls(aq speed) - 1 + * + * Returns: u32 value containing integer speed + */ +u32 ice_get_link_speed(u16 index) +{ + if (index >= ARRAY_SIZE(ice_aq_to_link_speed)) + return ICE_LINK_SPEED_UNKNOWN; + + return ice_aq_to_link_speed[index]; +} + /** * ice_fw_supports_fec_dis_auto * @hw: pointer to the hardware structure diff --git a/drivers/net/ice/base/ice_common.h b/drivers/net/ice/base/ice_common.h index df0a247263..894d650b1a 100644 --- a/drivers/net/ice/base/ice_common.h +++ b/drivers/net/ice/base/ice_common.h @@ -224,6 +224,7 @@ int ice_aq_sff_eeprom(struct ice_hw *hw, u16 lport, u8 bus_addr, u16 mem_addr, u8 page, u8 set_page, u8 *data, u8 length, bool write, struct ice_sq_cd *cd); +u32 ice_get_link_speed(u16 index); int ice_aq_prog_topo_dev_nvm(struct ice_hw *hw, diff --git a/drivers/net/ice/base/ice_lan_tx_rx.h b/drivers/net/ice/base/ice_lan_tx_rx.h index 39673e36f7..a28345c2c4 100644 --- a/drivers/net/ice/base/ice_lan_tx_rx.h +++ b/drivers/net/ice/base/ice_lan_tx_rx.h @@ -2469,5 +2469,5 @@ static inline struct ice_rx_ptype_decoded ice_decode_rx_desc_ptype(u16 ptype) #define ICE_LINK_SPEED_40000MBPS 40000 #define ICE_LINK_SPEED_50000MBPS 50000 #define ICE_LINK_SPEED_100000MBPS 100000 - +#define ICE_LINK_SPEED_200000MBPS 200000 #endif /* _ICE_LAN_TX_RX_H_ */ -- 2.43.0