Provide only a small subset of methods for now. Next patches will augment the file with more, based on newer netport MCDI.
Signed-off-by: Ivan Malov <ivan.ma...@arknetworks.am> Reviewed-by: Andy Moreton <andy.more...@amd.com> Reviewed-by: Pieter Jansen Van Vuuren <pieter.jansen-van-vuu...@amd.com> --- drivers/common/sfc_efx/base/efx_mac.c | 32 +++++++++++- drivers/common/sfc_efx/base/medford4_impl.h | 12 +++++ drivers/common/sfc_efx/base/medford4_mac.c | 54 +++++++++++++++++++++ drivers/common/sfc_efx/base/meson.build | 1 + 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 drivers/common/sfc_efx/base/medford4_mac.c diff --git a/drivers/common/sfc_efx/base/efx_mac.c b/drivers/common/sfc_efx/base/efx_mac.c index a2cbf02b46..dde0e5ab87 100644 --- a/drivers/common/sfc_efx/base/efx_mac.c +++ b/drivers/common/sfc_efx/base/efx_mac.c @@ -89,6 +89,31 @@ static const efx_mac_ops_t __efx_mac_rhead_ops = { }; #endif /* EFSYS_OPT_RIVERHEAD */ +#if EFSYS_OPT_MEDFORD4 +static const efx_mac_ops_t __efx_mac_medford4_ops = { + medford4_mac_poll, /* emo_poll */ + medford4_mac_up, /* emo_up */ + ef10_mac_addr_set, /* emo_addr_set */ + ef10_mac_pdu_set, /* emo_pdu_set */ + ef10_mac_pdu_get, /* emo_pdu_get */ + ef10_mac_reconfigure, /* emo_reconfigure */ + ef10_mac_multicast_list_set, /* emo_multicast_list_set */ + ef10_mac_filter_default_rxq_set, /* emo_filter_default_rxq_set */ + ef10_mac_filter_default_rxq_clear, + /* emo_filter_default_rxq_clear */ +#if EFSYS_OPT_LOOPBACK + ef10_mac_loopback_set, /* emo_loopback_set */ +#endif /* EFSYS_OPT_LOOPBACK */ +#if EFSYS_OPT_MAC_STATS + ef10_mac_stats_get_mask, /* emo_stats_get_mask */ + efx_mcdi_mac_stats_clear, /* emo_stats_clear */ + efx_mcdi_mac_stats_upload, /* emo_stats_upload */ + efx_mcdi_mac_stats_periodic, /* emo_stats_periodic */ + ef10_mac_stats_update /* emo_stats_update */ +#endif /* EFSYS_OPT_MAC_STATS */ +}; +#endif /* EFSYS_OPT_MEDFORD4 */ + __checkReturn efx_rc_t efx_mac_pdu_set( __in efx_nic_t *enp, @@ -271,6 +296,11 @@ efx_mac_drain( EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT); EFSYS_ASSERT(emop != NULL); + if (efx_np_supported(enp) != B_FALSE) { + /* Only pre-Medford4 boards have supported MAC drain control. */ + return (0); + } + if (epp->ep_mac_drain == enabled) return (0); @@ -955,7 +985,7 @@ efx_mac_select( #if EFSYS_OPT_MEDFORD4 case EFX_FAMILY_MEDFORD4: - emop = &__efx_mac_ef10_ops; + emop = &__efx_mac_medford4_ops; type = EFX_MAC_MEDFORD4; break; #endif /* EFSYS_OPT_MEDFORD4 */ diff --git a/drivers/common/sfc_efx/base/medford4_impl.h b/drivers/common/sfc_efx/base/medford4_impl.h index 795fd45bd4..6aa065c730 100644 --- a/drivers/common/sfc_efx/base/medford4_impl.h +++ b/drivers/common/sfc_efx/base/medford4_impl.h @@ -39,6 +39,18 @@ extern __checkReturn efx_rc_t medford4_phy_reconfigure( __in efx_nic_t *enp); +LIBEFX_INTERNAL +extern __checkReturn efx_rc_t +medford4_mac_poll( + __in efx_nic_t *enp, + __out efx_link_mode_t *link_modep); + +LIBEFX_INTERNAL +extern __checkReturn efx_rc_t +medford4_mac_up( + __in efx_nic_t *enp, + __out boolean_t *mac_upp); + #ifdef __cplusplus } #endif diff --git a/drivers/common/sfc_efx/base/medford4_mac.c b/drivers/common/sfc_efx/base/medford4_mac.c new file mode 100644 index 0000000000..57ddbecfaa --- /dev/null +++ b/drivers/common/sfc_efx/base/medford4_mac.c @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2025 Advanced Micro Devices, Inc. + */ +#include "efx.h" +#include "efx_impl.h" +#include "medford4_impl.h" + +#if EFSYS_OPT_MEDFORD4 + __checkReturn efx_rc_t +medford4_mac_poll( + __in efx_nic_t *enp, + __out efx_link_mode_t *link_modep) +{ + efx_port_t *epp = &(enp->en_port); + ef10_link_state_t els; + efx_rc_t rc; + + rc = medford4_phy_get_link(enp, &els); + if (rc != 0) + goto fail1; + + epp->ep_adv_cap_mask = els.epls.epls_adv_cap_mask; + epp->ep_fcntl = els.epls.epls_fcntl; + + *link_modep = els.epls.epls_link_mode; + return (0); + +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + *link_modep = EFX_LINK_UNKNOWN; + return (rc); +} + + __checkReturn efx_rc_t +medford4_mac_up( + __in efx_nic_t *enp, + __out boolean_t *mac_upp) +{ + ef10_link_state_t els; + efx_rc_t rc; + + rc = medford4_phy_get_link(enp, &els); + if (rc != 0) + goto fail1; + + *mac_upp = els.els_mac_up; + return (0); + +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} +#endif /* EFSYS_OPT_MEDFORD4 */ diff --git a/drivers/common/sfc_efx/base/meson.build b/drivers/common/sfc_efx/base/meson.build index 937e3820a0..f18011e186 100644 --- a/drivers/common/sfc_efx/base/meson.build +++ b/drivers/common/sfc_efx/base/meson.build @@ -57,6 +57,7 @@ sources = [ 'hunt_nic.c', 'medford_nic.c', 'medford2_nic.c', + 'medford4_mac.c', 'medford4_phy.c', 'rhead_ev.c', 'rhead_intr.c', -- 2.39.5