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 F3CBF4404F; Wed, 12 Jun 2024 17:22:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 594444300B; Wed, 12 Jun 2024 17:06:37 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by mails.dpdk.org (Postfix) with ESMTP id 731AD42EB6 for ; Wed, 12 Jun 2024 17:06:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718204795; x=1749740795; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=54fk+XngpUbIA+5K1mHv9pwA3yvG+yzx2Hn+EnFZu40=; b=iwy3DJxyFjCecEz7BhDpLVJZ0NmGhMRZKm4NYOXVSxP/pl/zsbenIwro ABiQO12IUcORcWgW/JcTr9v1u96rXL6ocSiKUSx8DF9QcFX50hXoIngpo RA2D/Ob8/sNe9sCrrieOXfgrdWv4VfnRtBvd0zTtMtuOA/G99W+xjJK76 xIYrIwdrw/ZiMfXcVUOLrnT6ZwzRQLgEohazIGZMEJiLtmnO7eQpB/Nzy yID0+BxgOwc4hC3gmlBHTn8vfWU0+WZAAp3gNglEJ5lMrsKpXFqzJkR8j xu7ESzuFCACb2V8l+sD2vhzaIN+dXnHLI1yZYIWO1328j5crC+PxCHE3j g==; X-CSE-ConnectionGUID: pQQ7a13KTFGqFe8HUfJgLw== X-CSE-MsgGUID: ZGbdMIW5QH2cd9IqwL/BnQ== X-IronPort-AV: E=McAfee;i="6700,10204,11101"; a="32460006" X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="32460006" 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:34 -0700 X-CSE-ConnectionGUID: jqK03Cg/TRyCnOZMuY1xgQ== X-CSE-MsgGUID: f3mD/tOJQB+/g3a0gOTbbg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="39925902" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by orviesa009.jf.intel.com with ESMTP; 12 Jun 2024 08:06:33 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: ian.stokes@intel.com, bruce.richardson@intel.com, Jesse Brandeburg Subject: [PATCH v2 117/148] net/ice/base: switch speed conversions to static lookups Date: Wed, 12 Jun 2024 16:01:51 +0100 Message-ID: <633fcb64d17e90b9370aaab40962041a60886ee6.1718204529.git.anatoly.burakov@intel.com> 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 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 e94bec26a8..eeba70a390 100644 --- a/drivers/net/ice/base/ice_common.c +++ b/drivers/net/ice/base/ice_common.c @@ -3417,8 +3417,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) @@ -6441,6 +6441,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 d680330369..de82248a51 100644 --- a/drivers/net/ice/base/ice_common.h +++ b/drivers/net/ice/base/ice_common.h @@ -226,6 +226,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