@@ -199,7 +199,9 @@ static void iser_free_device_ib_res(struct iser_device *device)
199
199
*
200
200
* returns 0 on success, or errno code on failure
201
201
*/
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 )
203
205
{
204
206
struct iser_device * device = ib_conn -> device ;
205
207
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)
216
218
if (!desc )
217
219
return - ENOMEM ;
218
220
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 ),
221
222
GFP_KERNEL );
222
223
if (!page_vec ) {
223
224
ret = - ENOMEM ;
@@ -227,9 +228,7 @@ int iser_alloc_fmr_pool(struct ib_conn *ib_conn, unsigned cmds_max)
227
228
page_vec -> pages = (u64 * )(page_vec + 1 );
228
229
229
230
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 ;
233
232
/* make the pool size twice the max number of SCSI commands *
234
233
* the ML is expected to queue, watermark for unmap at 50% */
235
234
params .pool_size = cmds_max * 2 ;
@@ -282,22 +281,22 @@ void iser_free_fmr_pool(struct ib_conn *ib_conn)
282
281
}
283
282
284
283
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 )
287
288
{
288
289
int ret ;
289
290
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 );
292
292
if (IS_ERR (res -> frpl )) {
293
293
ret = PTR_ERR (res -> frpl );
294
294
iser_err ("Failed to allocate ib_fast_reg_page_list err=%d\n" ,
295
295
ret );
296
296
return PTR_ERR (res -> frpl );
297
297
}
298
298
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 );
301
300
if (IS_ERR (res -> mr )) {
302
301
ret = PTR_ERR (res -> mr );
303
302
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)
321
320
}
322
321
323
322
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 )
326
327
{
327
328
struct iser_pi_context * pi_ctx = NULL ;
328
329
int ret ;
@@ -333,7 +334,7 @@ iser_alloc_pi_ctx(struct ib_device *ib_device, struct ib_pd *pd,
333
334
334
335
pi_ctx = desc -> pi_ctx ;
335
336
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 );
337
338
if (ret ) {
338
339
iser_err ("failed to allocate reg_resources\n" );
339
340
goto alloc_reg_res_err ;
@@ -366,8 +367,10 @@ iser_free_pi_ctx(struct iser_pi_context *pi_ctx)
366
367
}
367
368
368
369
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 )
371
374
{
372
375
struct iser_fr_desc * desc ;
373
376
int ret ;
@@ -376,12 +379,12 @@ iser_create_fastreg_desc(struct ib_device *ib_device, struct ib_pd *pd,
376
379
if (!desc )
377
380
return ERR_PTR (- ENOMEM );
378
381
379
- ret = iser_alloc_reg_res (ib_device , pd , & desc -> rsc );
382
+ ret = iser_alloc_reg_res (ib_device , pd , & desc -> rsc , size );
380
383
if (ret )
381
384
goto reg_res_alloc_failure ;
382
385
383
386
if (pi_enable ) {
384
- ret = iser_alloc_pi_ctx (ib_device , pd , desc );
387
+ ret = iser_alloc_pi_ctx (ib_device , pd , desc , size );
385
388
if (ret )
386
389
goto pi_ctx_alloc_failure ;
387
390
}
@@ -401,7 +404,9 @@ iser_create_fastreg_desc(struct ib_device *ib_device, struct ib_pd *pd,
401
404
* for fast registration work requests.
402
405
* returns 0 on success, or errno code on failure
403
406
*/
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 )
405
410
{
406
411
struct iser_device * device = ib_conn -> device ;
407
412
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)
413
418
fr_pool -> size = 0 ;
414
419
for (i = 0 ; i < cmds_max ; i ++ ) {
415
420
desc = iser_create_fastreg_desc (device -> ib_device , device -> pd ,
416
- ib_conn -> pi_support );
421
+ ib_conn -> pi_support , size );
417
422
if (IS_ERR (desc )) {
418
423
ret = PTR_ERR (desc );
419
424
goto err ;
0 commit comments