DPDK patches and discussions
 help / color / mirror / Atom feed
From: Michael Baum <michaelba@nvidia.com>
To: <dev@dpdk.org>
Cc: Matan Azrad <matan@nvidia.com>,
	Raslan Darawsheh <rasland@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Subject: [dpdk-dev] [RFC 16/21] common/mlx5: add HCA attributes to context device structure
Date: Tue, 17 Aug 2021 16:44:36 +0300	[thread overview]
Message-ID: <20210817134441.1966618-17-michaelba@nvidia.com> (raw)
In-Reply-To: <20210817134441.1966618-1-michaelba@nvidia.com>

Add HCA attributes structure as a field of context device structure.
It query in common probing, and check if the device supports the chosen
classes.

Signed-off-by: Michael Baum <michaelba@nvidia.com>
---
 drivers/common/mlx5/mlx5_common.c | 67 ++++++++++++++++++++++++++++++-
 drivers/common/mlx5/mlx5_common.h |  9 +++--
 2 files changed, 70 insertions(+), 6 deletions(-)

diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
index b500e7834e..e4c1984700 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -310,6 +310,56 @@ mlx5_dev_to_pci_str(const struct rte_device *dev, char *addr, size_t size)
 #endif
 }
 
+/**
+ * Validate HCA attributes.
+ *
+ * @param attr
+ *   Attributes device values.
+ * @param classes
+ *   Chosen classes come from device arguments.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+mlx5_hca_attr_validate(struct mlx5_hca_attr *attr, uint32_t classes)
+{
+	if (classes & MLX5_CLASS_VDPA) {
+		if (!attr->vdpa.valid || !attr->vdpa.max_num_virtio_queues) {
+			DRV_LOG(ERR,
+				"Not enough capabilities to support vDPA, maybe old FW/OFED version?");
+			rte_errno = ENOTSUP;
+			return -rte_errno;
+		}
+	}
+	if (classes & MLX5_CLASS_REGEX) {
+		if (!attr->regex || attr->regexp_num_of_engines == 0) {
+			DRV_LOG(ERR,
+				"Not enough capabilities to support RegEx, maybe old FW/OFED version?");
+			rte_errno = ENOTSUP;
+			return -rte_errno;
+		}
+	}
+	if (classes & MLX5_CLASS_COMPRESS) {
+		if (attr->mmo_compress_en == 0 ||
+		    attr->mmo_decompress_en == 0 || attr->mmo_dma_en == 0) {
+			DRV_LOG(ERR,
+				"Not enough capabilities to support compress operations, maybe old FW/OFED version?");
+			rte_errno = ENOTSUP;
+			return -ENOTSUP;
+		}
+	}
+	if (classes & MLX5_CLASS_CRYPTO) {
+		if (attr->crypto == 0 || attr->aes_xts == 0) {
+			DRV_LOG(ERR,
+				"Not enough capabilities to support crypto operations, maybe old FW/OFED version?");
+			rte_errno = ENOTSUP;
+			return -ENOTSUP;
+		}
+	}
+	return 0;
+}
+
 /**
  * Uninitialize context device and release all its resources.
  *
@@ -379,6 +429,13 @@ mlx5_dev_ctx_prepare(struct mlx5_dev_ctx *dev_ctx, struct rte_device *dev,
 	ret = mlx5_os_pd_create(dev_ctx);
 	if (ret)
 		goto error;
+	/* Query HCA attributes. */
+	ret = mlx5_devx_cmd_query_hca_attr(dev_ctx->ctx, &dev_ctx->hca_attr);
+	if (ret) {
+		DRV_LOG(ERR, "Unable to read HCA capabilities.");
+		rte_errno = ENOTSUP;
+		goto error;
+	}
 	return ret;
 error:
 	mlx5_dev_ctx_release(dev_ctx);
@@ -507,13 +564,19 @@ mlx5_common_dev_probe(struct rte_device *eal_dev)
 		new_device = true;
 	} else {
 		/* Validate combination here. */
-		ret = is_valid_class_combination(classes |
-						 dev->classes_loaded);
+		ret = is_valid_class_combination(classes | dev->classes_loaded);
 		if (ret != 0) {
 			DRV_LOG(ERR, "Unsupported mlx5 classes combination.");
 			return ret;
 		}
 	}
+	if (dev->ctx.ctx) {
+		/* Validate HCA attributes here. */
+		ret = mlx5_hca_attr_validate(&dev->ctx.hca_attr,
+					     classes | dev->classes_loaded);
+		if (ret)
+			goto class_err;
+	}
 	ret = drivers_probe(dev, classes);
 	if (ret)
 		goto class_err;
diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h
index 644dc58bc9..da03e160d2 100644
--- a/drivers/common/mlx5/mlx5_common.h
+++ b/drivers/common/mlx5/mlx5_common.h
@@ -329,10 +329,11 @@ void mlx5_common_init(void);
  * Contains HW device objects which belong to same device with multiple drivers.
  */
 struct mlx5_dev_ctx {
-	void *ctx;	/* Verbs/DV/DevX context. */
-	void *pd;	/* Protection Domain. */
-	uint32_t pdn;	/* Protection Domain Number. */
-	int numa_node;	/* Numa node of device. */
+	void *ctx;			/* Verbs/DV/DevX context. */
+	void *pd;			/* Protection Domain. */
+	uint32_t pdn;			/* Protection Domain Number. */
+	int numa_node;			/* Numa node of device. */
+	struct mlx5_hca_attr hca_attr;  /* HCA attributes. */
 };
 
 struct mlx5_common_device {
-- 
2.25.1


  parent reply	other threads:[~2021-08-17 13:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17 13:44 [dpdk-dev] [RFC 00/21] mlx5: sharing global MR cache between drivers Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 01/21] net/mlx5: fix shared device context creation error flow Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 02/21] net/mlx5: fix PCI probing " Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 03/21] common/mlx5: add context device structure Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 04/21] compress/mlx5: use " Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 05/21] crypto/mlx5: " Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 06/21] regex/mlx5: " Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 07/21] net/mlx5: improve probe function on Windows Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 08/21] net/mlx5: improve probe function on Linux Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 09/21] net/mlx5: improve spawn function Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 10/21] net/mlx5: use context device structure Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 11/21] net/mlx5: move NUMA node field to context device Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 12/21] common/mlx5: add ROCE disable in context device creation Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 13/21] vdpa/mlx5: use context device structure Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 14/21] mlx5: update device sent to probing Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 15/21] mlx5: share context device structure between drivers Michael Baum
2021-08-17 13:44 ` Michael Baum [this message]
2021-08-17 13:44 ` [dpdk-dev] [RFC 17/21] regex/mlx5: use HCA attributes from context device Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 18/21] vdpa/mlx5: " Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 19/21] compress/mlx5: " Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 20/21] crypto/mlx5: " Michael Baum
2021-08-17 13:44 ` [dpdk-dev] [RFC 21/21] net/mlx5: " Michael Baum

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=20210817134441.1966618-17-michaelba@nvidia.com \
    --to=michaelba@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=rasland@nvidia.com \
    --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).