From patchwork Mon Oct 25 11:04:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 102759 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 45BF7A0C52; Mon, 25 Oct 2021 13:04:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AF3EA40E3C; Mon, 25 Oct 2021 13:04:23 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 15B6F407FF 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 7336E7F66F; Mon, 25 Oct 2021 14:04:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 7336E7F66F DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1635159862; bh=YtE4599NJw5gaLqYVOEDM4tjRFAiojMkBveDN7L7fjk=; h=From:To:Cc:Subject:Date; b=YdEWyPmjjMHBF/TzeNRz2j+d3FQbJlyBco19R6u4oZ/SHOv9+XPsneNGfN/IiEc7d PRnUnmTC0BFDQDu0CtyaEolOmyrO2K5gAYM2r1G7nXlCdyeWdq1KWLXMVLbyPLZRYV ucc3Obl+UqphgLJJadJ2oL2BBpFjtUUEb1Lf9ALk= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Andy Moreton , Igor Romanov Date: Mon, 25 Oct 2021 14:04:09 +0300 Message-Id: <20211025110415.20683-1-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/7] net/sfc: do not allow flow rules to refer to VF representors 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" VF representors do not own dedicated m-ports and thus cannot be referred to as traffic endpoints in flow items or actions. Fixes: a62ec90522a6 ("net/sfc: add port representors infrastructure") Fixes: f55b61cec94a ("net/sfc: support port representor flow item") Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko --- drivers/net/sfc/sfc_switch.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/net/sfc/sfc_switch.c b/drivers/net/sfc/sfc_switch.c index a28e861de5..265a17f4c4 100644 --- a/drivers/net/sfc/sfc_switch.c +++ b/drivers/net/sfc/sfc_switch.c @@ -512,7 +512,7 @@ sfc_mae_clear_switch_port(uint16_t switch_domain_id, static int sfc_mae_find_switch_port_by_ethdev(uint16_t switch_domain_id, uint16_t ethdev_port_id, - efx_mport_sel_t *mport_sel) + struct sfc_mae_switch_port **switch_port) { struct sfc_mae_switch_domain *domain; struct sfc_mae_switch_port *port; @@ -528,7 +528,7 @@ sfc_mae_find_switch_port_by_ethdev(uint16_t switch_domain_id, TAILQ_FOREACH(port, &domain->ports, switch_domain_ports) { if (port->ethdev_port_id == ethdev_port_id) { - *mport_sel = port->ethdev_mport; + *switch_port = port; return 0; } } @@ -541,11 +541,27 @@ sfc_mae_switch_port_by_ethdev(uint16_t switch_domain_id, uint16_t ethdev_port_id, efx_mport_sel_t *mport_sel) { + 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, mport_sel); + ethdev_port_id, &port); + if (rc != 0) + goto unlock; + + if (port->type != SFC_MAE_SWITCH_PORT_INDEPENDENT) { + /* + * The ethdev is a "VF representor". It does not own + * a dedicated m-port suitable for use in flow rules. + */ + rc = ENOTSUP; + goto unlock; + } + + *mport_sel = port->ethdev_mport; + +unlock: rte_spinlock_unlock(&sfc_mae_switch.lock); return rc; From patchwork Mon Oct 25 11:04:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 102761 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 66DEFA0C52; Mon, 25 Oct 2021 13:04:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7122D4113B; Mon, 25 Oct 2021 13:04:25 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 5371B407FF 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 B39607F670; Mon, 25 Oct 2021 14:04:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru B39607F670 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1635159862; bh=+dhUt+JaCUFQS2/5B+SUJmpEDxqfNuSEPG7wxWI9D+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tuK8ufGTM86GPnua9YRQ39KHV+vICLG46xHUajTh74Q0AKjLlbgFAsuV4kE2S4zBg ZL28HsFMU04UUY+hDg3GN1mwcNcsw5AB45B4oOADtEMUA1xaisR3Op4mMNe9MMG6Sf uxT+UpE7eW7Qm2dvyaGP9Zn8dURg6b2gD9xPXATI= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko Date: Mon, 25 Oct 2021 14:04:10 +0300 Message-Id: <20211025110415.20683-2-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 2/7] net/sfc: rename ethdev m-port retrieval helper 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" The function in question has an unfortunate name that reads like finding a SW switch port entry. In fact just one of the two m-ports is retrieved from that entry. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko --- drivers/net/sfc/sfc_mae.c | 10 +++++----- drivers/net/sfc/sfc_switch.c | 6 +++--- drivers/net/sfc/sfc_switch.h | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index 455744c570..84b13925ff 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -1276,8 +1276,8 @@ sfc_mae_rule_parse_item_port_id(const struct rte_flow_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); + rc = sfc_mae_switch_get_ethdev_mport(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, @@ -1335,7 +1335,7 @@ sfc_mae_rule_parse_item_port_representor(const struct rte_flow_item *item, if (spec == NULL) return 0; - rc = sfc_mae_switch_port_by_ethdev( + rc = sfc_mae_switch_get_ethdev_mport( ctx_mae->sa->mae.switch_domain_id, spec->port_id, &mport_sel); if (rc != 0) { @@ -3406,8 +3406,8 @@ sfc_mae_rule_parse_action_port_id(struct sfc_adapter *sa, port_id = (conf->original != 0) ? sas->port_id : conf->id; - rc = sfc_mae_switch_port_by_ethdev(mae->switch_domain_id, - port_id, &mport); + rc = sfc_mae_switch_get_ethdev_mport(mae->switch_domain_id, + port_id, &mport); if (rc != 0) { sfc_err(sa, "failed to find MAE switch port SW entry for RTE ethdev port %u: %s", port_id, strerror(rc)); diff --git a/drivers/net/sfc/sfc_switch.c b/drivers/net/sfc/sfc_switch.c index 265a17f4c4..3f7518fa30 100644 --- a/drivers/net/sfc/sfc_switch.c +++ b/drivers/net/sfc/sfc_switch.c @@ -537,9 +537,9 @@ sfc_mae_find_switch_port_by_ethdev(uint16_t switch_domain_id, } int -sfc_mae_switch_port_by_ethdev(uint16_t switch_domain_id, - uint16_t ethdev_port_id, - efx_mport_sel_t *mport_sel) +sfc_mae_switch_get_ethdev_mport(uint16_t switch_domain_id, + uint16_t ethdev_port_id, + efx_mport_sel_t *mport_sel) { struct sfc_mae_switch_port *port; int rc; diff --git a/drivers/net/sfc/sfc_switch.h b/drivers/net/sfc/sfc_switch.h index 7917141038..a5a0fb4fc5 100644 --- a/drivers/net/sfc/sfc_switch.h +++ b/drivers/net/sfc/sfc_switch.h @@ -102,9 +102,9 @@ int sfc_mae_assign_switch_port(uint16_t switch_domain_id, int sfc_mae_clear_switch_port(uint16_t switch_domain_id, uint16_t switch_port_id); -int sfc_mae_switch_port_by_ethdev(uint16_t switch_domain_id, - uint16_t ethdev_port_id, - efx_mport_sel_t *mport_sel); +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_port_id_by_entity(uint16_t switch_domain_id, const efx_mport_sel_t *entity_mportp, From patchwork Mon Oct 25 11:04:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 102760 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 9CF12A0C52; Mon, 25 Oct 2021 13:04:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 711F94111B; Mon, 25 Oct 2021 13:04:24 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 4856640E32 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 EC2D77F6F8; Mon, 25 Oct 2021 14:04:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru EC2D77F6F8 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1635159863; bh=QfeYI2qnQEUC9Cmo+NDT2teQkDeHPTUZxp9rELws4mw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PXNqgpxVut1th1UcbL7Cpa3id0RwUsevucSFoGOWH4ICXFSfvafUzE5IXSbPjRHsM TGt2207p7WcslmchSqpLsEohKmfZjjdQo9fJcn2qTeTCzx3lcTc40jGLu9180xxyVH Z463il+G9XQcUjm2sQ216N382nFiW2potb+Fv1Zk= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko Date: Mon, 25 Oct 2021 14:04:11 +0300 Message-Id: <20211025110415.20683-3-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 3/7] net/sfc: improve m-port related log messages 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" Make these messages more specific. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko --- drivers/net/sfc/sfc_mae.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index 84b13925ff..a4a22f32c6 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -1281,7 +1281,7 @@ sfc_mae_rule_parse_item_port_id(const struct rte_flow_item *item, 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"); + "Can't get m-port for the given ethdev"); } rc = efx_mae_match_spec_mport_set(ctx_mae->match_spec, @@ -1341,7 +1341,7 @@ sfc_mae_rule_parse_item_port_representor(const struct rte_flow_item *item, 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"); + "Can't get m-port for the given ethdev"); } rc = efx_mae_match_spec_mport_set(ctx_mae->match_spec, @@ -3409,7 +3409,7 @@ sfc_mae_rule_parse_action_port_id(struct sfc_adapter *sa, rc = sfc_mae_switch_get_ethdev_mport(mae->switch_domain_id, port_id, &mport); if (rc != 0) { - sfc_err(sa, "failed to find MAE switch port SW entry for RTE ethdev port %u: %s", + sfc_err(sa, "failed to get m-port for the given ethdev (port_id=%u): %s", port_id, strerror(rc)); return rc; } From patchwork Mon Oct 25 11:04:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 102762 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 00A3CA0C52; Mon, 25 Oct 2021 13:04:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EE8B741152; Mon, 25 Oct 2021 13:04:29 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 7F9E740E32 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 33F837F6FA; Mon, 25 Oct 2021 14:04:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 33F837F6FA DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1635159863; bh=Vi693HbEbD5V0E8eQSLHnMKCQGusqfWKoC4CPsT/IpQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Xj1fE+OhFR0pqRLqcJG+XfjYxlZn17gFWyXjXJXSVGuFviDSGbcKy/A4i7ZxYrMe6 Q3yp3Wjg6e0/Kogx1uxrAUxQukZfRS+4zga+lqm/0GiA4fdvOIXhiNvEpkTOXf+cKV spzfRA2wOxWkcBqK3pp0/ppg633wsH+18wVaoLlU= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko Date: Mon, 25 Oct 2021 14:04:12 +0300 Message-Id: <20211025110415.20683-4-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 4/7] net/sfc: assign correct m-ports to independent switch ports 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" In accordance with patches [1-4], MAE admin ethdev represents a network port and not the PF which it sits on. Rework the way how "ethdev" and "entity" m-ports are assigned in SW switch port entries of independent ethdevs. Explain in comments. [1] commit 081e42dab11d ("ethdev: add port representor item to flow API") [2] commit 49863ae2bf95 ("ethdev: add represented port item to flow API") [3] commit 8edb6bc0263e ("ethdev: add port representor action to flow API") [4] commit 88caad251c8d ("ethdev: add represented port action to flow API") Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko --- drivers/net/sfc/sfc_mae.c | 41 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index a4a22f32c6..bd8a913a49 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -23,7 +23,7 @@ #include "sfc_service.h" static int -sfc_mae_assign_entity_mport(struct sfc_adapter *sa, +sfc_mae_assign_ethdev_mport(struct sfc_adapter *sa, efx_mport_sel_t *mportp) { const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic); @@ -32,6 +32,35 @@ sfc_mae_assign_entity_mport(struct sfc_adapter *sa, mportp); } +static int +sfc_mae_assign_entity_mport(struct sfc_adapter *sa, + efx_mport_sel_t *mportp) +{ + const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic); + int rc = 0; + + if (encp->enc_mae_admin) { + /* + * This ethdev sits on MAE admin PF. The represented + * entity is the network port assigned to that PF. + */ + rc = efx_mae_mport_by_phy_port(encp->enc_assigned_port, mportp); + } else { + /* + * This ethdev sits on unprivileged PF / VF. The entity + * represented by the ethdev can change dynamically + * as MAE admin changes default traffic rules. + * + * For the sake of simplicity, do not fill in the m-port + * and assume that flow rules should not be allowed to + * reference the entity represented by this ethdev. + */ + efx_mae_mport_invalid(mportp); + } + + return rc; +} + static int sfc_mae_counter_registry_init(struct sfc_mae_counter_registry *registry, uint32_t nb_counters_max) @@ -184,6 +213,7 @@ sfc_mae_attach(struct sfc_adapter *sa) struct sfc_adapter_shared * const sas = sfc_sa2shared(sa); struct sfc_mae_switch_port_request switch_port_request = {0}; const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic); + efx_mport_sel_t ethdev_mport; efx_mport_sel_t entity_mport; struct sfc_mae *mae = &sa->mae; struct sfc_mae_bounce_eh *bounce_eh = &mae->bounce_eh; @@ -218,6 +248,11 @@ sfc_mae_attach(struct sfc_adapter *sa) } } + sfc_log_init(sa, "assign ethdev MPORT"); + rc = sfc_mae_assign_ethdev_mport(sa, ðdev_mport); + if (rc != 0) + goto fail_mae_assign_ethdev_mport; + sfc_log_init(sa, "assign entity MPORT"); rc = sfc_mae_assign_entity_mport(sa, &entity_mport); if (rc != 0) @@ -230,9 +265,8 @@ sfc_mae_attach(struct sfc_adapter *sa) sfc_log_init(sa, "assign RTE switch port"); switch_port_request.type = SFC_MAE_SWITCH_PORT_INDEPENDENT; + switch_port_request.ethdev_mportp = ðdev_mport; switch_port_request.entity_mportp = &entity_mport; - /* RTE ethdev MPORT matches that of the entity for independent ports. */ - switch_port_request.ethdev_mportp = &entity_mport; switch_port_request.ethdev_port_id = sas->port_id; switch_port_request.port_data.indep.mae_admin = encp->enc_mae_admin == B_TRUE; @@ -272,6 +306,7 @@ sfc_mae_attach(struct sfc_adapter *sa) fail_mae_assign_switch_port: fail_mae_assign_switch_domain: fail_mae_assign_entity_mport: +fail_mae_assign_ethdev_mport: if (encp->enc_mae_admin) sfc_mae_counter_registry_fini(&mae->counter_registry); 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, From patchwork Mon Oct 25 11:04:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 102764 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 2A8E0A0C52; Mon, 25 Oct 2021 13:04:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EAF8D41145; Mon, 25 Oct 2021 13:04:31 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id DAD43410E2 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 AF9FF7F523; Mon, 25 Oct 2021 14:04:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru AF9FF7F523 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1635159863; bh=CBKnKE/FaBOfZeOD/ZjQLCur47w2tO3zx0zTHe48rMA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=x+KU/pOMQZTnMOjPN/CBfV7yQstd09UO0SZ3lyhsz1j1+kDT5jHZzaAH5ctlGbAt9 HczWWcuDTNSzZU3mCzB2jK70uNCWJADndWUfrYbdHb63zOHdAYmdXHkobfs+bhPSEn gbctKrKO14EBQCjVA1dwUZdL6T2doOtSErhOVTUY= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko Date: Mon, 25 Oct 2021 14:04:14 +0300 Message-Id: <20211025110415.20683-6-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 6/7] net/sfc: support port representor related flow actions 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 actions PORT_REPRESENTOR and REPRESENTED_PORT. The former should be used instead of ambiguous PORT_ID. The latter sends traffic to 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 | 2 + doc/guides/nics/sfc_efx.rst | 4 ++ drivers/net/sfc/sfc_mae.c | 66 ++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/doc/guides/nics/features/sfc.ini b/doc/guides/nics/features/sfc.ini index c830426eb2..0d785f4765 100644 --- a/doc/guides/nics/features/sfc.ini +++ b/doc/guides/nics/features/sfc.ini @@ -73,6 +73,8 @@ of_set_vlan_vid = Y pf = Y phy_port = Y port_id = Y +port_representor = Y +represented_port = Y queue = Y rss = Y vf = Y diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index 8dbd250b3c..960e25bf98 100644 --- a/doc/guides/nics/sfc_efx.rst +++ b/doc/guides/nics/sfc_efx.rst @@ -248,6 +248,10 @@ Supported actions (***transfer*** rules): - VF +- PORT_REPRESENTOR + +- REPRESENTED_PORT + - PORT_ID - COUNT diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index 8ec4036275..411f2ac27e 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -3488,6 +3488,58 @@ sfc_mae_rule_parse_action_port_id(struct sfc_adapter *sa, return rc; } +static int +sfc_mae_rule_parse_action_port_representor(struct sfc_adapter *sa, + const struct rte_flow_action_ethdev *conf, + efx_mae_actions_t *spec) +{ + struct sfc_mae *mae = &sa->mae; + efx_mport_sel_t mport; + int rc; + + rc = sfc_mae_switch_get_ethdev_mport(mae->switch_domain_id, + conf->port_id, &mport); + if (rc != 0) { + sfc_err(sa, "failed to get m-port for the given ethdev (port_id=%u): %s", + conf->port_id, strerror(rc)); + return rc; + } + + rc = efx_mae_action_set_populate_deliver(spec, &mport); + if (rc != 0) { + sfc_err(sa, "failed to request action DELIVER with m-port selector 0x%08x: %s", + mport.sel, strerror(rc)); + } + + return rc; +} + +static int +sfc_mae_rule_parse_action_represented_port(struct sfc_adapter *sa, + const struct rte_flow_action_ethdev *conf, + efx_mae_actions_t *spec) +{ + struct sfc_mae *mae = &sa->mae; + efx_mport_sel_t mport; + int rc; + + rc = sfc_mae_switch_get_entity_mport(mae->switch_domain_id, + conf->port_id, &mport); + if (rc != 0) { + sfc_err(sa, "failed to get m-port for the given ethdev (port_id=%u): %s", + conf->port_id, strerror(rc)); + return rc; + } + + rc = efx_mae_action_set_populate_deliver(spec, &mport); + if (rc != 0) { + sfc_err(sa, "failed to request action DELIVER with m-port selector 0x%08x: %s", + mport.sel, strerror(rc)); + } + + return rc; +} + static const char * const action_names[] = { [RTE_FLOW_ACTION_TYPE_VXLAN_DECAP] = "VXLAN_DECAP", [RTE_FLOW_ACTION_TYPE_OF_POP_VLAN] = "OF_POP_VLAN", @@ -3501,6 +3553,8 @@ static const char * const action_names[] = { [RTE_FLOW_ACTION_TYPE_PF] = "PF", [RTE_FLOW_ACTION_TYPE_VF] = "VF", [RTE_FLOW_ACTION_TYPE_PORT_ID] = "PORT_ID", + [RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR] = "PORT_REPRESENTOR", + [RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT] = "REPRESENTED_PORT", [RTE_FLOW_ACTION_TYPE_DROP] = "DROP", [RTE_FLOW_ACTION_TYPE_JUMP] = "JUMP", }; @@ -3609,6 +3663,18 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa, bundle->actions_mask); rc = sfc_mae_rule_parse_action_port_id(sa, action->conf, spec); break; + case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR: + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR, + bundle->actions_mask); + rc = sfc_mae_rule_parse_action_port_representor(sa, + action->conf, spec); + break; + case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT: + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT, + bundle->actions_mask); + rc = sfc_mae_rule_parse_action_represented_port(sa, + action->conf, spec); + break; case RTE_FLOW_ACTION_TYPE_DROP: SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_DROP, bundle->actions_mask); From patchwork Mon Oct 25 11:04:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 102765 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 8A576A0C53; Mon, 25 Oct 2021 13:05:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C6974113A; Mon, 25 Oct 2021 13:04:33 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 49561410E2 for ; Mon, 25 Oct 2021 13:04:24 +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 E75107F670; Mon, 25 Oct 2021 14:04:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru E75107F670 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1635159864; bh=49jIXYmNg/Gnp5cSZk8ztgwOhoTQDkJOJNBzFhSLh54=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gGAakP8em668D+tOK31pQbUMUxpFw/s+IFaJEDJk7Q/ENH0oVtKcjiVqdymZGARCU 0QO72qk1CkBhOQelT2vh6wfUQHXTwHFT01R8lM8lVqB5fNMG5Sy91VQRWSmykcnvaO fkH1DF8FXAydlTh+2PTsfRMeB4Q2OmHkrc62KpHQ= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko Date: Mon, 25 Oct 2021 14:04:15 +0300 Message-Id: <20211025110415.20683-7-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 7/7] net/sfc: ignore direction attributes in transfer flows 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" [1] has deprecated the use of direction attributes in "transfer" flows. Ignore them during the transition period. [1] commit 9d2a349b388a ("ethdev: deprecate direction attributes in transfer flows") Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko --- drivers/net/sfc/sfc_flow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index be2dfe778a..fc74c8035e 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -1252,13 +1252,13 @@ sfc_flow_parse_attr(struct sfc_adapter *sa, "Groups are not supported"); return -rte_errno; } - if (attr->egress != 0) { + if (attr->egress != 0 && attr->transfer == 0) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, attr, "Egress is not supported"); return -rte_errno; } - if (attr->ingress == 0) { + if (attr->ingress == 0 && attr->transfer == 0) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, attr, "Ingress is compulsory");