From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 39EA7A0C52; Wed, 13 Oct 2021 19:36:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 05A01411E8; Wed, 13 Oct 2021 19:35:20 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 1326241166 for ; Wed, 13 Oct 2021 19:35:05 +0200 (CEST) Received: from localhost.localdomain (unknown [5.144.123.99]) (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 ESMTPSA id C0F897F519; Wed, 13 Oct 2021 20:35:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru C0F897F519 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1634146504; bh=ED82LMtZx10I2tOxy1MhCmi3hoSZyd/5WN6/D+JmMNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kGLQaELW6nLx5p3wcoglscNqXR/ptRePYrn1sbqqM0P1nAJQe0vm8d0DovK/ASAt2 gpwbldlQCXgyDaS/PMyxa78YWwqXC2rpVERlHfSaQQeQ0MHWVAYHslRXr2gnZKsZob Jy/RRx7vvvMH03ltw0t7c7rQeDe5Yg5fgvb7qoTU= From: Ivan Malov To: dev@dpdk.org Cc: Ferruh Yigit , Thomas Monjalon , Ori Kam , Andrew Rybchenko Date: Wed, 13 Oct 2021 20:34:48 +0300 Message-Id: <20211013173448.28621-13-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211013173448.28621-1-ivan.malov@oktetlabs.ru> References: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> <20211013173448.28621-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v7 12/12] net/sfc: support port representor flow item 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" From: Andrew Rybchenko Add support for item PORT_REPRESENTOR which should be used instead of ambiguous item PORT_ID. Signed-off-by: Andrew Rybchenko --- doc/guides/nics/features/sfc.ini | 1 + doc/guides/nics/sfc_efx.rst | 2 + drivers/net/sfc/sfc_mae.c | 72 ++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/doc/guides/nics/features/sfc.ini b/doc/guides/nics/features/sfc.ini index 013fcd7086..6945f321f3 100644 --- a/doc/guides/nics/features/sfc.ini +++ b/doc/guides/nics/features/sfc.ini @@ -50,6 +50,7 @@ nvgre = Y pf = Y phy_port = Y port_id = Y +port_representor = Y pppoed = Y pppoes = Y tcp = Y diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index 4719031508..843c24991c 100644 --- a/doc/guides/nics/sfc_efx.rst +++ b/doc/guides/nics/sfc_efx.rst @@ -192,6 +192,8 @@ Supported actions (***non-transfer*** rules): Supported pattern items (***transfer*** rules): +- PORT_REPRESENTOR (cannot repeat; conflicts with other traffic source items) + - PORT_ID (cannot repeat; conflicts with other traffic source items) - PHY_PORT (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 ca91627d2f..4c5c7b776f 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -1284,6 +1284,66 @@ sfc_mae_rule_parse_item_port_id(const struct rte_flow_item *item, return 0; } +static int +sfc_mae_rule_parse_item_port_representor(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_ethdev supp_mask = { + .port_id = 0xffff, + }; + const void *def_mask = &rte_flow_item_ethdev_mask; + const struct rte_flow_item_ethdev *spec = NULL; + const struct rte_flow_item_ethdev *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_ethdev), error); + if (rc != 0) + return rc; + + if (mask->port_id != supp_mask.port_id) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Bad mask in the PORT_REPRESENTOR pattern item"); + } + + /* If "spec" is not set, could be any port ID */ + if (spec == NULL) + return 0; + + rc = sfc_mae_switch_port_by_ethdev( + ctx_mae->sa->mae.switch_domain_id, + spec->port_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, + &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, @@ -2211,6 +2271,18 @@ static const struct sfc_flow_item sfc_flow_items[] = { .ctx_type = SFC_FLOW_PARSE_CTX_MAE, .parse = sfc_mae_rule_parse_item_port_id, }, + { + .type = RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR, + .name = "PORT_REPRESENTOR", + /* + * 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_representor, + }, { .type = RTE_FLOW_ITEM_TYPE_PHY_PORT, .name = "PHY_PORT", -- 2.20.1