patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Michael Baum <michaelba@nvidia.com>
To: <stable@dpdk.org>
Cc: Matan Azrad <matan@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Gregory Etelson <getelson@nvidia.com>,
	"Kevin Traynor" <ktraynor@redhat.com>
Subject: [PATCH 21.11] net/mlx5: fix flex item availability
Date: Sun, 3 Apr 2022 19:08:40 +0300	[thread overview]
Message-ID: <20220403160840.42320-1-michaelba@nvidia.com> (raw)

From: Gregory Etelson <getelson@nvidia.com>

[ upstream commit 71adf25dbfb3a60731bd922342cc0f171714db81 ]

Flex item availability is restricted to BlueField-2 and BlueField-3
PF ports.

The patch validates port type compliance before proceeding to
flex item creation.

Fixes: db25cadc0887 ("net/mlx5: add flex item operations")

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---

It was checked on Windows, it is successfully compiled.

 drivers/common/mlx5/linux/mlx5_common_os.h |  1 +
 drivers/net/mlx5/mlx5_flow.c               | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/drivers/common/mlx5/linux/mlx5_common_os.h b/drivers/common/mlx5/linux/mlx5_common_os.h
index edf356a30a..a6190a34e6 100644
--- a/drivers/common/mlx5/linux/mlx5_common_os.h
+++ b/drivers/common/mlx5/linux/mlx5_common_os.h
@@ -9,6 +9,7 @@
 #include <malloc.h>
 
 #include <rte_pci.h>
+#include <rte_bus_pci.h>
 #include <rte_debug.h>
 #include <rte_atomic.h>
 #include <rte_log.h>
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index e603e39447..1ea6d030f3 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -18,6 +18,7 @@
 #include <rte_flow_driver.h>
 #include <rte_malloc.h>
 #include <rte_ip.h>
+#include <rte_bus_pci.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
@@ -9925,10 +9926,27 @@ mlx5_flow_flex_item_create(struct rte_eth_dev *dev,
 			   struct rte_flow_error *error)
 {
 	static const char err_msg[] = "flex item creation unsupported";
+	struct mlx5_priv *priv = dev->data->dev_private;
 	struct rte_flow_attr attr = { .transfer = 0 };
 	const struct mlx5_flow_driver_ops *fops =
 			flow_get_drv_ops(flow_get_drv_type(dev, &attr));
 
+	if (!priv->pci_dev) {
+		rte_flow_error_set(error, ENOTSUP,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+				   "create flex item on PF only");
+		return NULL;
+	}
+	switch (priv->pci_dev->id.device_id) {
+	case PCI_DEVICE_ID_MELLANOX_CONNECTX6DXBF:
+	case PCI_DEVICE_ID_MELLANOX_CONNECTX7BF:
+		break;
+	default:
+		rte_flow_error_set(error, ENOTSUP,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+				   "flex item available on BlueField ports only");
+		return NULL;
+	}
 	if (!fops->item_create) {
 		DRV_LOG(ERR, "port %u %s.", dev->data->port_id, err_msg);
 		rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION,
-- 
2.25.1


             reply	other threads:[~2022-04-03 16:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-03 16:08 Michael Baum [this message]
2022-04-04 15:51 ` 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=20220403160840.42320-1-michaelba@nvidia.com \
    --to=michaelba@nvidia.com \
    --cc=getelson@nvidia.com \
    --cc=ktraynor@redhat.com \
    --cc=matan@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=viacheslavo@nvidia.com \
    /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).