common/sfc_efx/base: add MAE init/fini APIs
authorIvan Malov <ivan.malov@oktetlabs.ru>
Tue, 20 Oct 2020 09:12:44 +0000 (10:12 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 3 Nov 2020 22:24:24 +0000 (23:24 +0100)
The patch adds APIs for client drivers to initialise / finalise
MAE-specific context in NIC control structure. The context
itself will be used by the follow-up patches to store
supportive data for library-internal consumers.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
drivers/common/sfc_efx/base/efx.h
drivers/common/sfc_efx/base/efx_impl.h
drivers/common/sfc_efx/base/efx_mae.c [new file with mode: 0644]
drivers/common/sfc_efx/base/meson.build
drivers/common/sfc_efx/version.map

index 9947882..f109c8e 100644 (file)
@@ -4036,6 +4036,20 @@ efx_proxy_auth_privilege_modify(
 
 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH_SERVER */
 
+#if EFSYS_OPT_MAE
+
+LIBEFX_API
+extern __checkReturn                   efx_rc_t
+efx_mae_init(
+       __in                            efx_nic_t *enp);
+
+LIBEFX_API
+extern                                 void
+efx_mae_fini(
+       __in                            efx_nic_t *enp);
+
+#endif /* EFSYS_OPT_MAE */
+
 #ifdef __cplusplus
 }
 #endif
index 196fd4a..8e72796 100644 (file)
@@ -780,6 +780,13 @@ typedef struct efx_proxy_ops_s {
 
 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH_SERVER */
 
+#if EFSYS_OPT_MAE
+
+typedef struct efx_mae_s {
+} efx_mae_t;
+
+#endif /* EFSYS_OPT_MAE */
+
 #define        EFX_DRV_VER_MAX         20
 
 typedef struct efx_drv_cfg_s {
@@ -886,6 +893,9 @@ struct efx_nic_s {
 #if EFSYS_OPT_MCDI_PROXY_AUTH_SERVER
        const efx_proxy_ops_t   *en_epop;
 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH_SERVER */
+#if EFSYS_OPT_MAE
+       efx_mae_t               *en_maep;
+#endif /* EFSYS_OPT_MAE */
 };
 
 #define        EFX_FAMILY_IS_EF10(_enp) \
diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c
new file mode 100644 (file)
index 0000000..0de9ccb
--- /dev/null
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2019 Xilinx, Inc. All rights reserved.
+ * All rights reserved.
+ */
+
+#include "efx.h"
+#include "efx_impl.h"
+
+
+#if EFSYS_OPT_MAE
+
+       __checkReturn                   efx_rc_t
+efx_mae_init(
+       __in                            efx_nic_t *enp)
+{
+       const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
+       efx_mae_t *maep;
+       efx_rc_t rc;
+
+       if (encp->enc_mae_supported == B_FALSE) {
+               rc = ENOTSUP;
+               goto fail1;
+       }
+
+       EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (*maep), maep);
+       if (maep == NULL) {
+               rc = ENOMEM;
+               goto fail2;
+       }
+
+       enp->en_maep = maep;
+
+       return (0);
+
+fail2:
+       EFSYS_PROBE(fail2);
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+       return (rc);
+}
+
+                                       void
+efx_mae_fini(
+       __in                            efx_nic_t *enp)
+{
+       const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
+       efx_mae_t *maep = enp->en_maep;
+
+       if (encp->enc_mae_supported == B_FALSE)
+               return;
+
+       EFSYS_KMEM_FREE(enp->en_esip, sizeof (*maep), maep);
+       enp->en_maep = NULL;
+}
+
+#endif /* EFSYS_OPT_MAE */
index e0acbda..2016346 100644 (file)
@@ -15,6 +15,7 @@ sources = [
        'efx_intr.c',
        'efx_lic.c',
        'efx_mac.c',
+       'efx_mae.c',
        'efx_mcdi.c',
        'efx_mon.c',
        'efx_nic.c',
index f656d5b..c76dfe1 100644 (file)
@@ -85,6 +85,9 @@ INTERNAL {
        efx_mac_stats_upload;
        efx_mac_up;
 
+       efx_mae_fini;
+       efx_mae_init;
+
        efx_mcdi_fini;
        efx_mcdi_get_proxy_handle;
        efx_mcdi_get_timeout;