aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/ulp/iser/iser_verbs.c
diff options
context:
space:
mode:
authorSagi Grimberg <sagig@mellanox.com>2014-03-05 12:43:41 -0500
committerRoland Dreier <roland@purestorage.com>2014-03-18 01:33:57 -0400
commit310b347c6017ca5f00fa1e574c2d9c5b1088a786 (patch)
tree685c74696d27afc7953dc5ba949a22d575f03371 /drivers/infiniband/ulp/iser/iser_verbs.c
parentd11ec4ecf022f49df33a784f0cf445638573f577 (diff)
IB/iser: Move fast_reg_descriptor initialization to a function
fastreg descriptor will include protection information context. In order to place the logic in one place we introduce iser_create_fr_desc function. This patch does not change any functionality. Signed-off-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Alex Tabachnik <alext@mellanox.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/ulp/iser/iser_verbs.c')
-rw-r--r--drivers/infiniband/ulp/iser/iser_verbs.c58
1 files changed, 40 insertions, 18 deletions
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
index dc5a0b49cfbe..9569e402d368 100644
--- a/drivers/infiniband/ulp/iser/iser_verbs.c
+++ b/drivers/infiniband/ulp/iser/iser_verbs.c
@@ -279,6 +279,39 @@ void iser_free_fmr_pool(struct iser_conn *ib_conn)
279 ib_conn->fmr.page_vec = NULL; 279 ib_conn->fmr.page_vec = NULL;
280} 280}
281 281
282static int
283iser_create_fastreg_desc(struct ib_device *ib_device, struct ib_pd *pd,
284 struct fast_reg_descriptor *desc)
285{
286 int ret;
287
288 desc->data_frpl = ib_alloc_fast_reg_page_list(ib_device,
289 ISCSI_ISER_SG_TABLESIZE + 1);
290 if (IS_ERR(desc->data_frpl)) {
291 ret = PTR_ERR(desc->data_frpl);
292 iser_err("Failed to allocate ib_fast_reg_page_list err=%d\n",
293 ret);
294 return PTR_ERR(desc->data_frpl);
295 }
296
297 desc->data_mr = ib_alloc_fast_reg_mr(pd, ISCSI_ISER_SG_TABLESIZE + 1);
298 if (IS_ERR(desc->data_mr)) {
299 ret = PTR_ERR(desc->data_mr);
300 iser_err("Failed to allocate ib_fast_reg_mr err=%d\n", ret);
301 goto fast_reg_mr_failure;
302 }
303 iser_info("Create fr_desc %p page_list %p\n",
304 desc, desc->data_frpl->page_list);
305 desc->valid = true;
306
307 return 0;
308
309fast_reg_mr_failure:
310 ib_free_fast_reg_page_list(desc->data_frpl);
311
312 return ret;
313}
314
282/** 315/**
283 * iser_create_fastreg_pool - Creates pool of fast_reg descriptors 316 * iser_create_fastreg_pool - Creates pool of fast_reg descriptors
284 * for fast registration work requests. 317 * for fast registration work requests.
@@ -300,32 +333,21 @@ int iser_create_fastreg_pool(struct iser_conn *ib_conn, unsigned cmds_max)
300 goto err; 333 goto err;
301 } 334 }
302 335
303 desc->data_frpl = ib_alloc_fast_reg_page_list(device->ib_device, 336 ret = iser_create_fastreg_desc(device->ib_device,
304 ISCSI_ISER_SG_TABLESIZE + 1); 337 device->pd, desc);
305 if (IS_ERR(desc->data_frpl)) { 338 if (ret) {
306 ret = PTR_ERR(desc->data_frpl); 339 iser_err("Failed to create fastreg descriptor err=%d\n",
307 iser_err("Failed to allocate ib_fast_reg_page_list err=%d\n", ret); 340 ret);
308 goto fast_reg_page_failure; 341 kfree(desc);
342 goto err;
309 } 343 }
310 344
311 desc->data_mr = ib_alloc_fast_reg_mr(device->pd,
312 ISCSI_ISER_SG_TABLESIZE + 1);
313 if (IS_ERR(desc->data_mr)) {
314 ret = PTR_ERR(desc->data_mr);
315 iser_err("Failed to allocate ib_fast_reg_mr err=%d\n", ret);
316 goto fast_reg_mr_failure;
317 }
318 desc->valid = true;
319 list_add_tail(&desc->list, &ib_conn->fastreg.pool); 345 list_add_tail(&desc->list, &ib_conn->fastreg.pool);
320 ib_conn->fastreg.pool_size++; 346 ib_conn->fastreg.pool_size++;
321 } 347 }
322 348
323 return 0; 349 return 0;
324 350
325fast_reg_mr_failure:
326 ib_free_fast_reg_page_list(desc->data_frpl);
327fast_reg_page_failure:
328 kfree(desc);
329err: 351err:
330 iser_free_fastreg_pool(ib_conn); 352 iser_free_fastreg_pool(ib_conn);
331 return ret; 353 return ret;