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 81C3EA04DD; Tue, 20 Oct 2020 11:00:30 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8A5E4AD33; Tue, 20 Oct 2020 10:49:50 +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 680C0BBAE for ; Tue, 20 Oct 2020 10:49:04 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.60]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 26AEF60054 for ; Tue, 20 Oct 2020 08:49:04 +0000 (UTC) Received: from us4-mdac16-62.ut7.mdlocal (unknown [10.7.66.61]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 274EF2009A 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 A57FC1C004F for ; Tue, 20 Oct 2020 08:49:03 +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 584324C0064 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 09K8mnEJ030805; 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 9C6321626EA; Tue, 20 Oct 2020 09:48:49 +0100 (BST) From: Andrew Rybchenko To: CC: , Ivan Malov Date: Tue, 20 Oct 2020 09:48:03 +0100 Message-ID: <1603183709-23420-37-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.832600-8.000000-10 X-TMASE-MatchedRID: 45LChreVRiQfKML5AJtfLabtlVLKF4zpaeMaKzvXUpljLp8Cm8vwFwoe RRhCZWIBfGzuoVn0Vs6PQi9XuOWoOPyUSi1R/9mUHl2pJS1lPFu1vfBQSgBJqJck4WtpRCa1KWM 3aQNUjqhSBYbXlRzeV/9vSUyC4hWYqj01FlWBadqHZXNSWjgdU3VNoFzxmabndPuD+FuuXo7u9+ Mep8zDYhRG3wzjcy8gbDgPJqIxAh83KXWd30Ii3RRFJJyf5BJe3QfwsVk0UbvqwGfCk7KUs5ezw SW0eLgTGSOflvkC6XLdl4U8LJxzABQUcgIVHunC8xDd5IZMw4de52L5QGdjqCnpv7jwCVldskhp jLV1Y07VtJPAMNyGQQ9cvEd/Et5dVEc5IqztENReYfSkFq6uAb7jE6+wkCSeftwZ3X11IV0= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--1.832600-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25736.003 X-MDID: 1603183744-V92rj4L0gGEs X-PPE-DISP: 1603183744;V92rj4L0gGEs Subject: [dpdk-dev] [PATCH 36/62] net/sfc: support flow items PF and VF 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 these flow items to MAE-specific RTE flow implementation. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- doc/guides/nics/sfc_efx.rst | 4 ++ drivers/net/sfc/sfc_mae.c | 126 ++++++++++++++++++++++++++++++++++++ drivers/net/sfc/sfc_mae.h | 1 + 3 files changed, 131 insertions(+) diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index ff0d094068..b0f19d51b4 100644 --- a/doc/guides/nics/sfc_efx.rst +++ b/doc/guides/nics/sfc_efx.rst @@ -192,6 +192,10 @@ Supported pattern items (***transfer*** rules): - PHY_PORT (cannot repeat; conflicts with other traffic source items) +- PF (cannot repeat; conflicts with other traffic source items) + +- VF (cannot repeat; conflicts with other traffic source items) + - ETH Supported actions (***transfer*** rules): diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index 1e7a368303..7d1a3b5999 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -276,6 +276,109 @@ sfc_mae_rule_parse_item_phy_port(const struct rte_flow_item *item, return 0; } +static int +sfc_mae_rule_parse_item_pf(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 efx_nic_cfg_t *encp = efx_nic_cfg_get(ctx_mae->sa->nic); + efx_mport_sel_t mport_v; + 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 = efx_mae_mport_by_pcie_function(encp->enc_pf, EFX_PCI_VF_INVALID, + &mport_v); + if (rc != 0) { + return rte_flow_error_set(error, rc, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Failed to convert the PF ID"); + } + + rc = efx_mae_match_spec_mport_set(ctx_mae->match_spec_action, + &mport_v, NULL); + if (rc != 0) { + return rte_flow_error_set(error, rc, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Failed to set MPORT for the PF"); + } + + ctx_mae->match_mport_set = B_TRUE; + + return 0; +} + +static int +sfc_mae_rule_parse_item_vf(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 efx_nic_cfg_t *encp = efx_nic_cfg_get(ctx_mae->sa->nic); + const struct rte_flow_item_vf supp_mask = { + .id = 0xffffffff, + }; + const void *def_mask = &rte_flow_item_vf_mask; + const struct rte_flow_item_vf *spec = NULL; + const struct rte_flow_item_vf *mask = NULL; + efx_mport_sel_t mport_v; + 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_vf), 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 VF pattern item"); + } + + /* + * If "spec" is not set, the item requests any VF related to the + * PF of the current DPDK port (but not the PF itself). + * Reject this match criterion as unsupported. + */ + if (spec == NULL) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Bad spec in the VF pattern item"); + } + + rc = efx_mae_mport_by_pcie_function(encp->enc_pf, spec->id, &mport_v); + if (rc != 0) { + return rte_flow_error_set(error, rc, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Failed to convert the PF + VF IDs"); + } + + rc = efx_mae_match_spec_mport_set(ctx_mae->match_spec_action, + &mport_v, NULL); + if (rc != 0) { + return rte_flow_error_set(error, rc, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Failed to set MPORT for the PF + VF"); + } + + ctx_mae->match_mport_set = B_TRUE; + + return 0; +} + struct sfc_mae_field_locator { efx_mae_field_id_t field_id; size_t size; @@ -387,6 +490,28 @@ static const struct sfc_flow_item sfc_flow_items[] = { .ctx_type = SFC_FLOW_PARSE_CTX_MAE, .parse = sfc_mae_rule_parse_item_phy_port, }, + { + .type = RTE_FLOW_ITEM_TYPE_PF, + /* + * 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_pf, + }, + { + .type = RTE_FLOW_ITEM_TYPE_VF, + /* + * 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_vf, + }, { .type = RTE_FLOW_ITEM_TYPE_ETH, .prev_layer = SFC_FLOW_ITEM_START_LAYER, @@ -407,6 +532,7 @@ sfc_mae_rule_parse_pattern(struct sfc_adapter *sa, int rc; memset(&ctx_mae, 0, sizeof(ctx_mae)); + ctx_mae.sa = sa; rc = efx_mae_match_spec_init(sa->nic, EFX_MAE_RULE_ACTION, spec->priority, diff --git a/drivers/net/sfc/sfc_mae.h b/drivers/net/sfc/sfc_mae.h index d9f0ee3cbc..3c34d08f88 100644 --- a/drivers/net/sfc/sfc_mae.h +++ b/drivers/net/sfc/sfc_mae.h @@ -57,6 +57,7 @@ struct sfc_adapter; struct sfc_flow_spec; struct sfc_mae_parse_ctx { + struct sfc_adapter *sa; efx_mae_match_spec_t *match_spec_action; bool match_mport_set; }; -- 2.17.1