patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: Shun Hao <shunh@nvidia.com>
Cc: Matan Azrad <matan@nvidia.com>, dpdk stable <stable@dpdk.org>
Subject: patch 'net/mlx5: fix metering on E-Switch Manager' has been queued to stable release 21.11.2
Date: Fri, 24 Jun 2022 17:10:14 +0100	[thread overview]
Message-ID: <20220624161016.1881349-12-ktraynor@redhat.com> (raw)
In-Reply-To: <20220624161016.1881349-1-ktraynor@redhat.com>

Hi,

FYI, your patch has been queued to stable release 21.11.2

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 06/27/22. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/f8b370bbb4bfb1b25ed19713113d8ff0d9905741

Thanks.

Kevin

---
From f8b370bbb4bfb1b25ed19713113d8ff0d9905741 Mon Sep 17 00:00:00 2001
From: Shun Hao <shunh@nvidia.com>
Date: Sun, 19 Jun 2022 06:21:28 +0300
Subject: [PATCH] net/mlx5: fix metering on E-Switch Manager

[ upstream commit 92b3c68e9f103d1e2449f8572854bb16bd736637 ]

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")

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

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 94fb2d8c95..42de516bfd 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -5058,5 +5058,5 @@ flow_meter_split_prep(struct rte_eth_dev *dev,
 	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;
@@ -5072,20 +5072,10 @@ flow_meter_split_prep(struct rte_eth_dev *dev,
 	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) {
@@ -10165,2 +10155,79 @@ 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 3e34b1c08a..29ccb98351 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -1771,3 +1771,9 @@ mlx5_get_tof(const struct rte_flow_item *items,
 #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 1ceb6a0cd7..dfa0dc0aad 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -94,31 +94,4 @@ 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.
@@ -5245,19 +5218,10 @@ 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)
@@ -9785,5 +9749,5 @@ 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;
 	}
-- 
2.34.3

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-06-24 16:54:05.908056719 +0100
+++ 0012-net-mlx5-fix-metering-on-E-Switch-Manager.patch	2022-06-24 16:54:05.594165193 +0100
@@ -1 +1 @@
-From 92b3c68e9f103d1e2449f8572854bb16bd736637 Mon Sep 17 00:00:00 2001
+From f8b370bbb4bfb1b25ed19713113d8ff0d9905741 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 92b3c68e9f103d1e2449f8572854bb16bd736637 ]
+
@@ -13 +14,0 @@
-Cc: stable@dpdk.org
@@ -20,2 +21,2 @@
- drivers/net/mlx5/mlx5_flow_dv.c | 48 +++--------------
- 3 files changed, 92 insertions(+), 55 deletions(-)
+ drivers/net/mlx5/mlx5_flow_dv.c | 46 ++--------------
+ 3 files changed, 91 insertions(+), 54 deletions(-)
@@ -24 +25 @@
-index 900ec8e4bc..8c93a3f2e5 100644
+index 94fb2d8c95..42de516bfd 100644
@@ -27 +28 @@
-@@ -5320,5 +5320,5 @@ flow_meter_split_prep(struct rte_eth_dev *dev,
+@@ -5058,5 +5058,5 @@ flow_meter_split_prep(struct rte_eth_dev *dev,
@@ -34 +35 @@
-@@ -5334,20 +5334,10 @@ flow_meter_split_prep(struct rte_eth_dev *dev,
+@@ -5072,20 +5072,10 @@ flow_meter_split_prep(struct rte_eth_dev *dev,
@@ -57 +58 @@
-@@ -10978,2 +10968,79 @@ mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
+@@ -10165,2 +10155,79 @@ mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
@@ -138 +139 @@
-index 7300390070..4c233cd94a 100644
+index 3e34b1c08a..29ccb98351 100644
@@ -141 +142 @@
-@@ -2081,3 +2081,9 @@ int flow_dv_convert_encap_data(const struct rte_flow_item *items, uint8_t *buf,
+@@ -1771,3 +1771,9 @@ mlx5_get_tof(const struct rte_flow_item *items,
@@ -152 +153 @@
-index 09f662bdcf..09349a021b 100644
+index 1ceb6a0cd7..dfa0dc0aad 100644
@@ -187 +188 @@
-@@ -5335,19 +5308,10 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev,
+@@ -5245,19 +5218,10 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev,
@@ -211 +212 @@
-@@ -10048,5 +10012,5 @@ flow_dv_translate_item_port_id(struct rte_eth_dev *dev, void *matcher,
+@@ -9785,5 +9749,5 @@ flow_dv_translate_item_port_id(struct rte_eth_dev *dev, void *matcher,
@@ -216,7 +216,0 @@
- 		return 0;
- 	}
-@@ -10119,5 +10083,5 @@ flow_dv_translate_item_represented_port(struct rte_eth_dev *dev, void *matcher,
- 	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);


  parent reply	other threads:[~2022-06-24 16:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-24 16:10 patch 'malloc: fix allocation of almost hugepage size' " Kevin Traynor
2022-06-24 16:10 ` patch 'net/octeontx: fix port close' " Kevin Traynor
2022-06-24 16:10 ` patch 'common/cnxk: fix decrypt packet count register update' " Kevin Traynor
2022-06-24 16:10 ` patch 'common/cnxk: handle ROC model init failure' " Kevin Traynor
2022-06-24 16:10 ` patch 'net/qede: fix build with GCC 13' " Kevin Traynor
2022-06-24 16:10 ` patch 'net/ice: fix race condition in Rx timestamp' " Kevin Traynor
2022-06-24 16:10 ` patch 'net/ice/base: fix build with GCC 12' " Kevin Traynor
2022-06-24 16:10 ` patch 'net/qede: " Kevin Traynor
2022-06-24 16:10 ` patch 'net/mlx5: fix build with clang 14' " Kevin Traynor
2022-06-24 16:10 ` patch 'net/mlx5: fix RSS expansion for patterns with ICMP item' " Kevin Traynor
2022-06-24 16:10 ` patch 'net/mlx5: add limitation for E-Switch Manager match' " Kevin Traynor
2022-06-24 16:10 ` Kevin Traynor [this message]
2022-06-24 16:10 ` patch 'net/mlx5: fix stack buffer overflow in drop action' " Kevin Traynor
2022-06-24 16:10 ` patch 'doc: fix flow integrity hardware support in mlx5 guide' " Kevin Traynor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220624161016.1881349-12-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=matan@nvidia.com \
    --cc=shunh@nvidia.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).