Skip to content

Commit 2944248

Browse files
MarkZhang81rleon
authored andcommitted
RDMA/nldev: Add support to dump device type and parent device if exists
If a device has a specific type or a parent device, dump them as well. Example: $ rdma dev show smi1 3: smi1: node_type ca fw 20.38.1002 node_guid 9803:9b03:009f:d5ef sys_image_guid 9803:9b03:009f:d5ee type smi parent ibp8s0f1 Signed-off-by: Mark Zhang <[email protected]> Link: https://lore.kernel.org/r/4c022e3e34b5de1254a3b367d502a362cdd0c53a.1718553901.git.leon@kernel.org Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 060c642 commit 2944248

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

drivers/infiniband/core/nldev.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
168168
[RDMA_NLDEV_SYS_ATTR_PRIVILEGED_QKEY_MODE] = { .type = NLA_U8 },
169169
[RDMA_NLDEV_ATTR_DRIVER_DETAILS] = { .type = NLA_U8 },
170170
[RDMA_NLDEV_ATTR_DEV_TYPE] = { .type = NLA_U8 },
171+
[RDMA_NLDEV_ATTR_PARENT_NAME] = { .type = NLA_NUL_STRING },
171172
};
172173

173174
static int put_driver_name_print_type(struct sk_buff *msg, const char *name,
@@ -302,6 +303,15 @@ static int fill_dev_info(struct sk_buff *msg, struct ib_device *device)
302303
if (nla_put_u8(msg, RDMA_NLDEV_ATTR_DEV_DIM, device->use_cq_dim))
303304
return -EMSGSIZE;
304305

306+
if (device->type &&
307+
nla_put_u8(msg, RDMA_NLDEV_ATTR_DEV_TYPE, device->type))
308+
return -EMSGSIZE;
309+
310+
if (device->parent &&
311+
nla_put_string(msg, RDMA_NLDEV_ATTR_PARENT_NAME,
312+
dev_name(&device->parent->dev)))
313+
return -EMSGSIZE;
314+
305315
/*
306316
* Link type is determined on first port and mlx4 device
307317
* which can potentially have two different link type for the same

include/uapi/rdma/rdma_netlink.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,8 @@ enum rdma_nldev_attr {
570570

571571
RDMA_NLDEV_ATTR_DEV_TYPE, /* u8 */
572572

573+
RDMA_NLDEV_ATTR_PARENT_NAME, /* string */
574+
573575
/*
574576
* Always the end
575577
*/

0 commit comments

Comments
 (0)