common/sfc_efx/base: add MAE limit query API
authorIvan Malov <ivan.malov@oktetlabs.ru>
Tue, 20 Oct 2020 09:12:46 +0000 (10:12 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 3 Nov 2020 22:24:24 +0000 (23:24 +0100)
Add an API for client drivers to query the engine limits.

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
drivers/common/sfc_efx/version.map

index f109c8e..db66be0 100644 (file)
@@ -4048,6 +4048,16 @@ extern                                   void
 efx_mae_fini(
        __in                            efx_nic_t *enp);
 
+typedef struct efx_mae_limits_s {
+       uint32_t                        eml_max_n_action_prios;
+} efx_mae_limits_t;
+
+LIBEFX_API
+extern __checkReturn                   efx_rc_t
+efx_mae_get_limits(
+       __in                            efx_nic_t *enp,
+       __out                           efx_mae_limits_t *emlp);
+
 #endif /* EFSYS_OPT_MAE */
 
 #ifdef __cplusplus
index 8e72796..6e9329c 100644 (file)
@@ -783,6 +783,7 @@ typedef struct efx_proxy_ops_s {
 #if EFSYS_OPT_MAE
 
 typedef struct efx_mae_s {
+       uint32_t                        em_max_n_action_prios;
 } efx_mae_t;
 
 #endif /* EFSYS_OPT_MAE */
index 0de9ccb..c93342d 100644 (file)
 
 #if EFSYS_OPT_MAE
 
+static __checkReturn                   efx_rc_t
+efx_mae_get_capabilities(
+       __in                            efx_nic_t *enp)
+{
+       efx_mcdi_req_t req;
+       EFX_MCDI_DECLARE_BUF(payload,
+           MC_CMD_MAE_GET_CAPS_IN_LEN,
+           MC_CMD_MAE_GET_CAPS_OUT_LEN);
+       struct efx_mae_s *maep = enp->en_maep;
+       efx_rc_t rc;
+
+       req.emr_cmd = MC_CMD_MAE_GET_CAPS;
+       req.emr_in_buf = payload;
+       req.emr_in_length = MC_CMD_MAE_GET_CAPS_IN_LEN;
+       req.emr_out_buf = payload;
+       req.emr_out_length = MC_CMD_MAE_GET_CAPS_OUT_LEN;
+
+       efx_mcdi_execute(enp, &req);
+
+       if (req.emr_rc != 0) {
+               rc = req.emr_rc;
+               goto fail1;
+       }
+
+       if (req.emr_out_length_used < MC_CMD_MAE_GET_CAPS_OUT_LEN) {
+               rc = EMSGSIZE;
+               goto fail2;
+       }
+
+       maep->em_max_n_action_prios =
+           MCDI_OUT_DWORD(req, MAE_GET_CAPS_OUT_ACTION_PRIOS);
+
+       return (0);
+
+fail2:
+       EFSYS_PROBE(fail2);
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+       return (rc);
+}
+
        __checkReturn                   efx_rc_t
 efx_mae_init(
        __in                            efx_nic_t *enp)
@@ -31,8 +72,16 @@ efx_mae_init(
 
        enp->en_maep = maep;
 
+       rc = efx_mae_get_capabilities(enp);
+       if (rc != 0)
+               goto fail3;
+
        return (0);
 
+fail3:
+       EFSYS_PROBE(fail3);
+       EFSYS_KMEM_FREE(enp->en_esip, sizeof (struct efx_mae_s), enp->en_maep);
+       enp->en_maep = NULL;
 fail2:
        EFSYS_PROBE(fail2);
 fail1:
@@ -54,4 +103,27 @@ efx_mae_fini(
        enp->en_maep = NULL;
 }
 
+       __checkReturn                   efx_rc_t
+efx_mae_get_limits(
+       __in                            efx_nic_t *enp,
+       __out                           efx_mae_limits_t *emlp)
+{
+       const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
+       struct efx_mae_s *maep = enp->en_maep;
+       efx_rc_t rc;
+
+       if (encp->enc_mae_supported == B_FALSE) {
+               rc = ENOTSUP;
+               goto fail1;
+       }
+
+       emlp->eml_max_n_action_prios = maep->em_max_n_action_prios;
+
+       return (0);
+
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+       return (rc);
+}
+
 #endif /* EFSYS_OPT_MAE */
index c76dfe1..4b500b6 100644 (file)
@@ -86,6 +86,7 @@ INTERNAL {
        efx_mac_up;
 
        efx_mae_fini;
+       efx_mae_get_limits;
        efx_mae_init;
 
        efx_mcdi_fini;