Commit 7b1e2099 authored by Dennis Dalessandro's avatar Dennis Dalessandro Committed by Doug Ledford

IB/rdmavt: Move memory registration into rdmavt

Use the memory registration routines in hfi1 and move them to rdmavt.
A follow on patch will address removing the duplicated code in the
hfi1 and qib drivers.
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 0b8a8aae
This diff is collapsed.
......@@ -49,6 +49,29 @@
*/
#include <rdma/rdma_vt.h>
struct rvt_fmr {
struct ib_fmr ibfmr;
struct rvt_mregion mr; /* must be last */
};
struct rvt_mr {
struct ib_mr ibmr;
struct ib_umem *umem;
struct rvt_mregion mr; /* must be last */
};
static inline struct rvt_fmr *to_ifmr(struct ib_fmr *ibfmr)
{
return container_of(ibfmr, struct rvt_fmr, ibfmr);
}
static inline struct rvt_mr *to_imr(struct ib_mr *ibmr)
{
return container_of(ibmr, struct rvt_mr, ibmr);
}
int rvt_driver_mr_init(struct rvt_dev_info *rdi);
void rvt_mr_exit(struct rvt_dev_info *rdi);
/* Mem Regions */
struct ib_mr *rvt_get_dma_mr(struct ib_pd *pd, int acc);
......
......@@ -214,6 +214,8 @@ static int rvt_get_port_immutable(struct ib_device *ibdev, u8 port_num,
int rvt_register_device(struct rvt_dev_info *rdi)
{
/* Validate that drivers have provided the right information */
int ret = 0;
if (!rdi)
return -EINVAL;
......@@ -262,6 +264,12 @@ int rvt_register_device(struct rvt_dev_info *rdi)
CHECK_DRIVER_OVERRIDE(rdi, detach_mcast);
/* Mem Region */
ret = rvt_driver_mr_init(rdi);
if (ret) {
rvt_pr_err(rdi, "Error in driver MR init.\n");
goto bail_no_mr;
}
CHECK_DRIVER_OVERRIDE(rdi, get_dma_mr);
CHECK_DRIVER_OVERRIDE(rdi, reg_user_mr);
CHECK_DRIVER_OVERRIDE(rdi, dereg_mr);
......@@ -289,10 +297,21 @@ int rvt_register_device(struct rvt_dev_info *rdi)
spin_lock_init(&rdi->n_pds_lock);
rdi->n_pds_allocated = 0;
/* We are now good to announce we exist */
ret = ib_register_device(&rdi->ibdev, rdi->driver_f.port_callback);
if (ret) {
rvt_pr_err(rdi, "Failed to register driver with ib core.\n");
goto bail_mr;
}
rvt_pr_info(rdi, "Registration with rdmavt done.\n");
return ret;
/* We are now good to announce we exist */
return ib_register_device(&rdi->ibdev, rdi->driver_f.port_callback);
bail_mr:
rvt_mr_exit(rdi);
bail_no_mr:
return ret;
}
EXPORT_SYMBOL(rvt_register_device);
......@@ -302,5 +321,6 @@ void rvt_unregister_device(struct rvt_dev_info *rdi)
return;
ib_unregister_device(&rdi->ibdev);
rvt_mr_exit(rdi);
}
EXPORT_SYMBOL(rvt_unregister_device);
......@@ -391,6 +391,7 @@ struct rvt_driver_params {
* Anything driver specific that is not covered by props
* For instance special module parameters. Goes here.
*/
unsigned int lkey_table_size;
};
/*
......@@ -416,6 +417,8 @@ struct rvt_pd {
};
struct rvt_dev_info {
struct ib_device ibdev; /* Keep this first. Nothing above here */
/*
* Prior to calling for registration the driver will be responsible for
* allocating space for this structure.
......@@ -423,7 +426,6 @@ struct rvt_dev_info {
* The driver will also be responsible for filling in certain members of
* dparms.props
*/
struct ib_device ibdev;
/* Driver specific properties */
struct rvt_driver_params dparms;
......@@ -453,7 +455,22 @@ static inline struct rvt_dev_info *ib_to_rvt(struct ib_device *ibdev)
return container_of(ibdev, struct rvt_dev_info, ibdev);
}
static inline void rvt_put_mr(struct rvt_mregion *mr)
{
if (unlikely(atomic_dec_and_test(&mr->refcount)))
complete(&mr->comp);
}
static inline void rvt_get_mr(struct rvt_mregion *mr)
{
atomic_inc(&mr->refcount);
}
int rvt_register_device(struct rvt_dev_info *rvd);
void rvt_unregister_device(struct rvt_dev_info *rvd);
int rvt_rkey_ok(struct rvt_qp *qp, struct rvt_sge *sge,
u32 len, u64 vaddr, u32 rkey, int acc);
int rvt_lkey_ok(struct rvt_lkey_table *rkt, struct rvt_pd *pd,
struct rvt_sge *isge, struct ib_sge *sge, int acc);
#endif /* DEF_RDMA_VT_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment