From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5E19EA0C41; Fri, 5 Nov 2021 22:54:54 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 77B6441137; Fri, 5 Nov 2021 22:54:36 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id A5DEC40689 for ; Fri, 5 Nov 2021 22:54:31 +0100 (CET) Received: from bree.oktetlabs.ru (bree.oktetlabs.ru [192.168.34.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPS id 70AA47F70C; Sat, 6 Nov 2021 00:54:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 70AA47F70C Authentication-Results: shelob.oktetlabs.ru/70AA47F70C; dkim=none; dkim-atps=neutral From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Andy Moreton , Ray Kinsella Date: Sat, 6 Nov 2021 00:54:08 +0300 Message-Id: <20211105215409.5706-5-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211105215409.5706-1-ivan.malov@oktetlabs.ru> References: <20211105215409.5706-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 4/5] common/sfc_efx/base: support adding dec. TTL action to a set X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Affects the outermost header, taking prior action DECAP into account. Takes care to also update IPv4 checksum accordingly. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/ef10_nic.c | 9 +++++++ drivers/common/sfc_efx/base/efx.h | 14 +++++++++++ drivers/common/sfc_efx/base/efx_impl.h | 8 ++++++ drivers/common/sfc_efx/base/efx_mae.c | 35 ++++++++++++++++++++++++++ drivers/common/sfc_efx/version.map | 1 + 5 files changed, 67 insertions(+) diff --git a/drivers/common/sfc_efx/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c index bbc59811ec..72d2caadb8 100644 --- a/drivers/common/sfc_efx/base/ef10_nic.c +++ b/drivers/common/sfc_efx/base/ef10_nic.c @@ -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; diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index 60533881c2..f08a004536 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -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( diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h index 5dcdb9c78d..eda41b4be0 100644 --- a/drivers/common/sfc_efx/base/efx_impl.h +++ b/drivers/common/sfc_efx/base/efx_impl.h @@ -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 */ diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index 41444e1926..756c35788e 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -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; diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map index ec862200ab..765ca39332 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -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; -- 2.30.2