RDMA: Report available cdevs through RDMA_NLDEV_CMD_GET_CHARDEV

Update the struct ib_client for all modules exporting cdevs related to the
ibdevice to also implement RDMA_NLDEV_CMD_GET_CHARDEV. All cdevs are now
autoloadable and discoverable by userspace over netlink instead of relying
on sysfs.

uverbs also exposes the DRIVER_ID for drivers that are able to support
driver id binding in rdma-core.

Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
Jason Gunthorpe
2019-06-13 21:38:19 -03:00
committed by Doug Ledford
parent 0e2d00eb6f
commit 8f71bb0030
10 changed files with 110 additions and 5 deletions

View File

@@ -51,6 +51,7 @@
#include <rdma/ib.h>
#include <rdma/uverbs_std_types.h>
#include <rdma/rdma_netlink.h>
#include "uverbs.h"
#include "core_priv.h"
@@ -1148,12 +1149,41 @@ static const struct file_operations uverbs_mmap_fops = {
.compat_ioctl = ib_uverbs_ioctl,
};
static int ib_uverbs_get_nl_info(struct ib_device *ibdev, void *client_data,
struct ib_client_nl_info *res)
{
struct ib_uverbs_device *uverbs_dev = client_data;
int ret;
if (res->port != -1)
return -EINVAL;
res->abi = ibdev->ops.uverbs_abi_ver;
res->cdev = &uverbs_dev->dev;
/*
* To support DRIVER_ID binding in userspace some of the driver need
* upgrading to expose their PCI dependent revision information
* through get_context instead of relying on modalias matching. When
* the drivers are fixed they can drop this flag.
*/
if (!ibdev->ops.uverbs_no_driver_id_binding) {
ret = nla_put_u32(res->nl_msg, RDMA_NLDEV_ATTR_UVERBS_DRIVER_ID,
ibdev->ops.driver_id);
if (ret)
return ret;
}
return 0;
}
static struct ib_client uverbs_client = {
.name = "uverbs",
.no_kverbs_req = true,
.add = ib_uverbs_add_one,
.remove = ib_uverbs_remove_one
.remove = ib_uverbs_remove_one,
.get_nl_info = ib_uverbs_get_nl_info,
};
MODULE_ALIAS_RDMA_CLIENT("uverbs");
static ssize_t ibdev_show(struct device *device, struct device_attribute *attr,
char *buf)