DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v1 0/2] Fix meter flow fail when matching E-Switch Manager
@ 2022-06-19  3:21 Shun Hao
  2022-06-19  3:21 ` [PATCH v1 1/2] net/mlx5: add limitation for E-Switch Manager match Shun Hao
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Shun Hao @ 2022-06-19  3:21 UTC (permalink / raw)
  To: viacheslavo, matan, orika; +Cc: dev, rasland

When using a meter in flow that matches E-Switch Manager, it will fail
due to not handling E-Switch Manager match item correctly. This series
fix this by using correct handling of parsing E-Switch Manager item.

Shun Hao (2):
  net/mlx5: add limitation for E-Switch Manager match
  net/mlx5: fix meter fail when used on E-Switch Manager

 doc/guides/nics/mlx5.rst        |  4 ++
 drivers/net/mlx5/mlx5_flow.c    | 93 ++++++++++++++++++++++++++++-----
 drivers/net/mlx5/mlx5_flow.h    | 10 ++++
 drivers/net/mlx5/mlx5_flow_dv.c | 42 +++------------
 4 files changed, 100 insertions(+), 49 deletions(-)

-- 
2.20.0


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

* [PATCH v1 1/2] net/mlx5: add limitation for E-Switch Manager match
  2022-06-19  3:21 [PATCH v1 0/2] Fix meter flow fail when matching E-Switch Manager Shun Hao
@ 2022-06-19  3:21 ` Shun Hao
  2022-06-19  3:21 ` [PATCH v1 2/2] net/mlx5: fix meter fail when used on E-Switch Manager Shun Hao
  2022-06-20  7:22 ` [PATCH v1 0/2] Fix meter flow fail when matching " Raslan Darawsheh
  2 siblings, 0 replies; 4+ messages in thread
From: Shun Hao @ 2022-06-19  3:21 UTC (permalink / raw)
  To: viacheslavo, matan, orika, Xueming Li; +Cc: dev, rasland, stable

For BF with old FW which doesn't expose the E-Switch Manager vport ID,
E-Switch Manager port matching works correctly only when BF is in
embedded CPU mode.

This patch adds the limitation description.

Fixes: a564038699f9 ("net/mlx5: support E-Switch manager egress traffic match")
Cc: stable@dpdk.org

Signed-off-by: Shun Hao <shunh@nvidia.com>
Acked-by: Matan Azard <matan@nvidia.com>
---
 doc/guides/nics/mlx5.rst        |  4 ++++
 drivers/net/mlx5/mlx5_flow.h    |  4 ++++
 drivers/net/mlx5/mlx5_flow_dv.c | 10 ++++++++--
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index 1b66b2bc33..f10e112d27 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -534,6 +534,10 @@ Limitations
   - When configuring host shaper with MLX5_HOST_SHAPER_FLAG_AVAIL_THRESH_TRIGGERED flag set,
     only rates 0 and 100Mbps are supported.
 
+- E-Switch Manager matching:
+
+  - For Bluefield with old FW which doesn't expose the E-Switch Manager vport ID in the capability, matching E-Switch Manager should be used only in Bluefield embedded CPU mode.
+
 Statistics
 ----------
 
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index f00c033fc5..7300390070 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -2076,4 +2076,8 @@ int flow_dv_action_query(struct rte_eth_dev *dev,
 size_t flow_dv_get_item_hdr_len(const enum rte_flow_item_type item_type);
 int flow_dv_convert_encap_data(const struct rte_flow_item *items, uint8_t *buf,
 			   size_t *size, struct rte_flow_error *error);
+
+#define MLX5_PF_VPORT_ID 0
+#define MLX5_ECPF_VPORT_ID 0xFFFE
+
 #endif /* RTE_PMD_MLX5_FLOW_H_ */
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 65b02b20ce..09f662bdcf 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -99,6 +99,7 @@ flow_dv_get_esw_manager_vport_id(struct rte_eth_dev *dev)
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_common_device *cdev = priv->sh->cdev;
 
+	/* New FW exposes E-Switch Manager vport ID, can use it directly. */
 	if (cdev->config.hca_attr.esw_mgr_vport_id_valid)
 		return (int16_t)cdev->config.hca_attr.esw_mgr_vport_id;
 
@@ -108,9 +109,14 @@ flow_dv_get_esw_manager_vport_id(struct rte_eth_dev *dev)
 	case PCI_DEVICE_ID_MELLANOX_CONNECTX5BF:
 	case PCI_DEVICE_ID_MELLANOX_CONNECTX6DXBF:
 	case PCI_DEVICE_ID_MELLANOX_CONNECTX7BF:
-		return (int16_t)0xfffe;
+	/*
+	 * In old FW which doesn't expose the E-Switch Manager vport ID in the capability,
+	 * only the BF embedded CPUs control the E-Switch Manager port. Hence,
+	 * ECPF vport ID is selected and not the host port (0) in any BF case.
+	 */
+		return (int16_t)MLX5_ECPF_VPORT_ID;
 	default:
-		return 0;
+		return MLX5_PF_VPORT_ID;
 	}
 }
 
-- 
2.20.0


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

* [PATCH v1 2/2] net/mlx5: fix meter fail when used on E-Switch Manager
  2022-06-19  3:21 [PATCH v1 0/2] Fix meter flow fail when matching E-Switch Manager Shun Hao
  2022-06-19  3:21 ` [PATCH v1 1/2] net/mlx5: add limitation for E-Switch Manager match Shun Hao
@ 2022-06-19  3:21 ` Shun Hao
  2022-06-20  7:22 ` [PATCH v1 0/2] Fix meter flow fail when matching " Raslan Darawsheh
  2 siblings, 0 replies; 4+ messages in thread
From: Shun Hao @ 2022-06-19  3:21 UTC (permalink / raw)
  To: viacheslavo, matan, orika; +Cc: dev, rasland, stable

When meter is used by E-Switch Manager port, there's an error that
cannot get correct port ID.

This patch fixes this by using specific parsing process to get port
ID for E-Switch Manager.

Fixes: 3c481324baf3 ("net/mlx5: fix meter flow direction check")
Cc: stable@dpdk.org

Signed-off-by: Shun Hao <shunh@nvidia.com>
Acked-by: Matan Azard <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow.c    | 93 ++++++++++++++++++++++++++++-----
 drivers/net/mlx5/mlx5_flow.h    |  6 +++
 drivers/net/mlx5/mlx5_flow_dv.c | 48 +++--------------
 3 files changed, 92 insertions(+), 55 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 090de0366b..cfcd884b82 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -5297,7 +5297,7 @@ flow_meter_split_prep(struct rte_eth_dev *dev,
 	const struct rte_flow_item *orig_items = items;
 	struct rte_flow_action *hw_mtr_action;
 	struct rte_flow_action *action_pre_head = NULL;
-	int32_t flow_src_port = priv->representor_id;
+	uint16_t flow_src_port = priv->representor_id;
 	bool mtr_first;
 	uint8_t mtr_id_offset = priv->mtr_reg_share ? MLX5_MTR_COLOR_BITS : 0;
 	uint8_t mtr_reg_bits = priv->mtr_reg_share ?
@@ -5311,22 +5311,12 @@ flow_meter_split_prep(struct rte_eth_dev *dev,
 	/* Prepare the suffix subflow items. */
 	tag_item = sfx_items++;
 	for (; items->type != RTE_FLOW_ITEM_TYPE_END; items++) {
-		struct mlx5_priv *port_priv;
-		const struct rte_flow_item_port_id *pid_v;
 		int item_type = items->type;
 
 		switch (item_type) {
 		case RTE_FLOW_ITEM_TYPE_PORT_ID:
-			pid_v = items->spec;
-			MLX5_ASSERT(pid_v);
-			port_priv = mlx5_port_to_eswitch_info(pid_v->id, false);
-			if (!port_priv)
-				return rte_flow_error_set(error,
-						rte_errno,
-						RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
-						pid_v,
-						"Failed to get port info.");
-			flow_src_port = port_priv->representor_id;
+			if (mlx5_flow_get_item_vport_id(dev, items, &flow_src_port, error))
+				return -rte_errno;
 			if (!fm->def_policy && wks->policy->is_hierarchy &&
 			    flow_src_port != priv->representor_id) {
 				if (flow_drv_mtr_hierarchy_rule_create(dev,
@@ -10955,3 +10945,80 @@ mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 	}
 	return  res;
 }
+
+/**
+ * Get the E-Switch Manager vport id.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ *
+ * @return
+ *   The vport id.
+ */
+int16_t mlx5_flow_get_esw_manager_vport_id(struct rte_eth_dev *dev)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_common_device *cdev = priv->sh->cdev;
+
+	/* New FW exposes E-Switch Manager vport ID, can use it directly. */
+	if (cdev->config.hca_attr.esw_mgr_vport_id_valid)
+		return (int16_t)cdev->config.hca_attr.esw_mgr_vport_id;
+
+	if (priv->pci_dev == NULL)
+		return 0;
+	switch (priv->pci_dev->id.device_id) {
+	case PCI_DEVICE_ID_MELLANOX_CONNECTX5BF:
+	case PCI_DEVICE_ID_MELLANOX_CONNECTX6DXBF:
+	case PCI_DEVICE_ID_MELLANOX_CONNECTX7BF:
+	/*
+	 * In old FW which doesn't expose the E-Switch Manager vport ID in the capability,
+	 * only the BF embedded CPUs control the E-Switch Manager port. Hence,
+	 * ECPF vport ID is selected and not the host port (0) in any BF case.
+	 */
+		return (int16_t)MLX5_ECPF_VPORT_ID;
+	default:
+		return MLX5_PF_VPORT_ID;
+	}
+}
+
+/**
+ * Parse item to get the vport id.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] item
+ *   The src port id match item.
+ * @param[out] vport_id
+ *   Pointer to put the vport id.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int mlx5_flow_get_item_vport_id(struct rte_eth_dev *dev,
+				const struct rte_flow_item *item,
+				uint16_t *vport_id,
+				struct rte_flow_error *error)
+{
+	struct mlx5_priv *port_priv;
+	const struct rte_flow_item_port_id *pid_v;
+
+	if (item->type != RTE_FLOW_ITEM_TYPE_PORT_ID)
+		return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
+					  NULL, "Incorrect item type.");
+	pid_v = item->spec;
+	if (!pid_v)
+		return 0;
+	if (pid_v->id == MLX5_PORT_ESW_MGR) {
+		*vport_id = mlx5_flow_get_esw_manager_vport_id(dev);
+	} else {
+		port_priv = mlx5_port_to_eswitch_info(pid_v->id, false);
+		if (!port_priv)
+			return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
+						  NULL, "Failed to get port info.");
+		*vport_id = port_priv->representor_id;
+	}
+
+	return 0;
+}
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 7300390070..4c233cd94a 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -2080,4 +2080,10 @@ int flow_dv_convert_encap_data(const struct rte_flow_item *items, uint8_t *buf,
 #define MLX5_PF_VPORT_ID 0
 #define MLX5_ECPF_VPORT_ID 0xFFFE
 
+int16_t mlx5_flow_get_esw_manager_vport_id(struct rte_eth_dev *dev);
+int mlx5_flow_get_item_vport_id(struct rte_eth_dev *dev,
+				const struct rte_flow_item *item,
+				uint16_t *vport_id,
+				struct rte_flow_error *error);
+
 #endif /* RTE_PMD_MLX5_FLOW_H_ */
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 09f662bdcf..09349a021b 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -93,33 +93,6 @@ static int
 flow_dv_jump_tbl_resource_release(struct rte_eth_dev *dev,
 				  uint32_t rix_jump);
 
-static int16_t
-flow_dv_get_esw_manager_vport_id(struct rte_eth_dev *dev)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-	struct mlx5_common_device *cdev = priv->sh->cdev;
-
-	/* New FW exposes E-Switch Manager vport ID, can use it directly. */
-	if (cdev->config.hca_attr.esw_mgr_vport_id_valid)
-		return (int16_t)cdev->config.hca_attr.esw_mgr_vport_id;
-
-	if (priv->pci_dev == NULL)
-		return 0;
-	switch (priv->pci_dev->id.device_id) {
-	case PCI_DEVICE_ID_MELLANOX_CONNECTX5BF:
-	case PCI_DEVICE_ID_MELLANOX_CONNECTX6DXBF:
-	case PCI_DEVICE_ID_MELLANOX_CONNECTX7BF:
-	/*
-	 * In old FW which doesn't expose the E-Switch Manager vport ID in the capability,
-	 * only the BF embedded CPUs control the E-Switch Manager port. Hence,
-	 * ECPF vport ID is selected and not the host port (0) in any BF case.
-	 */
-		return (int16_t)MLX5_ECPF_VPORT_ID;
-	default:
-		return MLX5_PF_VPORT_ID;
-	}
-}
-
 /**
  * Initialize flow attributes structure according to flow items' types.
  *
@@ -5334,21 +5307,12 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev,
 			 */
 			struct mlx5_priv *policy_port_priv =
 					mtr_policy->dev->data->dev_private;
-			int32_t flow_src_port = priv->representor_id;
+			uint16_t flow_src_port = priv->representor_id;
 
 			if (port_id_item) {
-				const struct rte_flow_item_port_id *spec =
-							port_id_item->spec;
-				struct mlx5_priv *port_priv =
-					mlx5_port_to_eswitch_info(spec->id,
-								  false);
-				if (!port_priv)
-					return rte_flow_error_set(error,
-						rte_errno,
-						RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
-						spec,
-						"Failed to get port info.");
-				flow_src_port = port_priv->representor_id;
+				if (mlx5_flow_get_item_vport_id(dev, port_id_item,
+								&flow_src_port, error))
+					return -rte_errno;
 			}
 			if (flow_src_port != policy_port_priv->representor_id)
 				return rte_flow_error_set(error,
@@ -10047,7 +10011,7 @@ flow_dv_translate_item_port_id(struct rte_eth_dev *dev, void *matcher,
 
 	if (pid_v && pid_v->id == MLX5_PORT_ESW_MGR) {
 		flow_dv_translate_item_source_vport(matcher, key,
-			flow_dv_get_esw_manager_vport_id(dev), 0xffff);
+			mlx5_flow_get_esw_manager_vport_id(dev), 0xffff);
 		return 0;
 	}
 	mask = pid_m ? pid_m->id : 0xffff;
@@ -10118,7 +10082,7 @@ flow_dv_translate_item_represented_port(struct rte_eth_dev *dev, void *matcher,
 		return 0;
 	if (pid_v && pid_v->port_id == UINT16_MAX) {
 		flow_dv_translate_item_source_vport(matcher, key,
-			flow_dv_get_esw_manager_vport_id(dev), UINT16_MAX);
+			mlx5_flow_get_esw_manager_vport_id(dev), UINT16_MAX);
 		return 0;
 	}
 	mask = pid_m ? pid_m->port_id : UINT16_MAX;
-- 
2.20.0


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

* RE: [PATCH v1 0/2] Fix meter flow fail when matching E-Switch Manager
  2022-06-19  3:21 [PATCH v1 0/2] Fix meter flow fail when matching E-Switch Manager Shun Hao
  2022-06-19  3:21 ` [PATCH v1 1/2] net/mlx5: add limitation for E-Switch Manager match Shun Hao
  2022-06-19  3:21 ` [PATCH v1 2/2] net/mlx5: fix meter fail when used on E-Switch Manager Shun Hao
@ 2022-06-20  7:22 ` Raslan Darawsheh
  2 siblings, 0 replies; 4+ messages in thread
From: Raslan Darawsheh @ 2022-06-20  7:22 UTC (permalink / raw)
  To: Shun Hao, Slava Ovsiienko, Matan Azrad, Ori Kam; +Cc: dev

Hi,

> -----Original Message-----
> From: Shun Hao <shunh@nvidia.com>
> Sent: Sunday, June 19, 2022 6:21 AM
> To: Slava Ovsiienko <viacheslavo@nvidia.com>; Matan Azrad
> <matan@nvidia.com>; Ori Kam <orika@nvidia.com>
> Cc: dev@dpdk.org; Raslan Darawsheh <rasland@nvidia.com>
> Subject: [PATCH v1 0/2] Fix meter flow fail when matching E-Switch Manager
> 
> When using a meter in flow that matches E-Switch Manager, it will fail due to
> not handling E-Switch Manager match item correctly. This series fix this by
> using correct handling of parsing E-Switch Manager item.
> 
> Shun Hao (2):
>   net/mlx5: add limitation for E-Switch Manager match
>   net/mlx5: fix meter fail when used on E-Switch Manager
> 
>  doc/guides/nics/mlx5.rst        |  4 ++
>  drivers/net/mlx5/mlx5_flow.c    | 93 ++++++++++++++++++++++++++++----
> -
>  drivers/net/mlx5/mlx5_flow.h    | 10 ++++
>  drivers/net/mlx5/mlx5_flow_dv.c | 42 +++------------
>  4 files changed, 100 insertions(+), 49 deletions(-)
> 
> --
> 2.20.0

Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

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

end of thread, other threads:[~2022-06-20  7:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-19  3:21 [PATCH v1 0/2] Fix meter flow fail when matching E-Switch Manager Shun Hao
2022-06-19  3:21 ` [PATCH v1 1/2] net/mlx5: add limitation for E-Switch Manager match Shun Hao
2022-06-19  3:21 ` [PATCH v1 2/2] net/mlx5: fix meter fail when used on E-Switch Manager Shun Hao
2022-06-20  7:22 ` [PATCH v1 0/2] Fix meter flow fail when matching " Raslan Darawsheh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).