Skip to content

Commit

Permalink
common/sfc_efx/base: add MAE action set provisioning APIs
Browse files Browse the repository at this point in the history
The patch adds APIs for action set allocation / release.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
  • Loading branch information
ol-ivanmal authored and Ferruh Yigit committed Nov 3, 2020
1 parent d487651 commit e61baa8
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 0 deletions.
20 changes: 20 additions & 0 deletions drivers/common/sfc_efx/base/efx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
128 changes: 128 additions & 0 deletions drivers/common/sfc_efx/base/efx_mae.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,4 +886,132 @@ efx_mae_match_specs_class_cmp(
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 */
2 changes: 2 additions & 0 deletions drivers/common/sfc_efx/version.map
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e61baa8

Please sign in to comment.