From patchwork Fri Nov 5 21:54:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 103888 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 A7409A0C41; Fri, 5 Nov 2021 22:54:37 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6B0A041101; Fri, 5 Nov 2021 22:54:33 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 1EE2D40DFD; 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 C46C07F6D4; Sat, 6 Nov 2021 00:54:30 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru C46C07F6D4 Authentication-Results: shelob.oktetlabs.ru/C46C07F6D4; dkim=none; dkim-atps=neutral From: Ivan Malov To: dev@dpdk.org Cc: stable@dpdk.org, Andrew Rybchenko , Andy Moreton Date: Sat, 6 Nov 2021 00:54:05 +0300 Message-Id: <20211105215409.5706-2-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 Subject: [dpdk-dev] [PATCH 1/5] common/sfc_efx/base: refine adding encap 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" 1) Invalid encap. header ID is always set by default. Do not set it again when adding the action. 2) Encap. header ID validity check is missing in the action set allocation helper. Introduce it. Fixes: 3907defa5bf0 ("common/sfc_efx/base: support adding encap action to a set") Cc: stable@dpdk.org Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx_mae.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index 154b6e1cdd..542c345b76 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -1525,16 +1525,13 @@ efx_mae_action_set_add_encap( * needs to check the order of actions submitted by user ("validate"), * without actually allocating an action set and inserting a rule. * - * For now, mark encap. header ID as invalid; the caller will invoke - * efx_mae_action_set_fill_in_eh_id() to override the field prior - * to action set allocation; otherwise, the allocation will fail. + * In order to fill in the encap. header ID, the caller is supposed to + * invoke efx_mae_action_set_fill_in_eh_id(). If they do not do that, + * efx_mae_action_set_alloc() invocation will throw an error. + * + * For now, no more work is supposed to be done. */ - spec->ema_rsrc.emar_eh_id.id = EFX_MAE_RSRC_ID_INVALID; - /* - * As explained above, there are no arguments to handle here. - * efx_mae_action_set_fill_in_eh_id() will take care of them. - */ if (arg_size != 0) { rc = EINVAL; goto fail1; @@ -2582,6 +2579,12 @@ efx_mae_action_set_alloc( goto fail1; } + if ((spec->ema_actions & (1U << EFX_MAE_ACTION_ENCAP)) != 0 && + spec->ema_rsrc.emar_eh_id.id == EFX_MAE_RSRC_ID_INVALID) { + rc = EINVAL; + goto fail2; + } + 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; @@ -2659,24 +2662,26 @@ efx_mae_action_set_alloc( if (req.emr_rc != 0) { rc = req.emr_rc; - goto fail2; + goto fail3; } if (req.emr_out_length_used < MC_CMD_MAE_ACTION_SET_ALLOC_OUT_LEN) { rc = EMSGSIZE; - goto fail3; + goto fail4; } 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; + goto fail5; } aset_idp->id = aset_id.id; return (0); +fail5: + EFSYS_PROBE(fail5); fail4: EFSYS_PROBE(fail4); fail3: From patchwork Fri Nov 5 21:54:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 103889 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 EA20DA0C41; Fri, 5 Nov 2021 22:54:43 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E5034111E; Fri, 5 Nov 2021 22:54:34 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 69E9440689; 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 05AD17F6F3; Sat, 6 Nov 2021 00:54:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 05AD17F6F3 Authentication-Results: shelob.oktetlabs.ru/05AD17F6F3; dkim=none; dkim-atps=neutral From: Ivan Malov To: dev@dpdk.org Cc: stable@dpdk.org, Andrew Rybchenko , Andy Moreton , Igor Romanov Date: Sat, 6 Nov 2021 00:54:06 +0300 Message-Id: <20211105215409.5706-3-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 Subject: [dpdk-dev] [PATCH 2/5] common/sfc_efx/base: refine adding count 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" 1) Invalid counter ID is always set by default. Do not set it again when adding the action. 2) Counter ID validity check is missing in the action set allocation helper. Introduce it. Fixes: 238306cf9aff ("common/sfc_efx/base: support counter in action set") Cc: stable@dpdk.org Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx_mae.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index 542c345b76..c93fe9bdfc 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -1567,13 +1567,14 @@ efx_mae_action_set_add_count( * two steps: first add this action to the action spec, and then * add the counter ID to the spec. This allows validity checking * and resource allocation to be done separately. - * Mark the counter ID as invalid in the spec to ensure that the - * caller must also invoke efx_mae_action_set_fill_in_counter_id() - * before action set allocation. + * + * In order to fill in the counter ID, the caller is supposed to invoke + * efx_mae_action_set_fill_in_counter_id(). If they do not do that, + * efx_mae_action_set_alloc() invocation will throw an error. + * + * For now, no arguments are supposed to be handled. */ - spec->ema_rsrc.emar_counter_id.id = EFX_MAE_RSRC_ID_INVALID; - /* Nothing else is supposed to take place over here. */ if (arg_size != 0) { rc = EINVAL; goto fail1; @@ -2585,6 +2586,12 @@ efx_mae_action_set_alloc( goto fail2; } + if (spec->ema_n_count_actions == 1 && + spec->ema_rsrc.emar_counter_id.id == EFX_MAE_RSRC_ID_INVALID) { + rc = EINVAL; + goto fail3; + } + 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; @@ -2662,24 +2669,26 @@ efx_mae_action_set_alloc( if (req.emr_rc != 0) { rc = req.emr_rc; - goto fail3; + goto fail4; } if (req.emr_out_length_used < MC_CMD_MAE_ACTION_SET_ALLOC_OUT_LEN) { rc = EMSGSIZE; - goto fail4; + goto fail5; } 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 fail5; + goto fail6; } aset_idp->id = aset_id.id; return (0); +fail6: + EFSYS_PROBE(fail6); fail5: EFSYS_PROBE(fail5); fail4: From patchwork Fri Nov 5 21:54:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 103890 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 F00DCA0C41; Fri, 5 Nov 2021 22:54:49 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 818F941130; Fri, 5 Nov 2021 22:54:35 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 849EC40DFD 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 3A18F7F52E; Sat, 6 Nov 2021 00:54:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 3A18F7F52E Authentication-Results: shelob.oktetlabs.ru/3A18F7F52E; dkim=none; dkim-atps=neutral From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Andy Moreton Date: Sat, 6 Nov 2021 00:54:07 +0300 Message-Id: <20211105215409.5706-4-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 Subject: [dpdk-dev] [PATCH 3/5] common/sfc_efx/base: factor out no-op helper functions 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" When an action gets added to an action set, a special helper is used to handle its arguments. There are actions which have no arguments, and the corresponding helpers are duplicates in fact. Use a unified no-op helper instead of them. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx_mae.c | 80 ++------------------------- 1 file changed, 4 insertions(+), 76 deletions(-) diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index c93fe9bdfc..41444e1926 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -1406,7 +1406,7 @@ efx_mae_action_set_spec_fini( } static __checkReturn efx_rc_t -efx_mae_action_set_add_decap( +efx_mae_action_set_no_op( __in efx_mae_actions_t *spec, __in size_t arg_size, __in_bcount(arg_size) const uint8_t *arg) @@ -1510,47 +1510,6 @@ efx_mae_action_set_add_vlan_push( return (rc); } -static __checkReturn efx_rc_t -efx_mae_action_set_add_encap( - __in efx_mae_actions_t *spec, - __in size_t arg_size, - __in_bcount(arg_size) const uint8_t *arg) -{ - efx_rc_t rc; - - /* - * Adding this specific action to an action set spec and setting encap. - * header ID in the spec are two individual steps. This design allows - * the client driver to avoid encap. header allocation when it simply - * needs to check the order of actions submitted by user ("validate"), - * without actually allocating an action set and inserting a rule. - * - * In order to fill in the encap. header ID, the caller is supposed to - * invoke efx_mae_action_set_fill_in_eh_id(). If they do not do that, - * efx_mae_action_set_alloc() invocation will throw an error. - * - * For now, no more work is supposed to be done. - */ - - if (arg_size != 0) { - rc = EINVAL; - goto fail1; - } - - if (arg != NULL) { - rc = EINVAL; - goto fail2; - } - - return (0); - -fail2: - EFSYS_PROBE(fail2); -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - return (rc); -} - static __checkReturn efx_rc_t efx_mae_action_set_add_count( __in efx_mae_actions_t *spec, @@ -1596,37 +1555,6 @@ efx_mae_action_set_add_count( return (rc); } -static __checkReturn efx_rc_t -efx_mae_action_set_add_flag( - __in efx_mae_actions_t *spec, - __in size_t arg_size, - __in_bcount(arg_size) const uint8_t *arg) -{ - efx_rc_t rc; - - _NOTE(ARGUNUSED(spec)) - - if (arg_size != 0) { - rc = EINVAL; - goto fail1; - } - - if (arg != NULL) { - rc = EINVAL; - goto fail2; - } - - /* This action does not have any arguments, so do nothing here. */ - - return (0); - -fail2: - EFSYS_PROBE(fail2); -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - return (rc); -} - static __checkReturn efx_rc_t efx_mae_action_set_add_mark( __in efx_mae_actions_t *spec, @@ -1693,7 +1621,7 @@ typedef struct efx_mae_action_desc_s { static const efx_mae_action_desc_t efx_mae_actions[EFX_MAE_NACTIONS] = { [EFX_MAE_ACTION_DECAP] = { - .emad_add = efx_mae_action_set_add_decap + .emad_add = efx_mae_action_set_no_op }, [EFX_MAE_ACTION_VLAN_POP] = { .emad_add = efx_mae_action_set_add_vlan_pop @@ -1702,13 +1630,13 @@ static const efx_mae_action_desc_t efx_mae_actions[EFX_MAE_NACTIONS] = { .emad_add = efx_mae_action_set_add_vlan_push }, [EFX_MAE_ACTION_ENCAP] = { - .emad_add = efx_mae_action_set_add_encap + .emad_add = efx_mae_action_set_no_op }, [EFX_MAE_ACTION_COUNT] = { .emad_add = efx_mae_action_set_add_count }, [EFX_MAE_ACTION_FLAG] = { - .emad_add = efx_mae_action_set_add_flag + .emad_add = efx_mae_action_set_no_op }, [EFX_MAE_ACTION_MARK] = { .emad_add = efx_mae_action_set_add_mark From patchwork Fri Nov 5 21:54:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 103891 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 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 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; From patchwork Fri Nov 5 21:54:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 103892 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 5C7A7A0C41; Fri, 5 Nov 2021 22:54:59 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 73B4641140; Fri, 5 Nov 2021 22:54:37 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 038C140689 for ; Fri, 5 Nov 2021 22:54:32 +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 A79A07F70D; Sat, 6 Nov 2021 00:54:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru A79A07F70D Authentication-Results: shelob.oktetlabs.ru/A79A07F70D; dkim=none; dkim-atps=neutral From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Andy Moreton Date: Sat, 6 Nov 2021 00:54:09 +0300 Message-Id: <20211105215409.5706-6-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 Subject: [dpdk-dev] [PATCH 5/5] net/sfc: support decrement IP TTL actions in transfer flows 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" These actions map to MAE action DECR_IP_TTL. It affects the outermost header in the current processing state of the packet, which might have been decapsulated by prior action DECAP. It also updates IPv4 checksum accordingly. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- doc/guides/nics/features/sfc.ini | 2 ++ doc/guides/nics/sfc_efx.rst | 4 ++++ drivers/net/sfc/sfc_mae.c | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/doc/guides/nics/features/sfc.ini b/doc/guides/nics/features/sfc.ini index 0d785f4765..1ce2dc46ba 100644 --- a/doc/guides/nics/features/sfc.ini +++ b/doc/guides/nics/features/sfc.ini @@ -62,10 +62,12 @@ vxlan = Y [rte_flow actions] count = Y +dec_ttl = Y drop = Y flag = Y jump = P mark = Y +of_dec_nw_ttl = Y of_pop_vlan = Y of_push_vlan = Y of_set_vlan_pcp = Y diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index 960e25bf98..00b95a4f58 100644 --- a/doc/guides/nics/sfc_efx.rst +++ b/doc/guides/nics/sfc_efx.rst @@ -234,6 +234,10 @@ Supported actions (***transfer*** rules): - OF_VLAN_SET_PCP +- OF_DEC_NW_TTL + +- DEC_TTL + - VXLAN_DECAP - VXLAN_ENCAP diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index 411f2ac27e..93cce60a3e 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -3587,6 +3587,14 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa, bundle->actions_mask); rc = efx_mae_action_set_populate_vlan_pop(spec); break; + case RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL: + case RTE_FLOW_ACTION_TYPE_DEC_TTL: + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL, + bundle->actions_mask); + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_DEC_TTL, + bundle->actions_mask); + rc = efx_mae_action_set_populate_decr_ip_ttl(spec); + break; case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN: SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN, bundle->actions_mask);