RDMA/netlink: Expose device and port capability masks
authorLeon Romanovsky <leonro@mellanox.com>
Tue, 20 Jun 2017 11:47:08 +0000 (14:47 +0300)
committerLeon Romanovsky <leon@kernel.org>
Thu, 10 Aug 2017 10:28:10 +0000 (13:28 +0300)
The port capability mask is exposed to user space via sysfs interface,
while device capabilities are available for verbs only.

This patch provides those capabilities through netlink interface.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
drivers/infiniband/core/nldev.c
include/uapi/rdma/rdma_netlink.h

index db9d9ffc14155cfd3e3418b6eb3ce519350bdf1b..94c1e49074f51249fe1b5c8dbe71a8ccd2b763cf 100644 (file)
@@ -50,18 +50,37 @@ static int fill_dev_info(struct sk_buff *msg, struct ib_device *device)
                return -EMSGSIZE;
        if (nla_put_u32(msg, RDMA_NLDEV_ATTR_PORT_INDEX, rdma_end_port(device)))
                return -EMSGSIZE;
+
+       BUILD_BUG_ON(sizeof(device->attrs.device_cap_flags) != sizeof(u64));
+       if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_CAP_FLAGS,
+                             device->attrs.device_cap_flags, 0))
+               return -EMSGSIZE;
+
        return 0;
 }
 
 static int fill_port_info(struct sk_buff *msg,
                          struct ib_device *device, u32 port)
 {
+       struct ib_port_attr attr;
+       int ret;
+
        if (nla_put_u32(msg, RDMA_NLDEV_ATTR_DEV_INDEX, device->index))
                return -EMSGSIZE;
        if (nla_put_string(msg, RDMA_NLDEV_ATTR_DEV_NAME, device->name))
                return -EMSGSIZE;
        if (nla_put_u32(msg, RDMA_NLDEV_ATTR_PORT_INDEX, port))
                return -EMSGSIZE;
+
+       ret = ib_query_port(device, port, &attr);
+       if (ret)
+               return ret;
+
+       BUILD_BUG_ON(sizeof(attr.port_cap_flags) > sizeof(u64));
+       if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_CAP_FLAGS,
+                             (u64)attr.port_cap_flags, 0))
+               return -EMSGSIZE;
+
        return 0;
 }
 
index a44229fa5eca3cbb6e26cfba5d13095096f93819..90de11db6580933ccded52eebb5f0c466641c1a0 100644 (file)
@@ -257,6 +257,11 @@ enum rdma_nldev_attr {
         */
        RDMA_NLDEV_ATTR_PORT_INDEX,             /* u32 */
 
+       /*
+        * Device and port capabilities
+        */
+       RDMA_NLDEV_ATTR_CAP_FLAGS,              /* u64 */
+
        RDMA_NLDEV_ATTR_MAX
 };
 #endif /* _UAPI_RDMA_NETLINK_H */