Skip to content

Commit

Permalink
net/sfc: support packet replay in transfer flows
Browse files Browse the repository at this point in the history
Packet replay enables users to leverage multiple counters in
one flow and allows to request delivery to multiple ports.

A given flow rule may use either one inline count action
and multiple indirect counters or just multiple indirect
counters. The inline count action (if any) must come
before the first delivery action or before the first
indirect count action, whichever comes earlier.

These are some testpmd examples of supported
multi-count and mirroring use cases:

flow create 0 transfer pattern represented_port ethdev_port_id is 0 / end \
 actions port_representor port_id 0 / port_representor port_id 1 / end

or

flow indirect_action 0 create action_id 239 transfer action count / end

flow create 0 transfer pattern represented_port ethdev_port_id is 0 / end \
 actions count / port_representor port_id 0 / indirect 239 / \
 port_representor port_id 1 / end

or

flow indirect_action 0 create action_id 239 transfer action count / end

flow create 0 transfer pattern represented_port ethdev_port_id is 0 / end \
 actions indirect 239 / port_representor port_id 0 / indirect 239 / \
 port_representor port_id 1 / end

and the likes.

Signed-off-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <andy.moreton@amd.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
  • Loading branch information
okt-imalov authored and ferruhy committed Oct 2, 2023
1 parent f858880 commit f538209
Show file tree
Hide file tree
Showing 6 changed files with 968 additions and 138 deletions.
1 change: 1 addition & 0 deletions doc/guides/rel_notes/release_23_11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ New Features
* **Updated Solarflare net driver.**

* Added support for transfer flow action ``INDIRECT`` with subtype ``VXLAN_ENCAP``.
* Supported packet replay (multi-count / multi-delivery) in transfer flows.

* **Updated Netronome/Corigine nfp driver.**

Expand Down
32 changes: 32 additions & 0 deletions drivers/common/sfc_efx/base/efx.h
Original file line number Diff line number Diff line change
Expand Up @@ -5327,6 +5327,38 @@ efx_table_entry_delete(
__in_bcount(data_size) uint8_t *entry_datap,
__in unsigned int data_size);

/*
* Clone the given MAE action set specification
* and drop actions COUNT and DELIVER from it.
*/
LIBEFX_API
extern __checkReturn efx_rc_t
efx_mae_action_set_replay(
__in efx_nic_t *enp,
__in const efx_mae_actions_t *spec_orig,
__out efx_mae_actions_t **spec_clonep);

/*
* The actual limit may be lower than this.
* This define merely limits the number of
* entries in a single allocation request.
*/
#define EFX_MAE_ACTION_SET_LIST_MAX_NENTRIES 254

LIBEFX_API
extern __checkReturn efx_rc_t
efx_mae_action_set_list_alloc(
__in efx_nic_t *enp,
__in unsigned int n_asets,
__in_ecount(n_asets) const efx_mae_aset_id_t *aset_ids,
__out efx_mae_aset_list_id_t *aset_list_idp);

LIBEFX_API
extern __checkReturn efx_rc_t
efx_mae_action_set_list_free(
__in efx_nic_t *enp,
__in const efx_mae_aset_list_id_t *aset_list_idp);

#ifdef __cplusplus
}
#endif
Expand Down
175 changes: 175 additions & 0 deletions drivers/common/sfc_efx/base/efx_mae.c
Original file line number Diff line number Diff line change
Expand Up @@ -4273,4 +4273,179 @@ efx_mae_read_mport_journal(
return (rc);
}

__checkReturn efx_rc_t
efx_mae_action_set_replay(
__in efx_nic_t *enp,
__in const efx_mae_actions_t *spec_orig,
__out efx_mae_actions_t **spec_clonep)
{
const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
efx_mae_actions_t *spec_clone;
efx_rc_t rc;

EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (*spec_clone), spec_clone);
if (spec_clone == NULL) {
rc = ENOMEM;
goto fail1;
}

*spec_clone = *spec_orig;

spec_clone->ema_rsrc.emar_counter_id.id = EFX_MAE_RSRC_ID_INVALID;
spec_clone->ema_actions &= ~(1U << EFX_MAE_ACTION_COUNT);
spec_clone->ema_n_count_actions = 0;

(void)efx_mae_mport_invalid(&spec_clone->ema_deliver_mport);
spec_clone->ema_actions &= ~(1U << EFX_MAE_ACTION_DELIVER);

*spec_clonep = spec_clone;

return (0);

fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}

__checkReturn efx_rc_t
efx_mae_action_set_list_alloc(
__in efx_nic_t *enp,
__in unsigned int n_asets,
__in_ecount(n_asets) const efx_mae_aset_id_t *aset_ids,
__out efx_mae_aset_list_id_t *aset_list_idp)
{
const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
EFX_MCDI_DECLARE_BUF(payload,
MC_CMD_MAE_ACTION_SET_LIST_ALLOC_IN_LENMAX_MCDI2,
MC_CMD_MAE_ACTION_SET_LIST_ALLOC_OUT_LEN);
efx_mae_aset_list_id_t aset_list_id;
efx_mcdi_req_t req;
efx_rc_t rc;

EFX_STATIC_ASSERT(EFX_MAE_ACTION_SET_LIST_MAX_NENTRIES ==
MC_CMD_MAE_ACTION_SET_LIST_ALLOC_IN_AS_IDS_MAXNUM_MCDI2);

EFX_STATIC_ASSERT(EFX_MAE_RSRC_ID_INVALID ==
MC_CMD_MAE_ACTION_SET_LIST_ALLOC_OUT_ACTION_SET_LIST_ID_NULL);

EFX_STATIC_ASSERT(sizeof (aset_list_idp->id) ==
MC_CMD_MAE_ACTION_SET_LIST_ALLOC_OUT_ASL_ID_LEN);

if (encp->enc_mae_supported == B_FALSE) {
rc = ENOTSUP;
goto fail1;
}

if (MC_CMD_MAE_ACTION_SET_LIST_ALLOC_IN_LEN(n_asets) >
MC_CMD_MAE_ACTION_SET_LIST_ALLOC_IN_LENMAX_MCDI2) {
rc = EINVAL;
goto fail2;
}

req.emr_cmd = MC_CMD_MAE_ACTION_SET_LIST_ALLOC;
req.emr_in_buf = payload;
req.emr_in_length = MC_CMD_MAE_ACTION_SET_LIST_ALLOC_IN_LEN(n_asets);
req.emr_out_buf = payload;
req.emr_out_length = MC_CMD_MAE_ACTION_SET_LIST_ALLOC_OUT_LEN;

MCDI_IN_SET_DWORD(req,
MAE_ACTION_SET_LIST_ALLOC_IN_COUNT, n_asets);

memcpy(MCDI_IN2(req, uint8_t, MAE_ACTION_SET_LIST_ALLOC_IN_AS_IDS),
aset_ids, n_asets * sizeof (*aset_ids));

efx_mcdi_execute(enp, &req);

if (req.emr_rc != 0) {
rc = req.emr_rc;
goto fail3;
}

if (req.emr_out_length_used < MC_CMD_MAE_ACTION_SET_LIST_ALLOC_OUT_LEN) {
rc = EMSGSIZE;
goto fail4;
}

aset_list_id.id =
MCDI_OUT_DWORD(req, MAE_ACTION_SET_LIST_ALLOC_OUT_ASL_ID);
if (aset_list_id.id == EFX_MAE_RSRC_ID_INVALID) {
rc = ENOENT;
goto fail5;
}

aset_list_idp->id = aset_list_id.id;

return (0);

fail5:
EFSYS_PROBE(fail5);
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_list_free(
__in efx_nic_t *enp,
__in const efx_mae_aset_list_id_t *aset_list_idp)
{
const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
EFX_MCDI_DECLARE_BUF(payload,
MC_CMD_MAE_ACTION_SET_LIST_FREE_IN_LEN(1),
MC_CMD_MAE_ACTION_SET_LIST_FREE_OUT_LEN(1));
efx_mcdi_req_t req;
efx_rc_t rc;

if (encp->enc_mae_supported == B_FALSE) {
rc = ENOTSUP;
goto fail1;
}

req.emr_cmd = MC_CMD_MAE_ACTION_SET_LIST_FREE;
req.emr_in_buf = payload;
req.emr_in_length = MC_CMD_MAE_ACTION_SET_LIST_FREE_IN_LEN(1);
req.emr_out_buf = payload;
req.emr_out_length = MC_CMD_MAE_ACTION_SET_LIST_FREE_OUT_LEN(1);

MCDI_IN_SET_DWORD(req,
MAE_ACTION_SET_LIST_FREE_IN_ASL_ID, aset_list_idp->id);

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_LIST_FREE_OUT_LENMIN) {
rc = EMSGSIZE;
goto fail3;
}

if (MCDI_OUT_DWORD(req, MAE_ACTION_SET_LIST_FREE_OUT_FREED_ASL_ID) !=
aset_list_idp->id) {
/* Firmware failed to free the action set list. */
rc = EAGAIN;
goto fail4;
}

return (0);

fail4:
EFSYS_PROBE(fail4);
fail3:
EFSYS_PROBE(fail3);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}

#endif /* EFSYS_OPT_MAE */
3 changes: 3 additions & 0 deletions drivers/common/sfc_efx/version.map
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ INTERNAL {
efx_mae_action_set_fill_in_src_mac_id;
efx_mae_action_set_free;
efx_mae_action_set_get_nb_count;
efx_mae_action_set_list_alloc;
efx_mae_action_set_list_free;
efx_mae_action_set_populate_count;
efx_mae_action_set_populate_decap;
efx_mae_action_set_populate_decr_ip_ttl;
Expand All @@ -111,6 +113,7 @@ INTERNAL {
efx_mae_action_set_populate_set_src_mac;
efx_mae_action_set_populate_vlan_pop;
efx_mae_action_set_populate_vlan_push;
efx_mae_action_set_replay;
efx_mae_action_set_spec_fini;
efx_mae_action_set_spec_init;
efx_mae_action_set_specs_equal;
Expand Down
Loading

0 comments on commit f538209

Please sign in to comment.