From patchwork Wed Jun 7 13:02:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 128315 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A781F42C4D; Wed, 7 Jun 2023 15:06:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8288C42FB6; Wed, 7 Jun 2023 15:03:22 +0200 (CEST) Received: from agw.arknetworks.am (agw.arknetworks.am [79.141.165.80]) by mails.dpdk.org (Postfix) with ESMTP id 9F6B142D63 for ; Wed, 7 Jun 2023 15:03:01 +0200 (CEST) Received: from localhost.localdomain (unknown [78.109.69.83]) (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 agw.arknetworks.am (Postfix) with ESMTPSA id 2BA6AE1253; Wed, 7 Jun 2023 17:03:01 +0400 (+04) From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Ferruh Yigit , Andy Moreton Subject: [PATCH v4 26/34] common/sfc_efx/base: support NAT edits in MAE Date: Wed, 7 Jun 2023 17:02:37 +0400 Message-Id: <20230607130245.8048-27-ivan.malov@arknetworks.am> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230607130245.8048-1-ivan.malov@arknetworks.am> References: <20230601195538.8265-1-ivan.malov@arknetworks.am> <20230607130245.8048-1-ivan.malov@arknetworks.am> MIME-Version: 1.0 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 NAT goes after IP TTL decrement. It can operate on the outermost frame only. In the case of prior decapsulation, that maps to the frame which was (originally) the inner one. Input data for the action comes from the response of the HW conntrack assistance table hit. Signed-off-by: Ivan Malov Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx.h | 13 +++++++++++++ drivers/common/sfc_efx/base/efx_impl.h | 1 + drivers/common/sfc_efx/base/efx_mae.c | 17 +++++++++++++++++ drivers/common/sfc_efx/version.map | 1 + 4 files changed, 32 insertions(+) diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index 5e3718050d..a296d34f29 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -4560,6 +4560,19 @@ extern __checkReturn efx_rc_t efx_mae_action_set_populate_decr_ip_ttl( __in efx_mae_actions_t *spec); +/* + * This only requests NAT action. The replacement IP address and + * L4 port number, as well as the edit direction (DST/SRC), come + * from the response to a hit in the conntrack assistance table. + * + * The action amends the outermost frame. In the case of prior + * decapsulation, that maps to the (originally) inner frame. + */ +LIBEFX_API +extern __checkReturn efx_rc_t +efx_mae_action_set_populate_nat( + __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 0a6a489d2c..e978ad0de8 100644 --- a/drivers/common/sfc_efx/base/efx_impl.h +++ b/drivers/common/sfc_efx/base/efx_impl.h @@ -1771,6 +1771,7 @@ typedef enum efx_mae_action_e { EFX_MAE_ACTION_SET_DST_MAC, EFX_MAE_ACTION_SET_SRC_MAC, EFX_MAE_ACTION_DECR_IP_TTL, + EFX_MAE_ACTION_NAT, EFX_MAE_ACTION_VLAN_PUSH, EFX_MAE_ACTION_COUNT, EFX_MAE_ACTION_ENCAP, diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index 546c743a02..aaea38c933 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -1837,6 +1837,9 @@ static const efx_mae_action_desc_t efx_mae_actions[EFX_MAE_NACTIONS] = { [EFX_MAE_ACTION_DECR_IP_TTL] = { .emad_add = efx_mae_action_set_no_op }, + [EFX_MAE_ACTION_NAT] = { + .emad_add = efx_mae_action_set_no_op + }, [EFX_MAE_ACTION_VLAN_PUSH] = { .emad_add = efx_mae_action_set_add_vlan_push }, @@ -1863,6 +1866,7 @@ static const uint32_t efx_mae_action_ordered_map = (1U << EFX_MAE_ACTION_SET_DST_MAC) | (1U << EFX_MAE_ACTION_SET_SRC_MAC) | (1U << EFX_MAE_ACTION_DECR_IP_TTL) | + (1U << EFX_MAE_ACTION_NAT) | (1U << EFX_MAE_ACTION_VLAN_PUSH) | /* * HW will conduct action COUNT after @@ -2038,6 +2042,14 @@ efx_mae_action_set_populate_decr_ip_ttl( return (rc); } + __checkReturn efx_rc_t +efx_mae_action_set_populate_nat( + __in efx_mae_actions_t *spec) +{ + return (efx_mae_action_set_spec_populate(spec, + EFX_MAE_ACTION_NAT, 0, NULL)); +} + __checkReturn efx_rc_t efx_mae_action_set_populate_vlan_push( __in efx_mae_actions_t *spec, @@ -3093,6 +3105,11 @@ efx_mae_action_set_alloc( MAE_ACTION_SET_ALLOC_IN_DO_DECR_IP_TTL, 1); } + if ((spec->ema_actions & (1U << EFX_MAE_ACTION_NAT)) != 0) { + MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS, + MAE_ACTION_SET_ALLOC_IN_DO_NAT, 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 28a2be0a95..1ff760a024 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -104,6 +104,7 @@ INTERNAL { efx_mae_action_set_populate_flag; efx_mae_action_set_populate_mark; efx_mae_action_set_populate_mark_reset; + efx_mae_action_set_populate_nat; efx_mae_action_set_populate_set_dst_mac; efx_mae_action_set_populate_set_src_mac; efx_mae_action_set_populate_vlan_pop;