Skip to contentSkip to conversation

net/mlx5: fix flow rules for external SQ

PATCH In review Suanming Mou 2 participants 4 messages Nov 9, 2023 – Nov 12, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

cover net/mlx5: fix flow rules for external SQ

If representor matching was enabled (device argument repr_matching_en is equal to 1, default configuration), then during registration of external SQs, mlx5 PMD would not create control flow rules in NIC Tx domain. This caused an issue with packet metadata. If a packet sent on external SQ had packet metadata attached, then it would be lost when it would go from NIC Tx to FDB domain.

Meanwhile, the external SQ flow rules should be managed individually and not be destroyed internally by PMD.

This series fixes these two issues for the external SQ flow rules in rte_pmd_mlx5_external_sq_enable().

Dariusz Sosnowski (1):
net/mlx5: fix missing flow rules for external SQ

Suanming Mou (1):
net/mlx5: fix destroying external representor matched flows

 drivers/net/mlx5/mlx5.h         |  41 ++++++++++
 drivers/net/mlx5/mlx5_flow.h    |   6 +-
 drivers/net/mlx5/mlx5_flow_hw.c | 132 ++++++++++++++++++++++++++++----
 drivers/net/mlx5/mlx5_trigger.c |   4 +-
 drivers/net/mlx5/mlx5_txq.c     |  12 ++-
 5 files changed, 176 insertions(+), 19 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 net/mlx5: fix missing flow rules for external SQ

From: Dariusz Sosnowski <[email protected]>

mlx5 PMD exposes a capability to register externally created SQs as if it was an SQ of a given representor port. Registration would cause a creation of control flow rules in FDB domain used to forward traffic betwen SQ and destination represented port.

Before this patch, if representor matching was enabled (device argument repr_matching_en is equal to 1, default configuration), then during registration of external SQs, mlx5 PMD would not create control flow rules in NIC Tx domain. This caused an issue with packet metadata. If a packet sent on external SQ had packet metadata attached, then it would be lost when it would go from NIC Tx to FDB domain.

With representor matching disabled everything is working correctly, because in that mode there is a single global flow rule for preserving packet metadata. This flow rule matches whole traffic on NIC Tx domain. With representor matching enabled, NIC Tx flow rules are created per SQ.

This patch fixes that behavior. If representor matching is enabled, then NIC Tx flow rules are created for each external SQ registered in rte_pmd_mlx5_external_sq_enable().

This patch also adds an ability to destroy SQ miss flow rules for a given port and SQ number. This is required for error rollback flow in rte_pmd_mlx5_external_sq_enable().

Fixes 26e1eaf2dac4 ("net/mlx5: support device control for E-Switch default rule")
---
 drivers/net/mlx5/mlx5.h         |  40 ++++++++++++
 drivers/net/mlx5/mlx5_flow.h    |   2 +
 drivers/net/mlx5/mlx5_flow_hw.c | 107 +++++++++++++++++++++++++++++---
 drivers/net/mlx5/mlx5_txq.c     |  12 +++-
 4 files changed, 149 insertions(+), 12 deletions(-)
drivers/net/mlx5/mlx5.h +40 -0
index f5eacb2c67..45ad0701f1 100644
@@ -1705,10 +1705,50 @@ struct mlx5_obj_ops {
 
 #define MLX5_RSS_HASH_FIELDS_LEN RTE_DIM(mlx5_rss_hash_fields)
 
+enum mlx5_hw_ctrl_flow_type {
+	MLX5_HW_CTRL_FLOW_TYPE_GENERAL,
+	MLX5_HW_CTRL_FLOW_TYPE_SQ_MISS_ROOT,
+	MLX5_HW_CTRL_FLOW_TYPE_SQ_MISS,
+	MLX5_HW_CTRL_FLOW_TYPE_DEFAULT_JUMP,
+	MLX5_HW_CTRL_FLOW_TYPE_TX_META_COPY,
+	MLX5_HW_CTRL_FLOW_TYPE_TX_REPR_MATCH,
+	MLX5_HW_CTRL_FLOW_TYPE_LACP_RX,
+	MLX5_HW_CTRL_FLOW_TYPE_DEFAULT_RX_RSS,
+};
+
+/** Additional info about control flow rule. */
+struct mlx5_hw_ctrl_flow_info {
+	/** Determines the kind of control flow rule. */
+	enum mlx5_hw_ctrl_flow_type type;
+	union {
+		/**
+		 * If control flow is a SQ miss flow (root or not),
+		 * then fields contains matching SQ number.
+		 */
+		uint32_t esw_mgr_sq;
+		/**
+		 * If control flow is a Tx representor matching,
+		 * then fields contains matching SQ number.
+		 */
+		uint32_t tx_repr_sq;
+	};
+};
+
+/** Entry for tracking control flow rules in HWS. */
 struct mlx5_hw_ctrl_flow {
 	LIST_ENTRY(mlx5_hw_ctrl_flow) next;
+	/**
+	 * Owner device is a port on behalf of which flow rule was created.
+	 *
+	 * It's different from the port which really created the flow rule
+	 * if and only if flow rule is created on transfer proxy port
+	 * on behalf of representor port.
+	 */
 	struct rte_eth_dev *owner_dev;
+	/** Pointer to flow rule handle. */
 	struct rte_flow *flow;
+	/** Additional information about the control flow rule. */
+	struct mlx5_hw_ctrl_flow_info info;
 };
 
 /*
drivers/net/mlx5/mlx5_flow.h +2 -0
index 094be12715..d57b3b5465 100644
@@ -2875,6 +2875,8 @@ int mlx5_flow_hw_flush_ctrl_flows(struct rte_eth_dev *dev);
 
 int mlx5_flow_hw_esw_create_sq_miss_flow(struct rte_eth_dev *dev,
 					 uint32_t sqn);
+int mlx5_flow_hw_esw_destroy_sq_miss_flow(struct rte_eth_dev *dev,
+					  uint32_t sqn);
 int mlx5_flow_hw_esw_create_default_jump_flow(struct rte_eth_dev *dev);
 int mlx5_flow_hw_create_tx_default_mreg_copy_flow(struct rte_eth_dev *dev);
 int mlx5_flow_hw_tx_repr_matching_flow(struct rte_eth_dev *dev, uint32_t sqn);
drivers/net/mlx5/mlx5_flow_hw.c +97 -10

234 lines not on this page · raw message

drivers/net/mlx5/mlx5_txq.c +10 -2
index b584055fa8..ccdf2ffb14 100644
@@ -1310,8 +1310,16 @@ rte_pmd_mlx5_external_sq_enable(uint16_t port_id, uint32_t sq_num)
 		return -rte_errno;
 	}
 #ifdef HAVE_MLX5_HWS_SUPPORT
-	if (priv->sh->config.dv_flow_en == 2)
-		return mlx5_flow_hw_esw_create_sq_miss_flow(dev, sq_num);
+	if (priv->sh->config.dv_flow_en == 2) {
+		if (mlx5_flow_hw_esw_create_sq_miss_flow(dev, sq_num))
+			return -rte_errno;
+		if (priv->sh->config.repr_matching &&
+		    mlx5_flow_hw_tx_repr_matching_flow(dev, sq_num)) {
+			mlx5_flow_hw_esw_destroy_sq_miss_flow(dev, sq_num);
+			return -rte_errno;
+		}
+		return 0;
+	}
 #endif
 	flow = mlx5_flow_create_devx_sq_miss_flow(dev, sq_num);
 	if (flow > 0)
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/2 net/mlx5: fix destroying external representor matched flows

In reply to Suanming Mou

The external representor matched SQ flows are managed by external SQ, PMD traffic enable/disable should not touch these flows.

This commit adds an extra external list for the external representor matched SQ flows.

Fixes 26e1eaf2dac4 ("net/mlx5: support device control for E-Switch default rule")
---
 drivers/net/mlx5/mlx5.h         |  1 +
 drivers/net/mlx5/mlx5_flow.h    |  4 +--
 drivers/net/mlx5/mlx5_flow_hw.c | 45 +++++++++++++++++++++++----------
 drivers/net/mlx5/mlx5_trigger.c |  4 +--
 drivers/net/mlx5/mlx5_txq.c     |  4 +--
 5 files changed, 39 insertions(+), 19 deletions(-)
drivers/net/mlx5/mlx5.h +1 -0
index 45ad0701f1..795748eddc 100644
@@ -1855,6 +1855,7 @@ struct mlx5_priv {
 	void *root_drop_action; /* Pointer to root drop action. */
 	rte_spinlock_t hw_ctrl_lock;
 	LIST_HEAD(hw_ctrl_flow, mlx5_hw_ctrl_flow) hw_ctrl_flows;
+	LIST_HEAD(hw_ext_ctrl_flow, mlx5_hw_ctrl_flow) hw_ext_ctrl_flows;
 	struct rte_flow_template_table *hw_esw_sq_miss_root_tbl;
 	struct rte_flow_template_table *hw_esw_sq_miss_tbl;
 	struct rte_flow_template_table *hw_esw_zero_tbl;
drivers/net/mlx5/mlx5_flow.h +2 -2
index d57b3b5465..8c0b9a4b60 100644
@@ -2874,12 +2874,12 @@ int flow_null_counter_query(struct rte_eth_dev *dev,
 int mlx5_flow_hw_flush_ctrl_flows(struct rte_eth_dev *dev);
 
 int mlx5_flow_hw_esw_create_sq_miss_flow(struct rte_eth_dev *dev,
-					 uint32_t sqn);
+					 uint32_t sqn, bool external);
 int mlx5_flow_hw_esw_destroy_sq_miss_flow(struct rte_eth_dev *dev,
 					  uint32_t sqn);
 int mlx5_flow_hw_esw_create_default_jump_flow(struct rte_eth_dev *dev);
 int mlx5_flow_hw_create_tx_default_mreg_copy_flow(struct rte_eth_dev *dev);
-int mlx5_flow_hw_tx_repr_matching_flow(struct rte_eth_dev *dev, uint32_t sqn);
+int mlx5_flow_hw_tx_repr_matching_flow(struct rte_eth_dev *dev, uint32_t sqn, bool external);
 int mlx5_flow_actions_validate(struct rte_eth_dev *dev,
 		const struct rte_flow_actions_template_attr *attr,
 		const struct rte_flow_action actions[],
drivers/net/mlx5/mlx5_flow_hw.c +32 -13

136 lines not on this page · raw message

drivers/net/mlx5/mlx5_trigger.c +2 -2
index 7bdb897612..d7ecb149fa 100644
@@ -1494,13 +1494,13 @@ mlx5_traffic_enable_hws(struct rte_eth_dev *dev)
 			continue;
 		queue = mlx5_txq_get_sqn(txq);
 		if ((priv->representor || priv->master) && config->dv_esw_en) {
-			if (mlx5_flow_hw_esw_create_sq_miss_flow(dev, queue)) {
+			if (mlx5_flow_hw_esw_create_sq_miss_flow(dev, queue, false)) {
 				mlx5_txq_release(dev, i);
 				goto error;
 			}
 		}
 		if (config->dv_esw_en && config->repr_matching) {
-			if (mlx5_flow_hw_tx_repr_matching_flow(dev, queue)) {
+			if (mlx5_flow_hw_tx_repr_matching_flow(dev, queue, false)) {
 				mlx5_txq_release(dev, i);
 				goto error;
 			}
drivers/net/mlx5/mlx5_txq.c +2 -2
index ccdf2ffb14..1ac43548b2 100644
@@ -1311,10 +1311,10 @@ rte_pmd_mlx5_external_sq_enable(uint16_t port_id, uint32_t sq_num)
 	}
 #ifdef HAVE_MLX5_HWS_SUPPORT
 	if (priv->sh->config.dv_flow_en == 2) {
-		if (mlx5_flow_hw_esw_create_sq_miss_flow(dev, sq_num))
+		if (mlx5_flow_hw_esw_create_sq_miss_flow(dev, sq_num, true))
 			return -rte_errno;
 		if (priv->sh->config.repr_matching &&
-		    mlx5_flow_hw_tx_repr_matching_flow(dev, sq_num)) {
+		    mlx5_flow_hw_tx_repr_matching_flow(dev, sq_num, true)) {
 			mlx5_flow_hw_esw_destroy_sq_miss_flow(dev, sq_num);
 			return -rte_errno;
 		}
Signature · 1 line
2.34.1
#3 lore raw
In reply to Suanming Mou

Hi,

Quoted 33 lines

-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Thursday, November 9, 2023 10:56 AM
Cc: [email protected]; Raslan Darawsheh <[email protected]>
Subject: [PATCH 0/2] net/mlx5: fix flow rules for external SQ

If representor matching was enabled (device argument repr_matching_en is equal to 1, default configuration), then during registration of external SQs, mlx5 PMD would not create control flow rules in NIC Tx domain. This caused an issue with packet metadata. If a packet sent on external SQ had packet metadata attached, then it would be lost when it would go from NIC Tx to FDB domain.

Meanwhile, the external SQ flow rules should be managed individually and not be destroyed internally by PMD.

This series fixes these two issues for the external SQ flow rules in rte_pmd_mlx5_external_sq_enable().

Dariusz Sosnowski (1):
net/mlx5: fix missing flow rules for external SQ

Suanming Mou (1):
net/mlx5: fix destroying external representor matched flows

 drivers/net/mlx5/mlx5.h         |  41 ++++++++++
 drivers/net/mlx5/mlx5_flow.h    |   6 +-
 drivers/net/mlx5/mlx5_flow_hw.c | 132
++++++++++++++++++++++++++++----
 drivers/net/mlx5/mlx5_trigger.c |   4 +-
 drivers/net/mlx5/mlx5_txq.c     |  12 ++-
 5 files changed, 176 insertions(+), 19 deletions(-)
Quoted 2 lines

--
2.34.1

Fixed a typo in the first commit, and fixed a warning for a line too long Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh