common/sfc_efx/base: add MAE limit query API

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>
This commit is contained in:
Ivan Malov 2020-10-20 10:12:46 +01:00 committed by Ferruh Yigit
parent 3af6451292
commit d761ec9f33
4 changed files with 84 additions and 0 deletions

View 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

View 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 */

View File

@ -10,6 +10,47 @@
#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 */

View File

@ -86,6 +86,7 @@ INTERNAL {
efx_mac_up;
efx_mae_fini;
efx_mae_get_limits;
efx_mae_init;
efx_mcdi_fini;