[PATCH v2 27/45] common/sfc_efx/base: refactor EF10 link mode decoding helper

Ivan Malov ivan.malov at arknetworks.am
Wed Apr 23 17:59:44 CEST 2025


Future patches will use this change for netport MCDI support.

Signed-off-by: Ivan Malov <ivan.malov at arknetworks.am>
Reviewed-by: Andy Moreton <andy.moreton at amd.com>
Reviewed-by: Pieter Jansen Van Vuuren <pieter.jansen-van-vuuren at amd.com>
---
 drivers/common/sfc_efx/base/ef10_impl.h | 13 +++++++++++
 drivers/common/sfc_efx/base/ef10_phy.c  | 31 ++++++++++++++++++-------
 2 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/drivers/common/sfc_efx/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h
index 3476f274ce..b872ec626c 100644
--- a/drivers/common/sfc_efx/base/ef10_impl.h
+++ b/drivers/common/sfc_efx/base/ef10_impl.h
@@ -801,6 +801,19 @@ ef10_phy_stats_update(
 
 #endif	/* EFSYS_OPT_PHY_STATS */
 
+LIBEFX_INTERNAL
+extern				void
+mcdi_phy_decode_link_mode(
+	__in			efx_nic_t *enp,
+	__in			boolean_t fd,
+	__in			boolean_t up,
+	__in			unsigned int speed,
+	__in			unsigned int fcntl,
+	__in			uint32_t fec,
+	__out			efx_link_mode_t *link_modep,
+	__out			unsigned int *fcntlp,
+	__out			efx_phy_fec_type_t *fecp);
+
 #if EFSYS_OPT_BIST
 
 LIBEFX_INTERNAL
diff --git a/drivers/common/sfc_efx/base/ef10_phy.c b/drivers/common/sfc_efx/base/ef10_phy.c
index 49babdecd5..d458199c7a 100644
--- a/drivers/common/sfc_efx/base/ef10_phy.c
+++ b/drivers/common/sfc_efx/base/ef10_phy.c
@@ -92,10 +92,21 @@ mcdi_phy_decode_cap(
 	*maskp = mask;
 }
 
-static			void
+static				void
+mcdi_phy_decode_link_up_duplex(
+	__in			uint32_t link_flags,
+	__out			boolean_t *fdp,
+	__out			boolean_t *upp)
+{
+	*fdp = !!(link_flags & (1U << MC_CMD_GET_LINK_OUT_FULL_DUPLEX_LBN));
+	*upp = !!(link_flags & (1U << MC_CMD_GET_LINK_OUT_LINK_UP_LBN));
+}
+
+			void
 mcdi_phy_decode_link_mode(
 	__in		efx_nic_t *enp,
-	__in		uint32_t link_flags,
+	__in		boolean_t fd,
+	__in		boolean_t up,
 	__in		unsigned int speed,
 	__in		unsigned int fcntl,
 	__in		uint32_t fec,
@@ -103,11 +114,6 @@ mcdi_phy_decode_link_mode(
 	__out		unsigned int *fcntlp,
 	__out		efx_phy_fec_type_t *fecp)
 {
-	boolean_t fd = !!(link_flags &
-		    (1 << MC_CMD_GET_LINK_OUT_FULL_DUPLEX_LBN));
-	boolean_t up = !!(link_flags &
-		    (1 << MC_CMD_GET_LINK_OUT_LINK_UP_LBN));
-
 	_NOTE(ARGUNUSED(enp))
 
 	if (!up)
@@ -179,6 +185,8 @@ ef10_phy_link_ev(
 	unsigned int ev_fcntl;
 	unsigned int ev_speed;
 	uint32_t lp_cap_mask;
+	boolean_t fd;
+	boolean_t up;
 
 	if (ev_is_v2) {
 		link_flags = (1 << MC_CMD_GET_LINK_OUT_FULL_DUPLEX_LBN);
@@ -226,7 +234,8 @@ ef10_phy_link_ev(
 		break;
 	}
 
-	mcdi_phy_decode_link_mode(enp, link_flags, speed, ev_fcntl,
+	mcdi_phy_decode_link_up_duplex(link_flags, &fd, &up);
+	mcdi_phy_decode_link_mode(enp, fd, up, speed, ev_fcntl,
 				    MC_CMD_FEC_NONE, &link_mode,
 				    &fcntl, &fec);
 	mcdi_phy_decode_cap(ev_lp_cap, &lp_cap_mask);
@@ -281,6 +290,8 @@ ef10_phy_get_link(
 	uint32_t fec;
 	EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_LINK_IN_LEN,
 		MC_CMD_GET_LINK_OUT_V2_LEN);
+	boolean_t fd;
+	boolean_t up;
 	efx_rc_t rc;
 
 	req.emr_cmd = MC_CMD_GET_LINK;
@@ -311,7 +322,9 @@ ef10_phy_get_link(
 	else
 		fec = MCDI_OUT_DWORD(req, GET_LINK_OUT_V2_FEC_TYPE);
 
-	mcdi_phy_decode_link_mode(enp, MCDI_OUT_DWORD(req, GET_LINK_OUT_FLAGS),
+	mcdi_phy_decode_link_up_duplex(MCDI_OUT_DWORD(req, GET_LINK_OUT_FLAGS),
+				    &fd, &up);
+	mcdi_phy_decode_link_mode(enp, fd, up,
 			    MCDI_OUT_DWORD(req, GET_LINK_OUT_LINK_SPEED),
 			    MCDI_OUT_DWORD(req, GET_LINK_OUT_FCNTL),
 			    fec, &elsp->epls.epls_link_mode,
-- 
2.39.5



More information about the dev mailing list