DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ivan Malov <ivan.malov@oktetlabs.ru>
To: dev@dpdk.org
Cc: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Subject: [dpdk-dev] [PATCH 4/7] net/sfc: assign correct m-ports to independent switch ports
Date: Mon, 25 Oct 2021 14:04:12 +0300	[thread overview]
Message-ID: <20211025110415.20683-4-ivan.malov@oktetlabs.ru> (raw)
In-Reply-To: <20211025110415.20683-1-ivan.malov@oktetlabs.ru>

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 <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 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, &ethdev_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 = &ethdev_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);
 
-- 
2.20.1


  parent reply	other threads:[~2021-10-25 11:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-25 11:04 [dpdk-dev] [PATCH 1/7] net/sfc: do not allow flow rules to refer to VF representors Ivan Malov
2021-10-25 11:04 ` [dpdk-dev] [PATCH 2/7] net/sfc: rename ethdev m-port retrieval helper Ivan Malov
2021-10-25 11:04 ` [dpdk-dev] [PATCH 3/7] net/sfc: improve m-port related log messages Ivan Malov
2021-10-25 11:04 ` Ivan Malov [this message]
2021-10-25 11:04 ` [dpdk-dev] [PATCH 5/7] net/sfc: support represented port flow item Ivan Malov
2021-10-25 11:04 ` [dpdk-dev] [PATCH 6/7] net/sfc: support port representor related flow actions Ivan Malov
2021-10-25 11:04 ` [dpdk-dev] [PATCH 7/7] net/sfc: ignore direction attributes in transfer flows Ivan Malov
2021-11-02 18:27 ` [dpdk-dev] [PATCH 1/7] net/sfc: do not allow flow rules to refer to VF representors Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211025110415.20683-4-ivan.malov@oktetlabs.ru \
    --to=ivan.malov@oktetlabs.ru \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).