Skip to contentSkip to conversation

net/mlx5: keep indirect actions across port restart

PATCH Superseded Dmitry Kozlyuk 3 participants 16 messages Jul 27, 2021 – Jul 29, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

cover net/mlx5: keep indirect actions across port restart

It was unspecified what happens to indirect actions when a port is stopped, possibly reconfigured, and started again. MLX5 PMD, the first one to use indirect actions, intended to keep them across such a sequence, but the implementation was buggy. Patches 1-3 fix the PMD behavior, patch 4 adds common specification with rationale.

Dmitry Kozlyuk (4):
net/mlx5: discover max flow priority using DevX net/mlx5: create drop queue using DevX net/mlx5: preserve indirect actions across port restart
ethdev: document indirect flow action life cycle

 doc/guides/prog_guide/rte_flow.rst |  10 +
 drivers/net/mlx5/linux/mlx5_os.c   |   5 -
 drivers/net/mlx5/mlx5_devx.c       | 204 +++++++++++++++++---
 drivers/net/mlx5/mlx5_flow.c       | 292 ++++++++++++++++++++++++++---
 drivers/net/mlx5/mlx5_flow.h       |   6 +
 drivers/net/mlx5/mlx5_flow_dv.c    | 103 ++++++++++
 drivers/net/mlx5/mlx5_flow_verbs.c |  77 +-------
 drivers/net/mlx5/mlx5_rx.h         |   4 +
 drivers/net/mlx5/mlx5_rxq.c        |  99 ++++++++--
 drivers/net/mlx5/mlx5_trigger.c    |  10 +
 lib/ethdev/rte_flow.h              |   4 +
 11 files changed, 680 insertions(+), 134 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/4 net/mlx5: discover max flow priority using DevX

Maximum available flow priority was discovered using Verbs API regardless of the selected flow engine. This required some Verbs objects to be initialized in order to use DevX engine. Make priority discovery an engine method and implement it for DevX using its API.

---
 drivers/net/mlx5/linux/mlx5_os.c   |   1 -
 drivers/net/mlx5/mlx5_flow.c       |  98 +++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_flow.h       |   4 ++
 drivers/net/mlx5/mlx5_flow_dv.c    | 103 +++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_flow_verbs.c |  77 +++------------------
 5 files changed, 215 insertions(+), 68 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +0 -1
index 4712bd6f9b..671dfface9 100644
@@ -1781,7 +1781,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 	priv->drop_queue.hrxq = mlx5_drop_action_create(eth_dev);
 	if (!priv->drop_queue.hrxq)
 		goto error;
-	/* Supported Verbs flow priority number detection. */
 	err = mlx5_flow_discover_priorities(eth_dev);
 	if (err < 0) {
 		err = -err;
drivers/net/mlx5/mlx5_flow.c +98 -0

101 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow.h +4 -0
index 3724293d26..da39eeb596 100644
@@ -1229,6 +1229,9 @@ typedef int (*mlx5_flow_create_def_policy_t)
 			(struct rte_eth_dev *dev);
 typedef void (*mlx5_flow_destroy_def_policy_t)
 			(struct rte_eth_dev *dev);
+typedef int (*mlx5_flow_discover_priorities_t)
+			(struct rte_eth_dev *dev,
+			 const uint16_t *vprio, int vprio_n);
 
 struct mlx5_flow_driver_ops {
 	mlx5_flow_validate_t validate;
@@ -1263,6 +1266,7 @@ struct mlx5_flow_driver_ops {
 	mlx5_flow_action_update_t action_update;
 	mlx5_flow_action_query_t action_query;
 	mlx5_flow_sync_domain_t sync_domain;
+	mlx5_flow_discover_priorities_t discover_priorities;
 };
 
 /* mlx5_flow.c */
drivers/net/mlx5/mlx5_flow_dv.c +103 -0

115 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow_verbs.c +10 -67

117 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/4 net/mlx5: create drop queue using DevX

In reply to Dmitry Kozlyuk

Drop queue creation and destruction were not implemented for DevX flow engine and Verbs engine methods were used as a workaround. Implement these methods for DevX so that there is a valid queue ID that can be used regardless of queue configuration via API.

---
 drivers/net/mlx5/linux/mlx5_os.c |   4 -
 drivers/net/mlx5/mlx5_devx.c     | 204 ++++++++++++++++++++++++++-----
 2 files changed, 176 insertions(+), 32 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +0 -4
index 671dfface9..791024c2c6 100644
@@ -1756,10 +1756,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 	}
 	if (config->devx && config->dv_flow_en && config->dest_tir) {
 		priv->obj_ops = devx_obj_ops;
-		priv->obj_ops.drop_action_create =
-						ibv_obj_ops.drop_action_create;
-		priv->obj_ops.drop_action_destroy =
-						ibv_obj_ops.drop_action_destroy;
 #ifndef HAVE_MLX5DV_DEVX_UAR_OFFSET
 		priv->obj_ops.txq_obj_modify = ibv_obj_ops.txq_obj_modify;
 #else
drivers/net/mlx5/mlx5_devx.c +176 -28

294 lines not on this page · raw message

Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/4 net/mlx5: preserve indirect actions across port restart

In reply to Dmitry Kozlyuk

MLX5 PMD uses reference counting to manage RX queue resources. After port stop shared RSS actions kept references to RX queues, preventing resource release. As a result, internal PMD mempool for such queues had been exhausted after a number of port restarts. Diagnostic message from rte_eth_dev_start():

Rx queue allocation failed: Cannot allocate memory

Dereference RX queues used by indirect actions on port stop (detach) and restore references on port start (attach) in order to allow RX queue resource release, but keep indirect actions across the port restart. Replace queue IDs in HW by drop queue ID on detach and restore actual queue IDs on attach.

Fixes 4b61b8774be9 ("ethdev: introduce indirect flow action")
---
 drivers/net/mlx5/mlx5_flow.c    | 194 ++++++++++++++++++++++++++++----
 drivers/net/mlx5/mlx5_flow.h    |   2 +
 drivers/net/mlx5/mlx5_rx.h      |   4 +
 drivers/net/mlx5/mlx5_rxq.c     |  99 ++++++++++++++--
 drivers/net/mlx5/mlx5_trigger.c |  10 ++
 5 files changed, 275 insertions(+), 34 deletions(-)
drivers/net/mlx5/mlx5_flow.c +171 -23
index e8d2678877..5343720ec9 100644
@@ -1524,6 +1524,58 @@ mlx5_flow_validate_action_queue(const struct rte_flow_action *action,
 	return 0;
 }
 
+/**
+ * Validate queue numbers for device RSS.
+ *
+ * @param[in] dev
+ *   Configured device.
+ * @param[in] queues
+ *   Array of queue numbers.
+ * @param[in] queues_n
+ *   Size of the @p queues array.
+ * @param[out] error
+ *   On error, filled with a textual error description.
+ * @param[out] queue
+ *   On error, filled with an offending queue index in @p queues array.
+ *
+ * @return
+ *   0 on success, a negative errno code on error.
+ */
+static int
+mlx5_validate_rss_queues(const struct rte_eth_dev *dev,
+			 const uint16_t *queues, uint32_t queues_n,
+			 const char **error, uint32_t *queue_idx)
+{
+	const struct mlx5_priv *priv = dev->data->dev_private;
+	enum mlx5_rxq_type rxq_type = MLX5_RXQ_TYPE_UNDEFINED;
+	uint32_t i;
+
+	for (i = 0; i != queues_n; ++i) {
+		struct mlx5_rxq_ctrl *rxq_ctrl;
+
+		if (queues[i] >= priv->rxqs_n) {
+			*error = "queue index out of range";
+			*queue_idx = i;
+			return -EINVAL;
+		}
+		if (!(*priv->rxqs)[queues[i]]) {
+			*error =  "queue is not configured";
+			*queue_idx = i;
+			return -EINVAL;
+		}
+		rxq_ctrl = container_of((*priv->rxqs)[queues[i]],
+					struct mlx5_rxq_ctrl, rxq);
+		if (i == 0)
+			rxq_type = rxq_ctrl->type;
+		if (rxq_type != rxq_ctrl->type) {
+			*error = "combining hairpin and regular RSS queues is not supported";
+			*queue_idx = i;
+			return -ENOTSUP;
+		}
+	}
+	return 0;
+}
+
 /*
  * Validate the rss action.
  *
@@ -1544,8 +1596,9 @@ mlx5_validate_action_rss(struct rte_eth_dev *dev,
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
 	const struct rte_flow_action_rss *rss = action->conf;
-	enum mlx5_rxq_type rxq_type = MLX5_RXQ_TYPE_UNDEFINED;
-	unsigned int i;
+	int ret;
+	const char *message;
+	uint32_t queue_idx;
 
 	if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT &&
 	    rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ)
@@ -1609,27 +1662,12 @@ mlx5_validate_action_rss(struct rte_eth_dev *dev,
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
 					  NULL, "No queues configured");
-	for (i = 0; i != rss->queue_num; ++i) {
-		struct mlx5_rxq_ctrl *rxq_ctrl;
-
-		if (rss->queue[i] >= priv->rxqs_n)
-			return rte_flow_error_set
-				(error, EINVAL,
-				 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
-				 &rss->queue[i], "queue index out of range");
-		if (!(*priv->rxqs)[rss->queue[i]])
-			return rte_flow_error_set
-				(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION_CONF,
-				 &rss->queue[i], "queue is not configured");
-		rxq_ctrl = container_of((*priv->rxqs)[rss->queue[i]],
-					struct mlx5_rxq_ctrl, rxq);
-		if (i == 0)
-			rxq_type = rxq_ctrl->type;
-		if (rxq_type != rxq_ctrl->type)
-			return rte_flow_error_set
-				(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION_CONF,
-				 &rss->queue[i],
-				 "combining hairpin and regular RSS queues is not supported");
+	ret = mlx5_validate_rss_queues(dev, rss->queue, rss->queue_num,
+				       &message, &queue_idx);
+	if (ret != 0) {
+		return rte_flow_error_set(error, -ret,
+					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
+					  &rss->queue[queue_idx], message);
 	}
 	return 0;
 }
@@ -8493,6 +8531,116 @@ mlx5_action_handle_flush(struct rte_eth_dev *dev)
 	return ret;
 }
 
+/**
+ * Validate existing indirect actions against current device configuration
+ * and attach them to device resources.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_action_handle_attach(struct rte_eth_dev *dev)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_indexed_pool *ipool =
+			priv->sh->ipool[MLX5_IPOOL_RSS_SHARED_ACTIONS];
+	struct mlx5_shared_action_rss *shared_rss, *shared_rss_last;
+	int ret = 0;
+	uint32_t idx;
+
+	ILIST_FOREACH(ipool, priv->rss_shared_actions, idx, shared_rss, next) {
+		struct mlx5_ind_table_obj *ind_tbl = shared_rss->ind_tbl;
+		const char *message;
+		uint32_t queue_idx;
+
+		ret = mlx5_validate_rss_queues(dev, ind_tbl->queues,
+					       ind_tbl->queues_n,
+					       &message, &queue_idx);
+		if (ret != 0) {
+			DRV_LOG(ERR, "Port %u cannot use queue %u in RSS: %s",
+				dev->data->port_id, ind_tbl->queues[queue_idx],
+				message);
+			break;
+		}
+	}
+	if (ret != 0)
+		return ret;
+	ILIST_FOREACH(ipool, priv->rss_shared_actions, idx, shared_rss, next) {
+		struct mlx5_ind_table_obj *ind_tbl = shared_rss->ind_tbl;
+
+		ret = mlx5_ind_table_obj_attach(dev, ind_tbl);
+		if (ret != 0) {
+			DRV_LOG(ERR, "Port %u could not attach "
+				"indirection table obj %p",
+				dev->data->port_id, (void *)ind_tbl);
+			goto error;
+		}
+	}
+	return 0;
+error:
+	shared_rss_last = shared_rss;
+	ILIST_FOREACH(ipool, priv->rss_shared_actions, idx, shared_rss, next) {
+		struct mlx5_ind_table_obj *ind_tbl = shared_rss->ind_tbl;
+
+		if (shared_rss == shared_rss_last)
+			break;
+		if (mlx5_ind_table_obj_detach(dev, ind_tbl) != 0)
+			DRV_LOG(CRIT, "Port %u could not detach "
+				"indirection table obj %p on rollback",
+				dev->data->port_id, (void *)ind_tbl);
+	}
+	return ret;
+}
+
+/**
+ * Detach indirect actions of the device from its resources.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_action_handle_detach(struct rte_eth_dev *dev)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_indexed_pool *ipool =
+			priv->sh->ipool[MLX5_IPOOL_RSS_SHARED_ACTIONS];
+	struct mlx5_shared_action_rss *shared_rss, *shared_rss_last;
+	int ret = 0;
+	uint32_t idx;
+
+	ILIST_FOREACH(ipool, priv->rss_shared_actions, idx, shared_rss, next) {
+		struct mlx5_ind_table_obj *ind_tbl = shared_rss->ind_tbl;
+
+		ret = mlx5_ind_table_obj_detach(dev, ind_tbl);
+		if (ret != 0) {
+			DRV_LOG(ERR, "Port %u could not detach "
+				"indirection table obj %p",
+				dev->data->port_id, (void *)ind_tbl);
+			goto error;
+		}
+	}
+	return 0;
+error:
+	shared_rss_last = shared_rss;
+	ILIST_FOREACH(ipool, priv->rss_shared_actions, idx, shared_rss, next) {
+		struct mlx5_ind_table_obj *ind_tbl = shared_rss->ind_tbl;
+
+		if (shared_rss == shared_rss_last)
+			break;
+		if (mlx5_ind_table_obj_attach(dev, ind_tbl) != 0)
+			DRV_LOG(CRIT, "Port %u could not attach "
+				"indirection table obj %p on rollback",
+				dev->data->port_id, (void *)ind_tbl);
+	}
+	return ret;
+}
+
 #ifndef HAVE_MLX5DV_DR
 #define MLX5_DOMAIN_SYNC_FLOW ((1 << 0) | (1 << 1))
 #else
drivers/net/mlx5/mlx5_flow.h +2 -0
index da39eeb596..251d643f8c 100644
@@ -1575,6 +1575,8 @@ struct mlx5_flow_meter_sub_policy *mlx5_flow_meter_sub_policy_rss_prepare
 void mlx5_flow_destroy_sub_policy_with_rxq(struct rte_eth_dev *dev,
 		struct mlx5_flow_meter_policy *mtr_policy);
 int mlx5_flow_dv_discover_counter_offset_support(struct rte_eth_dev *dev);
+int mlx5_action_handle_attach(struct rte_eth_dev *dev);
+int mlx5_action_handle_detach(struct rte_eth_dev *dev);
 int mlx5_action_handle_flush(struct rte_eth_dev *dev);
 void mlx5_release_tunnel_hub(struct mlx5_dev_ctx_shared *sh, uint16_t port_id);
 int mlx5_alloc_tunnel_hub(struct mlx5_dev_ctx_shared *sh);
drivers/net/mlx5/mlx5_rx.h +4 -0
index 3f2b99fb65..7319ad0264 100644
@@ -222,6 +222,10 @@ int mlx5_ind_table_obj_modify(struct rte_eth_dev *dev,
 			      struct mlx5_ind_table_obj *ind_tbl,
 			      uint16_t *queues, const uint32_t queues_n,
 			      bool standalone);
+int mlx5_ind_table_obj_attach(struct rte_eth_dev *dev,
+			      struct mlx5_ind_table_obj *ind_tbl);
+int mlx5_ind_table_obj_detach(struct rte_eth_dev *dev,
+			      struct mlx5_ind_table_obj *ind_tbl);
 struct mlx5_list_entry *mlx5_hrxq_create_cb(void *tool_ctx, void *cb_ctx);
 int mlx5_hrxq_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
 		       void *cb_ctx);
drivers/net/mlx5/mlx5_rxq.c +88 -11

118 lines not on this page · raw message

drivers/net/mlx5/mlx5_trigger.c +10 -0
index a9d5d58fd9..6761a84a68 100644
@@ -14,6 +14,7 @@
 #include <mlx5_malloc.h>
 
 #include "mlx5.h"
+#include "mlx5_flow.h"
 #include "mlx5_mr.h"
 #include "mlx5_rx.h"
 #include "mlx5_tx.h"
@@ -1115,6 +1116,14 @@ mlx5_dev_start(struct rte_eth_dev *dev)
 	mlx5_rxq_timestamp_set(dev);
 	/* Set a mask and offset of scheduling on timestamp into Tx queues. */
 	mlx5_txq_dynf_timestamp_set(dev);
+	/* Attach indirection table objects detached on port stop. */
+	ret = mlx5_action_handle_attach(dev);
+	if (ret) {
+		DRV_LOG(ERR,
+			"port %u failed to attach indirect actions: %s",
+			dev->data->port_id, rte_strerror(rte_errno));
+		goto error;
+	}
 	/*
 	 * In non-cached mode, it only needs to start the default mreg copy
 	 * action and no flow created by application exists anymore.
@@ -1187,6 +1196,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev)
 	/* All RX queue flags will be cleared in the flush interface. */
 	mlx5_flow_list_flush(dev, MLX5_FLOW_TYPE_GEN, true);
 	mlx5_flow_meter_rxq_flush(dev);
+	mlx5_action_handle_detach(dev);
 	mlx5_rx_intr_vec_disable(dev);
 	priv->sh->port[priv->dev_port - 1].ih_port_id = RTE_MAX_ETHPORTS;
 	priv->sh->port[priv->dev_port - 1].devx_ih_port_id = RTE_MAX_ETHPORTS;
Signature · 1 line
2.25.1
#4 lore raw

PATCH 4/4 ethdev: document indirect flow action life cycle

In reply to Dmitry Kozlyuk

rte_flow_action_handle_create() did not specify what happens with an indirect action when device is stopped, possibly reconfigured, and started again.

It is proposed that indirect actions persisted across such a sequence. This allows for easier API usage and better HW resources utilization by saving indirect actions flush and re-creation with associated error handling and rollback.

If between stop and start a device is reconfigured in a way that is incompatible with an existing indirect action, PMD is required to report an error at the device start. This is mandatory, because flow API does not supply users with capabilities, so this is the only way for a user to learn that configuration is invalid. Errors are not reported at configuration stage to give the user a chance to remove or change offending actions. For example, if number of queues changes and an RSS indirect action specifies queues that went away, user must update the action before starting the device. PMD is not allowed to silently adjust indirect actions (in the same example, to remove queues from the RSS), so that all configuration is explicit.

Fixes 4b61b8774be9 ("ethdev: introduce indirect flow action")
---
 doc/guides/prog_guide/rte_flow.rst | 10 ++++++++++
 lib/ethdev/rte_flow.h              |  4 ++++
 2 files changed, 14 insertions(+)
doc/guides/prog_guide/rte_flow.rst +10 -0
index 2b42d5ec8c..06dd06d9a6 100644
@@ -2785,6 +2785,16 @@ updated depend on the type of the ``action`` and different for every type.
 The indirect action specified data (e.g. counter) can be queried by
 ``rte_flow_action_handle_query()``.
 
+Indirect actions persist across device configure, stop, and start.
+If a new configuration is incompatible with an existing indirect action,
+the start operation will fail. "Incompatible" means that if this action
+was destroyed and created again, creation would fail.
+It is a programmer's responsibility to remove or update offending actions.
+
+PMD developers should use the same diagnostics for ``rte_eth_dev_start()``
+as for ``rte_flow_action_handle_create()``. PMD is not allowed to silently
+ignore or correct offending actions.
+
 .. _table_rte_flow_action_handle:
 
 .. table:: INDIRECT
lib/ethdev/rte_flow.h +4 -0
index 70f455d47d..f571a27fe7 100644
@@ -3969,6 +3969,10 @@ struct rte_flow_indir_action_conf {
  * The created object handle has single state and configuration
  * across all the flow rules using it.
  *
+ * Indirect actions persist across device configure, stop, and start.
+ * If a new configuration is incompatible with an existing indirect
+ * action, rte_eth_dev_start() will fail.
+ *
  * @param[in] port_id
  *    The port identifier of the Ethernet device.
  * @param[in] conf
Signature · 1 line
2.25.1
#5 lore raw

Re: [dpdk-dev] [PATCH 4/4] ethdev: document indirect flow action life cycle

Hi Dmitry,

Quoted 15 lines

-----Original Message-----
From: Dmitry Kozlyuk <[email protected]>
Sent: Tuesday, July 27, 2021 10:31 AM

Subject: [PATCH 4/4] ethdev: document indirect flow action life cycle

rte_flow_action_handle_create() did not specify what happens with an indirect action when device is stopped, possibly reconfigured, and started again.

It is proposed that indirect actions persisted across such a sequence. This allows for easier API usage and better HW resources utilization by saving indirect actions flush and re-creation with associated error handling and rollback.

Quoted 11 lines

If between stop and start a device is reconfigured in a way that is incompatible with an existing indirect action, PMD is required to report an error at the device start. This is mandatory, because flow API does not supply users with capabilities, so this is the only way for a user to learn that configuration is invalid. Errors are not reported at configuration stage to give the user a chance to remove or change offending actions. For example, if number of queues changes and an RSS indirect action specifies queues that went away, user must update the action before starting the device. PMD is not allowed to silently adjust indirect actions (in the same example, to remove queues from the RSS), so that all configuration is explicit.

I think some of the errors can be checked during configuration. For example when app removes a queue the PMD can check if there is any reference on this queue and fail at this point.

Quoted 21 lines
Fixes 4b61b8774be9 ("ethdev: introduce indirect flow action")
---
 doc/guides/prog_guide/rte_flow.rst | 10 ++++++++++
 lib/ethdev/rte_flow.h              |  4 ++++
 2 files changed, 14 insertions(+)
doc/guides/prog_guide/rte_flow.rst +0 -0
index 2b42d5ec8c..06dd06d9a6 100644
@@ -2785,6 +2785,16 @@ updated depend on the type of the ``action`` and

different for every type.
The indirect action specified data (e.g. counter) can be queried by
``rte_flow_action_handle_query()``.

Quoted 1 line

+Indirect actions persist across device configure, stop, and start.

+1

doc/guides/prog_guide/rte_flow.rst

Quoted 3 lines
doc/guides/prog_guide/rte_flow.rst +3 -0
+If a new configuration is incompatible with an existing indirect
+action, the start operation will fail. "Incompatible" means that if
+this action was destroyed and created again, creation would fail.

I think this test should be done during the configuration.
It is the application responsibility to use valid actions, it should be stated that changing the values of configuration may result in in valid actions.

Quoted 14 lines
doc/guides/prog_guide/rte_flow.rst +6 -0
+It is a programmer's responsibility to remove or update offending actions.
+
+PMD developers should use the same diagnostics for
+``rte_eth_dev_start()`` as for ``rte_flow_action_handle_create()``. PMD
+is not allowed to silently ignore or correct offending actions.
+
 .. _table_rte_flow_action_handle:
 
 .. table:: INDIRECT
lib/ethdev/rte_flow.h index renamed from lib/ethdev/rte_flow.h +0 -0

70f455d47d..f571a27fe7 100644

lib/ethdev/rte_flow.h struct rte_flow_indir_action_conf { · line 3975

Quoted 7 lines
lib/ethdev/rte_flow.h +4 -0
@@ -3969,6 +3969,10 @@ struct rte_flow_indir_action_conf {
  * The created object handle has single state and configuration
  * across all the flow rules using it.
  *
+ * Indirect actions persist across device configure, stop, and start.
+ * If a new configuration is incompatible with an existing indirect
+ * action, rte_eth_dev_start() will fail.
+ *

I don't think that dev start should check configuration it may slow down startup.

Quoted 5 lines
lib/ethdev/rte_flow.h +0 -1
  * @param[in] port_id
  *    The port identifier of the Ethernet device.
  * @param[in] conf
--

2.25.1

Thanks,
Ori

#6 lore raw
In reply to Dmitry Kozlyuk
Quoted 5 lines · Dmitry Kozlyuk

It was unspecified what happens to indirect actions when a port is stopped, possibly reconfigured, and started again. MLX5 PMD, the first one to use indirect actions, intended to keep them across such a sequence, but the implementation was buggy. Patches 1-3 fix the PMD behavior, patch 4 adds common specification with rationale.

I'm sorry, but it looks very inconsistent. If flow rules are not preserved across restart, indirect actions should not be preserved as well. We need very strong reasons to introduce the inconsistency.

If we finally accept it, I think it would be very useful to care about PMDs which cannot preserve it in HW across restart from the very beginning and save it in ethdev layer and restore on start automatically (i.e. do not force all such PMDs to care about the restore internally and basically duplicate the code).

#7 lore raw

Hi Andrew,

Quoted 11 lines

From: Andrew Rybchenko <[email protected]>

Quoted 5 lines · Dmitry Kozlyuk

It was unspecified what happens to indirect actions when a port is stopped, possibly reconfigured, and started again. MLX5 PMD, the first one to use indirect actions, intended to keep them across such a sequence, but the implementation was buggy. Patches 1-3 fix the PMD behavior, patch 4 adds common specification with rationale.

I'm sorry, but it looks very inconsistent. If flow rules are not preserved across restart, indirect actions should not be preserved as well. We need very strong reasons to introduce the inconsistency.

Indirect actions really don't need to behave like flow rules. They are just objects owned by the port and they can exist while it exists. Consider a counter: stopping and starting the port doesn't logically affect its state. MLX5 PMD destroys flow rules on port stop for internal reasons and documents this behavior, but ethdev API doesn't require it either.

Quoted 4 lines

If we finally accept it, I think it would be very useful to care about PMDs which cannot preserve it in HW across restart from the very beginning and save it in ethdev layer and restore on start automatically (i.e. do not force all such PMDs to care about the restore internally and basically duplicate the code).

Or keeping indirect actions can be an advertised PMD capability.
Given Ori's comments to patch 4, I think the common spec needs more work.
For this patchset that fixes MLX5 we can have the behavior documented for PMD and not require it from all the drivers.

#8 lore raw

Hi Dmitry and Andrew,

Quoted 28 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Dmitry Kozlyuk
Sent: Wednesday, July 28, 2021 2:19 PM

Hi Andrew,

Quoted 11 lines

From: Andrew Rybchenko <[email protected]> On 7/27/21

Quoted 5 lines · Dmitry Kozlyuk

It was unspecified what happens to indirect actions when a port is stopped, possibly reconfigured, and started again. MLX5 PMD, the first one to use indirect actions, intended to keep them across such a sequence, but the implementation was buggy. Patches 1-3 fix the PMD behavior, patch 4 adds common specification with rationale.

I'm sorry, but it looks very inconsistent. If flow rules are not preserved across restart, indirect actions should not be preserved as well. We need very strong reasons to introduce the inconsistency.

Indirect actions really don't need to behave like flow rules. They are just objects owned by the port and they can exist while it exists. Consider a
counter: stopping and starting the port doesn't logically affect its state. MLX5 PMD destroys flow rules on port stop for internal reasons and documents this behavior, but ethdev API doesn't require it either.

Quoted 4 lines

If we finally accept it, I think it would be very useful to care about PMDs which cannot preserve it in HW across restart from the very beginning and save it in ethdev layer and restore on start automatically (i.e. do not force all such PMDs to care about the restore

Quoted 6 lines

internally and basically duplicate the code).

Or keeping indirect actions can be an advertised PMD capability. Given Ori's comments to patch 4, I think the common spec needs more work. For this patchset that fixes MLX5 we can have the behavior documented for PMD and not require it from all the drivers.

This also effects if flows can be stored or not, (there was other thread about it) I think we should have device cap that says if flows are preserved,
if they can be created before start, the same goes to actions, but
what if some actions can be preserved and some not? For example RSS
can't in some HW (or due to configuration change) while other can? For example counter?
I don't want to have cap for each action, I think this info is based explained in each driver documentation.
Maybe we can have some general flag one for flows and one for actions, and each PMD will have detail doc.

Best,
Ori

#9 lore raw
In reply to Dmitry Kozlyuk
Quoted 10 lines · Dmitry Kozlyuk

Hi Andrew,

Quoted 8 lines

From: Andrew Rybchenko <[email protected]>

Quoted 5 lines · Dmitry Kozlyuk

It was unspecified what happens to indirect actions when a port is stopped, possibly reconfigured, and started again. MLX5 PMD, the first one to use indirect actions, intended to keep them across such a sequence, but the implementation was buggy. Patches 1-3 fix the PMD behavior, patch 4 adds common specification with rationale.

Quoted 5 lines
Quoted 3 lines

I'm sorry, but it looks very inconsistent. If flow rules are not preserved across restart, indirect actions should not be preserved as well. We need very strong reasons to introduce the inconsistency.

Indirect actions really don't need to behave like flow rules. They are just objects owned by the port and they can exist while it exists. Consider a counter: stopping and starting the port doesn't logically affect its state. MLX5 PMD destroys flow rules on port stop for internal reasons and documents this behavior, but ethdev API doesn't require it either.

It all sounds bad. All these gray areas just make it hard for DPDK applications to switch from one HW to another.
Any rules must not be motivated because of some PMD internal reasons. We should not adjust ethdev rules to fit some PMD behaviour. ethdev rules should be motivated by common sense and convenience from applications point of view.

For example, it is strange to preserve indirect RSS action with queues specified across device reconfiguration when queues count may change. I'd say that reconfiguration must drop all indirect actions.
However, just stop/start could preserve both indirect actions and flow
rues since it could be more convenient from application point of view.
If application really wants to remove all flow rules, it can call
rte_flow_flush().
The strong reason to flush indirect actions and flow rules across
restart is possible actions or rules restore failure on start.
However, may be it is sufficient to document that start should really
fail, if it can't restore everything and application should retry
after rte_flow_flush() taking it into account.

Quoted 8 lines
Quoted 4 lines

If we finally accept it, I think it would be very useful to care about PMDs which cannot preserve it in HW across restart from the very beginning and save it in ethdev layer and restore on start automatically (i.e. do not force all such PMDs to care about the restore internally and basically duplicate the code).

Or keeping indirect actions can be an advertised PMD capability.
Given Ori's comments to patch 4, I think the common spec needs more work.
For this patchset that fixes MLX5 we can have the behavior documented for PMD and not require it from all the drivers.

Are you going to drop 4th patch?

In general documenting PMD behaviour specifics in its documentation is a wrong direction since it does not help DPDK applications to be portable across different HW.

#10 lore raw
Quoted 32 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: 28 июля 2021 г. 15:27
To: Dmitry Kozlyuk <[email protected]>; [email protected]
Cc: David Marchand <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 0/4] net/mlx5: keep indirect actions across port restart

External email: Use caution opening links or attachments

Quoted 10 lines · Dmitry Kozlyuk

Hi Andrew,

Quoted 8 lines

From: Andrew Rybchenko <[email protected]> On 7/27/21

Quoted 5 lines · Dmitry Kozlyuk

It was unspecified what happens to indirect actions when a port is stopped, possibly reconfigured, and started again. MLX5 PMD, the first one to use indirect actions, intended to keep them across such a sequence, but the implementation was buggy. Patches 1-3 fix the PMD behavior, patch 4 adds common specification with rationale.

Quoted 5 lines
Quoted 3 lines

I'm sorry, but it looks very inconsistent. If flow rules are not preserved across restart, indirect actions should not be preserved as well. We need very strong reasons to introduce the inconsistency.

Indirect actions really don't need to behave like flow rules. They are just

objects owned by the port and they can exist while it exists. Consider a counter:
stopping and starting the port doesn't logically affect its state. MLX5 PMD destroys flow rules on port stop for internal reasons and documents this behavior, but ethdev API doesn't require it either.

Quoted 6 lines

It all sounds bad. All these gray areas just make it hard for DPDK applications to switch from one HW to another.
Any rules must not be motivated because of some PMD internal reasons. We should not adjust ethdev rules to fit some PMD behaviour.
ethdev rules should be motivated by common sense and convenience from applications point of view.

That is what this patchset is trying to do.
Current specification is unclear, application doesn't know
if it should destroy and recreate indirect actions or not.
MLX5 PMD is only mentioned above because it's the only one implementing indirect action API, but it's not an attempt to tailor API to it, quite the opposite.

Quoted 3 lines

For example, it is strange to preserve indirect RSS action with queues specified across device reconfiguration when queues count may change.
I'd say that reconfiguration must drop all indirect actions.

I don't like it because 1) it is implicit, 2) it may be unnecessary even for RSS, and it's only one example of an indirect action.

Quoted 2 lines

However, just stop/start could preserve both indirect actions and flow rues since it could be more convenient from application point of view.

For many cases I agree, but not for all.
What if an application creates numerous flows from its data path? They are transient by nature, but PMD will have to save them all at the cost of RAM and CPU but without benefit to anyone. OTOH, application always controls indirect actions it creates, because it is going to reuse or query them.
Therefore, it is both logical and convenient to preserve them.

Quoted 11 lines

If application really wants to remove all flow rules, it can call rte_flow_flush(). The strong reason to flush indirect actions and flow rules across restart is possible actions or rules restore failure on start.
However, may be it is sufficient to document that start should really fail, if it can't restore everything and application should retry after rte_flow_flush() taking it into account.

Quoted 4 lines
Quoted 4 lines

If we finally accept it, I think it would be very useful to care about PMDs which cannot preserve it in HW across restart from the very beginning and save it in ethdev layer and restore on start automatically (i.e. do not force all such PMDs to care about the restore

Quoted 8 lines

internally and basically duplicate the code).

Quoted 4 lines

Or keeping indirect actions can be an advertised PMD capability. Given Ori's comments to patch 4, I think the common spec needs more work. For this patchset that fixes MLX5 we can have the behavior documented for

PMD and not require it from all the drivers.

Are you going to drop 4th patch?

Yes.

Quoted 3 lines

In general documenting PMD behaviour specifics in its documentation is a wrong direction since it does not help DPDK applications to be portable across different HW.

I agree. But currently there is a clear resource leak in MLX5 PMD, that can be solved either by destroying indirect actions on port stop or by keeping them (this is what PMD maintainers prefer). The leak should be fixed and what happens to indirect actions must be clearly documented. Ideally the fix should be aligned with common ethdev API, but if you and Ori think its design is wrong, then at least behavior can be described in PMD docs and later fixed or promoted to API.

#11 lore raw

Hi,

Quoted 45 lines

-----Original Message-----
From: Dmitry Kozlyuk <[email protected]>
Sent: Wednesday, July 28, 2021 5:08 PM

Quoted 8 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: 28 июля 2021 г. 15:27
To: Dmitry Kozlyuk <[email protected]>; [email protected]
Cc: David Marchand <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 0/4] net/mlx5: keep indirect actions across port restart

Quoted 7 lines

External email: Use caution opening links or attachments

Quoted 3 lines · Dmitry Kozlyuk

Hi Andrew,

Quoted 1 line

From: Andrew Rybchenko <[email protected]> On

7/27/21

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines · Dmitry Kozlyuk

It was unspecified what happens to indirect actions when a port is stopped, possibly reconfigured, and started again. MLX5 PMD, the first one to use indirect actions, intended to keep them across such a sequence, but the implementation was buggy. Patches 1-3 fix the PMD behavior, patch 4 adds common specification with rationale.

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

I'm sorry, but it looks very inconsistent. If flow rules are not preserved across restart, indirect actions should not be preserved as well. We need very strong reasons to introduce the inconsistency.

Indirect actions really don't need to behave like flow rules. They are just

objects owned by the port and they can exist while it exists. Consider a

counter:

Quoted 9 lines

stopping and starting the port doesn't logically affect its state. MLX5 PMD destroys flow rules on port stop for internal reasons and documents this behavior, but ethdev API doesn't require it either.

It all sounds bad. All these gray areas just make it hard for DPDK applications to switch from one HW to another.
Any rules must not be motivated because of some PMD internal reasons. We should not adjust ethdev rules to fit some PMD behaviour. ethdev rules should be motivated by common sense and convenience

from

Quoted 9 lines
Quoted 1 line

applications point of view.

That is what this patchset is trying to do.
Current specification is unclear, application doesn't know if it should destroy and recreate indirect actions or not.
MLX5 PMD is only mentioned above because it's the only one implementing indirect action API, but it's not an attempt to tailor API to it, quite the opposite.

I agree gray areas are bad, but as more and more application are using more and more flows, insertion of flows become part of the datapath, optimization of actions and rules become even more critical. (To address this we are going to introduce additional API, which will enable async insertion, allocation of resources before flow insertion) So since each HW implements the actions and flows differently forcing the exact same behavior will result in performance degradation.

Quoted 48 lines
Quoted 3 lines

For example, it is strange to preserve indirect RSS action with queues specified across device reconfiguration when queues count may change. I'd say that reconfiguration must drop all indirect actions.

I don't like it because 1) it is implicit, 2) it may be unnecessary even for RSS, and it's only one example of an indirect action.

Quoted 2 lines

However, just stop/start could preserve both indirect actions and flow rues since it could be more convenient from application point of view.

For many cases I agree, but not for all.
What if an application creates numerous flows from its data path? They are transient by nature, but PMD will have to save them all at the cost of RAM and CPU but without benefit to anyone.
OTOH, application always controls indirect actions it creates, because it is going to reuse or query them.
Therefore, it is both logical and convenient to preserve them.

Quoted 1 line

If application really wants to remove all flow rules, it can call

rte_flow_flush().

Quoted 6 lines

The strong reason to flush indirect actions and flow rules across restart is possible actions or rules restore failure on start. However, may be it is sufficient to document that start should really fail, if it can't restore everything and application should retry after rte_flow_flush() taking it into account.

Quoted 9 lines
Quoted 5 lines
Quoted 5 lines

If we finally accept it, I think it would be very useful to care about PMDs which cannot preserve it in HW across restart from the very beginning and save it in ethdev layer and restore on start automatically (i.e. do not force all such PMDs to care about the restore

internally and basically duplicate the code).

Quoted 3 lines

Or keeping indirect actions can be an advertised PMD capability. Given Ori's comments to patch 4, I think the common spec needs more

work.

Quoted 5 lines
Quoted 2 lines

For this patchset that fixes MLX5 we can have the behavior documented for

PMD and not require it from all the drivers.

Are you going to drop 4th patch?

Yes.

Quoted 3 lines

In general documenting PMD behaviour specifics in its documentation is a wrong direction since it does not help DPDK applications to be portable across different HW.

Quoted 7 lines

I agree. But currently there is a clear resource leak in MLX5 PMD, that can be solved either by destroying indirect actions on port stop or by keeping them (this is what PMD maintainers prefer). The leak should be fixed and what happens to indirect actions must be clearly documented. Ideally the fix should be aligned with common ethdev API, but if you and Ori think its design is wrong, then at least behavior can be described in PMD docs and later fixed or promoted to API.

I think application should be aware to different possibilities between the PMD. If possible, it is best that all PMD will act the same but if there is HW issue I think different behavior is better then not supporting at all.
In any case the doc should state the min requirement if HW can support better than it can do so.

Best,
Ori

#12 lore raw

v2 cover net/mlx5: keep indirect actions across port restart

In reply to Dmitry Kozlyuk

It is unspecified what happens to indirect actions when a port is stopped, possibly reconfigured, and started again. MLX5 PMD, the first one to implement indirect action API, intended to keep them across such a sequence, but the implementation was buggy, This patcheset fixes it. There is no consensus yet what behavior should be specified for all drivers, so current behavior is described in PMD docs.

Dmitry Kozlyuk (3):
net/mlx5: discover max flow priority using DevX net/mlx5: create drop queue using DevX net/mlx5: preserve indirect actions across port restart

 doc/guides/nics/mlx5.rst           |   8 +
 drivers/net/mlx5/linux/mlx5_os.c   |   5 -
 drivers/net/mlx5/mlx5_devx.c       | 204 +++++++++++++++++---
 drivers/net/mlx5/mlx5_flow.c       | 292 ++++++++++++++++++++++++++---
 drivers/net/mlx5/mlx5_flow.h       |   6 +
 drivers/net/mlx5/mlx5_flow_dv.c    | 103 ++++++++++
 drivers/net/mlx5/mlx5_flow_verbs.c |  77 +-------
 drivers/net/mlx5/mlx5_rx.h         |   4 +
 drivers/net/mlx5/mlx5_rxq.c        |  99 ++++++++--
 drivers/net/mlx5/mlx5_trigger.c    |  10 +
 10 files changed, 674 insertions(+), 134 deletions(-)
Signature · 1 line
2.25.1
#13 lore raw

PATCH v2 1/3 net/mlx5: discover max flow priority using DevX

Maximum available flow priority was discovered using Verbs API regardless of the selected flow engine. This required some Verbs objects to be initialized in order to use DevX engine. Make priority discovery an engine method and implement it for DevX using its API.

---
 drivers/net/mlx5/linux/mlx5_os.c   |   1 -
 drivers/net/mlx5/mlx5_flow.c       |  98 +++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_flow.h       |   4 ++
 drivers/net/mlx5/mlx5_flow_dv.c    | 103 +++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_flow_verbs.c |  77 +++------------------
 5 files changed, 215 insertions(+), 68 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +0 -1
index 4712bd6f9b..671dfface9 100644
@@ -1781,7 +1781,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 	priv->drop_queue.hrxq = mlx5_drop_action_create(eth_dev);
 	if (!priv->drop_queue.hrxq)
 		goto error;
-	/* Supported Verbs flow priority number detection. */
 	err = mlx5_flow_discover_priorities(eth_dev);
 	if (err < 0) {
 		err = -err;
drivers/net/mlx5/mlx5_flow.c +98 -0

101 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow.h +4 -0
index 3724293d26..da39eeb596 100644
@@ -1229,6 +1229,9 @@ typedef int (*mlx5_flow_create_def_policy_t)
 			(struct rte_eth_dev *dev);
 typedef void (*mlx5_flow_destroy_def_policy_t)
 			(struct rte_eth_dev *dev);
+typedef int (*mlx5_flow_discover_priorities_t)
+			(struct rte_eth_dev *dev,
+			 const uint16_t *vprio, int vprio_n);
 
 struct mlx5_flow_driver_ops {
 	mlx5_flow_validate_t validate;
@@ -1263,6 +1266,7 @@ struct mlx5_flow_driver_ops {
 	mlx5_flow_action_update_t action_update;
 	mlx5_flow_action_query_t action_query;
 	mlx5_flow_sync_domain_t sync_domain;
+	mlx5_flow_discover_priorities_t discover_priorities;
 };
 
 /* mlx5_flow.c */
drivers/net/mlx5/mlx5_flow_dv.c +103 -0

115 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow_verbs.c +10 -67

117 lines not on this page · raw message

Signature · 1 line
2.25.1
#14 lore raw

PATCH v2 2/3 net/mlx5: create drop queue using DevX

In reply to Dmitry Kozlyuk

Drop queue creation and destruction were not implemented for DevX flow engine and Verbs engine methods were used as a workaround. Implement these methods for DevX so that there is a valid queue ID that can be used regardless of queue configuration via API.

---
 drivers/net/mlx5/linux/mlx5_os.c |   4 -
 drivers/net/mlx5/mlx5_devx.c     | 204 ++++++++++++++++++++++++++-----
 2 files changed, 176 insertions(+), 32 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +0 -4
index 671dfface9..791024c2c6 100644
@@ -1756,10 +1756,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 	}
 	if (config->devx && config->dv_flow_en && config->dest_tir) {
 		priv->obj_ops = devx_obj_ops;
-		priv->obj_ops.drop_action_create =
-						ibv_obj_ops.drop_action_create;
-		priv->obj_ops.drop_action_destroy =
-						ibv_obj_ops.drop_action_destroy;
 #ifndef HAVE_MLX5DV_DEVX_UAR_OFFSET
 		priv->obj_ops.txq_obj_modify = ibv_obj_ops.txq_obj_modify;
 #else
drivers/net/mlx5/mlx5_devx.c +176 -28

294 lines not on this page · raw message

Signature · 1 line
2.25.1
#15 lore raw

PATCH v2 3/3 net/mlx5: preserve indirect actions across port restart

In reply to Dmitry Kozlyuk

MLX5 PMD uses reference counting to manage RX queue resources. After port stop shared RSS actions kept references to RX queues, preventing resource release. As a result, internal PMD mempool for such queues had been exhausted after a number of port restarts. Diagnostic message from rte_eth_dev_start():

Rx queue allocation failed: Cannot allocate memory

Dereference RX queues used by indirect actions on port stop (detach) and restore references on port start (attach) in order to allow RX queue resource release, but keep indirect actions across the port restart. Replace queue IDs in HW by drop queue ID on detach and restore actual queue IDs on attach.

Since rte_flow_action_handle_create() does not specify indirect action behavior across port restart, document it for MLX5 PMD.

Fixes 4b61b8774be9 ("ethdev: introduce indirect flow action")
---
 doc/guides/nics/mlx5.rst        |   8 ++
 drivers/net/mlx5/mlx5_flow.c    | 194 ++++++++++++++++++++++++++++----
 drivers/net/mlx5/mlx5_flow.h    |   2 +
 drivers/net/mlx5/mlx5_rx.h      |   4 +
 drivers/net/mlx5/mlx5_rxq.c     |  99 ++++++++++++++--
 drivers/net/mlx5/mlx5_trigger.c |  10 ++
 6 files changed, 283 insertions(+), 34 deletions(-)
doc/guides/nics/mlx5.rst +8 -0
index a00793907f..f103126301 100644
@@ -1813,6 +1813,14 @@ directly but neither destroyed nor flushed.
 
 The application should re-create the flows as required after the port restart.
 
+Indirect actions persist across device configure, stop, and start.
+After reconfiguration an existing indirect action may become invalid
+because of incompatibility with the new configuration.
+Such actions cannot be used to create a flow rule,
+also ``rte_eth_dev_configure()`` and ``rte_eth_dev_start()`` may fail
+with the same diagnostics as ``rte_flow_action_handle_create()`` would give.
+It is a programmer's responsibility to remove or update offending actions.
+
 Notes for testpmd
 -----------------
 
drivers/net/mlx5/mlx5_flow.c +171 -23

218 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow.h +2 -0
index da39eeb596..251d643f8c 100644
@@ -1575,6 +1575,8 @@ struct mlx5_flow_meter_sub_policy *mlx5_flow_meter_sub_policy_rss_prepare
 void mlx5_flow_destroy_sub_policy_with_rxq(struct rte_eth_dev *dev,
 		struct mlx5_flow_meter_policy *mtr_policy);
 int mlx5_flow_dv_discover_counter_offset_support(struct rte_eth_dev *dev);
+int mlx5_action_handle_attach(struct rte_eth_dev *dev);
+int mlx5_action_handle_detach(struct rte_eth_dev *dev);
 int mlx5_action_handle_flush(struct rte_eth_dev *dev);
 void mlx5_release_tunnel_hub(struct mlx5_dev_ctx_shared *sh, uint16_t port_id);
 int mlx5_alloc_tunnel_hub(struct mlx5_dev_ctx_shared *sh);
drivers/net/mlx5/mlx5_rx.h +4 -0
index 3f2b99fb65..7319ad0264 100644
@@ -222,6 +222,10 @@ int mlx5_ind_table_obj_modify(struct rte_eth_dev *dev,
 			      struct mlx5_ind_table_obj *ind_tbl,
 			      uint16_t *queues, const uint32_t queues_n,
 			      bool standalone);
+int mlx5_ind_table_obj_attach(struct rte_eth_dev *dev,
+			      struct mlx5_ind_table_obj *ind_tbl);
+int mlx5_ind_table_obj_detach(struct rte_eth_dev *dev,
+			      struct mlx5_ind_table_obj *ind_tbl);
 struct mlx5_list_entry *mlx5_hrxq_create_cb(void *tool_ctx, void *cb_ctx);
 int mlx5_hrxq_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
 		       void *cb_ctx);
drivers/net/mlx5/mlx5_rxq.c +88 -11

118 lines not on this page · raw message

drivers/net/mlx5/mlx5_trigger.c +10 -0
index a9d5d58fd9..6761a84a68 100644
@@ -14,6 +14,7 @@
 #include <mlx5_malloc.h>
 
 #include "mlx5.h"
+#include "mlx5_flow.h"
 #include "mlx5_mr.h"
 #include "mlx5_rx.h"
 #include "mlx5_tx.h"
@@ -1115,6 +1116,14 @@ mlx5_dev_start(struct rte_eth_dev *dev)
 	mlx5_rxq_timestamp_set(dev);
 	/* Set a mask and offset of scheduling on timestamp into Tx queues. */
 	mlx5_txq_dynf_timestamp_set(dev);
+	/* Attach indirection table objects detached on port stop. */
+	ret = mlx5_action_handle_attach(dev);
+	if (ret) {
+		DRV_LOG(ERR,
+			"port %u failed to attach indirect actions: %s",
+			dev->data->port_id, rte_strerror(rte_errno));
+		goto error;
+	}
 	/*
 	 * In non-cached mode, it only needs to start the default mreg copy
 	 * action and no flow created by application exists anymore.
@@ -1187,6 +1196,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev)
 	/* All RX queue flags will be cleared in the flush interface. */
 	mlx5_flow_list_flush(dev, MLX5_FLOW_TYPE_GEN, true);
 	mlx5_flow_meter_rxq_flush(dev);
+	mlx5_action_handle_detach(dev);
 	mlx5_rx_intr_vec_disable(dev);
 	priv->sh->port[priv->dev_port - 1].ih_port_id = RTE_MAX_ETHPORTS;
 	priv->sh->port[priv->dev_port - 1].devx_ih_port_id = RTE_MAX_ETHPORTS;
Signature · 1 line
2.25.1