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 492D3A04DD; Tue, 20 Oct 2020 11:01:15 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 29247C81E; Tue, 20 Oct 2020 10:49:53 +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 EB4B4BBA6 for ; Tue, 20 Oct 2020 10:49:04 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.61]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 78B036004D for ; Tue, 20 Oct 2020 08:49:03 +0000 (UTC) Received: from us4-mdac16-58.ut7.mdlocal (unknown [10.7.66.29]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 78B518009E for ; Tue, 20 Oct 2020 08:49:03 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.200]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id DA38580057 for ; Tue, 20 Oct 2020 08:49:02 +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 907EB800058 for ; Tue, 20 Oct 2020 08:49:02 +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 09K8monK030888; Tue, 20 Oct 2020 09:48:50 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 22A221613A9; Tue, 20 Oct 2020 09:48:50 +0100 (BST) From: Andrew Rybchenko To: CC: , Ivan Malov Date: Tue, 20 Oct 2020 09:48:12 +0100 Message-ID: <1603183709-23420-46-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-1.793500-8.000000-10 X-TMASE-MatchedRID: wAskXJFQGCEfKML5AJtfLVkxnoxnQfVSL1eX+z9B1QxwkdIrVt8X1ciT Wug2C4DNNNN0dk/lb45w5T4Iaj538mJZXQNDzktS+ACG5oWJ7tLH6OsXtPNFLT8fBHJpFUzVM/3 +TuDqaXfbChJmGA7/2t7D7QDzMhW65kIIdSBWpoH9tX9U6Guaiti5W7Rf+s6QDpCUEeEFm7AVAs f1+cZFJ5yTP1lsxtj2Ehs1pFGBg9IAH0kGDN+N054CIKY/Hg3AaZGo0EeYG96i9JVLbqc4Fyq2r l3dzGQ1r1S3+0WjH8xzyAqWo2KjhG46VkHHINVQqsDD2EnxKvMtfwKLTZ0mnvjHqksKBdobrUGO Aofsk2R7ux96hbe72RAaAkgNd9JPUMQ8hJn9I6Q4oGQUCbwY5Q+g7mdwjo656FtDZCmYBJ3KTLw /lNgw8g== X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--1.793500-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25736.003 X-MDID: 1603183743-Lcc04bu64-68 X-PPE-DISP: 1603183743;Lcc04bu64-68 Subject: [dpdk-dev] [PATCH 45/62] net/sfc: support flow item PORT ID in transfer rules 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 Add support for this flow item to MAE-specific RTE flow implementation. The DPDK port must not relate to a different physical device. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- doc/guides/nics/sfc_efx.rst | 2 + drivers/net/sfc/sfc_mae.c | 76 +++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index 7b8c1c8527..e1cacf55ff 100644 --- a/doc/guides/nics/sfc_efx.rst +++ b/doc/guides/nics/sfc_efx.rst @@ -190,6 +190,8 @@ Supported actions (***non-transfer*** rules): Supported pattern items (***transfer*** rules): +- PORT_ID (cannot repeat; conflicts with other traffic source items) + - PHY_PORT (cannot repeat; conflicts with other traffic source items) - PF (cannot repeat; conflicts with other traffic source items) diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index f309efa2cf..14e6d33c55 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -260,6 +260,71 @@ sfc_mae_flow_cleanup(struct sfc_adapter *sa, efx_mae_match_spec_fini(sa->nic, spec_mae->match_spec); } +static int +sfc_mae_rule_parse_item_port_id(const struct rte_flow_item *item, + struct sfc_flow_parse_ctx *ctx, + struct rte_flow_error *error) +{ + struct sfc_mae_parse_ctx *ctx_mae = ctx->mae; + const struct rte_flow_item_port_id supp_mask = { + .id = 0xffffffff, + }; + const void *def_mask = &rte_flow_item_port_id_mask; + const struct rte_flow_item_port_id *spec = NULL; + const struct rte_flow_item_port_id *mask = NULL; + efx_mport_sel_t mport_sel; + int rc; + + if (ctx_mae->match_mport_set) { + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Can't handle multiple traffic source items"); + } + + rc = sfc_flow_parse_init(item, + (const void **)&spec, (const void **)&mask, + (const void *)&supp_mask, def_mask, + sizeof(struct rte_flow_item_port_id), error); + if (rc != 0) + return rc; + + if (mask->id != supp_mask.id) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Bad mask in the PORT_ID pattern item"); + } + + /* If "spec" is not set, could be any port ID */ + if (spec == NULL) + return 0; + + if (spec->id > UINT16_MAX) { + return rte_flow_error_set(error, EOVERFLOW, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "The port ID is too large"); + } + + rc = sfc_mae_switch_port_by_ethdev(ctx_mae->sa->mae.switch_domain_id, + spec->id, &mport_sel); + if (rc != 0) { + return rte_flow_error_set(error, rc, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Can't find RTE ethdev by the port ID"); + } + + rc = efx_mae_match_spec_mport_set(ctx_mae->match_spec_action, + &mport_sel, NULL); + if (rc != 0) { + return rte_flow_error_set(error, rc, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Failed to set MPORT for the port ID"); + } + + ctx_mae->match_mport_set = B_TRUE; + + return 0; +} + static int sfc_mae_rule_parse_item_phy_port(const struct rte_flow_item *item, struct sfc_flow_parse_ctx *ctx, @@ -521,6 +586,17 @@ sfc_mae_rule_parse_item_eth(const struct rte_flow_item *item, } static const struct sfc_flow_item sfc_flow_items[] = { + { + .type = RTE_FLOW_ITEM_TYPE_PORT_ID, + /* + * In terms of RTE flow, this item is a META one, + * and its position in the pattern is don't care. + */ + .prev_layer = SFC_FLOW_ITEM_ANY_LAYER, + .layer = SFC_FLOW_ITEM_ANY_LAYER, + .ctx_type = SFC_FLOW_PARSE_CTX_MAE, + .parse = sfc_mae_rule_parse_item_port_id, + }, { .type = RTE_FLOW_ITEM_TYPE_PHY_PORT, /* -- 2.17.1