From: Dariusz Sosnowski <dsosnowski@nvidia.com>
To: Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
Bing Zhao <bingz@nvidia.com>, Ori Kam <orika@nvidia.com>,
Suanming Mou <suanmingm@nvidia.com>,
Matan Azrad <matan@nvidia.com>
Cc: <dev@dpdk.org>
Subject: [PATCH 07/13] common/mlx5: always use EAL device for probing
Date: Mon, 26 Oct 2026 17:27:03 +0100 [thread overview]
Message-ID: <20261026162709.1292958-8-dsosnowski@nvidia.com> (raw)
In-Reply-To: <20261026162709.1292958-1-dsosnowski@nvidia.com>
Previous patch added gathering a list of all associated devices
for each mlx5 common device.
This patch prepars the mlx5 driver probing to take requested rte_device,
instead of relying on mlx5 common device to rte_device correspondence.
As of this patch, all mlx5 drivers will support only probing
with the main device (IB device owner).
Future patches will allow networking driver to probe
using multiple rte_device's.
Signed-off-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
drivers/common/mlx5/mlx5_common.c | 38 ++++++++++++++++++++++-----
drivers/common/mlx5/mlx5_common.h | 2 ++
drivers/compress/mlx5/mlx5_compress.c | 1 +
drivers/crypto/mlx5/mlx5_crypto.c | 1 +
drivers/net/mlx5/linux/mlx5_os.c | 3 +++
drivers/net/mlx5/mlx5.h | 1 +
drivers/net/mlx5/windows/mlx5_os.c | 1 +
drivers/regex/mlx5/mlx5_regex.c | 1 +
drivers/vdpa/mlx5/mlx5_vdpa.c | 1 +
9 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
index 67566e01b2..57f484fcb7 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -470,13 +470,30 @@ mlx5_bus_match(const struct mlx5_class_driver *drv,
return true;
}
+static bool
+mlx5_associated_device_contains(struct mlx5_common_device *cdev,
+ const struct rte_device *rte_dev)
+{
+ struct mlx5_associated_device *assoc;
+
+ TAILQ_FOREACH(assoc, &cdev->associated_devices, next) {
+ if (assoc->is_rte_device && rte_dev == assoc->dev)
+ return true;
+
+ if (mlx5_dev_matches(rte_dev, assoc->info.bus_name, assoc->info.dev_name))
+ return true;
+ }
+
+ return false;
+}
+
static struct mlx5_common_device *
to_mlx5_device(const struct rte_device *rte_dev)
{
struct mlx5_common_device *cdev;
TAILQ_FOREACH(cdev, &devices_list, next) {
- if (rte_dev == cdev->dev)
+ if (mlx5_associated_device_contains(cdev, rte_dev))
return cdev;
}
return NULL;
@@ -981,7 +998,9 @@ drivers_remove(struct mlx5_common_device *cdev, uint32_t enabled_classes)
}
static int
-drivers_probe(struct mlx5_common_device *cdev, uint32_t user_classes,
+drivers_probe(struct mlx5_common_device *cdev,
+ struct rte_device *dev,
+ uint32_t user_classes,
struct mlx5_kvargs_ctrl *mkvlist)
{
struct mlx5_class_driver *driver;
@@ -992,16 +1011,21 @@ drivers_probe(struct mlx5_common_device *cdev, uint32_t user_classes,
TAILQ_FOREACH(driver, &drivers_list, next) {
if ((driver->drv_class & user_classes) == 0)
continue;
- if (!mlx5_bus_match(driver, cdev->dev))
+ if (!mlx5_bus_match(driver, dev))
continue;
+ if (!driver->probe_associated && cdev->dev != dev) {
+ DRV_LOG(ERR, "Invalid device %s used to probe on common device %s",
+ dev->name, cdev->dev->name);
+ ret = -EINVAL;
+ goto probe_err;
+ }
already_loaded = cdev->classes_loaded & driver->drv_class;
if (already_loaded && driver->probe_again == 0) {
- DRV_LOG(ERR, "Device %s is already probed",
- cdev->dev->name);
+ DRV_LOG(ERR, "Device %s is already probed", dev->name);
ret = -EEXIST;
goto probe_err;
}
- ret = driver->probe(cdev, mkvlist);
+ ret = driver->probe(cdev, dev, mkvlist);
if (ret < 0) {
DRV_LOG(ERR, "Failed to load driver %s",
driver->name);
@@ -1091,7 +1115,7 @@ mlx5_common_dev_probe(struct rte_device *eal_dev)
DRV_LOG(ERR, "Unsupported mlx5 classes combination.");
goto class_err;
}
- ret = drivers_probe(cdev, classes, mkvlist_p);
+ ret = drivers_probe(cdev, eal_dev, classes, mkvlist_p);
if (ret)
goto class_err;
/*
diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h
index 8f8ab01700..0d940b1fdf 100644
--- a/drivers/common/mlx5/mlx5_common.h
+++ b/drivers/common/mlx5/mlx5_common.h
@@ -565,6 +565,7 @@ mlx5_imported_pd_and_ctx(struct mlx5_common_device *cdev)
* Initialization function for the driver called during device probing.
*/
typedef int (mlx5_class_driver_probe_t)(struct mlx5_common_device *cdev,
+ struct rte_device *dev,
struct mlx5_kvargs_ctrl *mkvlist);
/**
@@ -584,6 +585,7 @@ struct mlx5_class_driver {
const struct rte_pci_id *id_table; /**< ID table, NULL terminated. */
uint32_t probe_again:1;
/**< Device already probed can be probed again to check new device. */
+ uint32_t probe_associated:1; /**< Supports probing using associated devices. */
uint32_t intr_lsc:1; /**< Supports link state interrupt. */
uint32_t intr_rmv:1; /**< Supports device remove interrupt. */
};
diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c
index 1361dab630..ab503d74e3 100644
--- a/drivers/compress/mlx5/mlx5_compress.c
+++ b/drivers/compress/mlx5/mlx5_compress.c
@@ -820,6 +820,7 @@ mlx5_compress_fill_caps(struct mlx5_compress_priv *priv,
static int
mlx5_compress_dev_probe(struct mlx5_common_device *cdev,
+ struct rte_device *dev __rte_unused,
struct mlx5_kvargs_ctrl *mkvlist)
{
struct rte_compressdev *compressdev;
diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c
index 821dd54b31..aba56b300d 100644
--- a/drivers/crypto/mlx5/mlx5_crypto.c
+++ b/drivers/crypto/mlx5/mlx5_crypto.c
@@ -344,6 +344,7 @@ mlx5_crypto_parse_devargs(struct mlx5_kvargs_ctrl *mkvlist,
static int
mlx5_crypto_dev_probe(struct mlx5_common_device *cdev,
+ struct rte_device *dev __rte_unused,
struct mlx5_kvargs_ctrl *mkvlist)
{
struct rte_cryptodev *crypto_dev;
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 7c2c35c945..42b23e7f58 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -3163,6 +3163,8 @@ mlx5_os_auxiliary_probe(struct mlx5_common_device *cdev,
*
* @param[in] cdev
* Pointer to the common mlx5 device.
+ * @param[in] dev
+ * Pointer to the probed EAL device.
* @param[in, out] mkvlist
* Pointer to mlx5 kvargs control, can be NULL if there is no devargs.
*
@@ -3171,6 +3173,7 @@ mlx5_os_auxiliary_probe(struct mlx5_common_device *cdev,
*/
int
mlx5_os_net_probe(struct mlx5_common_device *cdev,
+ struct rte_device *dev __rte_unused,
struct mlx5_kvargs_ctrl *mkvlist)
{
int ret;
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index e3df458915..b1493745ee 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -2636,6 +2636,7 @@ struct rte_pci_driver;
int mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh);
void mlx5_os_free_shared_dr(struct mlx5_priv *priv);
int mlx5_os_net_probe(struct mlx5_common_device *cdev,
+ struct rte_device *dev,
struct mlx5_kvargs_ctrl *mkvlist);
void mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh);
void mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh);
diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
index cc60f07e17..8e3baa95b4 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -900,6 +900,7 @@ mlx5_os_get_allmulti(struct rte_eth_dev *dev)
*/
int
mlx5_os_net_probe(struct mlx5_common_device *cdev,
+ struct rte_device *dev __rte_unused,
struct mlx5_kvargs_ctrl *mkvlist)
{
struct rte_pci_device *pci_dev = RTE_BUS_DEVICE(cdev->dev, *pci_dev);
diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c
index 042f585abd..b5f4bfa875 100644
--- a/drivers/regex/mlx5/mlx5_regex.c
+++ b/drivers/regex/mlx5/mlx5_regex.c
@@ -68,6 +68,7 @@ mlx5_regex_get_name(char *name, struct rte_device *dev)
static int
mlx5_regex_dev_probe(struct mlx5_common_device *cdev,
+ struct rte_device *dev __rte_unused,
struct mlx5_kvargs_ctrl *mkvlist __rte_unused)
{
struct mlx5_regex_priv *priv = NULL;
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c
index 1bb5de51b6..a087b232b6 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.c
@@ -813,6 +813,7 @@ mlx5_vdpa_create_dev_resources(struct mlx5_vdpa_priv *priv)
static int
mlx5_vdpa_dev_probe(struct mlx5_common_device *cdev,
+ struct rte_device *dev __rte_unused,
struct mlx5_kvargs_ctrl *mkvlist)
{
struct mlx5_vdpa_priv *priv = NULL;
--
2.43.0
next prev parent reply other threads:[~2026-10-26 16:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 16:26 [PATCH 00/13] net/mlx5: support nested E-Switch Dariusz Sosnowski
2026-10-26 16:26 ` [PATCH 01/13] common/mlx5: rework IB port number query Dariusz Sosnowski
2026-10-26 16:26 ` [PATCH 02/13] common/mlx5: allow ifindex query without cache Dariusz Sosnowski
2026-10-26 16:26 ` [PATCH 03/13] common/mlx5: separate netdev info from switch info Dariusz Sosnowski
2026-10-26 16:27 ` [PATCH 04/13] common/mlx5: query parent device over Netlink Dariusz Sosnowski
2026-10-26 16:27 ` [PATCH 05/13] common/mlx5: add check for auxiliary device Dariusz Sosnowski
2026-10-26 16:27 ` [PATCH 06/13] common/mlx5: gather associated devices Dariusz Sosnowski
2026-10-26 16:27 ` Dariusz Sosnowski [this message]
2026-10-26 16:27 ` [PATCH 08/13] common/mlx5: query devlink port for netdevs Dariusz Sosnowski
2026-10-26 16:27 ` [PATCH 09/13] common/mlx5: get devlink port by port index Dariusz Sosnowski
2026-10-26 16:27 ` [PATCH 10/13] common/mlx5: add check for managed device Dariusz Sosnowski
2026-10-26 16:27 ` [PATCH 11/13] net/mlx5: add sibling device iteration macro Dariusz Sosnowski
2026-10-26 16:27 ` [PATCH 12/13] net/mlx5: allow associated devices Dariusz Sosnowski
2026-10-26 16:27 ` [PATCH 13/13] net/mlx5: allow multiport auxiliary device probe Dariusz Sosnowski
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=20261026162709.1292958-8-dsosnowski@nvidia.com \
--to=dsosnowski@nvidia.com \
--cc=bingz@nvidia.com \
--cc=dev@dpdk.org \
--cc=matan@nvidia.com \
--cc=orika@nvidia.com \
--cc=suanmingm@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