Skip to content

Commit f8db651

Browse files
Sagi Grimbergdledford
authored andcommitted
IB/iser: Pass registration pool a size parameter
Hard coded for now. This will allow to allocate different sized MRs depending on the IO size needed (and device capabilities). This patch does not change any functionality. Signed-off-by: Sagi Grimberg <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent 32467c4 commit f8db651

File tree

3 files changed

+36
-25
lines changed

3 files changed

+36
-25
lines changed

drivers/infiniband/ulp/iser/iscsi_iser.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ struct iser_comp {
339339
*/
340340
struct iser_reg_ops {
341341
int (*alloc_reg_res)(struct ib_conn *ib_conn,
342-
unsigned cmds_max);
342+
unsigned cmds_max,
343+
unsigned int size);
343344
void (*free_reg_res)(struct ib_conn *ib_conn);
344345
int (*reg_mem)(struct iscsi_iser_task *iser_task,
345346
struct iser_data_buf *mem,
@@ -658,9 +659,13 @@ int iser_initialize_task_headers(struct iscsi_task *task,
658659
struct iser_tx_desc *tx_desc);
659660
int iser_alloc_rx_descriptors(struct iser_conn *iser_conn,
660661
struct iscsi_session *session);
661-
int iser_alloc_fmr_pool(struct ib_conn *ib_conn, unsigned cmds_max);
662+
int iser_alloc_fmr_pool(struct ib_conn *ib_conn,
663+
unsigned cmds_max,
664+
unsigned int size);
662665
void iser_free_fmr_pool(struct ib_conn *ib_conn);
663-
int iser_alloc_fastreg_pool(struct ib_conn *ib_conn, unsigned cmds_max);
666+
int iser_alloc_fastreg_pool(struct ib_conn *ib_conn,
667+
unsigned cmds_max,
668+
unsigned int size);
664669
void iser_free_fastreg_pool(struct ib_conn *ib_conn);
665670
u8 iser_check_task_pi_status(struct iscsi_iser_task *iser_task,
666671
enum iser_data_dir cmd_dir, sector_t *sector);

drivers/infiniband/ulp/iser/iser_initiator.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ int iser_alloc_rx_descriptors(struct iser_conn *iser_conn,
258258
iser_conn->qp_max_recv_dtos_mask = session->cmds_max - 1; /* cmds_max is 2^N */
259259
iser_conn->min_posted_rx = iser_conn->qp_max_recv_dtos >> 2;
260260

261-
if (device->reg_ops->alloc_reg_res(ib_conn, session->scsi_cmds_max))
261+
if (device->reg_ops->alloc_reg_res(ib_conn, session->scsi_cmds_max,
262+
ISCSI_ISER_SG_TABLESIZE + 1))
262263
goto create_rdma_reg_res_failed;
263264

264265
if (iser_alloc_login_buf(iser_conn))

drivers/infiniband/ulp/iser/iser_verbs.c

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ static void iser_free_device_ib_res(struct iser_device *device)
199199
*
200200
* returns 0 on success, or errno code on failure
201201
*/
202-
int iser_alloc_fmr_pool(struct ib_conn *ib_conn, unsigned cmds_max)
202+
int iser_alloc_fmr_pool(struct ib_conn *ib_conn,
203+
unsigned cmds_max,
204+
unsigned int size)
203205
{
204206
struct iser_device *device = ib_conn->device;
205207
struct iser_fr_pool *fr_pool = &ib_conn->fr_pool;
@@ -216,8 +218,7 @@ int iser_alloc_fmr_pool(struct ib_conn *ib_conn, unsigned cmds_max)
216218
if (!desc)
217219
return -ENOMEM;
218220

219-
page_vec = kmalloc(sizeof(*page_vec) +
220-
(sizeof(u64) * (ISCSI_ISER_SG_TABLESIZE + 1)),
221+
page_vec = kmalloc(sizeof(*page_vec) + (sizeof(u64) * size),
221222
GFP_KERNEL);
222223
if (!page_vec) {
223224
ret = -ENOMEM;
@@ -227,9 +228,7 @@ int iser_alloc_fmr_pool(struct ib_conn *ib_conn, unsigned cmds_max)
227228
page_vec->pages = (u64 *)(page_vec + 1);
228229

229230
params.page_shift = SHIFT_4K;
230-
/* when the first/last SG element are not start/end *
231-
* page aligned, the map whould be of N+1 pages */
232-
params.max_pages_per_fmr = ISCSI_ISER_SG_TABLESIZE + 1;
231+
params.max_pages_per_fmr = size;
233232
/* make the pool size twice the max number of SCSI commands *
234233
* the ML is expected to queue, watermark for unmap at 50% */
235234
params.pool_size = cmds_max * 2;
@@ -282,22 +281,22 @@ void iser_free_fmr_pool(struct ib_conn *ib_conn)
282281
}
283282

284283
static int
285-
iser_alloc_reg_res(struct ib_device *ib_device, struct ib_pd *pd,
286-
struct iser_reg_resources *res)
284+
iser_alloc_reg_res(struct ib_device *ib_device,
285+
struct ib_pd *pd,
286+
struct iser_reg_resources *res,
287+
unsigned int size)
287288
{
288289
int ret;
289290

290-
res->frpl = ib_alloc_fast_reg_page_list(ib_device,
291-
ISCSI_ISER_SG_TABLESIZE + 1);
291+
res->frpl = ib_alloc_fast_reg_page_list(ib_device, size);
292292
if (IS_ERR(res->frpl)) {
293293
ret = PTR_ERR(res->frpl);
294294
iser_err("Failed to allocate ib_fast_reg_page_list err=%d\n",
295295
ret);
296296
return PTR_ERR(res->frpl);
297297
}
298298

299-
res->mr = ib_alloc_mr(pd, IB_MR_TYPE_MEM_REG,
300-
ISCSI_ISER_SG_TABLESIZE + 1);
299+
res->mr = ib_alloc_mr(pd, IB_MR_TYPE_MEM_REG, size);
301300
if (IS_ERR(res->mr)) {
302301
ret = PTR_ERR(res->mr);
303302
iser_err("Failed to allocate ib_fast_reg_mr err=%d\n", ret);
@@ -321,8 +320,10 @@ iser_free_reg_res(struct iser_reg_resources *rsc)
321320
}
322321

323322
static int
324-
iser_alloc_pi_ctx(struct ib_device *ib_device, struct ib_pd *pd,
325-
struct iser_fr_desc *desc)
323+
iser_alloc_pi_ctx(struct ib_device *ib_device,
324+
struct ib_pd *pd,
325+
struct iser_fr_desc *desc,
326+
unsigned int size)
326327
{
327328
struct iser_pi_context *pi_ctx = NULL;
328329
int ret;
@@ -333,7 +334,7 @@ iser_alloc_pi_ctx(struct ib_device *ib_device, struct ib_pd *pd,
333334

334335
pi_ctx = desc->pi_ctx;
335336

336-
ret = iser_alloc_reg_res(ib_device, pd, &pi_ctx->rsc);
337+
ret = iser_alloc_reg_res(ib_device, pd, &pi_ctx->rsc, size);
337338
if (ret) {
338339
iser_err("failed to allocate reg_resources\n");
339340
goto alloc_reg_res_err;
@@ -366,8 +367,10 @@ iser_free_pi_ctx(struct iser_pi_context *pi_ctx)
366367
}
367368

368369
static struct iser_fr_desc *
369-
iser_create_fastreg_desc(struct ib_device *ib_device, struct ib_pd *pd,
370-
bool pi_enable)
370+
iser_create_fastreg_desc(struct ib_device *ib_device,
371+
struct ib_pd *pd,
372+
bool pi_enable,
373+
unsigned int size)
371374
{
372375
struct iser_fr_desc *desc;
373376
int ret;
@@ -376,12 +379,12 @@ iser_create_fastreg_desc(struct ib_device *ib_device, struct ib_pd *pd,
376379
if (!desc)
377380
return ERR_PTR(-ENOMEM);
378381

379-
ret = iser_alloc_reg_res(ib_device, pd, &desc->rsc);
382+
ret = iser_alloc_reg_res(ib_device, pd, &desc->rsc, size);
380383
if (ret)
381384
goto reg_res_alloc_failure;
382385

383386
if (pi_enable) {
384-
ret = iser_alloc_pi_ctx(ib_device, pd, desc);
387+
ret = iser_alloc_pi_ctx(ib_device, pd, desc, size);
385388
if (ret)
386389
goto pi_ctx_alloc_failure;
387390
}
@@ -401,7 +404,9 @@ iser_create_fastreg_desc(struct ib_device *ib_device, struct ib_pd *pd,
401404
* for fast registration work requests.
402405
* returns 0 on success, or errno code on failure
403406
*/
404-
int iser_alloc_fastreg_pool(struct ib_conn *ib_conn, unsigned cmds_max)
407+
int iser_alloc_fastreg_pool(struct ib_conn *ib_conn,
408+
unsigned cmds_max,
409+
unsigned int size)
405410
{
406411
struct iser_device *device = ib_conn->device;
407412
struct iser_fr_pool *fr_pool = &ib_conn->fr_pool;
@@ -413,7 +418,7 @@ int iser_alloc_fastreg_pool(struct ib_conn *ib_conn, unsigned cmds_max)
413418
fr_pool->size = 0;
414419
for (i = 0; i < cmds_max; i++) {
415420
desc = iser_create_fastreg_desc(device->ib_device, device->pd,
416-
ib_conn->pi_support);
421+
ib_conn->pi_support, size);
417422
if (IS_ERR(desc)) {
418423
ret = PTR_ERR(desc);
419424
goto err;

0 commit comments

Comments
 (0)