[2/3] net/mlx5: add port representor destination to mirror

Message ID 20231017004401.698745-3-suanmingm@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: add port representor destination to mirror |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Suanming Mou Oct. 17, 2023, 12:44 a.m. UTC
  In order to clone the traffic from FDB to NIC TIR, user can set
port representor action as mirror clone destination. In that case
cloned traffic will be moved to E-Switch manager root table, and
goes to software TIR.

This commit adds the port representor support to mirror action.

Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 9feb40ddb3..46af492ac5 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -9735,6 +9735,7 @@  mlx5_mirror_destroy_clone(struct rte_eth_dev *dev,
 		flow_hw_jump_release(dev, clone->action_ctx);
 		break;
 	case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:
+	case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR:
 	case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
 	case RTE_FLOW_ACTION_TYPE_RAW_DECAP:
 	case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
@@ -9779,6 +9780,7 @@  mlx5_mirror_terminal_action(const struct rte_flow_action *action)
 	case RTE_FLOW_ACTION_TYPE_RSS:
 	case RTE_FLOW_ACTION_TYPE_QUEUE:
 	case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:
+	case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR:
 		return true;
 	default:
 		break;
@@ -9792,19 +9794,30 @@  mlx5_mirror_validate_sample_action(struct rte_eth_dev *dev,
 				   const struct rte_flow_action *action)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
+	const struct rte_flow_action_ethdev *port = NULL;
+	bool is_proxy = MLX5_HW_PORT_IS_PROXY(priv);
 
+	if (!action)
+		return false;
 	switch(action->type) {
 	case RTE_FLOW_ACTION_TYPE_QUEUE:
 	case RTE_FLOW_ACTION_TYPE_RSS:
 		if (flow_attr->transfer)
 			return false;
 		break;
+	case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR:
+		if (!is_proxy || !flow_attr->transfer)
+			return false;
+		port = action->conf;
+		if (!port || port->port_id != MLX5_REPRESENTED_PORT_ESW_MGR)
+			return false;
+		break;
 	case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:
 	case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
 	case RTE_FLOW_ACTION_TYPE_RAW_DECAP:
 	case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
 	case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
-		if (!priv->sh->esw_mode && !flow_attr->transfer)
+		if (!is_proxy || !flow_attr->transfer)
 			return false;
 		if (action[0].type == RTE_FLOW_ACTION_TYPE_RAW_DECAP &&
 		    action[1].type != RTE_FLOW_ACTION_TYPE_RAW_ENCAP)
@@ -9962,6 +9975,7 @@  hw_mirror_format_clone(struct rte_eth_dev *dev,
                        struct mlx5dr_action_dest_attr *dest_attr,
 		       uint8_t *reformat_buf, struct rte_flow_error *error)
 {
+	struct mlx5_priv *priv = dev->data->dev_private;
 	int ret;
 	uint32_t i;
 	bool decap_seen = false;
@@ -9988,6 +10002,9 @@  hw_mirror_format_clone(struct rte_eth_dev *dev,
 			if (ret)
 				return ret;
 			break;
+		case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR:
+			dest_attr->dest = priv->hw_def_miss;
+			break;
 		case RTE_FLOW_ACTION_TYPE_RAW_DECAP:
 			decap_seen = true;
 			break;