From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2B6A9A04DD; Tue, 20 Oct 2020 11:04:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 749B5C8D4; Tue, 20 Oct 2020 10:50:03 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id B743ABBB4 for ; Tue, 20 Oct 2020 10:49:04 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.62]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 8879360066 for ; Tue, 20 Oct 2020 08:49:04 +0000 (UTC) Received: from us4-mdac16-25.ut7.mdlocal (unknown [10.7.65.251]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 87A4D8009B for ; Tue, 20 Oct 2020 08:49:04 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.66.41]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 10B3028004D for ; Tue, 20 Oct 2020 08:49:04 +0000 (UTC) Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id B82974C0059 for ; Tue, 20 Oct 2020 08:49:03 +0000 (UTC) Received: from ukex01.SolarFlarecom.com (10.17.10.4) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 20 Oct 2020 09:48:50 +0100 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 20 Oct 2020 09:48:50 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id 09K8mnmO030803; Tue, 20 Oct 2020 09:48:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 3701A1626D8; Tue, 20 Oct 2020 09:48:49 +0100 (BST) From: Andrew Rybchenko To: CC: , Ivan Malov Date: Tue, 20 Oct 2020 09:47:55 +0100 Message-ID: <1603183709-23420-29-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603183709-23420-1-git-send-email-arybchenko@solarflare.com> References: <1603183709-23420-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25736.003 X-TM-AS-Result: No-6.694700-8.000000-10 X-TMASE-MatchedRID: 06MbsPpyjR8jNucrJ/Da40Qiyd+xo4asAPiR4btCEeaRoQLwUmtov+Z5 Gn23AeDZ8XVI39JCRnRuL3ESIrARlyHhSBQfglfsA9lly13c/gFe392/7zQs4B//bz4/xYKAg7l N9LOvFDvbKZq4ZwZRTVeJGcgaXvUTKjPlgWuJZGx0+657dxGJGFm0RpxOMxmR5lhx0mBJyPG9DD 1najpyL0FLaJMiMk4ci/W2oLMQ0YUEGNruDgdTzb09KAokwDFUBtG6netTkaWudK6ZkaOfBPyqd p7+4Qj9KexaoH99e/Qwg/gpNb2sRwXa2B9iG+md+4Fj9EzRyxxgRHGPNVoqHYpc3JtqeiRPeKaj vO6uWnCCukcfrdcoGfibKkET0a8ctLD+nJjWKTgjRwcsjqWGAgEFZ4PF7UrQbRmE6L06upYlXnw 1RqSfcI3FtUIcHUfM/vt4tYKcjeI6NBdUxznZvZCB65RjRY3sjlaPgQwpjaybKItl61J/yZ+inT K0bC9eKrauXd3MZDWg42+KMinH0UFnvntw+nrLyXgwBKCerXIGQ9s44ZGcccCdJ4a5sUpK X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--6.694700-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25736.003 X-MDID: 1603183744-m2s0K0Iu-HsQ X-PPE-DISP: 1603183744;m2s0K0Iu-HsQ Subject: [dpdk-dev] [PATCH 28/62] net/sfc: add facilities to handle bundles of actions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" From: Ivan Malov There are MAE actions which do not have uniform counterparts in terms of RTE flow. However, there are bundles of RTE flow actions which can be considered as such counterparts. Implement facilities to handle related RTE flow actions as parts of a whole. These facilities will be used by a later patch to add support for VLAN PUSH actions bundle. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_flow.c | 4 -- drivers/net/sfc/sfc_flow.h | 4 ++ drivers/net/sfc/sfc_mae.c | 112 ++++++++++++++++++++++++++++++++++++- 3 files changed, 115 insertions(+), 5 deletions(-) diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 3af95ac8ee..6ccefef477 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1679,9 +1679,6 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, return -rte_errno; } -#define SFC_BUILD_SET_OVERFLOW(_action, _set) \ - RTE_BUILD_BUG_ON(_action >= sizeof(_set) * CHAR_BIT) - for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { switch (actions->type) { case RTE_FLOW_ACTION_TYPE_VOID: @@ -1777,7 +1774,6 @@ sfc_flow_parse_actions(struct sfc_adapter *sa, actions_set |= (1UL << actions->type); } -#undef SFC_BUILD_SET_OVERFLOW /* When fate is unknown, drop traffic. */ if ((actions_set & fate_actions_mask) == 0) { diff --git a/drivers/net/sfc/sfc_flow.h b/drivers/net/sfc/sfc_flow.h index d3bdbd5f75..e991ae132c 100644 --- a/drivers/net/sfc/sfc_flow.h +++ b/drivers/net/sfc/sfc_flow.h @@ -26,6 +26,10 @@ extern "C" { */ #define SF_FLOW_SPEC_NB_FILTERS_MAX 8 +/* Used to guard action masks */ +#define SFC_BUILD_SET_OVERFLOW(_action, _set) \ + RTE_BUILD_BUG_ON((_action) >= sizeof(_set) * CHAR_BIT) + /* RSS configuration storage */ struct sfc_flow_rss { unsigned int rxq_hw_index_min; diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index a86a22ad8f..5fbf627f0a 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -445,6 +445,99 @@ sfc_mae_rule_parse_pattern(struct sfc_adapter *sa, return rc; } +/* + * An action supported by MAE may correspond to a bundle of RTE flow actions, + * in example, VLAN_PUSH = OF_PUSH_VLAN + OF_VLAN_SET_VID + OF_VLAN_SET_PCP. + * That is, related RTE flow actions need to be tracked as parts of a whole + * so that they can be combined into a single action and submitted to MAE + * representation of a given rule's action set. + * + * Each RTE flow action provided by an application gets classified as + * one belonging to some bundle type. If an action is not supposed to + * belong to any bundle, or if this action is END, it is described as + * one belonging to a dummy bundle of type EMPTY. + * + * A currently tracked bundle will be submitted if a repeating + * action or an action of different bundle type follows. + */ + +enum sfc_mae_actions_bundle_type { + SFC_MAE_ACTIONS_BUNDLE_EMPTY = 0, +}; + +struct sfc_mae_actions_bundle { + enum sfc_mae_actions_bundle_type type; + + /* Indicates actions already tracked by the current bundle */ + uint64_t actions_mask; +}; + +/* + * Combine configuration of RTE flow actions tracked by the bundle into a + * single action and submit the result to MAE action set specification. + * Do nothing in the case of dummy action bundle. + */ +static int +sfc_mae_actions_bundle_submit(const struct sfc_mae_actions_bundle *bundle, + __rte_unused efx_mae_actions_t *spec) +{ + int rc = 0; + + switch (bundle->type) { + case SFC_MAE_ACTIONS_BUNDLE_EMPTY: + break; + default: + SFC_ASSERT(B_FALSE); + break; + } + + return rc; +} + +/* + * Given the type of the next RTE flow action in the line, decide + * whether a new bundle is about to start, and, if this is the case, + * submit and reset the current bundle. + */ +static int +sfc_mae_actions_bundle_sync(const struct rte_flow_action *action, + struct sfc_mae_actions_bundle *bundle, + efx_mae_actions_t *spec, + struct rte_flow_error *error) +{ + enum sfc_mae_actions_bundle_type bundle_type_new; + int rc; + + switch (action->type) { + default: + /* + * Self-sufficient actions, including END, are handled in this + * case. No checks for unsupported actions are needed here + * because parsing doesn't occur at this point. + */ + bundle_type_new = SFC_MAE_ACTIONS_BUNDLE_EMPTY; + break; + } + + if (bundle_type_new != bundle->type || + (bundle->actions_mask & (1ULL << action->type)) != 0) { + rc = sfc_mae_actions_bundle_submit(bundle, spec); + if (rc != 0) + goto fail_submit; + + memset(bundle, 0, sizeof(*bundle)); + } + + bundle->type = bundle_type_new; + + return 0; + +fail_submit: + return rte_flow_error_set(error, rc, + RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "Failed to request the (group of) action(s)"); +} + static int sfc_mae_rule_parse_action_phy_port(struct sfc_adapter *sa, const struct rte_flow_action_phy_port *conf, @@ -469,6 +562,7 @@ sfc_mae_rule_parse_action_phy_port(struct sfc_adapter *sa, static int sfc_mae_rule_parse_action(struct sfc_adapter *sa, const struct rte_flow_action *action, + struct sfc_mae_actions_bundle *bundle, efx_mae_actions_t *spec, struct rte_flow_error *error) { @@ -476,9 +570,13 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa, switch (action->type) { case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN: + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_OF_POP_VLAN, + bundle->actions_mask); rc = efx_mae_action_set_populate_vlan_pop(spec); break; case RTE_FLOW_ACTION_TYPE_PHY_PORT: + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_PHY_PORT, + bundle->actions_mask); rc = sfc_mae_rule_parse_action_phy_port(sa, action->conf, spec); break; default: @@ -490,6 +588,8 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa, if (rc != 0) { rc = rte_flow_error_set(error, rc, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "Failed to request the action"); + } else { + bundle->actions_mask |= (1ULL << action->type); } return rc; @@ -501,6 +601,7 @@ sfc_mae_rule_parse_actions(struct sfc_adapter *sa, struct sfc_mae_action_set **action_setp, struct rte_flow_error *error) { + struct sfc_mae_actions_bundle bundle = {0}; const struct rte_flow_action *action; efx_mae_actions_t *spec; int rc; @@ -517,11 +618,20 @@ sfc_mae_rule_parse_actions(struct sfc_adapter *sa, for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) { - rc = sfc_mae_rule_parse_action(sa, action, spec, error); + rc = sfc_mae_actions_bundle_sync(action, &bundle, spec, error); + if (rc != 0) + goto fail_rule_parse_action; + + rc = sfc_mae_rule_parse_action(sa, action, &bundle, spec, + error); if (rc != 0) goto fail_rule_parse_action; } + rc = sfc_mae_actions_bundle_sync(action, &bundle, spec, error); + if (rc != 0) + goto fail_rule_parse_action; + *action_setp = sfc_mae_action_set_attach(sa, spec); if (*action_setp != NULL) { efx_mae_action_set_spec_fini(sa->nic, spec); -- 2.17.1