From: Ivan Malov Date: Tue, 20 Oct 2020 09:13:02 +0000 (+0100) Subject: common/sfc_efx/base: add MAE action set provisioning APIs X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=e61baa82e64b231577fd0b17841b4f4f820fd146;p=dpdk.git common/sfc_efx/base: add MAE action set provisioning APIs The patch adds APIs for action set allocation / release. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index 6f63a6ecd0..3053da75f8 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -4191,6 +4191,26 @@ efx_mae_match_specs_class_cmp( __in const efx_mae_match_spec_t *right, __out boolean_t *have_same_classp); +#define EFX_MAE_RSRC_ID_INVALID UINT32_MAX + +/* Action set ID */ +typedef struct efx_mae_aset_id_s { + uint32_t id; +} efx_mae_aset_id_t; + +LIBEFX_API +extern __checkReturn efx_rc_t +efx_mae_action_set_alloc( + __in efx_nic_t *enp, + __in const efx_mae_actions_t *spec, + __out efx_mae_aset_id_t *aset_idp); + +LIBEFX_API +extern __checkReturn efx_rc_t +efx_mae_action_set_free( + __in efx_nic_t *enp, + __in const efx_mae_aset_id_t *aset_idp); + #endif /* EFSYS_OPT_MAE */ #ifdef __cplusplus diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index 26e857c545..ea6302f89d 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -886,4 +886,132 @@ fail1: return (rc); } + __checkReturn efx_rc_t +efx_mae_action_set_alloc( + __in efx_nic_t *enp, + __in const efx_mae_actions_t *spec, + __out efx_mae_aset_id_t *aset_idp) +{ + const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp); + efx_mcdi_req_t req; + EFX_MCDI_DECLARE_BUF(payload, + MC_CMD_MAE_ACTION_SET_ALLOC_IN_LEN, + MC_CMD_MAE_ACTION_SET_ALLOC_OUT_LEN); + efx_mae_aset_id_t aset_id; + efx_rc_t rc; + + if (encp->enc_mae_supported == B_FALSE) { + rc = ENOTSUP; + goto fail1; + } + + req.emr_cmd = MC_CMD_MAE_ACTION_SET_ALLOC; + req.emr_in_buf = payload; + req.emr_in_length = MC_CMD_MAE_ACTION_SET_ALLOC_IN_LEN; + req.emr_out_buf = payload; + req.emr_out_length = MC_CMD_MAE_ACTION_SET_ALLOC_OUT_LEN; + + /* + * TODO: Remove these EFX_MAE_RSRC_ID_INVALID assignments once the + * corresponding resource types are supported by the implementation. + * Use proper resource ID assignments instead. + */ + MCDI_IN_SET_DWORD(req, + MAE_ACTION_SET_ALLOC_IN_COUNTER_LIST_ID, EFX_MAE_RSRC_ID_INVALID); + MCDI_IN_SET_DWORD(req, + MAE_ACTION_SET_ALLOC_IN_COUNTER_ID, EFX_MAE_RSRC_ID_INVALID); + MCDI_IN_SET_DWORD(req, + MAE_ACTION_SET_ALLOC_IN_ENCAP_HEADER_ID, EFX_MAE_RSRC_ID_INVALID); + + MCDI_IN_SET_DWORD(req, + MAE_ACTION_SET_ALLOC_IN_DELIVER, spec->ema_deliver_mport.sel); + + MCDI_IN_SET_DWORD(req, MAE_ACTION_SET_ALLOC_IN_SRC_MAC_ID, + MC_CMD_MAE_MAC_ADDR_ALLOC_OUT_MAC_ID_NULL); + MCDI_IN_SET_DWORD(req, MAE_ACTION_SET_ALLOC_IN_DST_MAC_ID, + MC_CMD_MAE_MAC_ADDR_ALLOC_OUT_MAC_ID_NULL); + + efx_mcdi_execute(enp, &req); + + if (req.emr_rc != 0) { + rc = req.emr_rc; + goto fail2; + } + + if (req.emr_out_length_used < MC_CMD_MAE_ACTION_SET_ALLOC_OUT_LEN) { + rc = EMSGSIZE; + goto fail3; + } + + aset_id.id = MCDI_OUT_DWORD(req, MAE_ACTION_SET_ALLOC_OUT_AS_ID); + if (aset_id.id == EFX_MAE_RSRC_ID_INVALID) { + rc = ENOENT; + goto fail4; + } + + aset_idp->id = aset_id.id; + + return (0); + +fail4: + EFSYS_PROBE(fail4); +fail3: + EFSYS_PROBE(fail3); +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} + + __checkReturn efx_rc_t +efx_mae_action_set_free( + __in efx_nic_t *enp, + __in const efx_mae_aset_id_t *aset_idp) +{ + const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp); + efx_mcdi_req_t req; + EFX_MCDI_DECLARE_BUF(payload, + MC_CMD_MAE_ACTION_SET_FREE_IN_LEN(1), + MC_CMD_MAE_ACTION_SET_FREE_OUT_LEN(1)); + efx_rc_t rc; + + if (encp->enc_mae_supported == B_FALSE) { + rc = ENOTSUP; + goto fail1; + } + + req.emr_cmd = MC_CMD_MAE_ACTION_SET_FREE; + req.emr_in_buf = payload; + req.emr_in_length = MC_CMD_MAE_ACTION_SET_FREE_IN_LEN(1); + req.emr_out_buf = payload; + req.emr_out_length = MC_CMD_MAE_ACTION_SET_FREE_OUT_LEN(1); + + MCDI_IN_SET_DWORD(req, MAE_ACTION_SET_FREE_IN_AS_ID, aset_idp->id); + + efx_mcdi_execute(enp, &req); + + if (req.emr_rc != 0) { + rc = req.emr_rc; + goto fail2; + } + + if (MCDI_OUT_DWORD(req, MAE_ACTION_SET_FREE_OUT_FREED_AS_ID) != + aset_idp->id) { + /* Firmware failed to free the action set. */ + rc = EAGAIN; + goto fail3; + } + + return (0); + +fail3: + EFSYS_PROBE(fail3); +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} + #endif /* EFSYS_OPT_MAE */ diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map index d2a5d58ae8..643b3bab52 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -85,6 +85,8 @@ INTERNAL { efx_mac_stats_upload; efx_mac_up; + efx_mae_action_set_alloc; + efx_mae_action_set_free; efx_mae_action_set_populate_deliver; efx_mae_action_set_spec_fini; efx_mae_action_set_spec_init;