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 04/13] common/mlx5: query parent device over Netlink
Date: Mon, 26 Oct 2026 17:27:00 +0100 [thread overview]
Message-ID: <20261026162709.1292958-5-dsosnowski@nvidia.com> (raw)
In-Reply-To: <20261026162709.1292958-1-dsosnowski@nvidia.com>
Extend mlx5_nl_netdev_info_get() to gather Linux netdev's
parent device and bus name. This will be used in follow up patches
to match probed additional rte_device related to
single mlx5 common device.
Signed-off-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
drivers/common/mlx5/linux/meson.build | 4 ++++
drivers/common/mlx5/linux/mlx5_nl.c | 24 ++++++++++++++++++++++++
drivers/common/mlx5/linux/mlx5_nl.h | 10 ++++++++++
3 files changed, 38 insertions(+)
diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build
index 3767e7a69b..1b2104b48e 100644
--- a/drivers/common/mlx5/linux/meson.build
+++ b/drivers/common/mlx5/linux/meson.build
@@ -154,6 +154,10 @@ has_sym_args = [
'IFLA_PHYS_SWITCH_ID' ],
[ 'HAVE_IFLA_PHYS_PORT_NAME', 'linux/if_link.h',
'IFLA_PHYS_PORT_NAME' ],
+ [ 'HAVE_IFLA_PARENT_DEV_NAME', 'linux/if_link.h',
+ 'IFLA_PARENT_DEV_NAME' ],
+ [ 'HAVE_IFLA_PARENT_DEV_BUS_NAME', 'linux/if_link.h',
+ 'IFLA_PARENT_DEV_BUS_NAME' ],
[ 'HAVE_RDMA_NL_NLDEV', 'rdma/rdma_netlink.h',
'RDMA_NL_NLDEV' ],
[ 'HAVE_RDMA_NLDEV_CMD_GET', 'rdma/rdma_netlink.h',
diff --git a/drivers/common/mlx5/linux/mlx5_nl.c b/drivers/common/mlx5/linux/mlx5_nl.c
index eafae78883..4eebec5223 100644
--- a/drivers/common/mlx5/linux/mlx5_nl.c
+++ b/drivers/common/mlx5/linux/mlx5_nl.c
@@ -113,6 +113,12 @@
#ifndef HAVE_IFLA_PHYS_PORT_NAME
#define IFLA_PHYS_PORT_NAME 38
#endif
+#ifndef HAVE_IFLA_PARENT_DEV_NAME
+#define IFLA_PARENT_DEV_NAME 56
+#endif
+#ifndef HAVE_IFLA_PARENT_DEV_BUS_NAME
+#define IFLA_PARENT_DEV_BUS_NAME 57
+#endif
/*
* Some Devlink defines may be missed in old kernel versions,
@@ -1427,6 +1433,24 @@ mlx5_nl_netdev_info_cb(struct nlmsghdr *nh, void *arg)
}
info.flags |= MLX5_NETDEV_INFO_FLAG_PHYS_SWITCH_ID;
break;
+ case IFLA_PARENT_DEV_NAME:
+ payload_len = RTA_PAYLOAD(ra);
+ /* Some kernels do not pad attributes with zero. */
+ if (payload_len > 0 && payload_len < MLX5_PARENT_DEV_NAME_MAX) {
+ memcpy(info.parent_dev_name, payload, payload_len);
+ info.parent_dev_name[payload_len] = '\0';
+ info.flags |= MLX5_NETDEV_INFO_FLAG_PARENT_DEV_NAME;
+ }
+ break;
+ case IFLA_PARENT_DEV_BUS_NAME:
+ payload_len = RTA_PAYLOAD(ra);
+ /* Some kernels do not pad attributes with zero. */
+ if (payload_len > 0 && payload_len < MLX5_PARENT_DEV_BUS_NAME_MAX) {
+ memcpy(info.parent_dev_bus_name, payload, payload_len);
+ info.parent_dev_bus_name[payload_len] = '\0';
+ info.flags |= MLX5_NETDEV_INFO_FLAG_PARENT_DEV_BUS_NAME;
+ }
+ break;
}
}
*out = info;
diff --git a/drivers/common/mlx5/linux/mlx5_nl.h b/drivers/common/mlx5/linux/mlx5_nl.h
index 6446df1812..39691569bc 100644
--- a/drivers/common/mlx5/linux/mlx5_nl.h
+++ b/drivers/common/mlx5/linux/mlx5_nl.h
@@ -56,9 +56,17 @@ struct mlx5_nl_port_info {
/* Maximal physical port name length. */
#define MLX5_PHYS_PORT_NAME_MAX 128
+/* Maximum length of parent device name. */
+#define MLX5_PARENT_DEV_NAME_MAX 128
+
+/* Maximum length of parent device bus name. */
+#define MLX5_PARENT_DEV_BUS_NAME_MAX 128
+
#define MLX5_NETDEV_INFO_FLAG_NUM_VF RTE_BIT32(0)
#define MLX5_NETDEV_INFO_FLAG_PHYS_PORT_NAME RTE_BIT32(1)
#define MLX5_NETDEV_INFO_FLAG_PHYS_SWITCH_ID RTE_BIT32(2)
+#define MLX5_NETDEV_INFO_FLAG_PARENT_DEV_NAME RTE_BIT32(3)
+#define MLX5_NETDEV_INFO_FLAG_PARENT_DEV_BUS_NAME RTE_BIT32(4)
struct mlx5_netdev_info {
unsigned int ifindex; /* [in] */
@@ -66,6 +74,8 @@ struct mlx5_netdev_info {
uint32_t num_vf; /* [out] */
char phys_port_name[MLX5_PHYS_PORT_NAME_MAX]; /* [out] */
uint64_t phys_switch_id; /* [out] */
+ char parent_dev_name[MLX5_PARENT_DEV_NAME_MAX]; /* [out] */
+ char parent_dev_bus_name[MLX5_PARENT_DEV_BUS_NAME_MAX]; /* [out] */
};
__rte_internal
--
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 ` Dariusz Sosnowski [this message]
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 ` [PATCH 07/13] common/mlx5: always use EAL device for probing Dariusz Sosnowski
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-5-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