From patchwork Mon Oct 25 11:04:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 102763 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 39C4CA0C52; Mon, 25 Oct 2021 13:04:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E6B314115B; Mon, 25 Oct 2021 13:04:30 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id BFD1F410DA for ; Mon, 25 Oct 2021 13:04:23 +0200 (CEST) Received: from localhost.localdomain (unknown [5.144.121.149]) (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 74BED7F6FC; Mon, 25 Oct 2021 14:04:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 74BED7F6FC DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1635159863; bh=OJBYh2cDOdpm9IaqZzCrVfilH2fUWzLb1rYhKrJrYSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PlC7bAaxbJzy/BIzMHIdpj2tteqCh9Y7CIFiRIdLSUwmxSRI/L+UpAAFr9lnSOFrH aUIhUIPnc08og1aH+c4yGGLtCyE6XFHAC8ZpKqTdR8W/0MXJpcWTGPomFzxzQn1OOo tYYmY9a3lEr6Z8LEO5dUO6aQaQproUxG/pxh/yZ0= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko Date: Mon, 25 Oct 2021 14:04:13 +0300 Message-Id: <20211025110415.20683-5-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211025110415.20683-1-ivan.malov@oktetlabs.ru> References: <20211025110415.20683-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 5/7] net/sfc: support represented port 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" Add support for item REPRESENTED_PORT to match on traffic entering the embedded switch from the entity represented by the given ethdev (network port or VF). Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko --- doc/guides/nics/features/sfc.ini | 1 + doc/guides/nics/sfc_efx.rst | 2 ++ drivers/net/sfc/sfc_mae.c | 52 +++++++++++++++++++++++++------- drivers/net/sfc/sfc_switch.c | 29 ++++++++++++++++++ drivers/net/sfc/sfc_switch.h | 4 +++ 5 files changed, 77 insertions(+), 11 deletions(-) diff --git a/doc/guides/nics/features/sfc.ini b/doc/guides/nics/features/sfc.ini index 7db868e59f..c830426eb2 100644 --- a/doc/guides/nics/features/sfc.ini +++ b/doc/guides/nics/features/sfc.ini @@ -53,6 +53,7 @@ port_id = Y port_representor = Y pppoed = Y pppoes = Y +represented_port = Y tcp = Y udp = Y vf = Y diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index 843c24991c..8dbd250b3c 100644 --- a/doc/guides/nics/sfc_efx.rst +++ b/doc/guides/nics/sfc_efx.rst @@ -194,6 +194,8 @@ Supported pattern items (***transfer*** rules): - PORT_REPRESENTOR (cannot repeat; conflicts with other traffic source items) +- REPRESENTED_PORT (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 bd8a913a49..8ec4036275 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -1333,9 +1333,9 @@ sfc_mae_rule_parse_item_port_id(const struct rte_flow_item *item, } 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) +sfc_mae_rule_parse_item_ethdev_based(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 = { @@ -1363,20 +1363,38 @@ sfc_mae_rule_parse_item_port_representor(const struct rte_flow_item *item, 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"); + "Bad mask in the ethdev-based pattern item"); } /* If "spec" is not set, could be any port ID */ if (spec == NULL) return 0; - rc = sfc_mae_switch_get_ethdev_mport( - ctx_mae->sa->mae.switch_domain_id, - spec->port_id, &mport_sel); - if (rc != 0) { - return rte_flow_error_set(error, rc, + switch (item->type) { + case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR: + rc = sfc_mae_switch_get_ethdev_mport( + 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 get m-port for the given ethdev"); + } + break; + case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT: + rc = sfc_mae_switch_get_entity_mport( + 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 get m-port for the given ethdev"); + } + break; + default: + return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, - "Can't get m-port for the given ethdev"); + "Unsupported ethdev-based flow item"); } rc = efx_mae_match_spec_mport_set(ctx_mae->match_spec, @@ -2329,7 +2347,19 @@ static const struct sfc_flow_item sfc_flow_items[] = { .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, + .parse = sfc_mae_rule_parse_item_ethdev_based, + }, + { + .type = RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT, + .name = "REPRESENTED_PORT", + /* + * 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_ethdev_based, }, { .type = RTE_FLOW_ITEM_TYPE_PHY_PORT, diff --git a/drivers/net/sfc/sfc_switch.c b/drivers/net/sfc/sfc_switch.c index 3f7518fa30..5c10e8fc74 100644 --- a/drivers/net/sfc/sfc_switch.c +++ b/drivers/net/sfc/sfc_switch.c @@ -567,6 +567,35 @@ sfc_mae_switch_get_ethdev_mport(uint16_t switch_domain_id, return rc; } +int +sfc_mae_switch_get_entity_mport(uint16_t switch_domain_id, + uint16_t ethdev_port_id, + efx_mport_sel_t *mport_sel) +{ + static struct sfc_mae_switch_port *port; + int rc; + + rte_spinlock_lock(&sfc_mae_switch.lock); + rc = sfc_mae_find_switch_port_by_ethdev(switch_domain_id, + ethdev_port_id, &port); + if (rc != 0) + goto unlock; + + if (port->type == SFC_MAE_SWITCH_PORT_INDEPENDENT && + !port->data.indep.mae_admin) { + /* See sfc_mae_assign_entity_mport() */ + rc = ENOTSUP; + goto unlock; + } + + *mport_sel = port->entity_mport; + +unlock: + rte_spinlock_unlock(&sfc_mae_switch.lock); + + return rc; +} + int sfc_mae_switch_port_id_by_entity(uint16_t switch_domain_id, const efx_mport_sel_t *entity_mportp, diff --git a/drivers/net/sfc/sfc_switch.h b/drivers/net/sfc/sfc_switch.h index a5a0fb4fc5..62aea9b785 100644 --- a/drivers/net/sfc/sfc_switch.h +++ b/drivers/net/sfc/sfc_switch.h @@ -106,6 +106,10 @@ int sfc_mae_switch_get_ethdev_mport(uint16_t switch_domain_id, uint16_t ethdev_port_id, efx_mport_sel_t *mport_sel); +int sfc_mae_switch_get_entity_mport(uint16_t switch_domain_id, + uint16_t ethdev_port_id, + efx_mport_sel_t *mport_sel); + int sfc_mae_switch_port_id_by_entity(uint16_t switch_domain_id, const efx_mport_sel_t *entity_mportp, enum sfc_mae_switch_port_type type,