forked from Minki/linux
RDMA: Move owner into struct ib_device_ops
This more closely follows how other subsytems work, with owner being a member of the structure containing the function pointers. Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> Reviewed-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
parent
72c6ec18eb
commit
7a15414252
@ -2323,6 +2323,10 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
|
||||
dev_ops->driver_id != ops->driver_id);
|
||||
dev_ops->driver_id = ops->driver_id;
|
||||
}
|
||||
if (ops->owner) {
|
||||
WARN_ON(dev_ops->owner && dev_ops->owner != ops->owner);
|
||||
dev_ops->owner = ops->owner;
|
||||
}
|
||||
if (ops->uverbs_abi_ver)
|
||||
dev_ops->uverbs_abi_ver = ops->uverbs_abi_ver;
|
||||
|
||||
|
@ -198,7 +198,7 @@ void ib_uverbs_release_file(struct kref *ref)
|
||||
ib_dev = srcu_dereference(file->device->ib_dev,
|
||||
&file->device->disassociate_srcu);
|
||||
if (ib_dev && !ib_dev->ops.disassociate_ucontext)
|
||||
module_put(ib_dev->owner);
|
||||
module_put(ib_dev->ops.owner);
|
||||
srcu_read_unlock(&file->device->disassociate_srcu, srcu_key);
|
||||
|
||||
if (atomic_dec_and_test(&file->device->refcount))
|
||||
@ -1065,7 +1065,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
|
||||
module_dependent = !(ib_dev->ops.disassociate_ucontext);
|
||||
|
||||
if (module_dependent) {
|
||||
if (!try_module_get(ib_dev->owner)) {
|
||||
if (!try_module_get(ib_dev->ops.owner)) {
|
||||
ret = -ENODEV;
|
||||
goto err;
|
||||
}
|
||||
@ -1100,7 +1100,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
|
||||
return stream_open(inode, filp);
|
||||
|
||||
err_module:
|
||||
module_put(ib_dev->owner);
|
||||
module_put(ib_dev->ops.owner);
|
||||
|
||||
err:
|
||||
mutex_unlock(&dev->lists_mutex);
|
||||
|
@ -596,6 +596,7 @@ static void bnxt_re_unregister_ib(struct bnxt_re_dev *rdev)
|
||||
}
|
||||
|
||||
static const struct ib_device_ops bnxt_re_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_BNXT_RE,
|
||||
.uverbs_abi_ver = BNXT_RE_ABI_VERSION,
|
||||
|
||||
@ -651,7 +652,6 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev)
|
||||
int ret;
|
||||
|
||||
/* ib device init */
|
||||
ibdev->owner = THIS_MODULE;
|
||||
ibdev->node_type = RDMA_NODE_IB_CA;
|
||||
strlcpy(ibdev->node_desc, BNXT_RE_DESC " HCA",
|
||||
strlen(BNXT_RE_DESC) + 5);
|
||||
|
@ -1236,6 +1236,7 @@ static void get_dev_fw_ver_str(struct ib_device *ibdev, char *str)
|
||||
}
|
||||
|
||||
static const struct ib_device_ops iwch_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_CXGB3,
|
||||
.uverbs_abi_ver = IWCH_UVERBS_ABI_VERSION,
|
||||
|
||||
@ -1285,7 +1286,6 @@ int iwch_register_device(struct iwch_dev *dev)
|
||||
pr_debug("%s iwch_dev %p\n", __func__, dev);
|
||||
memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid));
|
||||
memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6);
|
||||
dev->ibdev.owner = THIS_MODULE;
|
||||
dev->device_cap_flags = IB_DEVICE_LOCAL_DMA_LKEY |
|
||||
IB_DEVICE_MEM_WINDOW |
|
||||
IB_DEVICE_MEM_MGT_EXTENSIONS;
|
||||
|
@ -489,6 +489,7 @@ static int fill_res_entry(struct sk_buff *msg, struct rdma_restrack_entry *res)
|
||||
}
|
||||
|
||||
static const struct ib_device_ops c4iw_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_CXGB4,
|
||||
.uverbs_abi_ver = C4IW_UVERBS_ABI_VERSION,
|
||||
|
||||
@ -563,7 +564,6 @@ void c4iw_register_device(struct work_struct *work)
|
||||
pr_debug("c4iw_dev %p\n", dev);
|
||||
memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid));
|
||||
memcpy(&dev->ibdev.node_guid, dev->rdev.lldi.ports[0]->dev_addr, 6);
|
||||
dev->ibdev.owner = THIS_MODULE;
|
||||
dev->device_cap_flags = IB_DEVICE_LOCAL_DMA_LKEY | IB_DEVICE_MEM_WINDOW;
|
||||
if (fastreg_support)
|
||||
dev->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS;
|
||||
|
@ -197,6 +197,7 @@ static void efa_stats_init(struct efa_dev *dev)
|
||||
}
|
||||
|
||||
static const struct ib_device_ops efa_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_EFA,
|
||||
.uverbs_abi_ver = EFA_UVERBS_ABI_VERSION,
|
||||
|
||||
@ -262,7 +263,6 @@ static int efa_ib_device_add(struct efa_dev *dev)
|
||||
if (err)
|
||||
goto err_release_doorbell_bar;
|
||||
|
||||
dev->ibdev.owner = THIS_MODULE;
|
||||
dev->ibdev.node_type = RDMA_NODE_UNSPECIFIED;
|
||||
dev->ibdev.phys_port_cnt = 1;
|
||||
dev->ibdev.num_comp_vectors = 1;
|
||||
|
@ -1779,6 +1779,7 @@ static int get_hw_stats(struct ib_device *ibdev, struct rdma_hw_stats *stats,
|
||||
}
|
||||
|
||||
static const struct ib_device_ops hfi1_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_HFI1,
|
||||
|
||||
.alloc_hw_stats = alloc_hw_stats,
|
||||
@ -1831,7 +1832,6 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
|
||||
*/
|
||||
if (!ib_hfi1_sys_image_guid)
|
||||
ib_hfi1_sys_image_guid = ibdev->node_guid;
|
||||
ibdev->owner = THIS_MODULE;
|
||||
ibdev->phys_port_cnt = dd->num_pports;
|
||||
ibdev->dev.parent = &dd->pcidev->dev;
|
||||
|
||||
|
@ -414,6 +414,7 @@ static void hns_roce_unregister_device(struct hns_roce_dev *hr_dev)
|
||||
}
|
||||
|
||||
static const struct ib_device_ops hns_roce_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_HNS,
|
||||
.uverbs_abi_ver = 1,
|
||||
|
||||
@ -483,7 +484,6 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
|
||||
|
||||
ib_dev = &hr_dev->ib_dev;
|
||||
|
||||
ib_dev->owner = THIS_MODULE;
|
||||
ib_dev->node_type = RDMA_NODE_IB_CA;
|
||||
ib_dev->dev.parent = dev;
|
||||
|
||||
|
@ -2650,6 +2650,7 @@ static int i40iw_query_pkey(struct ib_device *ibdev,
|
||||
}
|
||||
|
||||
static const struct ib_device_ops i40iw_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_I40IW,
|
||||
/* NOTE: Older kernels wrongly use 0 for the uverbs_abi_ver */
|
||||
.uverbs_abi_ver = I40IW_ABI_VER,
|
||||
@ -2711,7 +2712,6 @@ static struct i40iw_ib_device *i40iw_init_rdma_device(struct i40iw_device *iwdev
|
||||
i40iw_pr_err("iwdev == NULL\n");
|
||||
return NULL;
|
||||
}
|
||||
iwibdev->ibdev.owner = THIS_MODULE;
|
||||
iwdev->iwibdev = iwibdev;
|
||||
iwibdev->iwdev = iwdev;
|
||||
|
||||
|
@ -2510,6 +2510,7 @@ static void get_fw_ver_str(struct ib_device *device, char *str)
|
||||
}
|
||||
|
||||
static const struct ib_device_ops mlx4_ib_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_MLX4,
|
||||
.uverbs_abi_ver = MLX4_IB_UVERBS_ABI_VERSION,
|
||||
|
||||
@ -2646,7 +2647,6 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
|
||||
ibdev->dev = dev;
|
||||
ibdev->bond_next_port = 0;
|
||||
|
||||
ibdev->ib_dev.owner = THIS_MODULE;
|
||||
ibdev->ib_dev.node_type = RDMA_NODE_IB_CA;
|
||||
ibdev->ib_dev.local_dma_lkey = dev->caps.reserved_lkey;
|
||||
ibdev->num_ports = num_ports;
|
||||
|
@ -6044,7 +6044,6 @@ static int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev)
|
||||
if (mlx5_use_mad_ifc(dev))
|
||||
get_ext_port_caps(dev);
|
||||
|
||||
dev->ib_dev.owner = THIS_MODULE;
|
||||
dev->ib_dev.node_type = RDMA_NODE_IB_CA;
|
||||
dev->ib_dev.local_dma_lkey = 0 /* not supported for now */;
|
||||
dev->ib_dev.phys_port_cnt = dev->num_ports;
|
||||
@ -6124,6 +6123,7 @@ static void mlx5_ib_stage_flow_db_cleanup(struct mlx5_ib_dev *dev)
|
||||
}
|
||||
|
||||
static const struct ib_device_ops mlx5_ib_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_MLX5,
|
||||
.uverbs_abi_ver = MLX5_IB_UVERBS_ABI_VERSION,
|
||||
|
||||
|
@ -1153,6 +1153,7 @@ static void get_dev_fw_str(struct ib_device *device, char *str)
|
||||
}
|
||||
|
||||
static const struct ib_device_ops mthca_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_MTHCA,
|
||||
.uverbs_abi_ver = MTHCA_UVERBS_ABI_VERSION,
|
||||
|
||||
@ -1246,8 +1247,6 @@ int mthca_register_device(struct mthca_dev *dev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
dev->ib_dev.owner = THIS_MODULE;
|
||||
|
||||
dev->ib_dev.uverbs_cmd_mask =
|
||||
(1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
|
||||
(1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) |
|
||||
|
@ -3558,6 +3558,7 @@ static void get_dev_fw_str(struct ib_device *dev, char *str)
|
||||
}
|
||||
|
||||
static const struct ib_device_ops nes_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_NES,
|
||||
/* NOTE: Older kernels wrongly use 0 for the uverbs_abi_ver */
|
||||
.uverbs_abi_ver = NES_ABI_USERSPACE_VER,
|
||||
@ -3617,7 +3618,6 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev)
|
||||
if (nesibdev == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
nesibdev->ibdev.owner = THIS_MODULE;
|
||||
|
||||
nesibdev->ibdev.node_type = RDMA_NODE_RNIC;
|
||||
memset(&nesibdev->ibdev.node_guid, 0, sizeof(nesibdev->ibdev.node_guid));
|
||||
|
@ -144,6 +144,7 @@ static const struct attribute_group ocrdma_attr_group = {
|
||||
};
|
||||
|
||||
static const struct ib_device_ops ocrdma_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_OCRDMA,
|
||||
.uverbs_abi_ver = OCRDMA_ABI_VERSION,
|
||||
|
||||
@ -203,7 +204,6 @@ static int ocrdma_register_device(struct ocrdma_dev *dev)
|
||||
BUILD_BUG_ON(sizeof(OCRDMA_NODE_DESC) > IB_DEVICE_NODE_DESC_MAX);
|
||||
memcpy(dev->ibdev.node_desc, OCRDMA_NODE_DESC,
|
||||
sizeof(OCRDMA_NODE_DESC));
|
||||
dev->ibdev.owner = THIS_MODULE;
|
||||
dev->ibdev.uverbs_cmd_mask =
|
||||
OCRDMA_UVERBS(GET_CONTEXT) |
|
||||
OCRDMA_UVERBS(QUERY_DEVICE) |
|
||||
|
@ -183,6 +183,7 @@ static void qedr_roce_register_device(struct qedr_dev *dev)
|
||||
}
|
||||
|
||||
static const struct ib_device_ops qedr_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_QEDR,
|
||||
.uverbs_abi_ver = QEDR_ABI_VERSION,
|
||||
|
||||
@ -234,7 +235,6 @@ static int qedr_register_device(struct qedr_dev *dev)
|
||||
|
||||
dev->ibdev.node_guid = dev->attr.node_guid;
|
||||
memcpy(dev->ibdev.node_desc, QEDR_NODE_DESC, sizeof(QEDR_NODE_DESC));
|
||||
dev->ibdev.owner = THIS_MODULE;
|
||||
|
||||
dev->ibdev.uverbs_cmd_mask = QEDR_UVERBS(GET_CONTEXT) |
|
||||
QEDR_UVERBS(QUERY_DEVICE) |
|
||||
|
@ -1482,6 +1482,7 @@ static void qib_fill_device_attr(struct qib_devdata *dd)
|
||||
}
|
||||
|
||||
static const struct ib_device_ops qib_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_QIB,
|
||||
|
||||
.init_port = qib_create_port_files,
|
||||
@ -1547,7 +1548,6 @@ int qib_register_ib_device(struct qib_devdata *dd)
|
||||
if (!ib_qib_sys_image_guid)
|
||||
ib_qib_sys_image_guid = ppd->guid;
|
||||
|
||||
ibdev->owner = THIS_MODULE;
|
||||
ibdev->node_guid = ppd->guid;
|
||||
ibdev->phys_port_cnt = dd->num_pports;
|
||||
ibdev->dev.parent = &dd->pcidev->dev;
|
||||
|
@ -329,6 +329,7 @@ static void usnic_get_dev_fw_str(struct ib_device *device, char *str)
|
||||
}
|
||||
|
||||
static const struct ib_device_ops usnic_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_USNIC,
|
||||
.uverbs_abi_ver = USNIC_UVERBS_ABI_VERSION,
|
||||
|
||||
@ -387,7 +388,6 @@ static void *usnic_ib_device_add(struct pci_dev *dev)
|
||||
|
||||
us_ibdev->pdev = dev;
|
||||
us_ibdev->netdev = pci_get_drvdata(dev);
|
||||
us_ibdev->ib_dev.owner = THIS_MODULE;
|
||||
us_ibdev->ib_dev.node_type = RDMA_NODE_USNIC_UDP;
|
||||
us_ibdev->ib_dev.phys_port_cnt = USNIC_IB_PORT_CNT;
|
||||
us_ibdev->ib_dev.num_comp_vectors = USNIC_IB_NUM_COMP_VECTORS;
|
||||
|
@ -144,6 +144,7 @@ static int pvrdma_port_immutable(struct ib_device *ibdev, u8 port_num,
|
||||
}
|
||||
|
||||
static const struct ib_device_ops pvrdma_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_VMW_PVRDMA,
|
||||
.uverbs_abi_ver = PVRDMA_UVERBS_ABI_VERSION,
|
||||
|
||||
@ -201,7 +202,6 @@ static int pvrdma_register_device(struct pvrdma_dev *dev)
|
||||
dev->ib_dev.node_guid = dev->dsr->caps.node_guid;
|
||||
dev->sys_image_guid = dev->dsr->caps.sys_image_guid;
|
||||
dev->flags = 0;
|
||||
dev->ib_dev.owner = THIS_MODULE;
|
||||
dev->ib_dev.num_comp_vectors = 1;
|
||||
dev->ib_dev.dev.parent = &dev->pdev->dev;
|
||||
dev->ib_dev.uverbs_cmd_mask =
|
||||
|
@ -1111,6 +1111,7 @@ static int rxe_enable_driver(struct ib_device *ib_dev)
|
||||
}
|
||||
|
||||
static const struct ib_device_ops rxe_dev_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.driver_id = RDMA_DRIVER_RXE,
|
||||
.uverbs_abi_ver = RXE_UVERBS_ABI_VERSION,
|
||||
|
||||
@ -1173,7 +1174,6 @@ int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name)
|
||||
|
||||
strlcpy(dev->node_desc, "rxe", sizeof(dev->node_desc));
|
||||
|
||||
dev->owner = THIS_MODULE;
|
||||
dev->node_type = RDMA_NODE_IB_CA;
|
||||
dev->phys_port_cnt = 1;
|
||||
dev->num_comp_vectors = num_possible_cpus();
|
||||
|
@ -2329,6 +2329,7 @@ struct iw_cm_conn_param;
|
||||
* need to define the supported operations, otherwise they will be set to null.
|
||||
*/
|
||||
struct ib_device_ops {
|
||||
struct module *owner;
|
||||
enum rdma_driver_id driver_id;
|
||||
u32 uverbs_abi_ver;
|
||||
|
||||
@ -2639,7 +2640,6 @@ struct ib_device {
|
||||
|
||||
int num_comp_vectors;
|
||||
|
||||
struct module *owner;
|
||||
union {
|
||||
struct device dev;
|
||||
struct ib_core_device coredev;
|
||||
|
Loading…
Reference in New Issue
Block a user