summaryrefslogtreecommitdiff
path: root/drivers/infiniband/core/verbs.c
diff options
context:
space:
mode:
authorSagi Grimberg <sagig@mellanox.com>2015-07-30 10:32:35 +0300
committerDoug Ledford <dledford@redhat.com>2015-08-30 18:08:44 -0400
commit9bee178b4f6b3e122ed8eda990450a638706e271 (patch)
tree8c924e218d74ff1f80a0f8dc69d67cdb41a30ab2 /drivers/infiniband/core/verbs.c
parent8b91ffc1cf67d3f0834197c80c5182890c8d508d (diff)
IB: Modify ib_create_mr API
Use ib_alloc_mr with specific parameters. Change the existing callers. Signed-off-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/core/verbs.c')
-rw-r--r--drivers/infiniband/core/verbs.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 8197ce7a64e5..f96dd456db3b 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -1235,15 +1235,32 @@ int ib_dereg_mr(struct ib_mr *mr)
}
EXPORT_SYMBOL(ib_dereg_mr);
-struct ib_mr *ib_create_mr(struct ib_pd *pd,
- struct ib_mr_init_attr *mr_init_attr)
+/**
+ * ib_alloc_mr() - Allocates a memory region
+ * @pd: protection domain associated with the region
+ * @mr_type: memory region type
+ * @max_num_sg: maximum sg entries available for registration.
+ *
+ * Notes:
+ * Memory registeration page/sg lists must not exceed max_num_sg.
+ * For mr_type IB_MR_TYPE_MEM_REG, the total length cannot exceed
+ * max_num_sg * used_page_size.
+ *
+ */
+struct ib_mr *ib_alloc_mr(struct ib_pd *pd,
+ enum ib_mr_type mr_type,
+ u32 max_num_sg)
{
struct ib_mr *mr;
- if (!pd->device->create_mr)
- return ERR_PTR(-ENOSYS);
-
- mr = pd->device->create_mr(pd, mr_init_attr);
+ if (pd->device->alloc_mr) {
+ mr = pd->device->alloc_mr(pd, mr_type, max_num_sg);
+ } else {
+ if (mr_type != IB_MR_TYPE_MEM_REG ||
+ !pd->device->alloc_fast_reg_mr)
+ return ERR_PTR(-ENOSYS);
+ mr = pd->device->alloc_fast_reg_mr(pd, max_num_sg);
+ }
if (!IS_ERR(mr)) {
mr->device = pd->device;
@@ -1255,7 +1272,7 @@ struct ib_mr *ib_create_mr(struct ib_pd *pd,
return mr;
}
-EXPORT_SYMBOL(ib_create_mr);
+EXPORT_SYMBOL(ib_alloc_mr);
struct ib_mr *ib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len)
{