Skip to contentSkip to conversation

ice: fix linking with CONFIG_PTP_1588_CLOCK=n

PATCH In review Jacob Keller 4 participants 10 messages Sep 19, 2023 – Oct 3, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ice: fix linking with CONFIG_PTP_1588_CLOCK=n

The recent changes to support DPLL in the ice driver accidentally broke linking the module if CONFIG_PTP_1588_CLOCK is disabled:

00:02:33  ld: vmlinux.o: in function `ice_init_feature_support':
00:02:33  (.text+0x8702b8): undefined reference to `ice_is_phy_rclk_present'
00:02:33  ld: (.text+0x8702cd): undefined reference to `ice_is_cgu_present'
00:02:33  ld: (.text+0x8702d9): undefined reference to `ice_is_clock_mux_present_e810t'
00:02:33  ld: vmlinux.o: in function `ice_dpll_init_info_direct_pins':
00:02:33  ice_dpll.c:(.text+0x894167): undefined reference to `ice_cgu_get_pin_freq_supp'
00:02:33  ld: ice_dpll.c:(.text+0x894197): undefined reference to `ice_cgu_get_pin_name'
00:02:33  ld: ice_dpll.c:(.text+0x8941a8): undefined reference to `ice_cgu_get_pin_type'
00:02:33  ld: vmlinux.o: in function `ice_dpll_update_state':
00:02:33  ice_dpll.c:(.text+0x894494): undefined reference to `ice_get_cgu_state'
00:02:33  ld: vmlinux.o: in function `ice_dpll_init':
00:02:33  (.text+0x8953d5): undefined reference to `ice_get_cgu_rclk_pin_info'
00:02:34  make[2]: *** [scripts/Makefile.vmlinux:36: vmlinux] Error 1
00:02:34  make[1]: *** [/home/jenkins/agent/workspace/ndlinuxc/reference-repos/update-kernel-repos/kernel/Makefile:1165: vmlinux] Error 2
00:02:34  make: *** [Makefile:234: __sub-make] Error 2

This occurs because of functions added to ice_ptp_hw.c which are only compiled when CONFIG_PTP_1588_CLOCK is enabled.

In addition, that series included similar code to logic I published at [1] which got feedback to make some suggested improvements:

This series fixes the compilation issues and aligns ice_find_netlist_node with the version that I posted at [1] and [2]:

[1]: https://lore.kernel.org/intel-wired-lan/[email protected]/
[2]: https://lore.kernel.org/netdev/[email protected]/

Jacob Keller (4):
ice: don't compile ice_dpll.c if CONFIG_PTP_1588_CLOCK is disabled
ice: move netlist check functions to ice_common.c
ice: make ice_get_pf_c827_idx static
ice: cleanup ice_find_netlist_node

 drivers/net/ethernet/intel/ice/Makefile     |  3 +-
 drivers/net/ethernet/intel/ice/ice_common.c | 96 +++++++++++++++++----
 drivers/net/ethernet/intel/ice/ice_common.h |  6 +-
 drivers/net/ethernet/intel/ice/ice_dpll.h   |  6 +-
 drivers/net/ethernet/intel/ice/ice_lib.c    |  6 +-
 drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 68 +--------------
 drivers/net/ethernet/intel/ice/ice_ptp_hw.h |  4 -
 7 files changed, 91 insertions(+), 98 deletions(-)

base-commit: 2fcb79a1962e88ff10552384fb8164fde815ccd3

Signature · 6 lines
2.41.0.1.g9857a21e0017.dirty

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#1 lore raw

PATCH 1/4 ice: don't compile ice_dpll.c if CONFIG_PTP_1588_CLOCK is disabled

The ice_dpll.c file was recently merged with support for the DPLL interface. This feature as currently written in the ice driver depends on the PTP infrastructure and causes compilation failures if CONFIG_PTP_1588_CLOCK is disabled:

ld: vmlinux.o: in function `ice_dpll_init_info_direct_pins':
ice_dpll.c:(.text+0x894167): undefined reference to `ice_cgu_get_pin_freq_supp'
ld: ice_dpll.c:(.text+0x894197): undefined reference to `ice_cgu_get_pin_name'
ld: ice_dpll.c:(.text+0x8941a8): undefined reference to `ice_cgu_get_pin_type'
ld: vmlinux.o: in function `ice_dpll_update_state':
ice_dpll.c:(.text+0x894494): undefined reference to `ice_get_cgu_state'
ld: vmlinux.o: in function `ice_dpll_init':
(.text+0x8953d5): undefined reference to `ice_get_cgu_rclk_pin_info'

This occurs because the ice_dpll.c file is compiled unconditionally, but it depends on functions in ice_ptp_hw.c which is only compiled with CONFIG_PTP_1588_CLOCK. It might be possible to break this dependency and expose those functions without CONFIG_PTP_1588_CLOCK, but that is not clear to me.

For now, simply fix the Makefile to compile ice_dpll.c only when we have PTP support enabled. Also update the ice_dpll.h header to provide no-op fallbacks for enabling and disabling the DPLL feature in this case.

---
 drivers/net/ethernet/intel/ice/Makefile   | 3 +--
 drivers/net/ethernet/intel/ice/ice_dpll.h | 6 +++++-
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/Makefile +1 -2
index 2bdd020b7939..8757bec23fb3 100644
@@ -35,7 +35,6 @@ ice-y := ice_main.o	\
 	 ice_ethtool.o  \
 	 ice_repr.o	\
 	 ice_tc_lib.o	\
-	 ice_dpll.o	\
 	 ice_fwlog.o	\
 	 ice_debugfs.o
 ice-$(CONFIG_PCI_IOV) +=	\
@@ -46,7 +45,7 @@ ice-$(CONFIG_PCI_IOV) +=	\
 	ice_vf_mbx.o		\
 	ice_vf_vsi_vlan_ops.o	\
 	ice_vf_lib.o
-ice-$(CONFIG_PTP_1588_CLOCK) += ice_ptp.o ice_ptp_hw.o
+ice-$(CONFIG_PTP_1588_CLOCK) += ice_ptp.o ice_ptp_hw.o ice_dpll.o
 ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_nl.o ice_dcb_lib.o
 ice-$(CONFIG_RFS_ACCEL) += ice_arfs.o
 ice-$(CONFIG_XDP_SOCKETS) += ice_xsk.o
drivers/net/ethernet/intel/ice/ice_dpll.h +5 -1
index 9c524c4bdfd7..2dfe764b81e1 100644
@@ -97,8 +97,12 @@ struct ice_dplls {
 	s32 output_phase_adj_max;
 };
 
+#if IS_ENABLED(CONFIG_PTP_1588_CLOCK)
 void ice_dpll_init(struct ice_pf *pf);
-
 void ice_dpll_deinit(struct ice_pf *pf);
+#else
+static inline void ice_dpll_init(struct ice_pf *pf) { }
+static inline void ice_dpll_deinit(struct ice_pf *pf) { }
+#endif
 
 #endif
Signature · 6 lines
2.41.0.1.g9857a21e0017.dirty

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#2 lore raw

PATCH 2/4 ice: move netlist check functions to ice_common.c

In reply to Jacob Keller

The ice_ptp_hw.c file has a few functions which check for whether the device netlist has a node indicating hardware support for certain features. These checks don't really make sense to be in ice_ptp_hw.c. In addition, their names could be confusing as they just say "is_present" but really are checking the netlist.

Additionally, these functions are only compiled into the ice module if CONFIG_PTP_1588_CLOCK is enabled. They are used in ice_lib.c which is unconditionally compiled, so this can result in build errors if the PTP support is disabled:

ld: vmlinux.o: in function `ice_init_feature_support':
(.text+0x8702b8): undefined reference to `ice_is_phy_rclk_present'
ld: (.text+0x8702cd): undefined reference to `ice_is_cgu_present'
ld: (.text+0x8702d9): undefined reference to `ice_is_clock_mux_present_e810t'

To fix this, we need to define these functions outside of ice_ptp.c or ice_ptp_hw.c.

The ice_common.c already hace ice_is_gps_in_netlist. Move the similar functions in ice_ptp_hw.c into ice_common.c, renaming them to use the postfix "_in_netlist" to match the GPS check. Where appropriate, also drop the _e810t postfix as well.

This also makes the ice_find_netlist_node only called from within ice_common.c, so its safe to mark it static and stop declaring it in the ice_common.h header.

---
 drivers/net/ethernet/intel/ice/ice_common.c | 66 ++++++++++++++++++++-
 drivers/net/ethernet/intel/ice/ice_common.h |  6 +-
 drivers/net/ethernet/intel/ice/ice_lib.c    |  6 +-
 drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 66 ---------------------
 drivers/net/ethernet/intel/ice/ice_ptp_hw.h |  3 -
 5 files changed, 69 insertions(+), 78 deletions(-)
drivers/net/ethernet/intel/ice/ice_common.c +63 -3
index bcf7d9c56248..12c09374c2be 100644
@@ -477,9 +477,8 @@ ice_aq_get_netlist_node(struct ice_hw *hw, struct ice_aqc_get_link_topo *cmd,
  * netlist. When found ICE_SUCCESS is returned, ICE_ERR_DOES_NOT_EXIST
  * otherwise. If node_handle provided, it would be set to found node handle.
  */
-int
-ice_find_netlist_node(struct ice_hw *hw, u8 node_type_ctx, u8 node_part_number,
-		      u16 *node_handle)
+static int ice_find_netlist_node(struct ice_hw *hw, u8 node_type_ctx,
+				 u8 node_part_number, u16 *node_handle)
 {
 	struct ice_aqc_get_link_topo cmd;
 	u8 rec_node_part_number;
@@ -2552,6 +2551,67 @@ bool ice_is_pf_c827(struct ice_hw *hw)
 	return false;
 }
 
+/**
+ * ice_is_phy_rclk_in_netlist
+ * @hw: pointer to the hw struct
+ *
+ * Check if the PHY Recovered Clock device is present in the netlist
+ */
+bool ice_is_phy_rclk_in_netlist(struct ice_hw *hw)
+{
+	if (ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
+				  ICE_AQC_GET_LINK_TOPO_NODE_NR_C827, NULL) &&
+	    ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
+				  ICE_AQC_GET_LINK_TOPO_NODE_NR_E822_PHY, NULL))
+		return false;
+
+	return true;
+}
+
+/**
+ * ice_is_clock_mux_in_netlist
+ * @hw: pointer to the hw struct
+ *
+ * Check if the Clock Multiplexer device is present in the netlist
+ */
+bool ice_is_clock_mux_in_netlist(struct ice_hw *hw)
+{
+	if (ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_MUX,
+				  ICE_AQC_GET_LINK_TOPO_NODE_NR_GEN_CLK_MUX,
+				  NULL))
+		return false;
+
+	return true;
+}
+
+/**
+ * ice_is_cgu_in_netlist - check for CGU presence
+ * @hw: pointer to the hw struct
+ *
+ * Check if the Clock Generation Unit (CGU) device is present in the netlist.
+ * Save the CGU part number in the hw structure for later use.
+ * Return:
+ * * true - cgu is present
+ * * false - cgu is not present
+ */
+bool ice_is_cgu_in_netlist(struct ice_hw *hw)
+{
+	if (!ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
+				   ICE_AQC_GET_LINK_TOPO_NODE_NR_ZL30632_80032,
+				   NULL)) {
+		hw->cgu_part_number = ICE_AQC_GET_LINK_TOPO_NODE_NR_ZL30632_80032;
+		return true;
+	} else if (!ice_find_netlist_node(hw,
+					  ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
+					  ICE_AQC_GET_LINK_TOPO_NODE_NR_SI5383_5384,
+					  NULL)) {
+		hw->cgu_part_number = ICE_AQC_GET_LINK_TOPO_NODE_NR_SI5383_5384;
+		return true;
+	}
+
+	return false;
+}
+
 /**
  * ice_is_gps_in_netlist
  * @hw: pointer to the hw struct
drivers/net/ethernet/intel/ice/ice_common.h +3 -3
index 59969f702dae..4a75c0c89301 100644
@@ -93,11 +93,11 @@ ice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode,
 		    struct ice_aqc_get_phy_caps_data *caps,
 		    struct ice_sq_cd *cd);
 bool ice_is_pf_c827(struct ice_hw *hw);
+bool ice_is_phy_rclk_in_netlist(struct ice_hw *hw);
+bool ice_is_clock_mux_in_netlist(struct ice_hw *hw);
+bool ice_is_cgu_in_netlist(struct ice_hw *hw);
 bool ice_is_gps_in_netlist(struct ice_hw *hw);
 int
-ice_find_netlist_node(struct ice_hw *hw, u8 node_type_ctx, u8 node_part_number,
-		      u16 *node_handle);
-int
 ice_aq_get_netlist_node(struct ice_hw *hw, struct ice_aqc_get_link_topo *cmd,
 			u8 *node_part_number, u16 *node_handle);
 int
drivers/net/ethernet/intel/ice/ice_lib.c +3 -3
index b96fbf76ca6d..6e70d678f323 100644
@@ -3995,14 +3995,14 @@ void ice_init_feature_support(struct ice_pf *pf)
 	case ICE_DEV_ID_E810_XXV_QSFP:
 	case ICE_DEV_ID_E810_XXV_SFP:
 		ice_set_feature_support(pf, ICE_F_DSCP);
-		if (ice_is_phy_rclk_present(&pf->hw))
+		if (ice_is_phy_rclk_in_netlist(&pf->hw))
 			ice_set_feature_support(pf, ICE_F_PHY_RCLK);
 		/* If we don't own the timer - don't enable other caps */
 		if (!ice_pf_src_tmr_owned(pf))
 			break;
-		if (ice_is_cgu_present(&pf->hw))
+		if (ice_is_cgu_in_netlist(&pf->hw))
 			ice_set_feature_support(pf, ICE_F_CGU);
-		if (ice_is_clock_mux_present_e810t(&pf->hw))
+		if (ice_is_clock_mux_in_netlist(&pf->hw))
 			ice_set_feature_support(pf, ICE_F_SMA_CTRL);
 		if (ice_gnss_is_gps_present(&pf->hw))
 			ice_set_feature_support(pf, ICE_F_GNSS);
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +0 -66

78 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_ptp_hw.h +0 -3
index 6f277e7b06b9..18a993134826 100644
@@ -271,10 +271,7 @@ int ice_read_sma_ctrl_e810t(struct ice_hw *hw, u8 *data);
 int ice_write_sma_ctrl_e810t(struct ice_hw *hw, u8 data);
 int ice_read_pca9575_reg_e810t(struct ice_hw *hw, u8 offset, u8 *data);
 bool ice_is_pca9575_present(struct ice_hw *hw);
-bool ice_is_phy_rclk_present(struct ice_hw *hw);
-bool ice_is_clock_mux_present_e810t(struct ice_hw *hw);
 int ice_get_pf_c827_idx(struct ice_hw *hw, u8 *idx);
-bool ice_is_cgu_present(struct ice_hw *hw);
 enum dpll_pin_type ice_cgu_get_pin_type(struct ice_hw *hw, u8 pin, bool input);
 struct dpll_pin_frequency *
 ice_cgu_get_pin_freq_supp(struct ice_hw *hw, u8 pin, bool input, u8 *num);
Signature · 6 lines
2.41.0.1.g9857a21e0017.dirty

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
maintainer
#3 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next 2/4] ice: move netlist check functions to ice_common.c

Quoted 11 lines · Jacob Keller

The ice_ptp_hw.c file has a few functions which check for whether the device netlist has a node indicating hardware support for certain features. These checks don't really make sense to be in ice_ptp_hw.c. In addition, their names could be confusing as they just say "is_present" but really are checking the netlist.

Additionally, these functions are only compiled into the ice module if CONFIG_PTP_1588_CLOCK is enabled. They are used in ice_lib.c which is unconditionally compiled, so this can result in build errors if the PTP support is disabled:

Quoted 5 lines

ld: vmlinux.o: in function `ice_init_feature_support':
(.text+0x8702b8): undefined reference to `ice_is_phy_rclk_present'
ld: (.text+0x8702cd): undefined reference to `ice_is_cgu_present'
ld: (.text+0x8702d9): undefined reference to `ice_is_clock_mux_present_e810t'

You have two commits that combined are fixing a build error, one of which is realatively small (1st in this series). Could you please combine them, if only to provide Fixes: tag?

Quoted 4 lines

To fix this, we need to define these functions outside of ice_ptp.c or ice_ptp_hw.c.

The ice_common.c already hace ice_is_gps_in_netlist. Move the similar

hace :)

Codewise it looks good, I recall some of the code already :D

Quoted 231 lines

functions in ice_ptp_hw.c into ice_common.c, renaming them to use the postfix "_in_netlist" to match the GPS check. Where appropriate, also drop the _e810t postfix as well.

This also makes the ice_find_netlist_node only called from within ice_common.c, so its safe to mark it static and stop declaring it in the ice_common.h header.

---
  drivers/net/ethernet/intel/ice/ice_common.c | 66 ++++++++++++++++++++-
  drivers/net/ethernet/intel/ice/ice_common.h |  6 +-
  drivers/net/ethernet/intel/ice/ice_lib.c    |  6 +-
  drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 66 ---------------------
  drivers/net/ethernet/intel/ice/ice_ptp_hw.h |  3 -
  5 files changed, 69 insertions(+), 78 deletions(-)
drivers/net/ethernet/intel/ice/ice_common.c +63 -3
index bcf7d9c56248..12c09374c2be 100644
@@ -477,9 +477,8 @@ ice_aq_get_netlist_node(struct ice_hw *hw, struct ice_aqc_get_link_topo *cmd,
   * netlist. When found ICE_SUCCESS is returned, ICE_ERR_DOES_NOT_EXIST
   * otherwise. If node_handle provided, it would be set to found node handle.
   */
-int
-ice_find_netlist_node(struct ice_hw *hw, u8 node_type_ctx, u8 node_part_number,
-		      u16 *node_handle)
+static int ice_find_netlist_node(struct ice_hw *hw, u8 node_type_ctx,
+				 u8 node_part_number, u16 *node_handle)
  {
  	struct ice_aqc_get_link_topo cmd;
  	u8 rec_node_part_number;
@@ -2552,6 +2551,67 @@ bool ice_is_pf_c827(struct ice_hw *hw)
  	return false;
  }
 
+/**
+ * ice_is_phy_rclk_in_netlist
+ * @hw: pointer to the hw struct
+ *
+ * Check if the PHY Recovered Clock device is present in the netlist
+ */
+bool ice_is_phy_rclk_in_netlist(struct ice_hw *hw)
+{
+	if (ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
+				  ICE_AQC_GET_LINK_TOPO_NODE_NR_C827, NULL) &&
+	    ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
+				  ICE_AQC_GET_LINK_TOPO_NODE_NR_E822_PHY, NULL))
+		return false;
+
+	return true;
+}
+
+/**
+ * ice_is_clock_mux_in_netlist
+ * @hw: pointer to the hw struct
+ *
+ * Check if the Clock Multiplexer device is present in the netlist
+ */
+bool ice_is_clock_mux_in_netlist(struct ice_hw *hw)
+{
+	if (ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_MUX,
+				  ICE_AQC_GET_LINK_TOPO_NODE_NR_GEN_CLK_MUX,
+				  NULL))
+		return false;
+
+	return true;
+}
+
+/**
+ * ice_is_cgu_in_netlist - check for CGU presence
+ * @hw: pointer to the hw struct
+ *
+ * Check if the Clock Generation Unit (CGU) device is present in the netlist.
+ * Save the CGU part number in the hw structure for later use.
+ * Return:
+ * * true - cgu is present
+ * * false - cgu is not present
+ */
+bool ice_is_cgu_in_netlist(struct ice_hw *hw)
+{
+	if (!ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
+				   ICE_AQC_GET_LINK_TOPO_NODE_NR_ZL30632_80032,
+				   NULL)) {
+		hw->cgu_part_number = ICE_AQC_GET_LINK_TOPO_NODE_NR_ZL30632_80032;
+		return true;
+	} else if (!ice_find_netlist_node(hw,
+					  ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
+					  ICE_AQC_GET_LINK_TOPO_NODE_NR_SI5383_5384,
+					  NULL)) {
+		hw->cgu_part_number = ICE_AQC_GET_LINK_TOPO_NODE_NR_SI5383_5384;
+		return true;
+	}
+
+	return false;
+}
+
  /**
   * ice_is_gps_in_netlist
   * @hw: pointer to the hw struct
drivers/net/ethernet/intel/ice/ice_common.h +3 -3
index 59969f702dae..4a75c0c89301 100644
@@ -93,11 +93,11 @@ ice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode,
  		    struct ice_aqc_get_phy_caps_data *caps,
  		    struct ice_sq_cd *cd);
  bool ice_is_pf_c827(struct ice_hw *hw);
+bool ice_is_phy_rclk_in_netlist(struct ice_hw *hw);
+bool ice_is_clock_mux_in_netlist(struct ice_hw *hw);
+bool ice_is_cgu_in_netlist(struct ice_hw *hw);
  bool ice_is_gps_in_netlist(struct ice_hw *hw);
  int
-ice_find_netlist_node(struct ice_hw *hw, u8 node_type_ctx, u8 node_part_number,
-		      u16 *node_handle);
-int
  ice_aq_get_netlist_node(struct ice_hw *hw, struct ice_aqc_get_link_topo *cmd,
  			u8 *node_part_number, u16 *node_handle);
  int
drivers/net/ethernet/intel/ice/ice_lib.c +3 -3
index b96fbf76ca6d..6e70d678f323 100644
@@ -3995,14 +3995,14 @@ void ice_init_feature_support(struct ice_pf *pf)
  	case ICE_DEV_ID_E810_XXV_QSFP:
  	case ICE_DEV_ID_E810_XXV_SFP:
  		ice_set_feature_support(pf, ICE_F_DSCP);
-		if (ice_is_phy_rclk_present(&pf->hw))
+		if (ice_is_phy_rclk_in_netlist(&pf->hw))
  			ice_set_feature_support(pf, ICE_F_PHY_RCLK);
  		/* If we don't own the timer - don't enable other caps */
  		if (!ice_pf_src_tmr_owned(pf))
  			break;
-		if (ice_is_cgu_present(&pf->hw))
+		if (ice_is_cgu_in_netlist(&pf->hw))
  			ice_set_feature_support(pf, ICE_F_CGU);
-		if (ice_is_clock_mux_present_e810t(&pf->hw))
+		if (ice_is_clock_mux_in_netlist(&pf->hw))
  			ice_set_feature_support(pf, ICE_F_SMA_CTRL);
  		if (ice_gnss_is_gps_present(&pf->hw))
  			ice_set_feature_support(pf, ICE_F_GNSS);
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +0 -66
index 5619644d5da7..882dfdad0021 100644
@@ -3556,45 +3556,6 @@ int ice_clear_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx)
  	}
  }
 
-/**
- * ice_is_phy_rclk_present - check recovered clk presence
- * @hw: pointer to the hw struct
- *
- * Check if the PHY Recovered Clock device is present in the netlist
- * Return:
- * * true - device found in netlist
- * * false - device not found
- */
-bool ice_is_phy_rclk_present(struct ice_hw *hw)
-{
-	if (ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
-				  ICE_AQC_GET_LINK_TOPO_NODE_NR_C827, NULL) &&
-	    ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
-				  ICE_AQC_GET_LINK_TOPO_NODE_NR_E822_PHY, NULL))
-		return false;
-
-	return true;
-}
-
-/**
- * ice_is_clock_mux_present_e810t
- * @hw: pointer to the hw struct
- *
- * Check if the Clock Multiplexer device is present in the netlist
- * Return:
- * * true - device found in netlist
- * * false - device not found
- */
-bool ice_is_clock_mux_present_e810t(struct ice_hw *hw)
-{
-	if (ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_MUX,
-				  ICE_AQC_GET_LINK_TOPO_NODE_NR_GEN_CLK_MUX,
-				  NULL))
-		return false;
-
-	return true;
-}
-
  /**
   * ice_get_pf_c827_idx - find and return the C827 index for the current pf
   * @hw: pointer to the hw struct
@@ -3708,33 +3669,6 @@ int ice_get_phy_tx_tstamp_ready(struct ice_hw *hw, u8 block, u64 *tstamp_ready)
  	}
  }
 
-/**
- * ice_is_cgu_present - check for CGU presence
- * @hw: pointer to the hw struct
- *
- * Check if the Clock Generation Unit (CGU) device is present in the netlist
- * Return:
- * * true - cgu is present
- * * false - cgu is not present
- */
-bool ice_is_cgu_present(struct ice_hw *hw)
-{
-	if (!ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
-				   ICE_AQC_GET_LINK_TOPO_NODE_NR_ZL30632_80032,
-				   NULL)) {
-		hw->cgu_part_number = ICE_AQC_GET_LINK_TOPO_NODE_NR_ZL30632_80032;
-		return true;
-	} else if (!ice_find_netlist_node(hw,
-					  ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
-					  ICE_AQC_GET_LINK_TOPO_NODE_NR_SI5383_5384,
-					  NULL)) {
-		hw->cgu_part_number = ICE_AQC_GET_LINK_TOPO_NODE_NR_SI5383_5384;
-		return true;
-	}
-
-	return false;
-}
-
  /**
   * ice_cgu_get_pin_desc_e823 - get pin description array
   * @hw: pointer to the hw struct
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +0 -0
index 6f277e7b06b9..18a993134826 100644

drivers/net/ethernet/intel/ice/ice_ptp_hw.h int ice_read_sma_ctrl_e810t(struct ice_hw *hw, u8 *data); · line 277

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +0 -3
@@ -271,10 +271,7 @@ int ice_read_sma_ctrl_e810t(struct ice_hw *hw, u8 *data);
  int ice_write_sma_ctrl_e810t(struct ice_hw *hw, u8 data);
  int ice_read_pca9575_reg_e810t(struct ice_hw *hw, u8 offset, u8 *data);
  bool ice_is_pca9575_present(struct ice_hw *hw);
-bool ice_is_phy_rclk_present(struct ice_hw *hw);
-bool ice_is_clock_mux_present_e810t(struct ice_hw *hw);
  int ice_get_pf_c827_idx(struct ice_hw *hw, u8 *idx);
-bool ice_is_cgu_present(struct ice_hw *hw);
  enum dpll_pin_type ice_cgu_get_pin_type(struct ice_hw *hw, u8 pin, bool input);
  struct dpll_pin_frequency *
  ice_cgu_get_pin_freq_supp(struct ice_hw *hw, u8 pin, bool input, u8 *num);

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#4 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next 2/4] ice: move netlist check functions to ice_common.c

Quoted 18 lines · Przemek Kitszel
Quoted 11 lines · Jacob Keller

The ice_ptp_hw.c file has a few functions which check for whether the device netlist has a node indicating hardware support for certain features. These checks don't really make sense to be in ice_ptp_hw.c. In addition, their names could be confusing as they just say "is_present" but really are checking the netlist.

Additionally, these functions are only compiled into the ice module if CONFIG_PTP_1588_CLOCK is enabled. They are used in ice_lib.c which is unconditionally compiled, so this can result in build errors if the PTP support is disabled:

Quoted 5 lines

ld: vmlinux.o: in function `ice_init_feature_support':
(.text+0x8702b8): undefined reference to `ice_is_phy_rclk_present'
ld: (.text+0x8702cd): undefined reference to `ice_is_cgu_present'
ld: (.text+0x8702d9): undefined reference to `ice_is_clock_mux_present_e810t'

Quoted 4 lines

You have two commits that combined are fixing a build error, one of which is realatively small (1st in this series). Could you please combine them, if only to provide Fixes: tag?

Sure I can squash these and add Fixes tag(s).

Quoted 6 lines
Quoted 4 lines

To fix this, we need to define these functions outside of ice_ptp.c or ice_ptp_hw.c.

The ice_common.c already hace ice_is_gps_in_netlist. Move the similar

hace :)

Good catch.

Quoted 3 lines

Codewise it looks good, I recall some of the code already :D

Yea, I sent a lot of the same code as part of another series a few weeks ago but didn't notice the conflicts with DPLL, and the DPLL series landed first. This aligns with the version I proposed.

Quoted 233 lines
Quoted 233 lines

functions in ice_ptp_hw.c into ice_common.c, renaming them to use the postfix "_in_netlist" to match the GPS check. Where appropriate, also drop the _e810t postfix as well.

This also makes the ice_find_netlist_node only called from within ice_common.c, so its safe to mark it static and stop declaring it in the ice_common.h header.

---
  drivers/net/ethernet/intel/ice/ice_common.c | 66 ++++++++++++++++++++-
  drivers/net/ethernet/intel/ice/ice_common.h |  6 +-
  drivers/net/ethernet/intel/ice/ice_lib.c    |  6 +-
  drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 66 ---------------------
  drivers/net/ethernet/intel/ice/ice_ptp_hw.h |  3 -
  5 files changed, 69 insertions(+), 78 deletions(-)
drivers/net/ethernet/intel/ice/ice_common.c +63 -3
index bcf7d9c56248..12c09374c2be 100644
@@ -477,9 +477,8 @@ ice_aq_get_netlist_node(struct ice_hw *hw, struct ice_aqc_get_link_topo *cmd,
   * netlist. When found ICE_SUCCESS is returned, ICE_ERR_DOES_NOT_EXIST
   * otherwise. If node_handle provided, it would be set to found node handle.
   */
-int
-ice_find_netlist_node(struct ice_hw *hw, u8 node_type_ctx, u8 node_part_number,
-		      u16 *node_handle)
+static int ice_find_netlist_node(struct ice_hw *hw, u8 node_type_ctx,
+				 u8 node_part_number, u16 *node_handle)
  {
  	struct ice_aqc_get_link_topo cmd;
  	u8 rec_node_part_number;
@@ -2552,6 +2551,67 @@ bool ice_is_pf_c827(struct ice_hw *hw)
  	return false;
  }
 
+/**
+ * ice_is_phy_rclk_in_netlist
+ * @hw: pointer to the hw struct
+ *
+ * Check if the PHY Recovered Clock device is present in the netlist
+ */
+bool ice_is_phy_rclk_in_netlist(struct ice_hw *hw)
+{
+	if (ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
+				  ICE_AQC_GET_LINK_TOPO_NODE_NR_C827, NULL) &&
+	    ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
+				  ICE_AQC_GET_LINK_TOPO_NODE_NR_E822_PHY, NULL))
+		return false;
+
+	return true;
+}
+
+/**
+ * ice_is_clock_mux_in_netlist
+ * @hw: pointer to the hw struct
+ *
+ * Check if the Clock Multiplexer device is present in the netlist
+ */
+bool ice_is_clock_mux_in_netlist(struct ice_hw *hw)
+{
+	if (ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_MUX,
+				  ICE_AQC_GET_LINK_TOPO_NODE_NR_GEN_CLK_MUX,
+				  NULL))
+		return false;
+
+	return true;
+}
+
+/**
+ * ice_is_cgu_in_netlist - check for CGU presence
+ * @hw: pointer to the hw struct
+ *
+ * Check if the Clock Generation Unit (CGU) device is present in the netlist.
+ * Save the CGU part number in the hw structure for later use.
+ * Return:
+ * * true - cgu is present
+ * * false - cgu is not present
+ */
+bool ice_is_cgu_in_netlist(struct ice_hw *hw)
+{
+	if (!ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
+				   ICE_AQC_GET_LINK_TOPO_NODE_NR_ZL30632_80032,
+				   NULL)) {
+		hw->cgu_part_number = ICE_AQC_GET_LINK_TOPO_NODE_NR_ZL30632_80032;
+		return true;
+	} else if (!ice_find_netlist_node(hw,
+					  ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
+					  ICE_AQC_GET_LINK_TOPO_NODE_NR_SI5383_5384,
+					  NULL)) {
+		hw->cgu_part_number = ICE_AQC_GET_LINK_TOPO_NODE_NR_SI5383_5384;
+		return true;
+	}
+
+	return false;
+}
+
  /**
   * ice_is_gps_in_netlist
   * @hw: pointer to the hw struct
drivers/net/ethernet/intel/ice/ice_common.h +3 -3
index 59969f702dae..4a75c0c89301 100644
@@ -93,11 +93,11 @@ ice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode,
  		    struct ice_aqc_get_phy_caps_data *caps,
  		    struct ice_sq_cd *cd);
  bool ice_is_pf_c827(struct ice_hw *hw);
+bool ice_is_phy_rclk_in_netlist(struct ice_hw *hw);
+bool ice_is_clock_mux_in_netlist(struct ice_hw *hw);
+bool ice_is_cgu_in_netlist(struct ice_hw *hw);
  bool ice_is_gps_in_netlist(struct ice_hw *hw);
  int
-ice_find_netlist_node(struct ice_hw *hw, u8 node_type_ctx, u8 node_part_number,
-		      u16 *node_handle);
-int
  ice_aq_get_netlist_node(struct ice_hw *hw, struct ice_aqc_get_link_topo *cmd,
  			u8 *node_part_number, u16 *node_handle);
  int
drivers/net/ethernet/intel/ice/ice_lib.c +3 -3
index b96fbf76ca6d..6e70d678f323 100644
@@ -3995,14 +3995,14 @@ void ice_init_feature_support(struct ice_pf *pf)
  	case ICE_DEV_ID_E810_XXV_QSFP:
  	case ICE_DEV_ID_E810_XXV_SFP:
  		ice_set_feature_support(pf, ICE_F_DSCP);
-		if (ice_is_phy_rclk_present(&pf->hw))
+		if (ice_is_phy_rclk_in_netlist(&pf->hw))
  			ice_set_feature_support(pf, ICE_F_PHY_RCLK);
  		/* If we don't own the timer - don't enable other caps */
  		if (!ice_pf_src_tmr_owned(pf))
  			break;
-		if (ice_is_cgu_present(&pf->hw))
+		if (ice_is_cgu_in_netlist(&pf->hw))
  			ice_set_feature_support(pf, ICE_F_CGU);
-		if (ice_is_clock_mux_present_e810t(&pf->hw))
+		if (ice_is_clock_mux_in_netlist(&pf->hw))
  			ice_set_feature_support(pf, ICE_F_SMA_CTRL);
  		if (ice_gnss_is_gps_present(&pf->hw))
  			ice_set_feature_support(pf, ICE_F_GNSS);
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +0 -66
index 5619644d5da7..882dfdad0021 100644
@@ -3556,45 +3556,6 @@ int ice_clear_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx)
  	}
  }
 
-/**
- * ice_is_phy_rclk_present - check recovered clk presence
- * @hw: pointer to the hw struct
- *
- * Check if the PHY Recovered Clock device is present in the netlist
- * Return:
- * * true - device found in netlist
- * * false - device not found
- */
-bool ice_is_phy_rclk_present(struct ice_hw *hw)
-{
-	if (ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
-				  ICE_AQC_GET_LINK_TOPO_NODE_NR_C827, NULL) &&
-	    ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
-				  ICE_AQC_GET_LINK_TOPO_NODE_NR_E822_PHY, NULL))
-		return false;
-
-	return true;
-}
-
-/**
- * ice_is_clock_mux_present_e810t
- * @hw: pointer to the hw struct
- *
- * Check if the Clock Multiplexer device is present in the netlist
- * Return:
- * * true - device found in netlist
- * * false - device not found
- */
-bool ice_is_clock_mux_present_e810t(struct ice_hw *hw)
-{
-	if (ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_MUX,
-				  ICE_AQC_GET_LINK_TOPO_NODE_NR_GEN_CLK_MUX,
-				  NULL))
-		return false;
-
-	return true;
-}
-
  /**
   * ice_get_pf_c827_idx - find and return the C827 index for the current pf
   * @hw: pointer to the hw struct
@@ -3708,33 +3669,6 @@ int ice_get_phy_tx_tstamp_ready(struct ice_hw *hw, u8 block, u64 *tstamp_ready)
  	}
  }
 
-/**
- * ice_is_cgu_present - check for CGU presence
- * @hw: pointer to the hw struct
- *
- * Check if the Clock Generation Unit (CGU) device is present in the netlist
- * Return:
- * * true - cgu is present
- * * false - cgu is not present
- */
-bool ice_is_cgu_present(struct ice_hw *hw)
-{
-	if (!ice_find_netlist_node(hw, ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
-				   ICE_AQC_GET_LINK_TOPO_NODE_NR_ZL30632_80032,
-				   NULL)) {
-		hw->cgu_part_number = ICE_AQC_GET_LINK_TOPO_NODE_NR_ZL30632_80032;
-		return true;
-	} else if (!ice_find_netlist_node(hw,
-					  ICE_AQC_LINK_TOPO_NODE_TYPE_CLK_CTRL,
-					  ICE_AQC_GET_LINK_TOPO_NODE_NR_SI5383_5384,
-					  NULL)) {
-		hw->cgu_part_number = ICE_AQC_GET_LINK_TOPO_NODE_NR_SI5383_5384;
-		return true;
-	}
-
-	return false;
-}
-
  /**
   * ice_cgu_get_pin_desc_e823 - get pin description array
   * @hw: pointer to the hw struct
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +0 -0
index 6f277e7b06b9..18a993134826 100644
@@ -271,10 +271,7 @@ int ice_read_sma_ctrl_e810t(struct ice_hw *hw, u8 *data);
  int ice_write_sma_ctrl_e810t(struct ice_hw *hw, u8 data);
  int ice_read_pca9575_reg_e810t(struct ice_hw *hw, u8 offset, u8 *data);
Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_ptp_hw.h int ice_read_sma_ctrl_e810t(struct ice_hw *hw, u8 *data); · line 277

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +0 -3
  bool ice_is_pca9575_present(struct ice_hw *hw);
-bool ice_is_phy_rclk_present(struct ice_hw *hw);
-bool ice_is_clock_mux_present_e810t(struct ice_hw *hw);
  int ice_get_pf_c827_idx(struct ice_hw *hw, u8 *idx);
-bool ice_is_cgu_present(struct ice_hw *hw);
  enum dpll_pin_type ice_cgu_get_pin_type(struct ice_hw *hw, u8 pin, bool input);
  struct dpll_pin_frequency *
  ice_cgu_get_pin_freq_supp(struct ice_hw *hw, u8 pin, bool input, u8 *num);

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#5 lore raw

PATCH 3/4 ice: make ice_get_pf_c827_idx static

In reply to Jacob Keller

The ice_get_pf_c827_idx function is only called inside of ice_ptp_hw.c, so there is no reason to export it. Mark it static and remove the declaration from ice_ptp_hw.h

---
 drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 2 +-
 drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +1 -1
index 882dfdad0021..0167e0577a55 100644
@@ -3564,7 +3564,7 @@ int ice_clear_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx)
  * * 0 - success
  * * negative - failure
  */
-int ice_get_pf_c827_idx(struct ice_hw *hw, u8 *idx)
+static int ice_get_pf_c827_idx(struct ice_hw *hw, u8 *idx)
 {
 	struct ice_aqc_get_link_topo cmd;
 	u8 node_part_number;
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +0 -1
index 18a993134826..36aeeef99ec0 100644
@@ -271,7 +271,6 @@ int ice_read_sma_ctrl_e810t(struct ice_hw *hw, u8 *data);
 int ice_write_sma_ctrl_e810t(struct ice_hw *hw, u8 data);
 int ice_read_pca9575_reg_e810t(struct ice_hw *hw, u8 offset, u8 *data);
 bool ice_is_pca9575_present(struct ice_hw *hw);
-int ice_get_pf_c827_idx(struct ice_hw *hw, u8 *idx);
 enum dpll_pin_type ice_cgu_get_pin_type(struct ice_hw *hw, u8 pin, bool input);
 struct dpll_pin_frequency *
 ice_cgu_get_pin_freq_supp(struct ice_hw *hw, u8 pin, bool input, u8 *num);
Signature · 6 lines
2.41.0.1.g9857a21e0017.dirty

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Tested-by on v1 3/4
#6 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next 3/4] ice: make ice_get_pf_c827_idx static

Quoted 11 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, September 20, 2023 5:05 AM
To: Intel Wired LAN <[email protected]>
Cc: Keller, Jacob E <[email protected]>; Nguyen, Anthony L <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next 3/4] ice: make ice_get_pf_c827_idx static

The ice_get_pf_c827_idx function is only called inside of ice_ptp_hw.c, so there is no reason to export it. Mark it static and remove the declaration from ice_ptp_hw.h

Quoted 6 lines
---
 drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 2 +-
 drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#7 lore raw

PATCH 4/4 ice: cleanup ice_find_netlist_node

In reply to Jacob Keller

The ice_find_netlist_node function was introduced in commit 8a3a565ff210 ("ice: add admin commands to access cgu configuration"). Variations of this function were reviewed concurrently on both intel-wired-lan[1][2], and netdev [3][4]

[1]: https://lore.kernel.org/intel-wired-lan/[email protected]/
[2]: https://lore.kernel.org/intel-wired-lan/[email protected]/
[3]: https://lore.kernel.org/netdev/[email protected]/
[4]: https://lore.kernel.org/netdev/[email protected]/

The variant I posted had a few changes due to review feedback which were never incorporated into the DPLL series:

* Replace the references to ancient and long removed ICE_SUCCESS and ICE_ERR_DOES_NOT_EXIST status codes in the function comment.

* Return -ENOENT instead of -ENOTBLK, as a more common way to indicate that an entry doesn't exist.

* Avoid the use of memset() and use simple static initialization for the cmd variable.

* Use FIELD_PREP to assign the node_type_ctx.

* Remove an unnecessary local variable to keep track of rec_node_handle, just pass the node_handle pointer directly into ice_aq_get_netlist_node.

---
 drivers/net/ethernet/intel/ice/ice_common.c | 30 ++++++++++-----------
 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/net/ethernet/intel/ice/ice_common.c +15 -15
index 12c09374c2be..d4e259b816b9 100644
@@ -473,41 +473,41 @@ ice_aq_get_netlist_node(struct ice_hw *hw, struct ice_aqc_get_link_topo *cmd,
  * @node_part_number: node part number to look for
  * @node_handle: output parameter if node found - optional
  *
- * Find and return the node handle for a given node type and part number in the
- * netlist. When found ICE_SUCCESS is returned, ICE_ERR_DOES_NOT_EXIST
- * otherwise. If node_handle provided, it would be set to found node handle.
+ * Scan the netlist for a node handle of the given node type and part number.
+ *
+ * If node_handle is non-NULL it will be modified on function exit. It is only
+ * valid if the function returns zero, and should be ignored on any non-zero
+ * return value.
+ *
+ * Returns: 0 if the node is found, -ENOENT if no handle was found, and
+ * a negative error code on failure to access the AQ.
  */
 static int ice_find_netlist_node(struct ice_hw *hw, u8 node_type_ctx,
 				 u8 node_part_number, u16 *node_handle)
 {
-	struct ice_aqc_get_link_topo cmd;
-	u8 rec_node_part_number;
-	u16 rec_node_handle;
 	u8 idx;
 
 	for (idx = 0; idx < ICE_MAX_NETLIST_SIZE; idx++) {
+		struct ice_aqc_get_link_topo cmd = {};
+		u8 rec_node_part_number;
 		int status;
 
-		memset(&cmd, 0, sizeof(cmd));
-
 		cmd.addr.topo_params.node_type_ctx =
-			(node_type_ctx << ICE_AQC_LINK_TOPO_NODE_TYPE_S);
+			FIELD_PREP(ICE_AQC_LINK_TOPO_NODE_TYPE_M,
+				   node_type_ctx);
 		cmd.addr.topo_params.index = idx;
 
 		status = ice_aq_get_netlist_node(hw, &cmd,
 						 &rec_node_part_number,
-						 &rec_node_handle);
+						 node_handle);
 		if (status)
 			return status;
 
-		if (rec_node_part_number == node_part_number) {
-			if (node_handle)
-				*node_handle = rec_node_handle;
+		if (rec_node_part_number == node_part_number)
 			return 0;
-		}
 	}
 
-	return -ENOTBLK;
+	return -ENOENT;
 }
 
 /**
Signature · 6 lines
2.41.0.1.g9857a21e0017.dirty

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Tested-by on v1 4/4
#8 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next 4/4] ice: cleanup ice_find_netlist_node

Quoted 31 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, September 20, 2023 5:05 AM
To: Intel Wired LAN <[email protected]>
Cc: Keller, Jacob E <[email protected]>; Nguyen, Anthony L <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next 4/4] ice: cleanup ice_find_netlist_node

The ice_find_netlist_node function was introduced in commit 8a3a565ff210 ("ice: add admin commands to access cgu configuration"). Variations of this function were reviewed concurrently on both intel-wired-lan[1][2], and netdev [3][4]

[1]: https://lore.kernel.org/intel-wired-lan/[email protected]/
[2]: https://lore.kernel.org/intel-wired-lan/[email protected]/
[3]: https://lore.kernel.org/netdev/[email protected]/
[4]: https://lore.kernel.org/netdev/[email protected]/

The variant I posted had a few changes due to review feedback which were never incorporated into the DPLL series:

* Replace the references to ancient and long removed ICE_SUCCESS and ICE_ERR_DOES_NOT_EXIST status codes in the function comment.

* Return -ENOENT instead of -ENOTBLK, as a more common way to indicate that an entry doesn't exist.

* Avoid the use of memset() and use simple static initialization for the cmd variable.

* Use FIELD_PREP to assign the node_type_ctx.

Quoted 8 lines

* Remove an unnecessary local variable to keep track of rec_node_handle, just pass the node_handle pointer directly into ice_aq_get_netlist_node.

---
 drivers/net/ethernet/intel/ice/ice_common.c | 30 ++++++++++-----------
 1 file changed, 15 insertions(+), 15 deletions(-)

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

Reviewed-by on v1 4/4
#9 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next 4/4] ice: cleanup ice_find_netlist_node

In reply to Jacob Keller

Dear Jacob,

Thank you for your patch. A small nit for the subject: The verb *clean up* is spelled with a space.

Am 20.09.23 um 01:34 schrieb Jacob Keller:

Quoted 19 lines

The ice_find_netlist_node function was introduced in commit 8a3a565ff210 ("ice: add admin commands to access cgu configuration"). Variations of this function were reviewed concurrently on both intel-wired-lan[1][2], and netdev [3][4]

[1]: https://lore.kernel.org/intel-wired-lan/[email protected]/
[2]: https://lore.kernel.org/intel-wired-lan/[email protected]/
[3]: https://lore.kernel.org/netdev/[email protected]/
[4]: https://lore.kernel.org/netdev/[email protected]/

The variant I posted had a few changes due to review feedback which were never incorporated into the DPLL series:

* Replace the references to ancient and long removed ICE_SUCCESS and ICE_ERR_DOES_NOT_EXIST status codes in the function comment.

* Return -ENOENT instead of -ENOTBLK, as a more common way to indicate that an entry doesn't exist.

Quoted 7 lines

* Avoid the use of memset() and use simple static initialization for the cmd variable.

* Use FIELD_PREP to assign the node_type_ctx.

* Remove an unnecessary local variable to keep track of rec_node_handle, just pass the node_handle pointer directly into ice_aq_get_netlist_node.

If you need to enumerate changes, with git it’s always good to do one commit per item. ;-) (Better to bisect and to revert.) Anyway, not important enough.

Quoted 56 lines
---
  drivers/net/ethernet/intel/ice/ice_common.c | 30 ++++++++++-----------
  1 file changed, 15 insertions(+), 15 deletions(-)
drivers/net/ethernet/intel/ice/ice_common.c +13 -13
index 12c09374c2be..d4e259b816b9 100644
@@ -473,41 +473,41 @@ ice_aq_get_netlist_node(struct ice_hw *hw, struct ice_aqc_get_link_topo *cmd,
   * @node_part_number: node part number to look for
   * @node_handle: output parameter if node found - optional
   *
- * Find and return the node handle for a given node type and part number in the
- * netlist. When found ICE_SUCCESS is returned, ICE_ERR_DOES_NOT_EXIST
- * otherwise. If node_handle provided, it would be set to found node handle.
+ * Scan the netlist for a node handle of the given node type and part number.
+ *
+ * If node_handle is non-NULL it will be modified on function exit. It is only
+ * valid if the function returns zero, and should be ignored on any non-zero
+ * return value.
+ *
+ * Returns: 0 if the node is found, -ENOENT if no handle was found, and
+ * a negative error code on failure to access the AQ.
   */
  static int ice_find_netlist_node(struct ice_hw *hw, u8 node_type_ctx,
  				 u8 node_part_number, u16 *node_handle)
  {
-	struct ice_aqc_get_link_topo cmd;
-	u8 rec_node_part_number;
-	u16 rec_node_handle;
  	u8 idx;
 
  	for (idx = 0; idx < ICE_MAX_NETLIST_SIZE; idx++) {
+		struct ice_aqc_get_link_topo cmd = {};
+		u8 rec_node_part_number;
  		int status;
 
-		memset(&cmd, 0, sizeof(cmd));
-
  		cmd.addr.topo_params.node_type_ctx =
-			(node_type_ctx << ICE_AQC_LINK_TOPO_NODE_TYPE_S);
+			FIELD_PREP(ICE_AQC_LINK_TOPO_NODE_TYPE_M,
+				   node_type_ctx);
  		cmd.addr.topo_params.index = idx;
 
  		status = ice_aq_get_netlist_node(hw, &cmd,
  						 &rec_node_part_number,
-						 &rec_node_handle);
+						 node_handle);
  		if (status)
  			return status;
 
-		if (rec_node_part_number == node_part_number) {
-			if (node_handle)
-				*node_handle = rec_node_handle;

drivers/net/ethernet/intel/ice/ice_common.c ice_aq_get_netlist_node(struct ice_hw *hw, struct ice_aqc_get_link_topo *cmd, · line 513

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_common.c +2 -2
+		if (rec_node_part_number == node_part_number)
  			return 0;
-		}
  	}
 
-	return -ENOTBLK;
+	return -ENOENT;
  }
 
  /**

Kind regards,

Paul
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan