DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/3] net/sfc: support transfer rule proxy
@ 2021-10-15  6:49 Andrew Rybchenko
  2021-10-15  6:49 ` [dpdk-dev] [PATCH 1/3] common/sfc_efx/base: support unprivileged MAE clients Andrew Rybchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Andrew Rybchenko @ 2021-10-15  6:49 UTC (permalink / raw)
  To: dev

Prepare driver infrastructure and add support for transfer rules
proxy. The API allows to find out right entry point for transfer
rules (which require corresponding priviledges).

Viacheslav Galaktionov (3):
  common/sfc_efx/base: support unprivileged MAE clients
  net/sfc: allow ports without MAE privilege
  net/sfc: implement the transfer proxy port callback

 doc/guides/rel_notes/release_21_11.rst  |  1 +
 drivers/common/sfc_efx/base/ef10_nic.c  | 12 +++-
 drivers/common/sfc_efx/base/efx.h       |  7 +++
 drivers/common/sfc_efx/base/siena_nic.c |  1 +
 drivers/net/sfc/sfc.c                   |  4 ++
 drivers/net/sfc/sfc_ethdev.c            | 11 ++--
 drivers/net/sfc/sfc_flow.c              | 23 +++++++-
 drivers/net/sfc/sfc_mae.c               | 75 +++++++++++++++----------
 drivers/net/sfc/sfc_mae.h               |  3 +-
 drivers/net/sfc/sfc_switch.c            | 68 +++++++++++++++++++++-
 drivers/net/sfc/sfc_switch.h            | 11 ++++
 11 files changed, 172 insertions(+), 44 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH 1/3] common/sfc_efx/base: support unprivileged MAE clients
  2021-10-15  6:49 [dpdk-dev] [PATCH 0/3] net/sfc: support transfer rule proxy Andrew Rybchenko
@ 2021-10-15  6:49 ` Andrew Rybchenko
  2021-10-15  6:49 ` [dpdk-dev] [PATCH 2/3] net/sfc: allow ports without MAE privilege Andrew Rybchenko
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Andrew Rybchenko @ 2021-10-15  6:49 UTC (permalink / raw)
  To: dev; +Cc: Viacheslav Galaktionov, Andy Moreton

From: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>

In order to differentiate between privileged and unprivileged MAE clients,
add a separate boolean flag to represent a NIC's MAE privilege level.

Allow initializing unprivileged MAE clients by avoiding calls to functions
that can only be called by the admin NIC.

Signed-off-by: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_nic.c  | 12 +++++++++---
 drivers/common/sfc_efx/base/efx.h       |  7 +++++++
 drivers/common/sfc_efx/base/siena_nic.c |  1 +
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/common/sfc_efx/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c
index 3cd9ff89d0..bbc59811ec 100644
--- a/drivers/common/sfc_efx/base/ef10_nic.c
+++ b/drivers/common/sfc_efx/base/ef10_nic.c
@@ -1442,13 +1442,19 @@ ef10_get_datapath_caps(
 	 * MAE support requires the privilege is granted initially,
 	 * and ignore later dynamic changes.
 	 */
-	if (CAP_FLAGS3(req, MAE_SUPPORTED) &&
-	    EFX_MCDI_HAVE_PRIVILEGE(encp->enc_privilege_mask, MAE))
+	if (CAP_FLAGS3(req, MAE_SUPPORTED)) {
 		encp->enc_mae_supported = B_TRUE;
-	else
+		if (EFX_MCDI_HAVE_PRIVILEGE(encp->enc_privilege_mask, MAE))
+			encp->enc_mae_admin = B_TRUE;
+		else
+			encp->enc_mae_admin = B_FALSE;
+	} else {
 		encp->enc_mae_supported = B_FALSE;
+		encp->enc_mae_admin = B_FALSE;
+	}
 #else
 	encp->enc_mae_supported = B_FALSE;
+	encp->enc_mae_admin = B_FALSE;
 #endif /* EFSYS_OPT_MAE */
 
 #undef CAP_FLAGS1
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index 8975c6e747..60533881c2 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -1618,6 +1618,13 @@ typedef struct efx_nic_cfg_s {
 	boolean_t		enc_hlb_counters;
 	/* NIC support for Match-Action Engine (MAE). */
 	boolean_t		enc_mae_supported;
+	/*
+	 * NIC is privileged, i.e. it is the MAE admin.
+	 * Only privileged MAE clients can manage MAE flow rules,
+	 * for example, modify, count and route traffic to selected
+	 * destination (a MAE client or network port).
+	 */
+	boolean_t		enc_mae_admin;
 	/* Firmware support for "FLAG" and "MARK" filter actions */
 	boolean_t		enc_filter_action_flag_supported;
 	boolean_t		enc_filter_action_mark_supported;
diff --git a/drivers/common/sfc_efx/base/siena_nic.c b/drivers/common/sfc_efx/base/siena_nic.c
index 29283eac72..8b810d3ae3 100644
--- a/drivers/common/sfc_efx/base/siena_nic.c
+++ b/drivers/common/sfc_efx/base/siena_nic.c
@@ -197,6 +197,7 @@ siena_board_cfg(
 	encp->enc_filter_action_mark_max = 0;
 
 	encp->enc_mae_supported = B_FALSE;
+	encp->enc_mae_admin = B_FALSE;
 
 	return (0);
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH 2/3] net/sfc: allow ports without MAE privilege
  2021-10-15  6:49 [dpdk-dev] [PATCH 0/3] net/sfc: support transfer rule proxy Andrew Rybchenko
  2021-10-15  6:49 ` [dpdk-dev] [PATCH 1/3] common/sfc_efx/base: support unprivileged MAE clients Andrew Rybchenko
@ 2021-10-15  6:49 ` Andrew Rybchenko
  2021-10-15  6:49 ` [dpdk-dev] [PATCH 3/3] net/sfc: implement the transfer proxy port callback Andrew Rybchenko
  2021-10-18 19:16 ` [dpdk-dev] [PATCH 0/3] net/sfc: support transfer rule proxy Ferruh Yigit
  3 siblings, 0 replies; 5+ messages in thread
From: Andrew Rybchenko @ 2021-10-15  6:49 UTC (permalink / raw)
  To: dev; +Cc: Viacheslav Galaktionov, Andy Moreton

From: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>

Register unprivileged ports in the switch domain registry in order to
allow redirecting traffic to them.

Differentiate between different levels of MAE support, update all MAE
status checks.

Signed-off-by: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_ethdev.c | 11 +++---
 drivers/net/sfc/sfc_flow.c   |  2 +-
 drivers/net/sfc/sfc_mae.c    | 73 +++++++++++++++++++++---------------
 drivers/net/sfc/sfc_mae.h    |  3 +-
 4 files changed, 51 insertions(+), 38 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 8ec56a9ed5..43fb34dffa 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -187,7 +187,8 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
 			     RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
 
-	if (mae->status == SFC_MAE_STATUS_SUPPORTED) {
+	if (mae->status == SFC_MAE_STATUS_SUPPORTED ||
+	    mae->status == SFC_MAE_STATUS_ADMIN) {
 		dev_info->switch_info.name = dev->device->driver->name;
 		dev_info->switch_info.domain_id = mae->switch_domain_id;
 		dev_info->switch_info.port_id = mae->switch_port_id;
@@ -2252,7 +2253,7 @@ sfc_representor_info_get(struct rte_eth_dev *dev,
 
 	sfc_adapter_lock(sa);
 
-	if (sa->mae.status != SFC_MAE_STATUS_SUPPORTED) {
+	if (sa->mae.status != SFC_MAE_STATUS_ADMIN) {
 		sfc_adapter_unlock(sa);
 		return -ENOTSUP;
 	}
@@ -2698,7 +2699,7 @@ sfc_parse_switch_mode(struct sfc_adapter *sa, bool has_representors)
 		goto fail_kvargs;
 
 	if (switch_mode == NULL) {
-		sa->switchdev = encp->enc_mae_supported &&
+		sa->switchdev = encp->enc_mae_admin &&
 				(!encp->enc_datapath_cap_evb ||
 				 has_representors);
 	} else if (strcasecmp(switch_mode, SFC_KVARG_SWITCH_MODE_LEGACY) == 0) {
@@ -2833,9 +2834,9 @@ sfc_eth_dev_init(struct rte_eth_dev *dev, void *init_params)
 	if (rc != 0)
 		goto fail_attach;
 
-	if (sa->switchdev && sa->mae.status != SFC_MAE_STATUS_SUPPORTED) {
+	if (sa->switchdev && sa->mae.status != SFC_MAE_STATUS_ADMIN) {
 		sfc_err(sa,
-			"failed to enable switchdev mode without MAE support");
+			"failed to enable switchdev mode without admin MAE privilege");
 		rc = ENOTSUP;
 		goto fail_switchdev_no_mae;
 	}
diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c
index 81b9923644..d57235f358 100644
--- a/drivers/net/sfc/sfc_flow.c
+++ b/drivers/net/sfc/sfc_flow.c
@@ -1275,7 +1275,7 @@ sfc_flow_parse_attr(struct sfc_adapter *sa,
 		spec_filter->template.efs_rss_context = EFX_RSS_CONTEXT_DEFAULT;
 		spec_filter->template.efs_priority = EFX_FILTER_PRI_MANUAL;
 	} else {
-		if (mae->status != SFC_MAE_STATUS_SUPPORTED) {
+		if (mae->status != SFC_MAE_STATUS_ADMIN) {
 			rte_flow_error_set(error, ENOTSUP,
 					   RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER,
 					   attr, "Transfer is not supported");
diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c
index 4c5c7b776f..6a1385283b 100644
--- a/drivers/net/sfc/sfc_mae.c
+++ b/drivers/net/sfc/sfc_mae.c
@@ -197,23 +197,25 @@ sfc_mae_attach(struct sfc_adapter *sa)
 		return 0;
 	}
 
-	sfc_log_init(sa, "init MAE");
-	rc = efx_mae_init(sa->nic);
-	if (rc != 0)
-		goto fail_mae_init;
+	if (encp->enc_mae_admin) {
+		sfc_log_init(sa, "init MAE");
+		rc = efx_mae_init(sa->nic);
+		if (rc != 0)
+			goto fail_mae_init;
 
-	sfc_log_init(sa, "get MAE limits");
-	rc = efx_mae_get_limits(sa->nic, &limits);
-	if (rc != 0)
-		goto fail_mae_get_limits;
+		sfc_log_init(sa, "get MAE limits");
+		rc = efx_mae_get_limits(sa->nic, &limits);
+		if (rc != 0)
+			goto fail_mae_get_limits;
 
-	sfc_log_init(sa, "init MAE counter registry");
-	rc = sfc_mae_counter_registry_init(&mae->counter_registry,
-					   limits.eml_max_n_counters);
-	if (rc != 0) {
-		sfc_err(sa, "failed to init MAE counters registry for %u entries: %s",
-			limits.eml_max_n_counters, rte_strerror(rc));
-		goto fail_counter_registry_init;
+		sfc_log_init(sa, "init MAE counter registry");
+		rc = sfc_mae_counter_registry_init(&mae->counter_registry,
+						   limits.eml_max_n_counters);
+		if (rc != 0) {
+			sfc_err(sa, "failed to init MAE counters registry for %u entries: %s",
+				limits.eml_max_n_counters, rte_strerror(rc));
+			goto fail_counter_registry_init;
+		}
 	}
 
 	sfc_log_init(sa, "assign entity MPORT");
@@ -238,21 +240,28 @@ sfc_mae_attach(struct sfc_adapter *sa)
 	if (rc != 0)
 		goto fail_mae_assign_switch_port;
 
-	sfc_log_init(sa, "allocate encap. header bounce buffer");
-	bounce_eh->buf_size = limits.eml_encap_header_size_limit;
-	bounce_eh->buf = rte_malloc("sfc_mae_bounce_eh",
-				    bounce_eh->buf_size, 0);
-	if (bounce_eh->buf == NULL)
-		goto fail_mae_alloc_bounce_eh;
-
-	mae->status = SFC_MAE_STATUS_SUPPORTED;
-	mae->nb_outer_rule_prios_max = limits.eml_max_n_outer_prios;
-	mae->nb_action_rule_prios_max = limits.eml_max_n_action_prios;
-	mae->encap_types_supported = limits.eml_encap_types_supported;
+	if (encp->enc_mae_admin) {
+		sfc_log_init(sa, "allocate encap. header bounce buffer");
+		bounce_eh->buf_size = limits.eml_encap_header_size_limit;
+		bounce_eh->buf = rte_malloc("sfc_mae_bounce_eh",
+					    bounce_eh->buf_size, 0);
+		if (bounce_eh->buf == NULL)
+			goto fail_mae_alloc_bounce_eh;
+
+		mae->nb_outer_rule_prios_max = limits.eml_max_n_outer_prios;
+		mae->nb_action_rule_prios_max = limits.eml_max_n_action_prios;
+		mae->encap_types_supported = limits.eml_encap_types_supported;
+	}
+
 	TAILQ_INIT(&mae->outer_rules);
 	TAILQ_INIT(&mae->encap_headers);
 	TAILQ_INIT(&mae->action_sets);
 
+	if (encp->enc_mae_admin)
+		mae->status = SFC_MAE_STATUS_ADMIN;
+	else
+		mae->status = SFC_MAE_STATUS_SUPPORTED;
+
 	sfc_log_init(sa, "done");
 
 	return 0;
@@ -261,11 +270,13 @@ sfc_mae_attach(struct sfc_adapter *sa)
 fail_mae_assign_switch_port:
 fail_mae_assign_switch_domain:
 fail_mae_assign_entity_mport:
-	sfc_mae_counter_registry_fini(&mae->counter_registry);
+	if (encp->enc_mae_admin)
+		sfc_mae_counter_registry_fini(&mae->counter_registry);
 
 fail_counter_registry_init:
 fail_mae_get_limits:
-	efx_mae_fini(sa->nic);
+	if (encp->enc_mae_admin)
+		efx_mae_fini(sa->nic);
 
 fail_mae_init:
 	sfc_log_init(sa, "failed %d", rc);
@@ -284,7 +295,7 @@ sfc_mae_detach(struct sfc_adapter *sa)
 	mae->nb_action_rule_prios_max = 0;
 	mae->status = SFC_MAE_STATUS_UNKNOWN;
 
-	if (status_prev != SFC_MAE_STATUS_SUPPORTED)
+	if (status_prev != SFC_MAE_STATUS_ADMIN)
 		return;
 
 	rte_free(mae->bounce_eh.buf);
@@ -4036,9 +4047,9 @@ sfc_mae_switchdev_init(struct sfc_adapter *sa)
 		return 0;
 	}
 
-	if (mae->status != SFC_MAE_STATUS_SUPPORTED) {
+	if (mae->status != SFC_MAE_STATUS_ADMIN) {
 		rc = ENOTSUP;
-		sfc_err(sa, "failed to init switchdev - no MAE support");
+		sfc_err(sa, "failed to init switchdev - no admin MAE privilege");
 		goto fail_no_mae;
 	}
 
diff --git a/drivers/net/sfc/sfc_mae.h b/drivers/net/sfc/sfc_mae.h
index 6c1a5bfee7..23dcf1e482 100644
--- a/drivers/net/sfc/sfc_mae.h
+++ b/drivers/net/sfc/sfc_mae.h
@@ -88,7 +88,8 @@ TAILQ_HEAD(sfc_mae_action_sets, sfc_mae_action_set);
 enum sfc_mae_status {
 	SFC_MAE_STATUS_UNKNOWN = 0,
 	SFC_MAE_STATUS_UNSUPPORTED,
-	SFC_MAE_STATUS_SUPPORTED
+	SFC_MAE_STATUS_SUPPORTED,
+	SFC_MAE_STATUS_ADMIN,
 };
 
 /*
-- 
2.30.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH 3/3] net/sfc: implement the transfer proxy port callback
  2021-10-15  6:49 [dpdk-dev] [PATCH 0/3] net/sfc: support transfer rule proxy Andrew Rybchenko
  2021-10-15  6:49 ` [dpdk-dev] [PATCH 1/3] common/sfc_efx/base: support unprivileged MAE clients Andrew Rybchenko
  2021-10-15  6:49 ` [dpdk-dev] [PATCH 2/3] net/sfc: allow ports without MAE privilege Andrew Rybchenko
@ 2021-10-15  6:49 ` Andrew Rybchenko
  2021-10-18 19:16 ` [dpdk-dev] [PATCH 0/3] net/sfc: support transfer rule proxy Ferruh Yigit
  3 siblings, 0 replies; 5+ messages in thread
From: Andrew Rybchenko @ 2021-10-15  6:49 UTC (permalink / raw)
  To: dev; +Cc: Viacheslav Galaktionov, Andy Moreton

From: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>

In sfc, MAE admin serves as a transfer proxy. In order to track which
ethdev is privileged, augment every independent switch port structure
with information about its MAE privilege.

Signed-off-by: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 doc/guides/rel_notes/release_21_11.rst |  1 +
 drivers/net/sfc/sfc.c                  |  4 ++
 drivers/net/sfc/sfc_flow.c             | 21 ++++++++
 drivers/net/sfc/sfc_mae.c              |  2 +
 drivers/net/sfc/sfc_switch.c           | 68 ++++++++++++++++++++++++--
 drivers/net/sfc/sfc_switch.h           | 11 +++++
 6 files changed, 104 insertions(+), 3 deletions(-)

diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index d35ca4fe82..ae0d2d1ffa 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -136,6 +136,7 @@ New Features
   Updated the Solarflare ``sfc_efx`` driver with changes including:
 
   * Added port representors support on SN1000 SmartNICs
+  * Added flow API transfer proxy support
 
 * **Updated Marvell cnxk crypto PMD.**
 
diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c
index f79f4d5ffc..431c42f508 100644
--- a/drivers/net/sfc/sfc.c
+++ b/drivers/net/sfc/sfc.c
@@ -25,6 +25,7 @@
 #include "sfc_kvargs.h"
 #include "sfc_tweak.h"
 #include "sfc_sw_stats.h"
+#include "sfc_switch.h"
 
 bool
 sfc_repr_supported(const struct sfc_adapter *sa)
@@ -1329,6 +1330,9 @@ sfc_unprobe(struct sfc_adapter *sa)
 	 */
 	rte_eal_alarm_cancel(sfc_restart_if_required, sa);
 
+	sfc_mae_clear_switch_port(sa->mae.switch_domain_id,
+				  sa->mae.switch_port_id);
+
 	sfc_log_init(sa, "destroy nic");
 	sa->nic = NULL;
 	efx_nic_destroy(enp);
diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c
index d57235f358..8096af5673 100644
--- a/drivers/net/sfc/sfc_flow.c
+++ b/drivers/net/sfc/sfc_flow.c
@@ -26,6 +26,7 @@
 #include "sfc_log.h"
 #include "sfc_dp_rx.h"
 #include "sfc_mae_counter.h"
+#include "sfc_switch.h"
 
 struct sfc_flow_ops_by_spec {
 	sfc_flow_parse_cb_t	*parse;
@@ -2924,6 +2925,25 @@ sfc_flow_isolate(struct rte_eth_dev *dev, int enable,
 	return ret;
 }
 
+static int
+sfc_flow_pick_transfer_proxy(struct rte_eth_dev *dev,
+			     uint16_t *transfer_proxy_port,
+			     struct rte_flow_error *error)
+{
+	struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
+	int ret;
+
+	ret = sfc_mae_get_switch_domain_admin(sa->mae.switch_domain_id,
+					      transfer_proxy_port);
+	if (ret != 0) {
+		return rte_flow_error_set(error, ret,
+					  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+					  NULL, NULL);
+	}
+
+	return 0;
+}
+
 const struct rte_flow_ops sfc_flow_ops = {
 	.validate = sfc_flow_validate,
 	.create = sfc_flow_create,
@@ -2936,6 +2956,7 @@ const struct rte_flow_ops sfc_flow_ops = {
 	.tunnel_action_decap_release = sfc_flow_tunnel_action_decap_release,
 	.tunnel_item_release = sfc_flow_tunnel_item_release,
 	.get_restore_info = sfc_flow_tunnel_get_restore_info,
+	.pick_transfer_proxy = sfc_flow_pick_transfer_proxy,
 };
 
 void
diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c
index 6a1385283b..455744c570 100644
--- a/drivers/net/sfc/sfc_mae.c
+++ b/drivers/net/sfc/sfc_mae.c
@@ -234,6 +234,8 @@ sfc_mae_attach(struct sfc_adapter *sa)
 	/* 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;
 	rc = sfc_mae_assign_switch_port(mae->switch_domain_id,
 					&switch_port_request,
 					&mae->switch_port_id);
diff --git a/drivers/net/sfc/sfc_switch.c b/drivers/net/sfc/sfc_switch.c
index dc5b9a676c..a28e861de5 100644
--- a/drivers/net/sfc/sfc_switch.c
+++ b/drivers/net/sfc/sfc_switch.c
@@ -93,6 +93,8 @@ struct sfc_mae_switch_domain {
 	efx_pcie_interface_t			*controllers;
 	/** Number of DPDK controllers and EFX interfaces */
 	size_t					nb_controllers;
+	/** MAE admin port */
+	struct sfc_mae_switch_port		*mae_admin_port;
 };
 
 TAILQ_HEAD(sfc_mae_switch_domains, sfc_mae_switch_domain);
@@ -454,13 +456,17 @@ sfc_mae_assign_switch_port(uint16_t switch_domain_id,
 	port->ethdev_mport = *req->ethdev_mportp;
 	port->ethdev_port_id = req->ethdev_port_id;
 
+	memcpy(&port->data, &req->port_data,
+	       sizeof(port->data));
+
 	switch (req->type) {
 	case SFC_MAE_SWITCH_PORT_INDEPENDENT:
-		/* No data */
+		if (port->data.indep.mae_admin) {
+			SFC_ASSERT(domain->mae_admin_port == NULL);
+			domain->mae_admin_port = port;
+		}
 		break;
 	case SFC_MAE_SWITCH_PORT_REPRESENTOR:
-		memcpy(&port->data.repr, &req->port_data,
-		       sizeof(port->data.repr));
 		break;
 	default:
 		SFC_ASSERT(B_FALSE);
@@ -478,6 +484,30 @@ sfc_mae_assign_switch_port(uint16_t switch_domain_id,
 	return rc;
 }
 
+int
+sfc_mae_clear_switch_port(uint16_t switch_domain_id,
+			  uint16_t switch_port_id)
+{
+	struct sfc_mae_switch_domain *domain;
+
+	rte_spinlock_lock(&sfc_mae_switch.lock);
+
+	domain = sfc_mae_find_switch_domain_by_id(switch_domain_id);
+	if (domain == NULL) {
+		rte_spinlock_unlock(&sfc_mae_switch.lock);
+		return EINVAL;
+	}
+
+	if (domain->mae_admin_port != NULL &&
+	    domain->mae_admin_port->id == switch_port_id) {
+		domain->mae_admin_port->data.indep.mae_admin = B_FALSE;
+		domain->mae_admin_port = NULL;
+	}
+
+	rte_spinlock_unlock(&sfc_mae_switch.lock);
+	return 0;
+}
+
 /* This function expects to be called only when the lock is held */
 static int
 sfc_mae_find_switch_port_by_ethdev(uint16_t switch_domain_id,
@@ -537,3 +567,35 @@ sfc_mae_switch_port_id_by_entity(uint16_t switch_domain_id,
 
 	return rc;
 }
+
+static int
+sfc_mae_get_switch_domain_admin_locked(uint16_t switch_domain_id,
+				       uint16_t *port_id)
+{
+	struct sfc_mae_switch_domain *domain;
+
+	SFC_ASSERT(rte_spinlock_is_locked(&sfc_mae_switch.lock));
+
+	domain = sfc_mae_find_switch_domain_by_id(switch_domain_id);
+	if (domain == NULL)
+		return EINVAL;
+
+	if (domain->mae_admin_port != NULL) {
+		*port_id = domain->mae_admin_port->ethdev_port_id;
+		return 0;
+	}
+
+	return ENOENT;
+}
+
+int
+sfc_mae_get_switch_domain_admin(uint16_t switch_domain_id,
+				uint16_t *port_id)
+{
+	int rc;
+
+	rte_spinlock_lock(&sfc_mae_switch.lock);
+	rc = sfc_mae_get_switch_domain_admin_locked(switch_domain_id, port_id);
+	rte_spinlock_unlock(&sfc_mae_switch.lock);
+	return rc;
+}
diff --git a/drivers/net/sfc/sfc_switch.h b/drivers/net/sfc/sfc_switch.h
index a77d2e6f28..7917141038 100644
--- a/drivers/net/sfc/sfc_switch.h
+++ b/drivers/net/sfc/sfc_switch.h
@@ -34,6 +34,10 @@ enum sfc_mae_switch_port_type {
 	SFC_MAE_SWITCH_PORT_REPRESENTOR,
 };
 
+struct sfc_mae_switch_port_indep_data {
+	bool					mae_admin;
+};
+
 struct sfc_mae_switch_port_repr_data {
 	efx_pcie_interface_t			intf;
 	uint16_t				pf;
@@ -41,6 +45,7 @@ struct sfc_mae_switch_port_repr_data {
 };
 
 union sfc_mae_switch_port_data {
+	struct sfc_mae_switch_port_indep_data	indep;
 	struct sfc_mae_switch_port_repr_data	repr;
 };
 
@@ -94,6 +99,9 @@ int sfc_mae_assign_switch_port(uint16_t switch_domain_id,
 			       const struct sfc_mae_switch_port_request *req,
 			       uint16_t *switch_port_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);
@@ -103,6 +111,9 @@ int sfc_mae_switch_port_id_by_entity(uint16_t switch_domain_id,
 				     enum sfc_mae_switch_port_type type,
 				     uint16_t *switch_port_id);
 
+int sfc_mae_get_switch_domain_admin(uint16_t switch_domain_id,
+				    uint16_t *port_id);
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.30.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH 0/3] net/sfc: support transfer rule proxy
  2021-10-15  6:49 [dpdk-dev] [PATCH 0/3] net/sfc: support transfer rule proxy Andrew Rybchenko
                   ` (2 preceding siblings ...)
  2021-10-15  6:49 ` [dpdk-dev] [PATCH 3/3] net/sfc: implement the transfer proxy port callback Andrew Rybchenko
@ 2021-10-18 19:16 ` Ferruh Yigit
  3 siblings, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2021-10-18 19:16 UTC (permalink / raw)
  To: Andrew Rybchenko, dev

On 10/15/2021 7:49 AM, Andrew Rybchenko wrote:
> Prepare driver infrastructure and add support for transfer rules
> proxy. The API allows to find out right entry point for transfer
> rules (which require corresponding priviledges).
> 
> Viacheslav Galaktionov (3):
>    common/sfc_efx/base: support unprivileged MAE clients
>    net/sfc: allow ports without MAE privilege
>    net/sfc: implement the transfer proxy port callback
> 

Series applied to dpdk-next-net/main, thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-18 19:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15  6:49 [dpdk-dev] [PATCH 0/3] net/sfc: support transfer rule proxy Andrew Rybchenko
2021-10-15  6:49 ` [dpdk-dev] [PATCH 1/3] common/sfc_efx/base: support unprivileged MAE clients Andrew Rybchenko
2021-10-15  6:49 ` [dpdk-dev] [PATCH 2/3] net/sfc: allow ports without MAE privilege Andrew Rybchenko
2021-10-15  6:49 ` [dpdk-dev] [PATCH 3/3] net/sfc: implement the transfer proxy port callback Andrew Rybchenko
2021-10-18 19:16 ` [dpdk-dev] [PATCH 0/3] net/sfc: support transfer rule proxy Ferruh Yigit

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).