From patchwork Sun Jun 4 23:25:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 128047 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 8F22F42C2C; Mon, 5 Jun 2023 01:27:34 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7047342F96; Mon, 5 Jun 2023 01:25:49 +0200 (CEST) Received: from agw.arknetworks.am (agw.arknetworks.am [79.141.165.80]) by mails.dpdk.org (Postfix) with ESMTP id 2345442D4E for ; Mon, 5 Jun 2023 01:25:35 +0200 (CEST) Received: from localhost.localdomain (unknown [78.109.68.201]) (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 A7280E12CA; Mon, 5 Jun 2023 03:25:34 +0400 (+04) From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Ferruh Yigit , Andy Moreton Subject: [PATCH v3 19/34] net/sfc: prepare MAE outer rules for action rule indirection Date: Mon, 5 Jun 2023 03:25:08 +0400 Message-Id: <20230604232523.6746-20-ivan.malov@arknetworks.am> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230604232523.6746-1-ivan.malov@arknetworks.am> References: <20230601195538.8265-1-ivan.malov@arknetworks.am> <20230604232523.6746-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 Flows provided by match-action engine (MAE) will be reworked by the next patch to make action rule (AR) entries shareable. To ensure correct AR specification comparison on attach path, augment the way outer rules (OR) are handled, namely, how OR IDs are indicated in a AR specification on parse and disable. Signed-off-by: Ivan Malov Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_mae.c | 44 ++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index 37292f5d7c..624be53269 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -397,8 +397,10 @@ sfc_mae_outer_rule_enable(struct sfc_adapter *sa, static void sfc_mae_outer_rule_disable(struct sfc_adapter *sa, - struct sfc_mae_outer_rule *rule) + struct sfc_mae_outer_rule *rule, + efx_mae_match_spec_t *match_spec_action) { + efx_mae_rule_id_t invalid_rule_id = { .id = EFX_MAE_RSRC_ID_INVALID }; struct sfc_mae_fw_rsrc *fw_rsrc; int rc; @@ -409,6 +411,18 @@ sfc_mae_outer_rule_disable(struct sfc_adapter *sa, fw_rsrc = &rule->fw_rsrc; + if (match_spec_action == NULL) + goto skip_action_rule; + + rc = efx_mae_match_spec_outer_rule_id_set(match_spec_action, + &invalid_rule_id); + if (rc != 0) { + sfc_err(sa, "cannot restore match on invalid outer rule ID: %s", + strerror(rc)); + return; + } + +skip_action_rule: if (fw_rsrc->rule_id.id == EFX_MAE_RSRC_ID_INVALID || fw_rsrc->refcnt == 0) { sfc_err(sa, "failed to disable outer_rule=%p: already disabled; OR_ID=0x%08x, refcnt=%u", @@ -2457,7 +2471,7 @@ sfc_mae_rule_process_outer(struct sfc_adapter *sa, struct sfc_mae_outer_rule **rulep, struct rte_flow_error *error) { - efx_mae_rule_id_t invalid_rule_id = { .id = EFX_MAE_RSRC_ID_INVALID }; + efx_mae_rule_id_t or_id = { .id = EFX_MAE_RSRC_ID_INVALID }; int rc; if (ctx->internal) { @@ -2504,13 +2518,20 @@ sfc_mae_rule_process_outer(struct sfc_adapter *sa, /* The spec has now been tracked by the outer rule entry. */ ctx->match_spec_outer = NULL; + or_id.id = (*rulep)->fw_rsrc.rule_id.id; + no_or_id: switch (ctx->ft_rule_type) { case SFC_FT_RULE_NONE: break; case SFC_FT_RULE_TUNNEL: - /* No action rule */ - return 0; + /* + * Workaround. TUNNEL flows are not supposed to involve + * MAE action rules, but, due to the currently limited + * HW/FW implementation, action rules are still needed. + * See sfc_mae_rule_parse_pattern(). + */ + break; case SFC_FT_RULE_SWITCH: /* * Match on recirculation ID rather than @@ -2536,14 +2557,13 @@ sfc_mae_rule_process_outer(struct sfc_adapter *sa, * outer rule table. Set OR_ID match field to 0xffffffff/0xffffffff * in the action rule specification; this ensures correct behaviour. * - * If, on the other hand, this flow does have an outer rule, its ID - * may be unknown at the moment (not yet allocated), but OR_ID mask - * has to be set to 0xffffffff anyway for correct class comparisons. - * When the outer rule has been allocated, this match field will be - * overridden by sfc_mae_outer_rule_enable() to use the right value. + * If, however, this flow does have an outer rule, OR_ID match must + * be set to the currently known value for that outer rule. It will + * be either 0xffffffff or some valid ID, depending on whether this + * outer rule is currently active (adapter state is STARTED) or not. */ rc = efx_mae_match_spec_outer_rule_id_set(ctx->match_spec_action, - &invalid_rule_id); + &or_id); if (rc != 0) { sfc_mae_outer_rule_del(sa, *rulep); *rulep = NULL; @@ -4170,7 +4190,7 @@ sfc_mae_flow_insert(struct sfc_adapter *sa, sfc_mae_action_set_disable(sa, action_set); fail_action_set_enable: - sfc_mae_outer_rule_disable(sa, outer_rule); + sfc_mae_outer_rule_disable(sa, outer_rule, spec_mae->match_spec); fail_outer_rule_enable: return rc; @@ -4205,7 +4225,7 @@ sfc_mae_flow_remove(struct sfc_adapter *sa, sfc_mae_action_set_disable(sa, action_set); skip_action_rule: - sfc_mae_outer_rule_disable(sa, outer_rule); + sfc_mae_outer_rule_disable(sa, outer_rule, spec_mae->match_spec); return 0; }