New NICs (for instance, Medford4) offer new netport MCDI for
managing physical ports, which will supersede the legacy one.
Scope out the new interface initialisation on NIC probe path.
That will be augmented with the actual code by later patches.

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/ef10_nic.c  | 30 ++++++++++++++++++------
 drivers/common/sfc_efx/base/efx_impl.h  | 15 ++++++++++++
 drivers/common/sfc_efx/base/efx_np.c    | 31 +++++++++++++++++++++++++
 drivers/common/sfc_efx/base/meson.build |  1 +
 4 files changed, 70 insertions(+), 7 deletions(-)
 create mode 100644 drivers/common/sfc_efx/base/efx_np.c

diff --git a/drivers/common/sfc_efx/base/ef10_nic.c 
b/drivers/common/sfc_efx/base/ef10_nic.c
index e1e8de5396..eb1b68b17e 100644
--- a/drivers/common/sfc_efx/base/ef10_nic.c
+++ b/drivers/common/sfc_efx/base/ef10_nic.c
@@ -2221,6 +2221,9 @@ efx_mcdi_nic_board_cfg(
 
        encp->enc_board_type = board_type;
 
+       if (efx_np_supported(enp) != B_FALSE)
+               goto skip_phy_props;
+
        /* Fill out fields in enp->en_port and enp->en_nic_cfg from MCDI */
        if ((rc = efx_mcdi_get_phy_cfg(enp)) != 0)
                goto fail8;
@@ -2246,6 +2249,7 @@ efx_mcdi_nic_board_cfg(
        epp->ep_default_adv_cap_mask = els.epls.epls_adv_cap_mask;
        epp->ep_adv_cap_mask = els.epls.epls_adv_cap_mask;
 
+skip_phy_props:
        /* Check capabilities of running datapath firmware */
        if ((rc = ef10_get_datapath_caps(enp)) != 0)
                goto fail10;
@@ -2499,6 +2503,10 @@ ef10_nic_probe(
        if ((rc = ef10_nic_board_cfg(enp)) != 0)
                goto fail4;
 
+       rc = efx_np_attach(enp);
+       if (rc != 0)
+               goto fail5;
+
        /*
         * Set default driver config limits (based on board config).
         *
@@ -2516,36 +2524,41 @@ ef10_nic_probe(
 #if EFSYS_OPT_MAC_STATS
        /* Wipe the MAC statistics */
        if ((rc = efx_mcdi_mac_stats_clear(enp)) != 0)
-               goto fail5;
+               goto fail6;
 #endif
 
 #if EFSYS_OPT_LOOPBACK
-       if ((rc = efx_mcdi_get_loopback_modes(enp)) != 0)
-               goto fail6;
+       if (efx_np_supported(enp) == B_FALSE) {
+               rc = efx_mcdi_get_loopback_modes(enp);
+               if (rc != 0)
+                       goto fail7;
+       }
 #endif
 
 #if EFSYS_OPT_MON_STATS
        if ((rc = mcdi_mon_cfg_build(enp)) != 0) {
                /* Unprivileged functions do not have access to sensors */
                if (rc != EACCES)
-                       goto fail7;
+                       goto fail8;
        }
 #endif
 
        return (0);
 
 #if EFSYS_OPT_MON_STATS
+fail8:
+       EFSYS_PROBE(fail8);
+#endif
+#if EFSYS_OPT_LOOPBACK
 fail7:
        EFSYS_PROBE(fail7);
 #endif
-#if EFSYS_OPT_LOOPBACK
+#if EFSYS_OPT_MAC_STATS
 fail6:
        EFSYS_PROBE(fail6);
 #endif
-#if EFSYS_OPT_MAC_STATS
 fail5:
        EFSYS_PROBE(fail5);
-#endif
 fail4:
        EFSYS_PROBE(fail4);
 fail3:
@@ -3005,6 +3018,9 @@ ef10_nic_unprobe(
 #if EFSYS_OPT_MON_STATS
        mcdi_mon_cfg_free(enp);
 #endif /* EFSYS_OPT_MON_STATS */
+
+       efx_np_detach(enp);
+
        (void) efx_mcdi_drv_attach(enp, B_FALSE);
 }
 
diff --git a/drivers/common/sfc_efx/base/efx_impl.h 
b/drivers/common/sfc_efx/base/efx_impl.h
index 89b7e0292e..9ad973ded7 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -1880,6 +1880,21 @@ struct efx_virtio_vq_s {
 
 #endif /* EFSYS_OPT_VIRTIO */
 
+LIBEFX_INTERNAL
+extern                 boolean_t
+efx_np_supported(
+       __in            efx_nic_t *enp);
+
+LIBEFX_INTERNAL
+extern __checkReturn   efx_rc_t
+efx_np_attach(
+       __in            efx_nic_t *enp);
+
+LIBEFX_INTERNAL
+extern         void
+efx_np_detach(
+       __in    efx_nic_t *enp);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/drivers/common/sfc_efx/base/efx_np.c 
b/drivers/common/sfc_efx/base/efx_np.c
new file mode 100644
index 0000000000..432185f311
--- /dev/null
+++ b/drivers/common/sfc_efx/base/efx_np.c
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2025 Advanced Micro Devices, Inc.
+ */
+#include "efx.h"
+#include "efx_impl.h"
+
+                       boolean_t
+efx_np_supported(
+       __in            efx_nic_t *enp)
+{
+       return (enp->en_family >= EFX_FAMILY_MEDFORD4) ? B_TRUE : B_FALSE;
+}
+
+       __checkReturn   efx_rc_t
+efx_np_attach(
+       __in            efx_nic_t *enp)
+{
+       if (efx_np_supported(enp) == B_FALSE)
+               return (0);
+
+       return (0);
+}
+
+               void
+efx_np_detach(
+       __in    efx_nic_t *enp)
+{
+       if (efx_np_supported(enp) == B_FALSE)
+               return;
+}
diff --git a/drivers/common/sfc_efx/base/meson.build 
b/drivers/common/sfc_efx/base/meson.build
index c8deb4555e..02d5b2fbb9 100644
--- a/drivers/common/sfc_efx/base/meson.build
+++ b/drivers/common/sfc_efx/base/meson.build
@@ -20,6 +20,7 @@ sources = [
         'efx_mcdi.c',
         'efx_mon.c',
         'efx_nic.c',
+        'efx_np.c',
         'efx_nvram.c',
         'efx_pci.c',
         'efx_phy.c',
-- 
2.39.5

Reply via email to