]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
rdma: Print net device name and index for RDMA device
authorLeon Romanovsky <leonro@mellanox.com>
Tue, 3 Apr 2018 04:29:14 +0000 (07:29 +0300)
committerDavid Ahern <dsahern@gmail.com>
Fri, 6 Apr 2018 16:02:32 +0000 (09:02 -0700)
The RDMA devices are operated in RoCE and iWARP modes have net device
underneath. Present their names in regular output and their net index
in detailed mode.

[root@nps ~]# rdma link show mlx5_3/1
4/1: mlx5_3/1: state ACTIVE physical_state LINK_UP netdev ens7
[root@nps ~]# rdma link show mlx5_3/1 -d
4/1: mlx5_3/1: state ACTIVE physical_state LINK_UP netdev ens7 netdev_index 7
    caps: <CM, IP_BASED_GIDS>

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
rdma/include/uapi/rdma/rdma_netlink.h
rdma/link.c
rdma/utils.c

index 9446a72136e859a8d51c6ca2f4457fffb51d41dd..45474f13e7d937bc3074dc8d5e5c06714c3f69f0 100644 (file)
@@ -388,6 +388,10 @@ enum rdma_nldev_attr {
        RDMA_NLDEV_ATTR_RES_LOCAL_DMA_LKEY,     /* u32 */
        RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY, /* u32 */
 
+       /* Netdev information for relevant protocols, like RoCE and iWARP */
+       RDMA_NLDEV_ATTR_NDEV_INDEX,             /* u32 */
+       RDMA_NLDEV_ATTR_NDEV_NAME,              /* string */
+
        RDMA_NLDEV_ATTR_MAX
 };
 #endif /* _RDMA_NETLINK_H */
index 66bcd50e54dba792b0e1509b0e1abb51f660fe55..7e914c870994e6f6c16356ab12d8e3f77a196e5c 100644 (file)
@@ -205,6 +205,26 @@ static void link_print_phys_state(struct rd *rd, struct nlattr **tb)
                pr_out("physical_state %s ", phys_state_to_str(phys_state));
 }
 
+static void link_print_netdev(struct rd *rd, struct nlattr **tb)
+{
+       const char *netdev_name;
+       uint32_t idx;
+
+       if (!tb[RDMA_NLDEV_ATTR_NDEV_NAME] || !tb[RDMA_NLDEV_ATTR_NDEV_INDEX])
+               return;
+
+       netdev_name = mnl_attr_get_str(tb[RDMA_NLDEV_ATTR_NDEV_NAME]);
+       idx = mnl_attr_get_u32(tb[RDMA_NLDEV_ATTR_NDEV_INDEX]);
+       if (rd->json_output) {
+               jsonw_string_field(rd->jw, "netdev", netdev_name);
+               jsonw_uint_field(rd->jw, "netdev_index", idx);
+       } else {
+               pr_out("netdev %s ", netdev_name);
+               if (rd->show_details)
+                       pr_out("netdev_index %u ", idx);
+       }
+}
+
 static int link_parse_cb(const struct nlmsghdr *nlh, void *data)
 {
        struct nlattr *tb[RDMA_NLDEV_ATTR_MAX] = {};
@@ -241,6 +261,7 @@ static int link_parse_cb(const struct nlmsghdr *nlh, void *data)
        link_print_lmc(rd, tb);
        link_print_state(rd, tb);
        link_print_phys_state(rd, tb);
+       link_print_netdev(rd, tb);
        if (rd->show_details)
                link_print_caps(rd, tb);
 
index 5c1e736afa408b0ea02676bc99891a1adb4f6cd1..49c967f39b042d3c958c4ed3c1503eb379316e50 100644 (file)
@@ -391,6 +391,8 @@ static const enum mnl_attr_data_type nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
        [RDMA_NLDEV_ATTR_RES_LKEY] = MNL_TYPE_U32,
        [RDMA_NLDEV_ATTR_RES_IOVA] = MNL_TYPE_U64,
        [RDMA_NLDEV_ATTR_RES_MRLEN] = MNL_TYPE_U64,
+       [RDMA_NLDEV_ATTR_NDEV_INDEX]            = MNL_TYPE_U32,
+       [RDMA_NLDEV_ATTR_NDEV_NAME]             = MNL_TYPE_NUL_STRING,
 };
 
 int rd_attr_cb(const struct nlattr *attr, void *data)