Skip to contentSkip to conversation

Shared action RSS PMD impl

PATCH Superseded Andrey Vesnovaty 6 participants 19 messages Oct 8, 2020 – Oct 26, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

cover Shared action RSS PMD impl

This patchset introduces Mellanox PMD implementation for shared RSS action. In was part of the 'RTE flow shared action API' patchset [1] but after v3 i was split to RTE flow layer [2] and PMD implementation (this patchset).

PMD implementation of this patcheset based on RTE flow API [3]. Current state of the patchset is draft & v2 will be sent very soon.

[1] RTE flow shared action API v1
http://inbox.dpdk.org/dev/[email protected]/
[2] RTE flow shared action API v4
http://inbox.dpdk.org/dev/[email protected]/
[3] RTE flow shared action API v7
http://inbox.dpdk.org/dev/[email protected]/

Andrey Vesnovaty (4):
common/mlx5: modify advanced Rx object via DevX
net/mlx5: modify hash Rx queue objects
net/mlx5: shared action PMD
net/mlx5: driver support for shared action

 drivers/common/mlx5/mlx5_devx_cmds.c          |  84 +++
 drivers/common/mlx5/mlx5_devx_cmds.h          |  10 +
 drivers/common/mlx5/mlx5_prm.h                |  29 +
 .../common/mlx5/rte_common_mlx5_version.map   |   1 +
 drivers/net/mlx5/mlx5.c                       |   1 +
 drivers/net/mlx5/mlx5.h                       |   6 +
 drivers/net/mlx5/mlx5_defs.h                  |   3 +
 drivers/net/mlx5/mlx5_devx.c                  | 173 ++++-
 drivers/net/mlx5/mlx5_flow.c                  | 497 ++++++++++++-
 drivers/net/mlx5/mlx5_flow.h                  |  86 +++
 drivers/net/mlx5/mlx5_flow_dv.c               | 684 +++++++++++++++++-
 drivers/net/mlx5/mlx5_rxq.c                   | 103 +++
 drivers/net/mlx5/mlx5_rxtx.h                  |   5 +-
 13 files changed, 1588 insertions(+), 94 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/4 common/mlx5: modify advanced Rx object via DevX

From: Andrey Vesnovaty <[email protected]>

Implement mlx5_devx_cmd_modify_tir() to modify TIR object using DevX API.
Add related structs in mlx5_prm.h.

---
 drivers/common/mlx5/mlx5_devx_cmds.c          | 84 +++++++++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h          | 10 +++
 drivers/common/mlx5/mlx5_prm.h                | 29 +++++++
 .../common/mlx5/rte_common_mlx5_version.map   |  1 +
 4 files changed, 124 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +84 -0
index 7c81ae15a9..2b109c4f65 100644
@@ -1080,6 +1080,90 @@ mlx5_devx_cmd_create_tir(void *ctx,
 	return tir;
 }
 
+/**
+ * Modify TIR using DevX API.
+ *
+ * @param[in] tir
+ *   Pointer to TIR DevX object structure.
+ * @param [in] modify_tir_attr
+ *   Pointer to TIR modification attributes structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_devx_cmd_modify_tir(struct mlx5_devx_obj *tir,
+			 struct mlx5_devx_modify_tir_attr *modify_tir_attr)
+{
+	struct mlx5_devx_tir_attr *tir_attr = &modify_tir_attr->tir;
+	uint32_t in[MLX5_ST_SZ_DW(modify_tir_in)] = {0};
+	uint32_t out[MLX5_ST_SZ_DW(modify_tir_out)] = {0};
+	void *tir_ctx;
+	int ret;
+
+	MLX5_SET(modify_tir_in, in, opcode, MLX5_CMD_OP_MODIFY_TIR);
+	MLX5_SET(modify_tir_in, in, tirn, modify_tir_attr->tirn);
+	MLX5_SET64(modify_tir_in, in, modify_bitmask,
+		modify_tir_attr->modify_bitmask);
+
+	tir_ctx = MLX5_ADDR_OF(modify_rq_in, in, ctx);
+	if (modify_tir_attr->modify_bitmask &
+			MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_LRO) {
+		MLX5_SET(tirc, tir_ctx, lro_timeout_period_usecs,
+			 tir_attr->lro_timeout_period_usecs);
+		MLX5_SET(tirc, tir_ctx, lro_enable_mask,
+			 tir_attr->lro_enable_mask);
+		MLX5_SET(tirc, tir_ctx, lro_max_msg_sz,
+			 tir_attr->lro_max_msg_sz);
+	}
+	if (modify_tir_attr->modify_bitmask &
+			MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_INDIRECT_TABLE)
+		MLX5_SET(tirc, tir_ctx, indirect_table,
+			 tir_attr->indirect_table);
+	if (modify_tir_attr->modify_bitmask &
+			MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_HASH) {
+		int i;
+		void *outer, *inner;
+		MLX5_SET(tirc, tir_ctx, rx_hash_symmetric,
+			tir_attr->rx_hash_symmetric);
+		MLX5_SET(tirc, tir_ctx, rx_hash_fn, tir_attr->rx_hash_fn);
+		for (i = 0; i < 10; i++) {
+			MLX5_SET(tirc, tir_ctx, rx_hash_toeplitz_key[i],
+				 tir_attr->rx_hash_toeplitz_key[i]);
+		}
+		outer = MLX5_ADDR_OF(tirc, tir_ctx,
+				     rx_hash_field_selector_outer);
+		MLX5_SET(rx_hash_field_select, outer, l3_prot_type,
+			 tir_attr->rx_hash_field_selector_outer.l3_prot_type);
+		MLX5_SET(rx_hash_field_select, outer, l4_prot_type,
+			 tir_attr->rx_hash_field_selector_outer.l4_prot_type);
+		MLX5_SET
+		(rx_hash_field_select, outer, selected_fields,
+		 tir_attr->rx_hash_field_selector_outer.selected_fields);
+		inner = MLX5_ADDR_OF(tirc, tir_ctx,
+				     rx_hash_field_selector_inner);
+		MLX5_SET(rx_hash_field_select, inner, l3_prot_type,
+			 tir_attr->rx_hash_field_selector_inner.l3_prot_type);
+		MLX5_SET(rx_hash_field_select, inner, l4_prot_type,
+			 tir_attr->rx_hash_field_selector_inner.l4_prot_type);
+		MLX5_SET
+		(rx_hash_field_select, inner, selected_fields,
+		 tir_attr->rx_hash_field_selector_inner.selected_fields);
+	}
+	if (modify_tir_attr->modify_bitmask &
+	    MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_SELF_LB_EN) {
+		MLX5_SET(tirc, tir_ctx, self_lb_block, tir_attr->self_lb_block);
+	}
+	ret = mlx5_glue->devx_obj_modify(tir->obj, in, sizeof(in),
+					 out, sizeof(out));
+	if (ret) {
+		DRV_LOG(ERR, "Failed to modify TIR using DevX");
+		rte_errno = errno;
+		return -errno;
+	}
+	return ret;
+}
+
 /**
  * Create RQT using DevX API.
  *
drivers/common/mlx5/mlx5_devx_cmds.h +10 -0
index 1c84cea851..ba6cb6ed51 100644
@@ -190,6 +190,13 @@ struct mlx5_devx_tir_attr {
 	struct mlx5_rx_hash_field_select rx_hash_field_selector_inner;
 };
 
+/* TIR attributes structure, used by TIR modify */
+struct mlx5_devx_modify_tir_attr {
+	uint32_t tirn:24;
+	uint64_t modify_bitmask;
+	struct mlx5_devx_tir_attr tir;
+};
+
 /* RQT attributes structure, used by RQT operations. */
 struct mlx5_devx_rqt_attr {
 	uint8_t rq_type;
@@ -434,6 +441,9 @@ __rte_internal
 int mlx5_devx_cmd_modify_rqt(struct mlx5_devx_obj *rqt,
 			     struct mlx5_devx_rqt_attr *rqt_attr);
 __rte_internal
+int mlx5_devx_cmd_modify_tir(struct mlx5_devx_obj *tir,
+			     struct mlx5_devx_modify_tir_attr *tir_attr);
+__rte_internal
 int mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
 				      uint32_t ids[], uint32_t num);
 
drivers/common/mlx5/mlx5_prm.h +29 -0
index 20f2fccd4f..2dbae445b3 100644
@@ -830,6 +830,7 @@ enum {
 	MLX5_CMD_OP_ACCESS_REGISTER = 0x805,
 	MLX5_CMD_OP_ALLOC_TRANSPORT_DOMAIN = 0x816,
 	MLX5_CMD_OP_CREATE_TIR = 0x900,
+	MLX5_CMD_OP_MODIFY_TIR = 0x901,
 	MLX5_CMD_OP_CREATE_SQ = 0X904,
 	MLX5_CMD_OP_MODIFY_SQ = 0X905,
 	MLX5_CMD_OP_CREATE_RQ = 0x908,
@@ -1858,6 +1859,34 @@ struct mlx5_ifc_create_tir_in_bits {
 	struct mlx5_ifc_tirc_bits ctx;
 };
 
+enum {
+	MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_LRO = 1ULL << 0,
+	MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_INDIRECT_TABLE = 1ULL << 1,
+	MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_HASH = 1ULL << 2,
+	/* bit 3 - tunneled_offload_en modify not supported */
+	MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_SELF_LB_EN = 1ULL << 4,
+};
+
+struct mlx5_ifc_modify_tir_out_bits {
+	u8 status[0x8];
+	u8 reserved_at_8[0x18];
+	u8 syndrome[0x20];
+	u8 reserved_at_40[0x40];
+};
+
+struct mlx5_ifc_modify_tir_in_bits {
+	u8 opcode[0x10];
+	u8 uid[0x10];
+	u8 reserved_at_20[0x10];
+	u8 op_mod[0x10];
+	u8 reserved_at_40[0x8];
+	u8 tirn[0x18];
+	u8 reserved_at_60[0x20];
+	u8 modify_bitmask[0x40];
+	u8 reserved_at_c0[0x40];
+	struct mlx5_ifc_tirc_bits ctx;
+};
+
 enum {
 	MLX5_INLINE_Q_TYPE_RQ = 0x0,
 	MLX5_INLINE_Q_TYPE_VIRTQ = 0x1,
drivers/common/mlx5/rte_common_mlx5_version.map +1 -0
index c4d57c08a7..884001ca7d 100644
@@ -30,6 +30,7 @@ INTERNAL {
 	mlx5_devx_cmd_modify_rq;
 	mlx5_devx_cmd_modify_rqt;
 	mlx5_devx_cmd_modify_sq;
+	mlx5_devx_cmd_modify_tir;
 	mlx5_devx_cmd_modify_virtq;
 	mlx5_devx_cmd_qp_query_tis_td;
 	mlx5_devx_cmd_query_hca_attr;
Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/4 net/mlx5: modify hash Rx queue objects

In reply to Andrey Vesnovaty

From: Andrey Vesnovaty <[email protected]>

Implement mlx5_hrxq_modify() to modify hash RX queue object. This commit relays on capability to modify TIR object via DevX.

---
 drivers/net/mlx5/mlx5.h      |   4 +
 drivers/net/mlx5/mlx5_devx.c | 173 +++++++++++++++++++++++++++--------
 drivers/net/mlx5/mlx5_rxq.c  | 103 +++++++++++++++++++++
 drivers/net/mlx5/mlx5_rxtx.h |   5 +-
 4 files changed, 246 insertions(+), 39 deletions(-)
drivers/net/mlx5/mlx5.h +4 -0
index 87d3c15f07..7b85f64167 100644
@@ -784,6 +784,10 @@ struct mlx5_obj_ops {
 	void (*ind_table_destroy)(struct mlx5_ind_table_obj *ind_tbl);
 	int (*hrxq_new)(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq,
 			int tunnel __rte_unused);
+	int (*hrxq_modify)(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq,
+			   const uint8_t *rss_key,
+			   uint64_t hash_fields,
+			   const struct mlx5_ind_table_obj *ind_tbl);
 	void (*hrxq_destroy)(struct mlx5_hrxq *hrxq);
 	int (*drop_action_create)(struct rte_eth_dev *dev);
 	void (*drop_action_destroy)(struct rte_eth_dev *dev);
drivers/net/mlx5/mlx5_devx.c +135 -38

226 lines not on this page · raw message

drivers/net/mlx5/mlx5_rxq.c +103 -0

115 lines not on this page · raw message

drivers/net/mlx5/mlx5_rxtx.h +4 -1
index 674296ee98..09499cc730 100644
@@ -347,7 +347,10 @@ void mlx5_drop_action_destroy(struct rte_eth_dev *dev);
 uint64_t mlx5_get_rx_port_offloads(void);
 uint64_t mlx5_get_rx_queue_offloads(struct rte_eth_dev *dev);
 void mlx5_rxq_timestamp_set(struct rte_eth_dev *dev);
-
+int mlx5_hrxq_modify(struct rte_eth_dev *dev, uint32_t hxrq_idx,
+		     const uint8_t *rss_key, uint32_t rss_key_len,
+		     uint64_t hash_fields,
+		     const uint16_t *queues, uint32_t queues_n);
 
 /* mlx5_txq.c */
 
Signature · 1 line
2.26.2
#3 lore raw

PATCH 3/4 net/mlx5: shared action PMD

In reply to Andrey Vesnovaty

From: Andrey Vesnovaty <[email protected]>

Implement rte_flow shared action API for mlx5 PMD. Handle shared action on flow create/destroy.

---
 drivers/net/mlx5/mlx5.c      |   1 +
 drivers/net/mlx5/mlx5.h      |   2 +
 drivers/net/mlx5/mlx5_defs.h |   3 +
 drivers/net/mlx5/mlx5_flow.c | 497 ++++++++++++++++++++++++++++++++---
 drivers/net/mlx5/mlx5_flow.h |  86 ++++++
 5 files changed, 557 insertions(+), 32 deletions(-)
drivers/net/mlx5/mlx5.c +1 -0
index e5ca392fed..562c4a3e33 100644
@@ -1384,6 +1384,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	 * then this will return directly without any action.
 	 */
 	mlx5_flow_list_flush(dev, &priv->flows, true);
+	mlx5_shared_action_flush(dev);
 	mlx5_flow_meter_flush(dev, NULL);
 	/* Free the intermediate buffers for flow creation. */
 	mlx5_flow_free_intermediate(dev);
drivers/net/mlx5/mlx5.h +2 -0
index 7b85f64167..879cc9a51e 100644
@@ -877,6 +877,8 @@ struct mlx5_priv {
 	uint8_t fdb_def_rule; /* Whether fdb jump to table 1 is configured. */
 	struct mlx5_mp_id mp_id; /* ID of a multi-process process */
 	LIST_HEAD(fdir, mlx5_fdir_flow) fdir_flows; /* fdir flows. */
+	LIST_HEAD(shared_action, rte_flow_shared_action) shared_actions;
+	/* shared actions */
 };
 
 #define PORT_ID(priv) ((priv)->dev_data->port_id)
drivers/net/mlx5/mlx5_defs.h +3 -0
index 0df47391ee..22e41df1eb 100644
@@ -197,6 +197,9 @@
 #define MLX5_HAIRPIN_QUEUE_STRIDE 6
 #define MLX5_HAIRPIN_JUMBO_LOG_SIZE (14 + 2)
 
+/* Maximum number of shared actions supported by rte_flow */
+#define MLX5_MAX_SHARED_ACTIONS 1
+
 /* Definition of static_assert found in /usr/include/assert.h */
 #ifndef HAVE_STATIC_ASSERT
 #define static_assert _Static_assert
drivers/net/mlx5/mlx5_flow.c +465 -32

602 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow.h +86 -0

126 lines not on this page · raw message

Signature · 1 line
2.26.2
#4 lore raw

PATCH 4/4 net/mlx5: driver support for shared action

In reply to Andrey Vesnovaty

From: Andrey Vesnovaty <[email protected]>

Implement shared action create/destroy/update/query. Implement RSS shared action and handle shared RSS on flow apply and release.

Note: currently implemented for sharede RSS action only

---
 drivers/net/mlx5/mlx5_flow_dv.c | 684 ++++++++++++++++++++++++++++++--
 1 file changed, 661 insertions(+), 23 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +661 -23
index 79fdf34c0e..b99db65d2d 100644
@@ -8928,6 +8928,157 @@ __flow_dv_translate(struct rte_eth_dev *dev,
 	return 0;
 }
 
+/**
+ * Set hash RX queue by hash fields (see enum ibv_rx_hash_fields)
+ * and tunnel.
+ *
+ * @param[in, out] action
+ *   Shred RSS action holding hash RX queue objects.
+ * @param[in] hash_fields
+ *   Defines combination of packet fields to participate in RX hash.
+ * @param[in] tunnel
+ *   Tunnel type
+ * @param[in] hrxq_idx
+ *   Hash RX queue index to set.
+ *
+ * @return
+ *   0 on success, otherwise negative errno value.
+ */
+static int
+__flow_dv_action_rss_hrxq_set(struct mlx5_shared_action_rss *action,
+			      const uint64_t hash_fields,
+			      const int tunnel,
+			      uint32_t hrxq_idx)
+{
+	uint32_t *hrxqs = (tunnel) ? action->hrxq : action->hrxq_tunnel;
+
+	switch (hash_fields & ~IBV_RX_HASH_INNER) {
+	case MLX5_RSS_HASH_IPV4:
+		hrxqs[0] = hrxq_idx;
+		return 0;
+	case MLX5_RSS_HASH_IPV4_TCP:
+		hrxqs[1] = hrxq_idx;
+		return 0;
+	case MLX5_RSS_HASH_IPV4_UDP:
+		hrxqs[2] = hrxq_idx;
+		return 0;
+	case MLX5_RSS_HASH_IPV6:
+		hrxqs[3] = hrxq_idx;
+		return 0;
+	case MLX5_RSS_HASH_IPV6_TCP:
+		hrxqs[4] = hrxq_idx;
+		return 0;
+	case MLX5_RSS_HASH_IPV6_UDP:
+		hrxqs[5] = hrxq_idx;
+		return 0;
+	case MLX5_RSS_HASH_NONE:
+		hrxqs[6] = hrxq_idx;
+		return 0;
+	default:
+		return -1;
+	}
+}
+
+/**
+ * Look up for hash RX queue by hash fields (see enum ibv_rx_hash_fields)
+ * and tunnel.
+ *
+ * @param[in] action
+ *   Shred RSS action holding hash RX queue objects.
+ * @param[in] hash_fields
+ *   Defines combination of packet fields to participate in RX hash.
+ * @param[in] tunnel
+ *   Tunnel type
+ *
+ * @return
+ *   Valid hash RX queue index, otherwise 0.
+ */
+static uint32_t
+__flow_dv_action_rss_hrxq_lookup(const struct mlx5_shared_action_rss *action,
+				 const uint64_t hash_fields,
+				 const int tunnel)
+{
+	const uint32_t *hrxqs = (tunnel) ? action->hrxq : action->hrxq_tunnel;
+
+	switch (hash_fields & ~IBV_RX_HASH_INNER) {
+	case MLX5_RSS_HASH_IPV4:
+		return hrxqs[0];
+	case MLX5_RSS_HASH_IPV4_TCP:
+		return hrxqs[1];
+	case MLX5_RSS_HASH_IPV4_UDP:
+		return hrxqs[2];
+	case MLX5_RSS_HASH_IPV6:
+		return hrxqs[3];
+	case MLX5_RSS_HASH_IPV6_TCP:
+		return hrxqs[4];
+	case MLX5_RSS_HASH_IPV6_UDP:
+		return hrxqs[5];
+	case MLX5_RSS_HASH_NONE:
+		return hrxqs[6];
+	default:
+		return 0;
+	}
+}
+
+/**
+ * Retrieves hash RX queue suitable for the *flow*.
+ * If shared action configured for *flow* suitable hash RX queue will be
+ * retrieved from attached shared action.
+ *
+ * @param[in] flow
+ *   Shred RSS action holding hash RX queue objects.
+ * @param[in] dev_flow
+ *   Pointer to the sub flow.
+ * @param[out] hrxq
+ *   Pointer to retrieved hash RX queue object.
+ *
+ * @return
+ *   Valid hash RX queue index, otherwise 0 and rte_errno is set.
+ */
+static uint32_t
+__flow_dv_rss_get_hrxq(struct rte_eth_dev *dev, struct rte_flow *flow,
+			   struct mlx5_flow *dev_flow,
+			   struct mlx5_hrxq **hrxq)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	uint32_t hrxq_idx;
+
+	if (flow->shared_rss) {
+		hrxq_idx = __flow_dv_action_rss_hrxq_lookup
+				(flow->shared_rss, dev_flow->hash_fields,
+				 !!(dev_flow->handle->layers &
+				    MLX5_FLOW_LAYER_TUNNEL));
+		if (hrxq_idx) {
+			*hrxq = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_HRXQ],
+					       hrxq_idx);
+			rte_atomic32_inc(&(*hrxq)->refcnt);
+		}
+	} else {
+		struct mlx5_flow_rss_desc *rss_desc =
+				&((struct mlx5_flow_rss_desc *)priv->rss_desc)
+				[!!priv->flow_nested_idx];
+
+		MLX5_ASSERT(rss_desc->queue_num);
+		hrxq_idx = mlx5_hrxq_get(dev, rss_desc->key,
+					 MLX5_RSS_HASH_KEY_LEN,
+					 dev_flow->hash_fields,
+					 rss_desc->queue, rss_desc->queue_num);
+		if (!hrxq_idx) {
+			hrxq_idx = mlx5_hrxq_new(dev,
+						 rss_desc->key,
+						 MLX5_RSS_HASH_KEY_LEN,
+						 dev_flow->hash_fields,
+						 rss_desc->queue,
+						 rss_desc->queue_num,
+						 !!(dev_flow->handle->layers &
+						 MLX5_FLOW_LAYER_TUNNEL));
+		}
+		*hrxq = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_HRXQ],
+				       hrxq_idx);
+	}
+	return hrxq_idx;
+}
+
 /**
  * Apply the flow to the NIC, lock free,
  * (mutex should be acquired by caller).
@@ -8986,30 +9137,10 @@ __flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow,
 				dv->actions[n++] = drop_hrxq->action;
 			}
 		} else if (dh->fate_action == MLX5_FLOW_FATE_QUEUE) {
-			struct mlx5_hrxq *hrxq;
-			uint32_t hrxq_idx;
-			struct mlx5_flow_rss_desc *rss_desc =
-				&((struct mlx5_flow_rss_desc *)priv->rss_desc)
-				[!!priv->flow_nested_idx];
+			struct mlx5_hrxq *hrxq = NULL;
+			uint32_t hrxq_idx = __flow_dv_rss_get_hrxq
+						(dev, flow, dev_flow, &hrxq);
 
-			MLX5_ASSERT(rss_desc->queue_num);
-			hrxq_idx = mlx5_hrxq_get(dev, rss_desc->key,
-						 MLX5_RSS_HASH_KEY_LEN,
-						 dev_flow->hash_fields,
-						 rss_desc->queue,
-						 rss_desc->queue_num);
-			if (!hrxq_idx) {
-				hrxq_idx = mlx5_hrxq_new
-						(dev, rss_desc->key,
-						 MLX5_RSS_HASH_KEY_LEN,
-						 dev_flow->hash_fields,
-						 rss_desc->queue,
-						 rss_desc->queue_num,
-						 !!(dh->layers &
-						 MLX5_FLOW_LAYER_TUNNEL));
-			}
-			hrxq = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_HRXQ],
-					      hrxq_idx);
 			if (!hrxq) {
 				rte_flow_error_set
 					(error, rte_errno,
@@ -9427,12 +9558,16 @@ __flow_dv_remove(struct rte_eth_dev *dev, struct rte_flow *flow)
 static void
 __flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)
 {
+	struct rte_flow_shared_action *shared;
 	struct mlx5_flow_handle *dev_handle;
 	struct mlx5_priv *priv = dev->data->dev_private;
 
 	if (!flow)
 		return;
 	__flow_dv_remove(dev, flow);
+	shared = mlx5_flow_get_shared_rss(flow);
+	if (shared)
+		rte_atomic32_dec(&shared->refcnt);
 	if (flow->counter) {
 		flow_dv_counter_release(dev, flow->counter);
 		flow->counter = 0;
@@ -9472,6 +9607,419 @@ __flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)
 	}
 }
 
+/**
+ * Release array of hash RX queue objects.
+ * Helper function.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in, out] hrxqs
+ *   Array of hash RX queue objects.
+ *
+ * @return
+ *   Total number of references to hash RX queue objects in *hrxqs* array
+ *   after this operation.
+ */
+static int
+__flow_dv_hrxqs_release(struct rte_eth_dev *dev,
+			uint32_t (*hrxqs)[MLX5_RSS_HASH_FIELDS_LEN])
+{
+	size_t i;
+	int remaining = 0, ret = 0, ret_tunnel = 0;
+
+	for (i = 0; i < RTE_DIM(*hrxqs); i++) {
+		ret = mlx5_hrxq_release(dev, (*hrxqs)[i]);
+		if (!ret)
+			(*hrxqs)[i] = 0;
+		remaining += ret + ret_tunnel;
+	}
+	return remaining;
+}
+
+/**
+ * Release all hash RX queue objects representing shared RSS action.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in, out] action
+ *   Shared RSS action to remove hash RX queue objects from.
+ *
+ * @return
+ *   Total number of references to hash RX queue objects stored in *action*
+ *   after this operation.
+ *   Expected to be 0 if no external references held.
+ */
+static int
+__flow_dv_action_rss_hrxqs_release(struct rte_eth_dev *dev,
+				 struct mlx5_shared_action_rss *action)
+{
+	return __flow_dv_hrxqs_release(dev, &action->hrxq) +
+		__flow_dv_hrxqs_release(dev, &action->hrxq_tunnel);
+}
+
+/**
+ * Setup shared RSS action.
+ * Prepare set of hash RX queue objects sufficient to handle all valid
+ * hash_fields combinations (see enum ibv_rx_hash_fields).
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in, out] action
+ *   Partially initialized shared RSS action.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   0 on success, otherwise negative errno value.
+ */
+static int
+__flow_dv_action_rss_setup(struct rte_eth_dev *dev,
+			struct mlx5_shared_action_rss *action,
+			struct rte_flow_error *error)
+{
+	size_t i;
+	int err;
+
+	for (i = 0; i < MLX5_RSS_HASH_FIELDS_LEN; i++) {
+		uint32_t hrxq_idx;
+		uint64_t hash_fields = mlx5_rss_hash_fields[i];
+		int tunnel;
+
+		for (tunnel = 0; tunnel < 2; tunnel++) {
+			hrxq_idx = mlx5_hrxq_new(dev, action->origin.key,
+					MLX5_RSS_HASH_KEY_LEN,
+					hash_fields,
+					action->origin.queue,
+					action->origin.queue_num,
+					tunnel);
+			if (!hrxq_idx) {
+				rte_flow_error_set
+					(error, rte_errno,
+					 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+					 "cannot get hash queue");
+				goto error_hrxq_new;
+			}
+			err = __flow_dv_action_rss_hrxq_set
+				(action, hash_fields, tunnel, hrxq_idx);
+			MLX5_ASSERT(!err);
+		}
+	}
+	return 0;
+error_hrxq_new:
+	err = rte_errno;
+	__flow_dv_action_rss_hrxqs_release(dev, action);
+	rte_errno = err;
+	return -rte_errno;
+}
+
+/**
+ * Create shared RSS action.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] conf
+ *   Shared action configuration.
+ * @param[in] rss
+ *   RSS action specification used to create shared action.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   A valid shared action handle in case of success, NULL otherwise and
+ *   rte_errno is set.
+ */
+static struct rte_flow_shared_action *
+__flow_dv_action_rss_create(struct rte_eth_dev *dev,
+			    const struct rte_flow_shared_action_conf *conf,
+			    const struct rte_flow_action_rss *rss,
+			    struct rte_flow_error *error)
+{
+	struct rte_flow_shared_action *shared_action = NULL;
+	void *queue = NULL;
+	uint32_t queue_size;
+	struct mlx5_shared_action_rss *shared_rss;
+	struct rte_flow_action_rss *origin;
+	const uint8_t *rss_key;
+
+	(void)conf;
+	queue_size = RTE_ALIGN_CEIL(rss->queue_num * sizeof(uint16_t),
+				    sizeof(void *));
+	queue = rte_calloc(__func__, 1, queue_size, 0);
+	shared_action = rte_calloc(__func__, 1, sizeof(*shared_action), 0);
+	if (!shared_action || !queue) {
+		rte_flow_error_set(error, ENOMEM,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+				   "cannot allocate resource memory");
+		goto error_rss_init;
+	}
+	shared_rss = &shared_action->rss;
+	shared_rss->queue = queue;
+	origin = &shared_rss->origin;
+	origin->func = rss->func;
+	origin->level = rss->level;
+	/* RSS type 0 indicates default RSS type (ETH_RSS_IP). */
+	origin->types = !rss->types ? ETH_RSS_IP : rss->types;
+	/* NULL RSS key indicates default RSS key. */
+	rss_key = !rss->key ? rss_hash_default_key : rss->key;
+	rte_memcpy(shared_rss->key, rss_key, MLX5_RSS_HASH_KEY_LEN);
+	origin->key = &shared_rss->key[0];
+	origin->key_len = MLX5_RSS_HASH_KEY_LEN;
+	rte_memcpy(shared_rss->queue, rss->queue, queue_size);
+	origin->queue = shared_rss->queue;
+	origin->queue_num = rss->queue_num;
+	if (__flow_dv_action_rss_setup(dev, shared_rss, error))
+		goto error_rss_init;
+	shared_action->type = MLX5_FLOW_ACTION_SHARED_RSS;
+	return shared_action;
+error_rss_init:
+	rte_free(shared_action);
+	rte_free(queue);
+	return NULL;
+}
+
+/**
+ * Destroy the shared RSS action.
+ * Release related hash RX queue objects.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] shared_rss
+ *   The shared RSS action object to be removed.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   0 on success, otherwise negative errno value.
+ */
+static int
+__flow_dv_action_rss_release(struct rte_eth_dev *dev,
+			 struct mlx5_shared_action_rss *shared_rss,
+			 struct rte_flow_error *error)
+{
+	struct rte_flow_shared_action *shared_action = NULL;
+	int remaining = __flow_dv_action_rss_hrxqs_release(dev, shared_rss);
+
+	if (remaining) {
+		return rte_flow_error_set(error, ETOOMANYREFS,
+					  RTE_FLOW_ERROR_TYPE_ACTION,
+					  NULL,
+					  "shared rss hrxq has references");
+	}
+	shared_action = container_of(shared_rss,
+				     struct rte_flow_shared_action, rss);
+	if (!rte_atomic32_dec_and_test(&shared_action->refcnt)) {
+		return rte_flow_error_set(error, ETOOMANYREFS,
+					  RTE_FLOW_ERROR_TYPE_ACTION,
+					  NULL,
+					  "shared rss has references");
+	}
+	rte_free(shared_rss->queue);
+	return 0;
+}
+
+/**
+ * Create shared action, lock free,
+ * (mutex should be acquired by caller).
+ * Dispatcher for action type specific call.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] conf
+ *   Shared action configuration.
+ * @param[in] action
+ *   Action specification used to create shared action.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   A valid shared action handle in case of success, NULL otherwise and
+ *   rte_errno is set.
+ */
+static struct rte_flow_shared_action *
+__flow_dv_action_create(struct rte_eth_dev *dev,
+			const struct rte_flow_shared_action_conf *conf,
+			const struct rte_flow_action *action,
+			struct rte_flow_error *error)
+{
+	struct rte_flow_shared_action *shared_action = NULL;
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	switch (action->type) {
+	case RTE_FLOW_ACTION_TYPE_RSS:
+		shared_action = __flow_dv_action_rss_create(dev, conf,
+							    action->conf,
+							    error);
+		break;
+	default:
+		rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION,
+				   NULL, "action type not supported");
+		break;
+	}
+	if (shared_action) {
+		rte_atomic32_inc(&shared_action->refcnt);
+		LIST_INSERT_HEAD(&priv->shared_actions, shared_action, next);
+	}
+	return shared_action;
+}
+
+/**
+ * Destroy the shared action.
+ * Release action related resources on the NIC and the memory.
+ * Lock free, (mutex should be acquired by caller).
+ * Dispatcher for action type specific call.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] action
+ *   The shared action object to be removed.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   0 on success, otherwise negative errno value.
+ */
+static int
+__flow_dv_action_destroy(struct rte_eth_dev *dev,
+			 struct rte_flow_shared_action *action,
+			 struct rte_flow_error *error)
+{
+	int ret;
+
+	switch (action->type) {
+	case MLX5_FLOW_ACTION_SHARED_RSS:
+		ret = __flow_dv_action_rss_release(dev, &action->rss, error);
+		break;
+	default:
+		return rte_flow_error_set(error, ENOTSUP,
+					  RTE_FLOW_ERROR_TYPE_ACTION,
+					  NULL,
+					  "action type not supported");
+	}
+	if (ret)
+		return ret;
+	LIST_REMOVE(action, next);
+	rte_free(action);
+	return 0;
+}
+
+/**
+ * Updates in place shared RSS action configuration.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] shared_rss
+ *   The shared RSS action object to be updated.
+ * @param[in] action_conf
+ *   RSS action specification used to modify *shared_rss*.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   0 on success, otherwise negative errno value.
+ * @note: currently only support update of RSS queues.
+ */
+static int
+__flow_dv_action_rss_update(struct rte_eth_dev *dev,
+			    struct mlx5_shared_action_rss *shared_rss,
+			    const struct rte_flow_action_rss *action_conf,
+			    struct rte_flow_error *error)
+{
+	size_t i;
+	int ret;
+	void *queue = NULL;
+	uint32_t queue_size;
+	const uint8_t *rss_key;
+	uint32_t rss_key_len;
+
+	queue_size = RTE_ALIGN_CEIL(action_conf->queue_num * sizeof(uint16_t),
+				    sizeof(void *));
+	queue = rte_calloc(__func__, 1, queue_size, 0);
+	if (!queue) {
+		return rte_flow_error_set(error, ENOMEM,
+					  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+					  NULL,
+					  "cannot allocate resource memory");
+	}
+	if (action_conf->key) {
+		rss_key = action_conf->key;
+		rss_key_len = action_conf->key_len;
+	} else {
+		rss_key = rss_hash_default_key;
+		rss_key_len = MLX5_RSS_HASH_KEY_LEN;
+	}
+	for (i = 0; i < MLX5_RSS_HASH_FIELDS_LEN; i++) {
+		uint32_t hrxq_idx;
+		uint64_t hash_fields = mlx5_rss_hash_fields[i];
+		int tunnel;
+
+		for (tunnel = 0; tunnel < 2; tunnel++) {
+			hrxq_idx = __flow_dv_action_rss_hrxq_lookup
+					(shared_rss, hash_fields, tunnel);
+			MLX5_ASSERT(hrxq_idx);
+			ret = mlx5_hrxq_modify
+				(dev, hrxq_idx,
+				 rss_key, rss_key_len,
+				 hash_fields,
+				 action_conf->queue, action_conf->queue_num);
+			if (ret) {
+				rte_free(queue);
+				return rte_flow_error_set
+					(error, rte_errno,
+					 RTE_FLOW_ERROR_TYPE_ACTION, NULL,
+					 "cannot update hash queue");
+			}
+		}
+	}
+	rte_free(shared_rss->queue);
+	shared_rss->queue = queue;
+	rte_memcpy(shared_rss->queue, action_conf->queue, queue_size);
+	shared_rss->origin.queue = shared_rss->queue;
+	shared_rss->origin.queue_num = action_conf->queue_num;
+	return 0;
+}
+
+/**
+ * Updates in place shared action configuration, lock free,
+ * (mutex should be acquired by caller).
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] action
+ *   The shared action object to be updated.
+ * @param[in] action_conf
+ *   Action specification used to modify *action*.
+ *   *action_conf* should be of type correlating with type of the *action*,
+ *   otherwise considered as invalid.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   0 on success, otherwise negative errno value.
+ */
+static int
+__flow_dv_action_update(struct rte_eth_dev *dev,
+			struct rte_flow_shared_action *action,
+			const void *action_conf,
+			struct rte_flow_error *error)
+{
+	switch (action->type) {
+	case MLX5_FLOW_ACTION_SHARED_RSS:
+		return __flow_dv_action_rss_update(dev, &action->rss,
+						   action_conf, error);
+	default:
+		return rte_flow_error_set(error, ENOTSUP,
+					  RTE_FLOW_ERROR_TYPE_ACTION,
+					  NULL,
+					  "action type not supported");
+	}
+}
 /**
  * Query a dv flow  rule for its statistics via devx.
  *
@@ -10150,6 +10698,92 @@ flow_dv_counter_free(struct rte_eth_dev *dev, uint32_t cnt)
 	flow_dv_shared_unlock(dev);
 }
 
+/**
+ * Validate shared action.
+ * Dispatcher for action type specific validation.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] conf
+ *   Shared action configuration.
+ * @param[in] action
+ *   The shared action object to validate.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   0 on success, otherwise negative errno value.
+ */
+static int
+flow_dv_action_validate(struct rte_eth_dev *dev,
+			const struct rte_flow_shared_action_conf *conf,
+			const struct rte_flow_action *action,
+			struct rte_flow_error *error)
+{
+	(void)conf;
+	switch (action->type) {
+	case RTE_FLOW_ACTION_TYPE_RSS:
+		return mlx5_validate_action_rss(dev, action, error);
+	default:
+		return rte_flow_error_set(error, ENOTSUP,
+					  RTE_FLOW_ERROR_TYPE_ACTION,
+					  NULL,
+					  "action type not supported");
+	}
+}
+
+/*
+ * Mutex-protected thunk to lock-free  __flow_dv_action_create().
+ */
+static struct rte_flow_shared_action *
+flow_dv_action_create(struct rte_eth_dev *dev,
+		      const struct rte_flow_shared_action_conf *conf,
+		      const struct rte_flow_action *action,
+		      struct rte_flow_error *error)
+{
+	struct rte_flow_shared_action *shared_action = NULL;
+
+	flow_dv_shared_lock(dev);
+	shared_action = __flow_dv_action_create(dev, conf, action, error);
+	flow_dv_shared_unlock(dev);
+	return shared_action;
+}
+
+/*
+ * Mutex-protected thunk to lock-free  __flow_dv_action_destroy().
+ */
+static int
+flow_dv_action_destroy(struct rte_eth_dev *dev,
+		       struct rte_flow_shared_action *action,
+		       struct rte_flow_error *error)
+{
+	int ret;
+
+	flow_dv_shared_lock(dev);
+	ret = __flow_dv_action_destroy(dev, action, error);
+	flow_dv_shared_unlock(dev);
+	return ret;
+}
+
+/*
+ * Mutex-protected thunk to lock-free  __flow_dv_action_update().
+ */
+static int
+flow_dv_action_update(struct rte_eth_dev *dev,
+		      struct rte_flow_shared_action *action,
+		      const void *action_conf,
+		      struct rte_flow_error *error)
+{
+	int ret;
+
+	flow_dv_shared_lock(dev);
+	ret = __flow_dv_action_update(dev, action, action_conf,
+				      error);
+	flow_dv_shared_unlock(dev);
+	return ret;
+}
+
 const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops = {
 	.validate = flow_dv_validate,
 	.prepare = flow_dv_prepare,
@@ -10166,6 +10800,10 @@ const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops = {
 	.counter_free = flow_dv_counter_free,
 	.counter_query = flow_dv_counter_query,
 	.get_aged_flows = flow_get_aged_flows,
+	.action_validate = flow_dv_action_validate,
+	.action_create = flow_dv_action_create,
+	.action_destroy = flow_dv_action_destroy,
+	.action_update = flow_dv_action_update,
 };
 
 #endif /* HAVE_IBV_FLOW_DV_SUPPORT */
Signature · 1 line
2.26.2
#5 lore raw

v2 cover Shared action RSS PMD impl

In reply to Andrey Vesnovaty

This patchset introduces Mellanox PMD implementation for shared RSS action. It was part of the 'RTE flow shared action API' patchset [1]. After v3 the ptchset was split to RTE flow layer [2] and PMD implementation (this patchset).

PMD implementation of this patchset is based on RTE flow API [3].

v2 changes (v1 was a draft):
* lots fo cosmetic changes
* fix spelling/rephrases in comments and commit messages
* fix code styling issues
* code cleanups
* bugfix: prevent non shared action modification

[1] RTE flow shared action API v1
http://inbox.dpdk.org/dev/[email protected]/
[2] RTE flow shared action API v4
http://inbox.dpdk.org/dev/[email protected]/
[3] RTE flow shared action API v8
http://inbox.dpdk.org/dev/[email protected]/

Andrey Vesnovaty (4):
common/mlx5: modify advanced Rx object via DevX
net/mlx5: modify hash Rx queue objects
net/mlx5: shared action PMD
net/mlx5: driver support for shared action

 drivers/common/mlx5/mlx5_devx_cmds.c |  84 ++++
 drivers/common/mlx5/mlx5_devx_cmds.h |  10 +
 drivers/common/mlx5/mlx5_prm.h       |  29 ++
 drivers/common/mlx5/version.map      |   1 +
 drivers/net/mlx5/mlx5.c              |   1 +
 drivers/net/mlx5/mlx5.h              |   7 +
 drivers/net/mlx5/mlx5_defs.h         |   3 +
 drivers/net/mlx5/mlx5_devx.c         | 151 ++++--
 drivers/net/mlx5/mlx5_flow.c         | 499 +++++++++++++++++--
 drivers/net/mlx5/mlx5_flow.h         |  86 ++++
 drivers/net/mlx5/mlx5_flow_dv.c      | 705 +++++++++++++++++++++++++--
 drivers/net/mlx5/mlx5_flow_verbs.c   |   3 +-
 drivers/net/mlx5/mlx5_rxq.c          | 110 ++++-
 drivers/net/mlx5/mlx5_rxtx.h         |   7 +-
 14 files changed, 1596 insertions(+), 100 deletions(-)
Signature · 1 line
2.26.2
#6 lore raw

PATCH v2 1/4 common/mlx5: modify advanced Rx object via DevX

Implement TIR modification (see mlx5_devx_cmd_modify_tir()) using DevX API. TIR is the object containing the hashed table of Rx queue. The functionality to configure/modify this HW-related object is prerequisite to implement rete_flow_shared_action_update() for shared RSS action in mlx5 PMD. HW-related structures for TIR modification add in mlx5_prm.h.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 84 ++++++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h | 10 ++++
 drivers/common/mlx5/mlx5_prm.h       | 29 ++++++++++
 drivers/common/mlx5/version.map      |  1 +
 4 files changed, 124 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +84 -0
index d3e90b5311..8aee12d527 100644
@@ -1109,6 +1109,90 @@ mlx5_devx_cmd_create_tir(void *ctx,
 	return tir;
 }
 
+/**
+ * Modify TIR using DevX API.
+ *
+ * @param[in] tir
+ *   Pointer to TIR DevX object structure.
+ * @param [in] modify_tir_attr
+ *   Pointer to TIR modification attributes structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_devx_cmd_modify_tir(struct mlx5_devx_obj *tir,
+			 struct mlx5_devx_modify_tir_attr *modify_tir_attr)
+{
+	struct mlx5_devx_tir_attr *tir_attr = &modify_tir_attr->tir;
+	uint32_t in[MLX5_ST_SZ_DW(modify_tir_in)] = {0};
+	uint32_t out[MLX5_ST_SZ_DW(modify_tir_out)] = {0};
+	void *tir_ctx;
+	int ret;
+
+	MLX5_SET(modify_tir_in, in, opcode, MLX5_CMD_OP_MODIFY_TIR);
+	MLX5_SET(modify_tir_in, in, tirn, modify_tir_attr->tirn);
+	MLX5_SET64(modify_tir_in, in, modify_bitmask,
+		   modify_tir_attr->modify_bitmask);
+	tir_ctx = MLX5_ADDR_OF(modify_rq_in, in, ctx);
+	if (modify_tir_attr->modify_bitmask &
+			MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_LRO) {
+		MLX5_SET(tirc, tir_ctx, lro_timeout_period_usecs,
+			 tir_attr->lro_timeout_period_usecs);
+		MLX5_SET(tirc, tir_ctx, lro_enable_mask,
+			 tir_attr->lro_enable_mask);
+		MLX5_SET(tirc, tir_ctx, lro_max_msg_sz,
+			 tir_attr->lro_max_msg_sz);
+	}
+	if (modify_tir_attr->modify_bitmask &
+			MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_INDIRECT_TABLE)
+		MLX5_SET(tirc, tir_ctx, indirect_table,
+			 tir_attr->indirect_table);
+	if (modify_tir_attr->modify_bitmask &
+			MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_HASH) {
+		int i;
+		void *outer, *inner;
+
+		MLX5_SET(tirc, tir_ctx, rx_hash_symmetric,
+			 tir_attr->rx_hash_symmetric);
+		MLX5_SET(tirc, tir_ctx, rx_hash_fn, tir_attr->rx_hash_fn);
+		for (i = 0; i < 10; i++) {
+			MLX5_SET(tirc, tir_ctx, rx_hash_toeplitz_key[i],
+				 tir_attr->rx_hash_toeplitz_key[i]);
+		}
+		outer = MLX5_ADDR_OF(tirc, tir_ctx,
+				     rx_hash_field_selector_outer);
+		MLX5_SET(rx_hash_field_select, outer, l3_prot_type,
+			 tir_attr->rx_hash_field_selector_outer.l3_prot_type);
+		MLX5_SET(rx_hash_field_select, outer, l4_prot_type,
+			 tir_attr->rx_hash_field_selector_outer.l4_prot_type);
+		MLX5_SET
+		(rx_hash_field_select, outer, selected_fields,
+		 tir_attr->rx_hash_field_selector_outer.selected_fields);
+		inner = MLX5_ADDR_OF(tirc, tir_ctx,
+				     rx_hash_field_selector_inner);
+		MLX5_SET(rx_hash_field_select, inner, l3_prot_type,
+			 tir_attr->rx_hash_field_selector_inner.l3_prot_type);
+		MLX5_SET(rx_hash_field_select, inner, l4_prot_type,
+			 tir_attr->rx_hash_field_selector_inner.l4_prot_type);
+		MLX5_SET
+		(rx_hash_field_select, inner, selected_fields,
+		 tir_attr->rx_hash_field_selector_inner.selected_fields);
+	}
+	if (modify_tir_attr->modify_bitmask &
+	    MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_SELF_LB_EN) {
+		MLX5_SET(tirc, tir_ctx, self_lb_block, tir_attr->self_lb_block);
+	}
+	ret = mlx5_glue->devx_obj_modify(tir->obj, in, sizeof(in),
+					 out, sizeof(out));
+	if (ret) {
+		DRV_LOG(ERR, "Failed to modify TIR using DevX");
+		rte_errno = errno;
+		return -errno;
+	}
+	return ret;
+}
+
 /**
  * Create RQT using DevX API.
  *
drivers/common/mlx5/mlx5_devx_cmds.h +10 -0
index c2d089cab8..abbea67784 100644
@@ -192,6 +192,13 @@ struct mlx5_devx_tir_attr {
 	struct mlx5_rx_hash_field_select rx_hash_field_selector_inner;
 };
 
+/* TIR attributes structure, used by TIR modify. */
+struct mlx5_devx_modify_tir_attr {
+	uint32_t tirn:24;
+	uint64_t modify_bitmask;
+	struct mlx5_devx_tir_attr tir;
+};
+
 /* RQT attributes structure, used by RQT operations. */
 struct mlx5_devx_rqt_attr {
 	uint8_t rq_type;
@@ -436,6 +443,9 @@ __rte_internal
 int mlx5_devx_cmd_modify_rqt(struct mlx5_devx_obj *rqt,
 			     struct mlx5_devx_rqt_attr *rqt_attr);
 __rte_internal
+int mlx5_devx_cmd_modify_tir(struct mlx5_devx_obj *tir,
+			     struct mlx5_devx_modify_tir_attr *tir_attr);
+__rte_internal
 int mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
 				      uint32_t ids[], uint32_t num);
 
drivers/common/mlx5/mlx5_prm.h +29 -0
index b8b656a53f..d342263c85 100644
@@ -830,6 +830,7 @@ enum {
 	MLX5_CMD_OP_ACCESS_REGISTER = 0x805,
 	MLX5_CMD_OP_ALLOC_TRANSPORT_DOMAIN = 0x816,
 	MLX5_CMD_OP_CREATE_TIR = 0x900,
+	MLX5_CMD_OP_MODIFY_TIR = 0x901,
 	MLX5_CMD_OP_CREATE_SQ = 0X904,
 	MLX5_CMD_OP_MODIFY_SQ = 0X905,
 	MLX5_CMD_OP_CREATE_RQ = 0x908,
@@ -1919,6 +1920,34 @@ struct mlx5_ifc_create_tir_in_bits {
 	struct mlx5_ifc_tirc_bits ctx;
 };
 
+enum {
+	MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_LRO = 1ULL << 0,
+	MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_INDIRECT_TABLE = 1ULL << 1,
+	MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_HASH = 1ULL << 2,
+	/* bit 3 - tunneled_offload_en modify not supported. */
+	MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_SELF_LB_EN = 1ULL << 4,
+};
+
+struct mlx5_ifc_modify_tir_out_bits {
+	u8 status[0x8];
+	u8 reserved_at_8[0x18];
+	u8 syndrome[0x20];
+	u8 reserved_at_40[0x40];
+};
+
+struct mlx5_ifc_modify_tir_in_bits {
+	u8 opcode[0x10];
+	u8 uid[0x10];
+	u8 reserved_at_20[0x10];
+	u8 op_mod[0x10];
+	u8 reserved_at_40[0x8];
+	u8 tirn[0x18];
+	u8 reserved_at_60[0x20];
+	u8 modify_bitmask[0x40];
+	u8 reserved_at_c0[0x40];
+	struct mlx5_ifc_tirc_bits ctx;
+};
+
 enum {
 	MLX5_INLINE_Q_TYPE_RQ = 0x0,
 	MLX5_INLINE_Q_TYPE_VIRTQ = 0x1,
drivers/common/mlx5/version.map +1 -0
index c4d57c08a7..884001ca7d 100644
@@ -30,6 +30,7 @@ INTERNAL {
 	mlx5_devx_cmd_modify_rq;
 	mlx5_devx_cmd_modify_rqt;
 	mlx5_devx_cmd_modify_sq;
+	mlx5_devx_cmd_modify_tir;
 	mlx5_devx_cmd_modify_virtq;
 	mlx5_devx_cmd_qp_query_tis_td;
 	mlx5_devx_cmd_query_hca_attr;
Signature · 1 line
2.26.2
Acked-by on v2 1/4
#7 lore raw

Re: [dpdk-dev] [PATCH v2 1/4] common/mlx5: modify advanced Rx object via DevX

Quoted 13 lines

-----Original Message-----
From: Andrey Vesnovaty <[email protected]>
Sent: Friday, October 23, 2020 13:24
To: [email protected]
Cc: [email protected]; [email protected]; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]; [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>
Subject: [PATCH v2 1/4] common/mlx5: modify advanced Rx object via DevX

Quoted 7 lines

Implement TIR modification (see mlx5_devx_cmd_modify_tir()) using DevX API. TIR is the object containing the hashed table of Rx queue. The functionality to configure/modify this HW-related object is prerequisite to implement rete_flow_shared_action_update() for shared RSS action in mlx5 PMD. HW-related structures for TIR modification add in mlx5_prm.h.

#8 lore raw

PATCH v2 2/4 net/mlx5: modify hash Rx queue objects

In reply to Andrey Vesnovaty

Implement modification for hashed table of Rx queue object (see mlx5_hrxq_modify()). This implementation relies on the capability to modify TIR object via DevX API, i.e. current implementation doesn't support verbs HW object operations. The functionality to modify hashed table of Rx queue object is prerequisite to implement rete_flow_shared_action_update() for shared RSS action in mlx5 PMD.

---
 drivers/net/mlx5/mlx5.h            |   5 +
 drivers/net/mlx5/mlx5_devx.c       | 151 ++++++++++++++++++++++-------
 drivers/net/mlx5/mlx5_flow_dv.c    |  19 ++--
 drivers/net/mlx5/mlx5_flow_verbs.c |   3 +-
 drivers/net/mlx5/mlx5_rxq.c        | 110 ++++++++++++++++++++-
 drivers/net/mlx5/mlx5_rxtx.h       |   7 +-
 6 files changed, 245 insertions(+), 50 deletions(-)
drivers/net/mlx5/mlx5.h +5 -0
index c9d5d71630..9be3061165 100644
@@ -727,6 +727,7 @@ struct mlx5_ind_table_obj {
 struct mlx5_hrxq {
 	ILIST_ENTRY(uint32_t)next; /* Index to the next element. */
 	rte_atomic32_t refcnt; /* Reference counter. */
+	uint8_t shared:1; /* This object used in shared action. */
 	struct mlx5_ind_table_obj *ind_table; /* Indirection table. */
 	RTE_STD_C11
 	union {
@@ -798,6 +799,10 @@ struct mlx5_obj_ops {
 	void (*ind_table_destroy)(struct mlx5_ind_table_obj *ind_tbl);
 	int (*hrxq_new)(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq,
 			int tunnel __rte_unused);
+	int (*hrxq_modify)(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq,
+			   const uint8_t *rss_key,
+			   uint64_t hash_fields,
+			   const struct mlx5_ind_table_obj *ind_tbl);
 	void (*hrxq_destroy)(struct mlx5_hrxq *hrxq);
 	int (*drop_action_create)(struct rte_eth_dev *dev);
 	void (*drop_action_destroy)(struct rte_eth_dev *dev);
drivers/net/mlx5/mlx5_devx.c +116 -35

207 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow_dv.c +8 -11
index 15cd34e331..2bac7dac9b 100644
@@ -8425,20 +8425,16 @@ flow_dv_handle_rx_queue(struct rte_eth_dev *dev,
 	struct mlx5_hrxq *hrxq;
 
 	MLX5_ASSERT(rss_desc->queue_num);
-	*hrxq_idx = mlx5_hrxq_get(dev, rss_desc->key,
-				  MLX5_RSS_HASH_KEY_LEN,
+	*hrxq_idx = mlx5_hrxq_get(dev, rss_desc->key, MLX5_RSS_HASH_KEY_LEN,
 				  dev_flow->hash_fields,
-				  rss_desc->queue,
-				  rss_desc->queue_num);
+				  rss_desc->queue, rss_desc->queue_num);
 	if (!*hrxq_idx) {
 		*hrxq_idx = mlx5_hrxq_new
-				(dev, rss_desc->key,
-				 MLX5_RSS_HASH_KEY_LEN,
+				(dev, rss_desc->key, MLX5_RSS_HASH_KEY_LEN,
 				 dev_flow->hash_fields,
-				 rss_desc->queue,
-				 rss_desc->queue_num,
-				 !!(dh->layers &
-				 MLX5_FLOW_LAYER_TUNNEL));
+				 rss_desc->queue, rss_desc->queue_num,
+				 !!(dh->layers & MLX5_FLOW_LAYER_TUNNEL),
+				 false);
 		if (!*hrxq_idx)
 			return NULL;
 	}
@@ -10026,7 +10022,8 @@ __flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow,
 						 rss_desc->queue,
 						 rss_desc->queue_num,
 						 !!(dh->layers &
-						 MLX5_FLOW_LAYER_TUNNEL));
+						 MLX5_FLOW_LAYER_TUNNEL),
+						 false);
 			}
 			hrxq = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_HRXQ],
 					      hrxq_idx);
drivers/net/mlx5/mlx5_flow_verbs.c +2 -1
index 710622ce92..9cc4410667 100644
@@ -1984,7 +1984,8 @@ flow_verbs_apply(struct rte_eth_dev *dev, struct rte_flow *flow,
 						 rss_desc->queue,
 						 rss_desc->queue_num,
 						 !!(handle->layers &
-						 MLX5_FLOW_LAYER_TUNNEL));
+						 MLX5_FLOW_LAYER_TUNNEL),
+						 false);
 			hrxq = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_HRXQ],
 					      hrxq_idx);
 			if (!hrxq) {
drivers/net/mlx5/mlx5_rxq.c +109 -1

146 lines not on this page · raw message

drivers/net/mlx5/mlx5_rxtx.h +5 -2
index 0eafa22d63..1b35a2669c 100644
@@ -339,7 +339,7 @@ uint32_t mlx5_hrxq_new(struct rte_eth_dev *dev,
 		       const uint8_t *rss_key, uint32_t rss_key_len,
 		       uint64_t hash_fields,
 		       const uint16_t *queues, uint32_t queues_n,
-		       int tunnel __rte_unused);
+		       int tunnel, bool shared);
 uint32_t mlx5_hrxq_get(struct rte_eth_dev *dev,
 		       const uint8_t *rss_key, uint32_t rss_key_len,
 		       uint64_t hash_fields,
@@ -352,7 +352,10 @@ void mlx5_drop_action_destroy(struct rte_eth_dev *dev);
 uint64_t mlx5_get_rx_port_offloads(void);
 uint64_t mlx5_get_rx_queue_offloads(struct rte_eth_dev *dev);
 void mlx5_rxq_timestamp_set(struct rte_eth_dev *dev);
-
+int mlx5_hrxq_modify(struct rte_eth_dev *dev, uint32_t hxrq_idx,
+		     const uint8_t *rss_key, uint32_t rss_key_len,
+		     uint64_t hash_fields,
+		     const uint16_t *queues, uint32_t queues_n);
 
 /* mlx5_txq.c */
 
Signature · 1 line
2.26.2
Acked-by on v2 2/4
#9 lore raw

Re: [dpdk-dev] [PATCH v2 2/4] net/mlx5: modify hash Rx queue objects

Quoted 13 lines

-----Original Message-----
From: Andrey Vesnovaty <[email protected]>
Sent: Friday, October 23, 2020 13:24
To: [email protected]
Cc: [email protected]; [email protected]; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]; [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>
Subject: [PATCH v2 2/4] net/mlx5: modify hash Rx queue objects

Quoted 8 lines

Implement modification for hashed table of Rx queue object (see mlx5_hrxq_modify()). This implementation relies on the capability to modify TIR object via DevX API, i.e. current implementation doesn't support verbs HW object operations. The functionality to modify hashed table of Rx queue object is prerequisite to implement
rete_flow_shared_action_update() for shared RSS action in mlx5 PMD.

#10 lore raw

PATCH v2 3/4 net/mlx5: shared action PMD

In reply to Andrey Vesnovaty

Handle shared action on flow validation/creation/destruction. mlx5 PMD translates shared action into a regular one before handling flow validation/creation. The shared action translation applied to utilize the same execution path for both shared and regular actions. The current implementation supports shared action translation for shared RSS action only.

RSS action validation split to validate shared RSS action on its creation in addition to action validation in flow validation/creation path.

Implement rte_flow shared action API for mlx5 PMD, mostly forwarding calls to flow driver operations (see struct mlx5_flow_driver_ops).

---
 drivers/net/mlx5/mlx5.c      |   1 +
 drivers/net/mlx5/mlx5.h      |   2 +
 drivers/net/mlx5/mlx5_defs.h |   3 +
 drivers/net/mlx5/mlx5_flow.c | 499 +++++++++++++++++++++++++++++++++--
 drivers/net/mlx5/mlx5_flow.h |  86 ++++++
 5 files changed, 563 insertions(+), 28 deletions(-)
drivers/net/mlx5/mlx5.c +1 -0
index e4ce9a9cb7..2484251b2f 100644
@@ -1401,6 +1401,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 	 * then this will return directly without any action.
 	 */
 	mlx5_flow_list_flush(dev, &priv->flows, true);
+	mlx5_shared_action_flush(dev);
 	mlx5_flow_meter_flush(dev, NULL);
 	/* Free the intermediate buffers for flow creation. */
 	mlx5_flow_free_intermediate(dev);
drivers/net/mlx5/mlx5.h +2 -0
index 9be3061165..658533de6f 100644
@@ -891,6 +891,8 @@ struct mlx5_priv {
 	uint8_t fdb_def_rule; /* Whether fdb jump to table 1 is configured. */
 	struct mlx5_mp_id mp_id; /* ID of a multi-process process */
 	LIST_HEAD(fdir, mlx5_fdir_flow) fdir_flows; /* fdir flows. */
+	LIST_HEAD(shared_action, rte_flow_shared_action) shared_actions;
+	/* shared actions */
 };
 
 #define PORT_ID(priv) ((priv)->dev_data->port_id)
drivers/net/mlx5/mlx5_defs.h +3 -0
index 0df47391ee..22e41df1eb 100644
@@ -197,6 +197,9 @@
 #define MLX5_HAIRPIN_QUEUE_STRIDE 6
 #define MLX5_HAIRPIN_JUMBO_LOG_SIZE (14 + 2)
 
+/* Maximum number of shared actions supported by rte_flow */
+#define MLX5_MAX_SHARED_ACTIONS 1
+
 /* Definition of static_assert found in /usr/include/assert.h */
 #ifndef HAVE_STATIC_ASSERT
 #define static_assert _Static_assert
drivers/net/mlx5/mlx5_flow.c +471 -28

609 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow.h +86 -0

126 lines not on this page · raw message

Signature · 1 line
2.26.2
Acked-by on v2 3/4
#11 lore raw

Re: [dpdk-dev] [PATCH v2 3/4] net/mlx5: shared action PMD

Quoted 20 lines

-----Original Message-----
From: Andrey Vesnovaty <[email protected]>
Sent: Friday, October 23, 2020 13:24
To: [email protected]
Cc: [email protected]; [email protected]; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]; [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>
Subject: [PATCH v2 3/4] net/mlx5: shared action PMD

Handle shared action on flow validation/creation/destruction. mlx5 PMD translates shared action into a regular one before handling flow validation/creation. The shared action translation applied to utilize the same execution path for both shared and regular actions.
The current implementation supports shared action translation for shared RSS action only.

Quoted 7 lines

RSS action validation split to validate shared RSS action on its creation in addition to action validation in flow validation/creation path.

Implement rte_flow shared action API for mlx5 PMD, mostly forwarding calls to flow driver operations (see struct mlx5_flow_driver_ops).

#12 lore raw

PATCH v2 4/4 net/mlx5: driver support for shared action

In reply to Andrey Vesnovaty

Implement shared action create/destroy/update/query. The current implementation support is limited to shared RSS action only. The shared RSS action create operation prepares hash RX queue objects for all supported permutations of the hash. The shared RSS action update operation relies on functionality to modify hash RX queue introduced in one of the previous commits in this patch series.

Implement RSS shared action and handle shared RSS on flow apply and release. The lookup for hash RX queue object for RSS action is limited to the set of objects stored in the shared action itself and when handling shared RSS action. The lookup for hash RX queue object inside shared action is performed by hash only.

Current implementation limited to DV flow driver operations i.e. verbs flow driver operations doesn't support shared action.

---
 drivers/net/mlx5/mlx5_flow_dv.c | 690 ++++++++++++++++++++++++++++++--
 1 file changed, 666 insertions(+), 24 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +666 -24
index 2bac7dac9b..66d81e9598 100644
@@ -9943,6 +9943,158 @@ __flow_dv_translate(struct rte_eth_dev *dev,
 	return 0;
 }
 
+/**
+ * Set hash RX queue by hash fields (see enum ibv_rx_hash_fields)
+ * and tunnel.
+ *
+ * @param[in, out] action
+ *   Shred RSS action holding hash RX queue objects.
+ * @param[in] hash_fields
+ *   Defines combination of packet fields to participate in RX hash.
+ * @param[in] tunnel
+ *   Tunnel type
+ * @param[in] hrxq_idx
+ *   Hash RX queue index to set.
+ *
+ * @return
+ *   0 on success, otherwise negative errno value.
+ */
+static int
+__flow_dv_action_rss_hrxq_set(struct mlx5_shared_action_rss *action,
+			      const uint64_t hash_fields,
+			      const int tunnel,
+			      uint32_t hrxq_idx)
+{
+	uint32_t *hrxqs = tunnel ? action->hrxq : action->hrxq_tunnel;
+
+	switch (hash_fields & ~IBV_RX_HASH_INNER) {
+	case MLX5_RSS_HASH_IPV4:
+		hrxqs[0] = hrxq_idx;
+		return 0;
+	case MLX5_RSS_HASH_IPV4_TCP:
+		hrxqs[1] = hrxq_idx;
+		return 0;
+	case MLX5_RSS_HASH_IPV4_UDP:
+		hrxqs[2] = hrxq_idx;
+		return 0;
+	case MLX5_RSS_HASH_IPV6:
+		hrxqs[3] = hrxq_idx;
+		return 0;
+	case MLX5_RSS_HASH_IPV6_TCP:
+		hrxqs[4] = hrxq_idx;
+		return 0;
+	case MLX5_RSS_HASH_IPV6_UDP:
+		hrxqs[5] = hrxq_idx;
+		return 0;
+	case MLX5_RSS_HASH_NONE:
+		hrxqs[6] = hrxq_idx;
+		return 0;
+	default:
+		return -1;
+	}
+}
+
+/**
+ * Look up for hash RX queue by hash fields (see enum ibv_rx_hash_fields)
+ * and tunnel.
+ *
+ * @param[in] action
+ *   Shred RSS action holding hash RX queue objects.
+ * @param[in] hash_fields
+ *   Defines combination of packet fields to participate in RX hash.
+ * @param[in] tunnel
+ *   Tunnel type
+ *
+ * @return
+ *   Valid hash RX queue index, otherwise 0.
+ */
+static uint32_t
+__flow_dv_action_rss_hrxq_lookup(const struct mlx5_shared_action_rss *action,
+				 const uint64_t hash_fields,
+				 const int tunnel)
+{
+	const uint32_t *hrxqs = tunnel ? action->hrxq : action->hrxq_tunnel;
+
+	switch (hash_fields & ~IBV_RX_HASH_INNER) {
+	case MLX5_RSS_HASH_IPV4:
+		return hrxqs[0];
+	case MLX5_RSS_HASH_IPV4_TCP:
+		return hrxqs[1];
+	case MLX5_RSS_HASH_IPV4_UDP:
+		return hrxqs[2];
+	case MLX5_RSS_HASH_IPV6:
+		return hrxqs[3];
+	case MLX5_RSS_HASH_IPV6_TCP:
+		return hrxqs[4];
+	case MLX5_RSS_HASH_IPV6_UDP:
+		return hrxqs[5];
+	case MLX5_RSS_HASH_NONE:
+		return hrxqs[6];
+	default:
+		return 0;
+	}
+}
+
+/**
+ * Retrieves hash RX queue suitable for the *flow*.
+ * If shared action configured for *flow* suitable hash RX queue will be
+ * retrieved from attached shared action.
+ *
+ * @param[in] flow
+ *   Shred RSS action holding hash RX queue objects.
+ * @param[in] dev_flow
+ *   Pointer to the sub flow.
+ * @param[out] hrxq
+ *   Pointer to retrieved hash RX queue object.
+ *
+ * @return
+ *   Valid hash RX queue index, otherwise 0 and rte_errno is set.
+ */
+static uint32_t
+__flow_dv_rss_get_hrxq(struct rte_eth_dev *dev, struct rte_flow *flow,
+			   struct mlx5_flow *dev_flow,
+			   struct mlx5_hrxq **hrxq)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	uint32_t hrxq_idx;
+
+	if (flow->shared_rss) {
+		hrxq_idx = __flow_dv_action_rss_hrxq_lookup
+				(flow->shared_rss, dev_flow->hash_fields,
+				 !!(dev_flow->handle->layers &
+				    MLX5_FLOW_LAYER_TUNNEL));
+		if (hrxq_idx) {
+			*hrxq = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_HRXQ],
+					       hrxq_idx);
+			rte_atomic32_inc(&(*hrxq)->refcnt);
+		}
+	} else {
+		struct mlx5_flow_rss_desc *rss_desc =
+				&((struct mlx5_flow_rss_desc *)priv->rss_desc)
+				[!!priv->flow_nested_idx];
+
+		MLX5_ASSERT(rss_desc->queue_num);
+		hrxq_idx = mlx5_hrxq_get(dev, rss_desc->key,
+					 MLX5_RSS_HASH_KEY_LEN,
+					 dev_flow->hash_fields,
+					 rss_desc->queue, rss_desc->queue_num);
+		if (!hrxq_idx) {
+			hrxq_idx = mlx5_hrxq_new(dev,
+						 rss_desc->key,
+						 MLX5_RSS_HASH_KEY_LEN,
+						 dev_flow->hash_fields,
+						 rss_desc->queue,
+						 rss_desc->queue_num,
+						 !!(dev_flow->handle->layers &
+						 MLX5_FLOW_LAYER_TUNNEL),
+						 false);
+		}
+		*hrxq = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_HRXQ],
+				       hrxq_idx);
+	}
+	return hrxq_idx;
+}
+
 /**
  * Apply the flow to the NIC, lock free,
  * (mutex should be acquired by caller).
@@ -10002,31 +10154,10 @@ __flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow,
 			}
 		} else if (dh->fate_action == MLX5_FLOW_FATE_QUEUE &&
 			   !dv_h->rix_sample && !dv_h->rix_dest_array) {
-			struct mlx5_hrxq *hrxq;
-			uint32_t hrxq_idx;
-			struct mlx5_flow_rss_desc *rss_desc =
-				&((struct mlx5_flow_rss_desc *)priv->rss_desc)
-				[!!priv->flow_nested_idx];
+			struct mlx5_hrxq *hrxq = NULL;
+			uint32_t hrxq_idx = __flow_dv_rss_get_hrxq
+						(dev, flow, dev_flow, &hrxq);
 
-			MLX5_ASSERT(rss_desc->queue_num);
-			hrxq_idx = mlx5_hrxq_get(dev, rss_desc->key,
-						 MLX5_RSS_HASH_KEY_LEN,
-						 dev_flow->hash_fields,
-						 rss_desc->queue,
-						 rss_desc->queue_num);
-			if (!hrxq_idx) {
-				hrxq_idx = mlx5_hrxq_new
-						(dev, rss_desc->key,
-						 MLX5_RSS_HASH_KEY_LEN,
-						 dev_flow->hash_fields,
-						 rss_desc->queue,
-						 rss_desc->queue_num,
-						 !!(dh->layers &
-						 MLX5_FLOW_LAYER_TUNNEL),
-						 false);
-			}
-			hrxq = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_HRXQ],
-					      hrxq_idx);
 			if (!hrxq) {
 				rte_flow_error_set
 					(error, rte_errno,
@@ -10579,12 +10710,16 @@ __flow_dv_remove(struct rte_eth_dev *dev, struct rte_flow *flow)
 static void
 __flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)
 {
+	struct rte_flow_shared_action *shared;
 	struct mlx5_flow_handle *dev_handle;
 	struct mlx5_priv *priv = dev->data->dev_private;
 
 	if (!flow)
 		return;
 	__flow_dv_remove(dev, flow);
+	shared = mlx5_flow_get_shared_rss(flow);
+	if (shared)
+		__atomic_sub_fetch(&shared->refcnt, 1, __ATOMIC_RELAXED);
 	if (flow->counter) {
 		flow_dv_counter_release(dev, flow->counter);
 		flow->counter = 0;
@@ -10629,6 +10764,423 @@ __flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)
 	}
 }
 
+/**
+ * Release array of hash RX queue objects.
+ * Helper function.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in, out] hrxqs
+ *   Array of hash RX queue objects.
+ *
+ * @return
+ *   Total number of references to hash RX queue objects in *hrxqs* array
+ *   after this operation.
+ */
+static int
+__flow_dv_hrxqs_release(struct rte_eth_dev *dev,
+			uint32_t (*hrxqs)[MLX5_RSS_HASH_FIELDS_LEN])
+{
+	size_t i;
+	int remaining = 0;
+
+	for (i = 0; i < RTE_DIM(*hrxqs); i++) {
+		int ret = mlx5_hrxq_release(dev, (*hrxqs)[i]);
+
+		if (!ret)
+			(*hrxqs)[i] = 0;
+		remaining += ret;
+	}
+	return remaining;
+}
+
+/**
+ * Release all hash RX queue objects representing shared RSS action.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in, out] action
+ *   Shared RSS action to remove hash RX queue objects from.
+ *
+ * @return
+ *   Total number of references to hash RX queue objects stored in *action*
+ *   after this operation.
+ *   Expected to be 0 if no external references held.
+ */
+static int
+__flow_dv_action_rss_hrxqs_release(struct rte_eth_dev *dev,
+				 struct mlx5_shared_action_rss *action)
+{
+	return __flow_dv_hrxqs_release(dev, &action->hrxq) +
+		__flow_dv_hrxqs_release(dev, &action->hrxq_tunnel);
+}
+
+/**
+ * Setup shared RSS action.
+ * Prepare set of hash RX queue objects sufficient to handle all valid
+ * hash_fields combinations (see enum ibv_rx_hash_fields).
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in, out] action
+ *   Partially initialized shared RSS action.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   0 on success, otherwise negative errno value.
+ */
+static int
+__flow_dv_action_rss_setup(struct rte_eth_dev *dev,
+			struct mlx5_shared_action_rss *action,
+			struct rte_flow_error *error)
+{
+	size_t i;
+	int err;
+
+	for (i = 0; i < MLX5_RSS_HASH_FIELDS_LEN; i++) {
+		uint32_t hrxq_idx;
+		uint64_t hash_fields = mlx5_rss_hash_fields[i];
+		int tunnel;
+
+		for (tunnel = 0; tunnel < 2; tunnel++) {
+			hrxq_idx = mlx5_hrxq_new(dev, action->origin.key,
+					MLX5_RSS_HASH_KEY_LEN,
+					hash_fields,
+					action->origin.queue,
+					action->origin.queue_num,
+					tunnel, true);
+			if (!hrxq_idx) {
+				rte_flow_error_set
+					(error, rte_errno,
+					 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+					 "cannot get hash queue");
+				goto error_hrxq_new;
+			}
+			err = __flow_dv_action_rss_hrxq_set
+				(action, hash_fields, tunnel, hrxq_idx);
+			MLX5_ASSERT(!err);
+		}
+	}
+	return 0;
+error_hrxq_new:
+	err = rte_errno;
+	__flow_dv_action_rss_hrxqs_release(dev, action);
+	rte_errno = err;
+	return -rte_errno;
+}
+
+/**
+ * Create shared RSS action.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] conf
+ *   Shared action configuration.
+ * @param[in] rss
+ *   RSS action specification used to create shared action.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   A valid shared action handle in case of success, NULL otherwise and
+ *   rte_errno is set.
+ */
+static struct rte_flow_shared_action *
+__flow_dv_action_rss_create(struct rte_eth_dev *dev,
+			    const struct rte_flow_shared_action_conf *conf,
+			    const struct rte_flow_action_rss *rss,
+			    struct rte_flow_error *error)
+{
+	struct rte_flow_shared_action *shared_action = NULL;
+	void *queue = NULL;
+	struct mlx5_shared_action_rss *shared_rss;
+	struct rte_flow_action_rss *origin;
+	const uint8_t *rss_key;
+	uint32_t queue_size = rss->queue_num * sizeof(uint16_t);
+
+	RTE_SET_USED(conf);
+	queue = mlx5_malloc(0, RTE_ALIGN_CEIL(queue_size, sizeof(void *)),
+			    0, SOCKET_ID_ANY);
+	shared_action = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*shared_action), 0,
+				    SOCKET_ID_ANY);
+	if (!shared_action || !queue) {
+		rte_flow_error_set(error, ENOMEM,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+				   "cannot allocate resource memory");
+		goto error_rss_init;
+	}
+	shared_rss = &shared_action->rss;
+	shared_rss->queue = queue;
+	origin = &shared_rss->origin;
+	origin->func = rss->func;
+	origin->level = rss->level;
+	/* RSS type 0 indicates default RSS type (ETH_RSS_IP). */
+	origin->types = !rss->types ? ETH_RSS_IP : rss->types;
+	/* NULL RSS key indicates default RSS key. */
+	rss_key = !rss->key ? rss_hash_default_key : rss->key;
+	memcpy(shared_rss->key, rss_key, MLX5_RSS_HASH_KEY_LEN);
+	origin->key = &shared_rss->key[0];
+	origin->key_len = MLX5_RSS_HASH_KEY_LEN;
+	memcpy(shared_rss->queue, rss->queue, queue_size);
+	origin->queue = shared_rss->queue;
+	origin->queue_num = rss->queue_num;
+	if (__flow_dv_action_rss_setup(dev, shared_rss, error))
+		goto error_rss_init;
+	shared_action->type = MLX5_RTE_FLOW_ACTION_TYPE_SHARED_RSS;
+	return shared_action;
+error_rss_init:
+	mlx5_free(shared_action);
+	mlx5_free(queue);
+	return NULL;
+}
+
+/**
+ * Destroy the shared RSS action.
+ * Release related hash RX queue objects.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] shared_rss
+ *   The shared RSS action object to be removed.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   0 on success, otherwise negative errno value.
+ */
+static int
+__flow_dv_action_rss_release(struct rte_eth_dev *dev,
+			 struct mlx5_shared_action_rss *shared_rss,
+			 struct rte_flow_error *error)
+{
+	struct rte_flow_shared_action *shared_action = NULL;
+	uint32_t old_refcnt = 1;
+	int remaining = __flow_dv_action_rss_hrxqs_release(dev, shared_rss);
+
+	if (remaining) {
+		return rte_flow_error_set(error, ETOOMANYREFS,
+					  RTE_FLOW_ERROR_TYPE_ACTION,
+					  NULL,
+					  "shared rss hrxq has references");
+	}
+	shared_action = container_of(shared_rss,
+				     struct rte_flow_shared_action, rss);
+	if (!__atomic_compare_exchange_n(&shared_action->refcnt, &old_refcnt,
+					 0, 0,
+					 __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
+		return rte_flow_error_set(error, ETOOMANYREFS,
+					  RTE_FLOW_ERROR_TYPE_ACTION,
+					  NULL,
+					  "shared rss has references");
+	}
+	rte_free(shared_rss->queue);
+	return 0;
+}
+
+/**
+ * Create shared action, lock free,
+ * (mutex should be acquired by caller).
+ * Dispatcher for action type specific call.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] conf
+ *   Shared action configuration.
+ * @param[in] action
+ *   Action specification used to create shared action.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   A valid shared action handle in case of success, NULL otherwise and
+ *   rte_errno is set.
+ */
+static struct rte_flow_shared_action *
+__flow_dv_action_create(struct rte_eth_dev *dev,
+			const struct rte_flow_shared_action_conf *conf,
+			const struct rte_flow_action *action,
+			struct rte_flow_error *error)
+{
+	struct rte_flow_shared_action *shared_action = NULL;
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	switch (action->type) {
+	case RTE_FLOW_ACTION_TYPE_RSS:
+		shared_action = __flow_dv_action_rss_create(dev, conf,
+							    action->conf,
+							    error);
+		break;
+	default:
+		rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION,
+				   NULL, "action type not supported");
+		break;
+	}
+	if (shared_action) {
+		__atomic_add_fetch(&shared_action->refcnt, 1,
+				   __ATOMIC_RELAXED);
+		LIST_INSERT_HEAD(&priv->shared_actions, shared_action, next);
+	}
+	return shared_action;
+}
+
+/**
+ * Destroy the shared action.
+ * Release action related resources on the NIC and the memory.
+ * Lock free, (mutex should be acquired by caller).
+ * Dispatcher for action type specific call.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] action
+ *   The shared action object to be removed.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   0 on success, otherwise negative errno value.
+ */
+static int
+__flow_dv_action_destroy(struct rte_eth_dev *dev,
+			 struct rte_flow_shared_action *action,
+			 struct rte_flow_error *error)
+{
+	int ret;
+
+	switch (action->type) {
+	case MLX5_RTE_FLOW_ACTION_TYPE_SHARED_RSS:
+		ret = __flow_dv_action_rss_release(dev, &action->rss, error);
+		break;
+	default:
+		return rte_flow_error_set(error, ENOTSUP,
+					  RTE_FLOW_ERROR_TYPE_ACTION,
+					  NULL,
+					  "action type not supported");
+	}
+	if (ret)
+		return ret;
+	LIST_REMOVE(action, next);
+	rte_free(action);
+	return 0;
+}
+
+/**
+ * Updates in place shared RSS action configuration.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] shared_rss
+ *   The shared RSS action object to be updated.
+ * @param[in] action_conf
+ *   RSS action specification used to modify *shared_rss*.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   0 on success, otherwise negative errno value.
+ * @note: currently only support update of RSS queues.
+ */
+static int
+__flow_dv_action_rss_update(struct rte_eth_dev *dev,
+			    struct mlx5_shared_action_rss *shared_rss,
+			    const struct rte_flow_action_rss *action_conf,
+			    struct rte_flow_error *error)
+{
+	size_t i;
+	int ret;
+	void *queue = NULL;
+	const uint8_t *rss_key;
+	uint32_t rss_key_len;
+	uint32_t queue_size = action_conf->queue_num * sizeof(uint16_t);
+
+	queue = mlx5_malloc(MLX5_MEM_ZERO,
+			    RTE_ALIGN_CEIL(queue_size, sizeof(void *)),
+			    0, SOCKET_ID_ANY);
+	if (!queue)
+		return rte_flow_error_set(error, ENOMEM,
+					  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+					  NULL,
+					  "cannot allocate resource memory");
+	if (action_conf->key) {
+		rss_key = action_conf->key;
+		rss_key_len = action_conf->key_len;
+	} else {
+		rss_key = rss_hash_default_key;
+		rss_key_len = MLX5_RSS_HASH_KEY_LEN;
+	}
+	for (i = 0; i < MLX5_RSS_HASH_FIELDS_LEN; i++) {
+		uint32_t hrxq_idx;
+		uint64_t hash_fields = mlx5_rss_hash_fields[i];
+		int tunnel;
+
+		for (tunnel = 0; tunnel < 2; tunnel++) {
+			hrxq_idx = __flow_dv_action_rss_hrxq_lookup
+					(shared_rss, hash_fields, tunnel);
+			MLX5_ASSERT(hrxq_idx);
+			ret = mlx5_hrxq_modify
+				(dev, hrxq_idx,
+				 rss_key, rss_key_len,
+				 hash_fields,
+				 action_conf->queue, action_conf->queue_num);
+			if (ret) {
+				mlx5_free(queue);
+				return rte_flow_error_set
+					(error, rte_errno,
+					 RTE_FLOW_ERROR_TYPE_ACTION, NULL,
+					 "cannot update hash queue");
+			}
+		}
+	}
+	mlx5_free(shared_rss->queue);
+	shared_rss->queue = queue;
+	memcpy(shared_rss->queue, action_conf->queue, queue_size);
+	shared_rss->origin.queue = shared_rss->queue;
+	shared_rss->origin.queue_num = action_conf->queue_num;
+	return 0;
+}
+
+/**
+ * Updates in place shared action configuration, lock free,
+ * (mutex should be acquired by caller).
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] action
+ *   The shared action object to be updated.
+ * @param[in] action_conf
+ *   Action specification used to modify *action*.
+ *   *action_conf* should be of type correlating with type of the *action*,
+ *   otherwise considered as invalid.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   0 on success, otherwise negative errno value.
+ */
+static int
+__flow_dv_action_update(struct rte_eth_dev *dev,
+			struct rte_flow_shared_action *action,
+			const void *action_conf,
+			struct rte_flow_error *error)
+{
+	switch (action->type) {
+	case MLX5_RTE_FLOW_ACTION_TYPE_SHARED_RSS:
+		return __flow_dv_action_rss_update(dev, &action->rss,
+						   action_conf, error);
+	default:
+		return rte_flow_error_set(error, ENOTSUP,
+					  RTE_FLOW_ERROR_TYPE_ACTION,
+					  NULL,
+					  "action type not supported");
+	}
+}
 /**
  * Query a dv flow  rule for its statistics via devx.
  *
@@ -11453,6 +12005,92 @@ flow_dv_counter_free(struct rte_eth_dev *dev, uint32_t cnt)
 	flow_dv_shared_unlock(dev);
 }
 
+/**
+ * Validate shared action.
+ * Dispatcher for action type specific validation.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] conf
+ *   Shared action configuration.
+ * @param[in] action
+ *   The shared action object to validate.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   0 on success, otherwise negative errno value.
+ */
+static int
+flow_dv_action_validate(struct rte_eth_dev *dev,
+			const struct rte_flow_shared_action_conf *conf,
+			const struct rte_flow_action *action,
+			struct rte_flow_error *error)
+{
+	RTE_SET_USED(conf);
+	switch (action->type) {
+	case RTE_FLOW_ACTION_TYPE_RSS:
+		return mlx5_validate_action_rss(dev, action, error);
+	default:
+		return rte_flow_error_set(error, ENOTSUP,
+					  RTE_FLOW_ERROR_TYPE_ACTION,
+					  NULL,
+					  "action type not supported");
+	}
+}
+
+/*
+ * Mutex-protected thunk to lock-free  __flow_dv_action_create().
+ */
+static struct rte_flow_shared_action *
+flow_dv_action_create(struct rte_eth_dev *dev,
+		      const struct rte_flow_shared_action_conf *conf,
+		      const struct rte_flow_action *action,
+		      struct rte_flow_error *error)
+{
+	struct rte_flow_shared_action *shared_action = NULL;
+
+	flow_dv_shared_lock(dev);
+	shared_action = __flow_dv_action_create(dev, conf, action, error);
+	flow_dv_shared_unlock(dev);
+	return shared_action;
+}
+
+/*
+ * Mutex-protected thunk to lock-free  __flow_dv_action_destroy().
+ */
+static int
+flow_dv_action_destroy(struct rte_eth_dev *dev,
+		       struct rte_flow_shared_action *action,
+		       struct rte_flow_error *error)
+{
+	int ret;
+
+	flow_dv_shared_lock(dev);
+	ret = __flow_dv_action_destroy(dev, action, error);
+	flow_dv_shared_unlock(dev);
+	return ret;
+}
+
+/*
+ * Mutex-protected thunk to lock-free  __flow_dv_action_update().
+ */
+static int
+flow_dv_action_update(struct rte_eth_dev *dev,
+		      struct rte_flow_shared_action *action,
+		      const void *action_conf,
+		      struct rte_flow_error *error)
+{
+	int ret;
+
+	flow_dv_shared_lock(dev);
+	ret = __flow_dv_action_update(dev, action, action_conf,
+				      error);
+	flow_dv_shared_unlock(dev);
+	return ret;
+}
+
 const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops = {
 	.validate = flow_dv_validate,
 	.prepare = flow_dv_prepare,
@@ -11469,6 +12107,10 @@ const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops = {
 	.counter_free = flow_dv_counter_free,
 	.counter_query = flow_dv_counter_query,
 	.get_aged_flows = flow_get_aged_flows,
+	.action_validate = flow_dv_action_validate,
+	.action_create = flow_dv_action_create,
+	.action_destroy = flow_dv_action_destroy,
+	.action_update = flow_dv_action_update,
 };
 
 #endif /* HAVE_IBV_FLOW_DV_SUPPORT */
Signature · 1 line
2.26.2
Acked-by on v2 4/4
#13 lore raw

Re: [dpdk-dev] [PATCH v2 4/4] net/mlx5: driver support for shared action

Quoted 26 lines

-----Original Message-----
From: Andrey Vesnovaty <[email protected]>
Sent: Friday, October 23, 2020 13:24
To: [email protected]
Cc: [email protected]; [email protected]; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]; [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>
Subject: [PATCH v2 4/4] net/mlx5: driver support for shared action

Implement shared action create/destroy/update/query. The current implementation support is limited to shared RSS action only. The shared RSS action create operation prepares hash RX queue objects for all supported permutations of the hash. The shared RSS action update operation relies on functionality to modify hash RX queue introduced in one of the previous commits in this patch series.

Implement RSS shared action and handle shared RSS on flow apply and release. The lookup for hash RX queue object for RSS action is limited to the set of objects stored in the shared action itself and when handling shared RSS action. The lookup for hash RX queue object inside shared action is performed by hash only.

Quoted 4 lines

Current implementation limited to DV flow driver operations i.e. verbs flow driver operations doesn't support shared action.

#14 lore raw

Re: [dpdk-dev] [PATCH v2 4/4] net/mlx5: driver support for shared action

In reply to Andrey Vesnovaty
Quoted 17 lines · Andrey Vesnovaty

Implement shared action create/destroy/update/query. The current implementation support is limited to shared RSS action only. The shared RSS action create operation prepares hash RX queue objects for all supported permutations of the hash. The shared RSS action update operation relies on functionality to modify hash RX queue introduced in one of the previous commits in this patch series.

Implement RSS shared action and handle shared RSS on flow apply and release. The lookup for hash RX queue object for RSS action is limited to the set of objects stored in the shared action itself and when handling shared RSS action. The lookup for hash RX queue object inside shared action is performed by hash only.

Current implementation limited to DV flow driver operations i.e. verbs flow driver operations doesn't support shared action.

<...>

Quoted 7 lines
drivers/net/mlx5/mlx5_flow_dv.c +7 -0
+static uint32_t
+__flow_dv_rss_get_hrxq(struct rte_eth_dev *dev, struct rte_flow *flow,
+			   struct mlx5_flow *dev_flow,
+			   struct mlx5_hrxq **hrxq)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	uint32_t hrxq_idx;

drivers/net/mlx5/mlx5_flow_dv.c __flow_dv_translate(struct rte_eth_dev *dev, · line 10069

Quoted 10 lines
drivers/net/mlx5/mlx5_flow_dv.c +10 -0
+
+	if (flow->shared_rss) {
+		hrxq_idx = __flow_dv_action_rss_hrxq_lookup
+				(flow->shared_rss, dev_flow->hash_fields,
+				 !!(dev_flow->handle->layers &
+				    MLX5_FLOW_LAYER_TUNNEL));
+		if (hrxq_idx) {
+			*hrxq = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_HRXQ],
+					       hrxq_idx);
+			rte_atomic32_inc(&(*hrxq)->refcnt);

I remember adding more 'rte_atomicNN_xxx' to driver has been discussed before, and it has been mentioned that a seperate commit will be done to replace all instances, I would like to remind it, and is that work planned for the -rc2?

#15 lore raw

Re: [dpdk-dev] [PATCH v2 4/4] net/mlx5: driver support for shared action

26/10/2020 17:38, Ferruh Yigit:

Quoted 6 lines · Andrey Vesnovaty

drivers/net/mlx5/mlx5_flow_dv.c __flow_dv_translate(struct rte_eth_dev *dev, · line 10069

Quoted 1 line
drivers/net/mlx5/mlx5_flow_dv.c +1 -0
+			rte_atomic32_inc(&(*hrxq)->refcnt);

I remember adding more 'rte_atomicNN_xxx' to driver has been discussed before, and it has been mentioned that a seperate commit will be done to replace all instances, I would like to remind it, and is that work planned for the -rc2?

Adding Asaf to reply about the timeline.

#16 lore raw

Re: [dpdk-dev] [PATCH v2 4/4] net/mlx5: driver support for shared action

As Slava mentioned we are already working on a patch to align all pmd calls. It should be in the ML soon. We target it for rc2.

Regards,
Asaf Penso

________________________________
From: Thomas Monjalon <[email protected]>
Sent: Monday, October 26, 2020 6:40:13 PM
To: Andrey Vesnovaty <[email protected]>; Ferruh Yigit <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Asaf Penso <[email protected]>
Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Ori Kam <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Shahaf Shuler <[email protected]>
Subject: Re: [PATCH v2 4/4] net/mlx5: driver support for shared action

26/10/2020 17:38, Ferruh Yigit:

Quoted 6 lines · Andrey Vesnovaty
Quoted 1 line

+ rte_atomic32_inc(&(*hrxq)->refcnt);

I remember adding more 'rte_atomicNN_xxx' to driver has been discussed before, and it has been mentioned that a seperate commit will be done to replace all instances, I would like to remind it, and is that work planned for the -rc2?

Adding Asaf to reply about the timeline.

#17 lore raw

Re: [dpdk-dev] [PATCH v2 4/4] net/mlx5: driver support for shared action

In reply to Ferruh Yigit
Quoted 49 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, October 26, 2020 18:38
To: Andrey Vesnovaty <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>
Subject: Re: [PATCH v2 4/4] net/mlx5: driver support for shared action

Quoted 17 lines · Andrey Vesnovaty

Implement shared action create/destroy/update/query. The current implementation support is limited to shared RSS action only. The shared RSS action create operation prepares hash RX queue objects for all supported permutations of the hash. The shared RSS action update operation relies on functionality to modify hash RX queue introduced in one of the previous commits in this patch series.

Implement RSS shared action and handle shared RSS on flow apply and release. The lookup for hash RX queue object for RSS action is limited to the set of objects stored in the shared action itself and when handling shared RSS action. The lookup for hash RX queue object inside shared action is performed by hash only.

Current implementation limited to DV flow driver operations i.e. verbs flow driver operations doesn't support shared action.

<...>

Quoted 15 lines
drivers/net/mlx5/mlx5_flow_dv.c +15 -0
+static uint32_t
+__flow_dv_rss_get_hrxq(struct rte_eth_dev *dev, struct rte_flow *flow,
+			   struct mlx5_flow *dev_flow,
+			   struct mlx5_hrxq **hrxq)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	uint32_t hrxq_idx;
+
+	if (flow->shared_rss) {
+		hrxq_idx = __flow_dv_action_rss_hrxq_lookup
+				(flow->shared_rss, dev_flow->hash_fields,
+				 !!(dev_flow->handle->layers &
+				    MLX5_FLOW_LAYER_TUNNEL));
+		if (hrxq_idx) {
+			*hrxq = mlx5_ipool_get(priv->sh-
Quoted 9 lines

drivers/net/mlx5/mlx5_flow_dv.c __flow_dv_translate(struct rte_eth_dev *dev, · line 10069

Quoted 3 lines

ipool[MLX5_IPOOL_HRXQ],

drivers/net/mlx5/mlx5_flow_dv.c +2 -0
+					       hrxq_idx);
+			rte_atomic32_inc(&(*hrxq)->refcnt);

I remember adding more 'rte_atomicNN_xxx' to driver has been discussed before, and it has been mentioned that a seperate commit will be done to replace all instances, I would like to remind it, and is that work planned for the -rc2?

There is coming common patch to resolve all rte_atomic_xxx issues including mentioned ones. We decided to keep this atomic in order not to trigger massive changes in this "shared action" patch as not relevant to the feature.

With best regards, Slava

#18 lore raw
In reply to Andrey Vesnovaty

Hi,

Quoted 77 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Andrey Vesnovaty
Sent: Friday, October 23, 2020 1:24 PM
To: [email protected]
Cc: [email protected]; [email protected]; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]; [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [dpdk-dev] [PATCH v2 0/4] Shared action RSS PMD impl

This patchset introduces Mellanox PMD implementation for shared RSS action. It was part of the 'RTE flow shared action API' patchset [1]. After v3 the ptchset was split to RTE flow layer [2] and PMD implementation (this patchset).

PMD implementation of this patchset is based on RTE flow API [3].

v2 changes (v1 was a draft):
* lots fo cosmetic changes
* fix spelling/rephrases in comments and commit messages
* fix code styling issues
* code cleanups
* bugfix: prevent non shared action modification

[1] RTE flow shared action API v1
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Finbox
.dpdk.org%2Fdev%2F20200702120511.16315-1- andreyv%40mellanox.com%2F&amp;data=04%7C01%7Crasland%40nvidia.co m%7C7b680d1b14f54e64ea6308d8773ddcb4%7C43083d15727340c1b7db39ef d9ccc17a%7C0%7C0%7C637390454872691372%7CUnknown%7CTWFpbGZsb3 d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0 %3D%7C1000&amp;sdata=vt5%2FEROn9p1F2g%2FklmD%2Fr5TqThYS4ldui6y wdK51cdc%3D&amp;reserved=0
[2] RTE flow shared action API v4
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Finbox
.dpdk.org%2Fdev%2F20201006200835.30017-1- andreyv%40nvidia.com%2F&amp;data=04%7C01%7Crasland%40nvidia.com% 7C7b680d1b14f54e64ea6308d8773ddcb4%7C43083d15727340c1b7db39efd9cc c17a%7C0%7C0%7C637390454872691372%7CUnknown%7CTWFpbGZsb3d8ey JWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D% 7C1000&amp;sdata=1ats9R%2BuNxzEakcT3BhwaWc3xk6Swv33WVm5q11Hc %2FQ%3D&amp;reserved=0
[3] RTE flow shared action API v8
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Finbox
.dpdk.org%2Fdev%2F20201014114015.17197-1- andreyv%40nvidia.com%2F&amp;data=04%7C01%7Crasland%40nvidia.com% 7C7b680d1b14f54e64ea6308d8773ddcb4%7C43083d15727340c1b7db39efd9cc c17a%7C0%7C0%7C637390454872691372%7CUnknown%7CTWFpbGZsb3d8ey JWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D% 7C1000&amp;sdata=HyQu2GHjHbtOJcSueXb9i9wrZ%2Fz5BxUN2pOOQ5TV4e c%3D&amp;reserved=0

Andrey Vesnovaty (4):
common/mlx5: modify advanced Rx object via DevX
net/mlx5: modify hash Rx queue objects
net/mlx5: shared action PMD
net/mlx5: driver support for shared action

 drivers/common/mlx5/mlx5_devx_cmds.c |  84 ++++
 drivers/common/mlx5/mlx5_devx_cmds.h |  10 +
 drivers/common/mlx5/mlx5_prm.h       |  29 ++
 drivers/common/mlx5/version.map      |   1 +
 drivers/net/mlx5/mlx5.c              |   1 +
 drivers/net/mlx5/mlx5.h              |   7 +
 drivers/net/mlx5/mlx5_defs.h         |   3 +
 drivers/net/mlx5/mlx5_devx.c         | 151 ++++--
 drivers/net/mlx5/mlx5_flow.c         | 499 +++++++++++++++++--
 drivers/net/mlx5/mlx5_flow.h         |  86 ++++
 drivers/net/mlx5/mlx5_flow_dv.c      | 705 +++++++++++++++++++++++++-
-
 drivers/net/mlx5/mlx5_flow_verbs.c   |   3 +-
 drivers/net/mlx5/mlx5_rxq.c          | 110 ++++-
 drivers/net/mlx5/mlx5_rxtx.h         |   7 +-
 14 files changed, 1596 insertions(+), 100 deletions(-)
Quoted 2 lines

--
2.26.2

Series applied to next-net-mlx,
With small comment that you are still using rte_atomic operation but since we have a commitment on changing this for all MLX PMD's need to take into consideration this one as well.

Kindest regards,
Raslan Darawsheh