diff options
author | Sagi Grimberg <sagig@mellanox.com> | 2013-07-28 05:35:41 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2013-08-09 20:18:09 -0400 |
commit | e657571b76faf96a1de1aaf40b2111adcf76c673 (patch) | |
tree | 7782f5e5f5e87801930bf9de42e597bfbf822e53 /drivers/infiniband | |
parent | 919fc274ef102841ad56a37d482720f332d459d1 (diff) |
IB/iser: Place the fmr pool into a union in iser's IB conn struct
This is preparation step for other memory registration methods to be
added. In addition, change reg/unreg routines signature to indicate
they use FMRs.
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/ulp/iser/iscsi_iser.h | 18 | ||||
-rw-r--r-- | drivers/infiniband/ulp/iser/iser_memory.c | 24 | ||||
-rw-r--r-- | drivers/infiniband/ulp/iser/iser_verbs.c | 47 |
3 files changed, 48 insertions, 41 deletions
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h index 78117be0c89e..75c535260e78 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.h +++ b/drivers/infiniband/ulp/iser/iscsi_iser.h | |||
@@ -286,7 +286,6 @@ struct iser_conn { | |||
286 | struct iser_device *device; /* device context */ | 286 | struct iser_device *device; /* device context */ |
287 | struct rdma_cm_id *cma_id; /* CMA ID */ | 287 | struct rdma_cm_id *cma_id; /* CMA ID */ |
288 | struct ib_qp *qp; /* QP */ | 288 | struct ib_qp *qp; /* QP */ |
289 | struct ib_fmr_pool *fmr_pool; /* pool of IB FMRs */ | ||
290 | wait_queue_head_t wait; /* waitq for conn/disconn */ | 289 | wait_queue_head_t wait; /* waitq for conn/disconn */ |
291 | unsigned qp_max_recv_dtos; /* num of rx buffers */ | 290 | unsigned qp_max_recv_dtos; /* num of rx buffers */ |
292 | unsigned qp_max_recv_dtos_mask; /* above minus 1 */ | 291 | unsigned qp_max_recv_dtos_mask; /* above minus 1 */ |
@@ -294,8 +293,6 @@ struct iser_conn { | |||
294 | int post_recv_buf_count; /* posted rx count */ | 293 | int post_recv_buf_count; /* posted rx count */ |
295 | atomic_t post_send_buf_count; /* posted tx count */ | 294 | atomic_t post_send_buf_count; /* posted tx count */ |
296 | char name[ISER_OBJECT_NAME_SIZE]; | 295 | char name[ISER_OBJECT_NAME_SIZE]; |
297 | struct iser_page_vec *page_vec; /* represents SG to fmr maps* | ||
298 | * maps serialized as tx is*/ | ||
299 | struct list_head conn_list; /* entry in ig conn list */ | 296 | struct list_head conn_list; /* entry in ig conn list */ |
300 | 297 | ||
301 | char *login_buf; | 298 | char *login_buf; |
@@ -304,6 +301,13 @@ struct iser_conn { | |||
304 | unsigned int rx_desc_head; | 301 | unsigned int rx_desc_head; |
305 | struct iser_rx_desc *rx_descs; | 302 | struct iser_rx_desc *rx_descs; |
306 | struct ib_recv_wr rx_wr[ISER_MIN_POSTED_RX]; | 303 | struct ib_recv_wr rx_wr[ISER_MIN_POSTED_RX]; |
304 | union { | ||
305 | struct { | ||
306 | struct ib_fmr_pool *pool; /* pool of IB FMRs */ | ||
307 | struct iser_page_vec *page_vec; /* represents SG to fmr maps* | ||
308 | * maps serialized as tx is*/ | ||
309 | } fmr; | ||
310 | } fastreg; | ||
307 | }; | 311 | }; |
308 | 312 | ||
309 | struct iscsi_iser_conn { | 313 | struct iscsi_iser_conn { |
@@ -387,8 +391,8 @@ void iser_free_rx_descriptors(struct iser_conn *ib_conn); | |||
387 | void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_task *task, | 391 | void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_task *task, |
388 | enum iser_data_dir cmd_dir); | 392 | enum iser_data_dir cmd_dir); |
389 | 393 | ||
390 | int iser_reg_rdma_mem(struct iscsi_iser_task *task, | 394 | int iser_reg_rdma_mem_fmr(struct iscsi_iser_task *task, |
391 | enum iser_data_dir cmd_dir); | 395 | enum iser_data_dir cmd_dir); |
392 | 396 | ||
393 | int iser_connect(struct iser_conn *ib_conn, | 397 | int iser_connect(struct iser_conn *ib_conn, |
394 | struct sockaddr_in *src_addr, | 398 | struct sockaddr_in *src_addr, |
@@ -399,8 +403,8 @@ int iser_reg_page_vec(struct iser_conn *ib_conn, | |||
399 | struct iser_page_vec *page_vec, | 403 | struct iser_page_vec *page_vec, |
400 | struct iser_mem_reg *mem_reg); | 404 | struct iser_mem_reg *mem_reg); |
401 | 405 | ||
402 | void iser_unreg_mem(struct iscsi_iser_task *iser_task, | 406 | void iser_unreg_mem_fmr(struct iscsi_iser_task *iser_task, |
403 | enum iser_data_dir cmd_dir); | 407 | enum iser_data_dir cmd_dir); |
404 | 408 | ||
405 | int iser_post_recvl(struct iser_conn *ib_conn); | 409 | int iser_post_recvl(struct iser_conn *ib_conn); |
406 | int iser_post_recvm(struct iser_conn *ib_conn, int count); | 410 | int iser_post_recvm(struct iser_conn *ib_conn, int count); |
diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c index 4dea1ba1278f..1985e907f03a 100644 --- a/drivers/infiniband/ulp/iser/iser_memory.c +++ b/drivers/infiniband/ulp/iser/iser_memory.c | |||
@@ -374,13 +374,13 @@ static int fall_to_bounce_buf(struct iscsi_iser_task *iser_task, | |||
374 | } | 374 | } |
375 | 375 | ||
376 | /** | 376 | /** |
377 | * iser_reg_rdma_mem - Registers memory intended for RDMA, | 377 | * iser_reg_rdma_mem_fmr - Registers memory intended for RDMA, |
378 | * obtaining rkey and va | 378 | * using FMR (if possible) obtaining rkey and va |
379 | * | 379 | * |
380 | * returns 0 on success, errno code on failure | 380 | * returns 0 on success, errno code on failure |
381 | */ | 381 | */ |
382 | int iser_reg_rdma_mem(struct iscsi_iser_task *iser_task, | 382 | int iser_reg_rdma_mem_fmr(struct iscsi_iser_task *iser_task, |
383 | enum iser_data_dir cmd_dir) | 383 | enum iser_data_dir cmd_dir) |
384 | { | 384 | { |
385 | struct iser_conn *ib_conn = iser_task->iser_conn->ib_conn; | 385 | struct iser_conn *ib_conn = iser_task->iser_conn->ib_conn; |
386 | struct iser_device *device = ib_conn->device; | 386 | struct iser_device *device = ib_conn->device; |
@@ -396,7 +396,7 @@ int iser_reg_rdma_mem(struct iscsi_iser_task *iser_task, | |||
396 | 396 | ||
397 | aligned_len = iser_data_buf_aligned_len(mem, ibdev); | 397 | aligned_len = iser_data_buf_aligned_len(mem, ibdev); |
398 | if (aligned_len != mem->dma_nents || | 398 | if (aligned_len != mem->dma_nents || |
399 | (!ib_conn->fmr_pool && mem->dma_nents > 1)) { | 399 | (!ib_conn->fastreg.fmr.pool && mem->dma_nents > 1)) { |
400 | err = fall_to_bounce_buf(iser_task, ibdev, | 400 | err = fall_to_bounce_buf(iser_task, ibdev, |
401 | cmd_dir, aligned_len); | 401 | cmd_dir, aligned_len); |
402 | if (err) { | 402 | if (err) { |
@@ -423,19 +423,21 @@ int iser_reg_rdma_mem(struct iscsi_iser_task *iser_task, | |||
423 | (unsigned long)regd_buf->reg.va, | 423 | (unsigned long)regd_buf->reg.va, |
424 | (unsigned long)regd_buf->reg.len); | 424 | (unsigned long)regd_buf->reg.len); |
425 | } else { /* use FMR for multiple dma entries */ | 425 | } else { /* use FMR for multiple dma entries */ |
426 | iser_page_vec_build(mem, ib_conn->page_vec, ibdev); | 426 | iser_page_vec_build(mem, ib_conn->fastreg.fmr.page_vec, ibdev); |
427 | err = iser_reg_page_vec(ib_conn, ib_conn->page_vec, ®d_buf->reg); | 427 | err = iser_reg_page_vec(ib_conn, ib_conn->fastreg.fmr.page_vec, |
428 | ®d_buf->reg); | ||
428 | if (err && err != -EAGAIN) { | 429 | if (err && err != -EAGAIN) { |
429 | iser_data_buf_dump(mem, ibdev); | 430 | iser_data_buf_dump(mem, ibdev); |
430 | iser_err("mem->dma_nents = %d (dlength = 0x%x)\n", | 431 | iser_err("mem->dma_nents = %d (dlength = 0x%x)\n", |
431 | mem->dma_nents, | 432 | mem->dma_nents, |
432 | ntoh24(iser_task->desc.iscsi_header.dlength)); | 433 | ntoh24(iser_task->desc.iscsi_header.dlength)); |
433 | iser_err("page_vec: data_size = 0x%x, length = %d, offset = 0x%x\n", | 434 | iser_err("page_vec: data_size = 0x%x, length = %d, offset = 0x%x\n", |
434 | ib_conn->page_vec->data_size, ib_conn->page_vec->length, | 435 | ib_conn->fastreg.fmr.page_vec->data_size, |
435 | ib_conn->page_vec->offset); | 436 | ib_conn->fastreg.fmr.page_vec->length, |
436 | for (i=0 ; i<ib_conn->page_vec->length ; i++) | 437 | ib_conn->fastreg.fmr.page_vec->offset); |
438 | for (i = 0; i < ib_conn->fastreg.fmr.page_vec->length; i++) | ||
437 | iser_err("page_vec[%d] = 0x%llx\n", i, | 439 | iser_err("page_vec[%d] = 0x%llx\n", i, |
438 | (unsigned long long) ib_conn->page_vec->pages[i]); | 440 | (unsigned long long) ib_conn->fastreg.fmr.page_vec->pages[i]); |
439 | } | 441 | } |
440 | if (err) | 442 | if (err) |
441 | return err; | 443 | return err; |
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c index 5b5342895c05..d9a47b91fe43 100644 --- a/drivers/infiniband/ulp/iser/iser_verbs.c +++ b/drivers/infiniband/ulp/iser/iser_verbs.c | |||
@@ -77,8 +77,8 @@ static int iser_create_device_ib_res(struct iser_device *device) | |||
77 | /* Assign function handles */ | 77 | /* Assign function handles */ |
78 | device->iser_alloc_rdma_reg_res = iser_create_fmr_pool; | 78 | device->iser_alloc_rdma_reg_res = iser_create_fmr_pool; |
79 | device->iser_free_rdma_reg_res = iser_free_fmr_pool; | 79 | device->iser_free_rdma_reg_res = iser_free_fmr_pool; |
80 | device->iser_reg_rdma_mem = iser_reg_rdma_mem; | 80 | device->iser_reg_rdma_mem = iser_reg_rdma_mem_fmr; |
81 | device->iser_unreg_rdma_mem = iser_unreg_mem; | 81 | device->iser_unreg_rdma_mem = iser_unreg_mem_fmr; |
82 | 82 | ||
83 | device->cqs_used = min(ISER_MAX_CQ, device->ib_device->num_comp_vectors); | 83 | device->cqs_used = min(ISER_MAX_CQ, device->ib_device->num_comp_vectors); |
84 | iser_info("using %d CQs, device %s supports %d vectors\n", | 84 | iser_info("using %d CQs, device %s supports %d vectors\n", |
@@ -194,13 +194,13 @@ int iser_create_fmr_pool(struct iser_conn *ib_conn, unsigned cmds_max) | |||
194 | struct ib_fmr_pool_param params; | 194 | struct ib_fmr_pool_param params; |
195 | int ret = -ENOMEM; | 195 | int ret = -ENOMEM; |
196 | 196 | ||
197 | ib_conn->page_vec = kmalloc(sizeof(struct iser_page_vec) + | 197 | ib_conn->fastreg.fmr.page_vec = kmalloc(sizeof(struct iser_page_vec) + |
198 | (sizeof(u64)*(ISCSI_ISER_SG_TABLESIZE+1)), | 198 | (sizeof(u64)*(ISCSI_ISER_SG_TABLESIZE + 1)), |
199 | GFP_KERNEL); | 199 | GFP_KERNEL); |
200 | if (!ib_conn->page_vec) | 200 | if (!ib_conn->fastreg.fmr.page_vec) |
201 | return ret; | 201 | return ret; |
202 | 202 | ||
203 | ib_conn->page_vec->pages = (u64 *)(ib_conn->page_vec + 1); | 203 | ib_conn->fastreg.fmr.page_vec->pages = (u64 *)(ib_conn->fastreg.fmr.page_vec + 1); |
204 | 204 | ||
205 | params.page_shift = SHIFT_4K; | 205 | params.page_shift = SHIFT_4K; |
206 | /* when the first/last SG element are not start/end * | 206 | /* when the first/last SG element are not start/end * |
@@ -216,16 +216,16 @@ int iser_create_fmr_pool(struct iser_conn *ib_conn, unsigned cmds_max) | |||
216 | IB_ACCESS_REMOTE_WRITE | | 216 | IB_ACCESS_REMOTE_WRITE | |
217 | IB_ACCESS_REMOTE_READ); | 217 | IB_ACCESS_REMOTE_READ); |
218 | 218 | ||
219 | ib_conn->fmr_pool = ib_create_fmr_pool(device->pd, ¶ms); | 219 | ib_conn->fastreg.fmr.pool = ib_create_fmr_pool(device->pd, ¶ms); |
220 | if (!IS_ERR(ib_conn->fmr_pool)) | 220 | if (!IS_ERR(ib_conn->fastreg.fmr.pool)) |
221 | return 0; | 221 | return 0; |
222 | 222 | ||
223 | /* no FMR => no need for page_vec */ | 223 | /* no FMR => no need for page_vec */ |
224 | kfree(ib_conn->page_vec); | 224 | kfree(ib_conn->fastreg.fmr.page_vec); |
225 | ib_conn->page_vec = NULL; | 225 | ib_conn->fastreg.fmr.page_vec = NULL; |
226 | 226 | ||
227 | ret = PTR_ERR(ib_conn->fmr_pool); | 227 | ret = PTR_ERR(ib_conn->fastreg.fmr.pool); |
228 | ib_conn->fmr_pool = NULL; | 228 | ib_conn->fastreg.fmr.pool = NULL; |
229 | if (ret != -ENOSYS) { | 229 | if (ret != -ENOSYS) { |
230 | iser_err("FMR allocation failed, err %d\n", ret); | 230 | iser_err("FMR allocation failed, err %d\n", ret); |
231 | return ret; | 231 | return ret; |
@@ -241,15 +241,15 @@ int iser_create_fmr_pool(struct iser_conn *ib_conn, unsigned cmds_max) | |||
241 | void iser_free_fmr_pool(struct iser_conn *ib_conn) | 241 | void iser_free_fmr_pool(struct iser_conn *ib_conn) |
242 | { | 242 | { |
243 | iser_info("freeing conn %p fmr pool %p\n", | 243 | iser_info("freeing conn %p fmr pool %p\n", |
244 | ib_conn, ib_conn->fmr_pool); | 244 | ib_conn, ib_conn->fastreg.fmr.pool); |
245 | 245 | ||
246 | if (ib_conn->fmr_pool != NULL) | 246 | if (ib_conn->fastreg.fmr.pool != NULL) |
247 | ib_destroy_fmr_pool(ib_conn->fmr_pool); | 247 | ib_destroy_fmr_pool(ib_conn->fastreg.fmr.pool); |
248 | 248 | ||
249 | ib_conn->fmr_pool = NULL; | 249 | ib_conn->fastreg.fmr.pool = NULL; |
250 | 250 | ||
251 | kfree(ib_conn->page_vec); | 251 | kfree(ib_conn->fastreg.fmr.page_vec); |
252 | ib_conn->page_vec = NULL; | 252 | ib_conn->fastreg.fmr.page_vec = NULL; |
253 | } | 253 | } |
254 | 254 | ||
255 | /** | 255 | /** |
@@ -692,7 +692,7 @@ int iser_reg_page_vec(struct iser_conn *ib_conn, | |||
692 | page_list = page_vec->pages; | 692 | page_list = page_vec->pages; |
693 | io_addr = page_list[0]; | 693 | io_addr = page_list[0]; |
694 | 694 | ||
695 | mem = ib_fmr_pool_map_phys(ib_conn->fmr_pool, | 695 | mem = ib_fmr_pool_map_phys(ib_conn->fastreg.fmr.pool, |
696 | page_list, | 696 | page_list, |
697 | page_vec->length, | 697 | page_vec->length, |
698 | io_addr); | 698 | io_addr); |
@@ -725,10 +725,11 @@ int iser_reg_page_vec(struct iser_conn *ib_conn, | |||
725 | } | 725 | } |
726 | 726 | ||
727 | /** | 727 | /** |
728 | * Unregister (previosuly registered) memory. | 728 | * Unregister (previosuly registered using FMR) memory. |
729 | * If memory is non-FMR does nothing. | ||
729 | */ | 730 | */ |
730 | void iser_unreg_mem(struct iscsi_iser_task *iser_task, | 731 | void iser_unreg_mem_fmr(struct iscsi_iser_task *iser_task, |
731 | enum iser_data_dir cmd_dir) | 732 | enum iser_data_dir cmd_dir) |
732 | { | 733 | { |
733 | struct iser_mem_reg *reg = &iser_task->rdma_regd[cmd_dir].reg; | 734 | struct iser_mem_reg *reg = &iser_task->rdma_regd[cmd_dir].reg; |
734 | int ret; | 735 | int ret; |