common/sfc_efx/base: add API to decrement TTL action to set

Affects the outermost header, taking prior action DECAP into
account. Takes care to also update IPv4 checksum accordingly.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
This commit is contained in:
Ivan Malov 2021-11-06 00:54:08 +03:00 committed by Ferruh Yigit
parent ecf2cb283e
commit c6e3e6c42a
5 changed files with 67 additions and 0 deletions

View File

@ -1452,6 +1452,15 @@ ef10_get_datapath_caps(
encp->enc_mae_supported = B_FALSE;
encp->enc_mae_admin = B_FALSE;
}
/*
* Check support for MAE action set v2 features.
* These provide support for packet edits.
*/
if (CAP_FLAGS3(req, MAE_ACTION_SET_ALLOC_V2_SUPPORTED))
encp->enc_mae_aset_v2_supported = B_TRUE;
else
encp->enc_mae_aset_v2_supported = B_FALSE;
#else
encp->enc_mae_supported = B_FALSE;
encp->enc_mae_admin = B_FALSE;

View File

@ -1625,6 +1625,8 @@ typedef struct efx_nic_cfg_s {
* destination (a MAE client or network port).
*/
boolean_t enc_mae_admin;
/* NIC support for MAE action set v2 features. */
boolean_t enc_mae_aset_v2_supported;
/* Firmware support for "FLAG" and "MARK" filter actions */
boolean_t enc_filter_action_flag_supported;
boolean_t enc_filter_action_mark_supported;
@ -4435,6 +4437,18 @@ extern __checkReturn efx_rc_t
efx_mae_action_set_populate_vlan_pop(
__in efx_mae_actions_t *spec);
/*
* This always amends the outermost header. This way, for a tunnel
* packet, if action DECAP is not requested, this will affect the
* outer header; otherwise, the inner header will be updated.
*
* This will also take care to update IPv4 checksum accordingly.
*/
LIBEFX_API
extern __checkReturn efx_rc_t
efx_mae_action_set_populate_decr_ip_ttl(
__in efx_mae_actions_t *spec);
LIBEFX_API
extern __checkReturn efx_rc_t
efx_mae_action_set_populate_vlan_push(

View File

@ -1740,6 +1740,7 @@ typedef enum efx_mae_action_e {
/* These actions are strictly ordered. */
EFX_MAE_ACTION_DECAP,
EFX_MAE_ACTION_VLAN_POP,
EFX_MAE_ACTION_DECR_IP_TTL,
EFX_MAE_ACTION_VLAN_PUSH,
EFX_MAE_ACTION_COUNT,
EFX_MAE_ACTION_ENCAP,
@ -1793,6 +1794,13 @@ struct efx_mae_actions_s {
* to make sure that resource IDs are not compared.
*/
efx_mae_actions_rsrc_t ema_rsrc;
/*
* A copy of encp->enc_mae_aset_v2_supported.
* It is set by efx_mae_action_set_spec_init().
* This value is ignored on spec comparisons.
*/
boolean_t ema_v2_is_supported;
};
#endif /* EFSYS_OPT_MAE */

View File

@ -1376,6 +1376,7 @@ efx_mae_action_set_spec_init(
__in efx_nic_t *enp,
__out efx_mae_actions_t **specp)
{
const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
efx_mae_actions_t *spec;
efx_rc_t rc;
@ -1388,6 +1389,12 @@ efx_mae_action_set_spec_init(
spec->ema_rsrc.emar_eh_id.id = EFX_MAE_RSRC_ID_INVALID;
spec->ema_rsrc.emar_counter_id.id = EFX_MAE_RSRC_ID_INVALID;
/*
* Helpers which populate v2 actions must reject them when v2 is not
* supported. As they have no EFX NIC argument, save v2 status here.
*/
spec->ema_v2_is_supported = encp->enc_mae_aset_v2_supported;
*specp = spec;
return (0);
@ -1626,6 +1633,9 @@ static const efx_mae_action_desc_t efx_mae_actions[EFX_MAE_NACTIONS] = {
[EFX_MAE_ACTION_VLAN_POP] = {
.emad_add = efx_mae_action_set_add_vlan_pop
},
[EFX_MAE_ACTION_DECR_IP_TTL] = {
.emad_add = efx_mae_action_set_no_op
},
[EFX_MAE_ACTION_VLAN_PUSH] = {
.emad_add = efx_mae_action_set_add_vlan_push
},
@ -1649,6 +1659,7 @@ static const efx_mae_action_desc_t efx_mae_actions[EFX_MAE_NACTIONS] = {
static const uint32_t efx_mae_action_ordered_map =
(1U << EFX_MAE_ACTION_DECAP) |
(1U << EFX_MAE_ACTION_VLAN_POP) |
(1U << EFX_MAE_ACTION_DECR_IP_TTL) |
(1U << EFX_MAE_ACTION_VLAN_PUSH) |
/*
* HW will conduct action COUNT after
@ -1767,6 +1778,25 @@ efx_mae_action_set_populate_vlan_pop(
EFX_MAE_ACTION_VLAN_POP, 0, NULL));
}
__checkReturn efx_rc_t
efx_mae_action_set_populate_decr_ip_ttl(
__in efx_mae_actions_t *spec)
{
efx_rc_t rc;
if (spec->ema_v2_is_supported == B_FALSE) {
rc = ENOTSUP;
goto fail1;
}
return (efx_mae_action_set_spec_populate(spec,
EFX_MAE_ACTION_DECR_IP_TTL, 0, NULL));
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
__checkReturn efx_rc_t
efx_mae_action_set_populate_vlan_push(
__in efx_mae_actions_t *spec,
@ -2542,6 +2572,11 @@ efx_mae_action_set_alloc(
MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS,
MAE_ACTION_SET_ALLOC_IN_VLAN_POP, spec->ema_n_vlan_tags_to_pop);
if ((spec->ema_actions & (1U << EFX_MAE_ACTION_DECR_IP_TTL)) != 0) {
MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS,
MAE_ACTION_SET_ALLOC_IN_DO_DECR_IP_TTL, 1);
}
if (spec->ema_n_vlan_tags_to_push > 0) {
unsigned int outer_tag_idx;

View File

@ -95,6 +95,7 @@ INTERNAL {
efx_mae_action_set_get_nb_count;
efx_mae_action_set_populate_count;
efx_mae_action_set_populate_decap;
efx_mae_action_set_populate_decr_ip_ttl;
efx_mae_action_set_populate_deliver;
efx_mae_action_set_populate_drop;
efx_mae_action_set_populate_encap;