[Intel-wired-lan] [PATCH iwl-next 8/10] ice: move ice_phy_get_speed_eth56g() from ice_ptp_hw.c to ice_common.c

Aleksandr Loktionov
2026-04-10T07:49:40Z

ice_phy_get_speed_eth56g() is currently a file-local (static)
helper in ice_ptp_hw.c. Future users outside that compilation
unit require access to it.

Move the function to ice_common.c, add a declaration in
ice_common.h, and relocate the enum ice_eth56g_link_spd from
ice_ptp_hw.h to ice_type.h so it is visible to callers of the
new exported function.

Suggested-by: Karol Kolacinski <karol.kolacinski@intel.com>
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
---
drivers/net/ethernet/intel/ice/ice_common.c | 45 +++++++++++++++++++++
drivers/net/ethernet/intel/ice/ice_common.h | 1 +
drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 45 ---------------------
drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 13 ------
drivers/net/ethernet/intel/ice/ice_type.h | 13 ++++++
5 files changed, 59 insertions(+), 58 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index ce11fea..2cebe4e 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -3513,6 +3513,51 @@ u16 ice_get_link_speed_based_on_phy_type(u64 phy_type_low, u64 phy_type_high)
return speed_phy_type_high;
}

+/**
+ * ice_phy_get_speed_eth56g - Get link speed based on PHY link type
+ * @li: pointer to link information struct
+ *
+ * Return: simplified ETH56G PHY speed
+ */
+enum ice_eth56g_link_spd ice_phy_get_speed_eth56g(struct ice_link_status *li)
+{
+ u16 speed = ice_get_link_speed_based_on_phy_type(li->phy_type_low,
+ li->phy_type_high);
+
+ switch (speed) {
+ case ICE_AQ_LINK_SPEED_1000MB:
+ return ICE_ETH56G_LNK_SPD_1G;
+ case ICE_AQ_LINK_SPEED_2500MB:
+ return ICE_ETH56G_LNK_SPD_2_5G;
+ case ICE_AQ_LINK_SPEED_10GB:
+ return ICE_ETH56G_LNK_SPD_10G;
+ case ICE_AQ_LINK_SPEED_25GB:
+ return ICE_ETH56G_LNK_SPD_25G;
+ case ICE_AQ_LINK_SPEED_40GB:
+ return ICE_ETH56G_LNK_SPD_40G;
+ case ICE_AQ_LINK_SPEED_50GB:
+ switch (li->phy_type_low) {
+ case ICE_PHY_TYPE_LOW_50GBASE_SR:
+ case ICE_PHY_TYPE_LOW_50GBASE_FR:
+ case ICE_PHY_TYPE_LOW_50GBASE_LR:
+ case ICE_PHY_TYPE_LOW_50GBASE_KR_PAM4:
+ case ICE_PHY_TYPE_LOW_50G_AUI1_AOC_ACC:
+ case ICE_PHY_TYPE_LOW_50G_AUI1:
+ return ICE_ETH56G_LNK_SPD_50G;
+ default:
+ return ICE_ETH56G_LNK_SPD_50G2;
+ }
+ case ICE_AQ_LINK_SPEED_100GB:
+ if (li->phy_type_high ||
+ li->phy_type_low == ICE_PHY_TYPE_LOW_100GBASE_SR2)
+ return ICE_ETH56G_LNK_SPD_100G2;
+ else
+ return ICE_ETH56G_LNK_SPD_100G;
+ default:
+ return ICE_ETH56G_LNK_SPD_1G;
+ }
+}
+
/**
* ice_update_phy_type
* @phy_type_low: pointer to the lower part of phy_type
diff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h
index e700ac0..cc5cee8 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.h
+++ b/drivers/net/ethernet/intel/ice/ice_common.h
@@ -342,6 +342,7 @@ ice_aq_get_gpio(struct ice_hw *hw, u16 gpio_ctrl_handle, u8 pin_idx,
bool *value, struct ice_sq_cd *cd);
bool ice_is_100m_speed_supported(struct ice_hw *hw);
u16 ice_get_link_speed_based_on_phy_type(u64 phy_type_low, u64 phy_type_high);
+enum ice_eth56g_link_spd ice_phy_get_speed_eth56g(struct ice_link_status *li);
int
ice_aq_set_lldp_mib(struct ice_hw *hw, u8 mib_type, void *buf, u16 buf_size,
struct ice_sq_cd *cd);
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
index 61c0a0d..54a8afa 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
@@ -1401,51 +1401,6 @@ static int ice_ptp_write_port_cmd_eth56g(struct ice_hw *hw, u8 port,
return 0;
}

-/**
- * ice_phy_get_speed_eth56g - Get link speed based on PHY link type
- * @li: pointer to link information struct
- *
- * Return: simplified ETH56G PHY speed
- */
-static enum ice_eth56g_link_spd
-ice_phy_get_speed_eth56g(struct ice_link_status *li)
-{
- u16 speed = ice_get_link_speed_based_on_phy_type(li->phy_type_low,
- li->phy_type_high);
-
- switch (speed) {
- case ICE_AQ_LINK_SPEED_1000MB:
- return ICE_ETH56G_LNK_SPD_1G;
- case ICE_AQ_LINK_SPEED_2500MB:
- return ICE_ETH56G_LNK_SPD_2_5G;
- case ICE_AQ_LINK_SPEED_10GB:
- return ICE_ETH56G_LNK_SPD_10G;
- case ICE_AQ_LINK_SPEED_25GB:
- return ICE_ETH56G_LNK_SPD_25G;
- case ICE_AQ_LINK_SPEED_40GB:
- return ICE_ETH56G_LNK_SPD_40G;
- case ICE_AQ_LINK_SPEED_50GB:
- switch (li->phy_type_low) {
- case ICE_PHY_TYPE_LOW_50GBASE_SR:
- case ICE_PHY_TYPE_LOW_50GBASE_FR:
- case ICE_PHY_TYPE_LOW_50GBASE_LR:
- case ICE_PHY_TYPE_LOW_50GBASE_KR_PAM4:
- case ICE_PHY_TYPE_LOW_50G_AUI1_AOC_ACC:
- case ICE_PHY_TYPE_LOW_50G_AUI1:
- return ICE_ETH56G_LNK_SPD_50G;
- default:
- return ICE_ETH56G_LNK_SPD_50G2;
- }
- case ICE_AQ_LINK_SPEED_100GB:
- if (li->phy_type_high ||
- li->phy_type_low == ICE_PHY_TYPE_LOW_100GBASE_SR2)
- return ICE_ETH56G_LNK_SPD_100G2;
- else
- return ICE_ETH56G_LNK_SPD_100G;
- default:
- return ICE_ETH56G_LNK_SPD_1G;
- }
-}

/**
* ice_phy_cfg_parpcs_eth56g - Configure TUs per PAR/PCS clock cycle
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
index 9bfd3e7..a13256a 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
+++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
@@ -50,19 +50,6 @@ enum eth56g_res_type {
NUM_ETH56G_PHY_RES
};

-enum ice_eth56g_link_spd {
- ICE_ETH56G_LNK_SPD_1G,
- ICE_ETH56G_LNK_SPD_2_5G,
- ICE_ETH56G_LNK_SPD_10G,
- ICE_ETH56G_LNK_SPD_25G,
- ICE_ETH56G_LNK_SPD_40G,
- ICE_ETH56G_LNK_SPD_50G,
- ICE_ETH56G_LNK_SPD_50G2,
- ICE_ETH56G_LNK_SPD_100G,
- ICE_ETH56G_LNK_SPD_100G2,
- NUM_ICE_ETH56G_LNK_SPD /* Must be last */
-};
-
/**
* struct ice_phy_reg_info_eth56g - ETH56G PHY register parameters
* @base_addr: base address for each PHY block
diff --git a/drivers/net/ethernet/intel/ice/ice_type.h b/drivers/net/ethernet/intel/ice/ice_type.h
index 1e82f4c..4db235a 100644
--- a/drivers/net/ethernet/intel/ice/ice_type.h
+++ b/drivers/net/ethernet/intel/ice/ice_type.h
@@ -859,6 +859,19 @@ struct ice_mbx_data {
#define ICE_PORTS_PER_QUAD 4
#define ICE_GET_QUAD_NUM(port) ((port) / ICE_PORTS_PER_QUAD)

+enum ice_eth56g_link_spd {
+ ICE_ETH56G_LNK_SPD_1G,
+ ICE_ETH56G_LNK_SPD_2_5G,
+ ICE_ETH56G_LNK_SPD_10G,
+ ICE_ETH56G_LNK_SPD_25G,
+ ICE_ETH56G_LNK_SPD_40G,
+ ICE_ETH56G_LNK_SPD_50G,
+ ICE_ETH56G_LNK_SPD_50G2,
+ ICE_ETH56G_LNK_SPD_100G,
+ ICE_ETH56G_LNK_SPD_100G2,
+ NUM_ICE_ETH56G_LNK_SPD /* Must be last */
+};
+
#define ATQBAL_FLAGS_INTR_IN_PROGRESS BIT(0)

struct ice_e810_params {
--
2.52.0