aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/infiniband/ulp/iser/iscsi_iser.h13
-rw-r--r--drivers/infiniband/ulp/iser/iser_initiator.c34
-rw-r--r--drivers/infiniband/ulp/iser/iser_verbs.c13
3 files changed, 40 insertions, 20 deletions
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h
index d2fc55a15e95..78117be0c89e 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.h
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
@@ -252,6 +252,9 @@ struct iser_rx_desc {
252 252
253#define ISER_MAX_CQ 4 253#define ISER_MAX_CQ 4
254 254
255struct iser_conn;
256struct iscsi_iser_task;
257
255struct iser_device { 258struct iser_device {
256 struct ib_device *ib_device; 259 struct ib_device *ib_device;
257 struct ib_pd *pd; 260 struct ib_pd *pd;
@@ -265,6 +268,13 @@ struct iser_device {
265 int cq_active_qps[ISER_MAX_CQ]; 268 int cq_active_qps[ISER_MAX_CQ];
266 int cqs_used; 269 int cqs_used;
267 struct iser_cq_desc *cq_desc; 270 struct iser_cq_desc *cq_desc;
271 int (*iser_alloc_rdma_reg_res)(struct iser_conn *ib_conn,
272 unsigned cmds_max);
273 void (*iser_free_rdma_reg_res)(struct iser_conn *ib_conn);
274 int (*iser_reg_rdma_mem)(struct iscsi_iser_task *iser_task,
275 enum iser_data_dir cmd_dir);
276 void (*iser_unreg_rdma_mem)(struct iscsi_iser_task *iser_task,
277 enum iser_data_dir cmd_dir);
268}; 278};
269 279
270struct iser_conn { 280struct iser_conn {
@@ -389,7 +399,8 @@ int iser_reg_page_vec(struct iser_conn *ib_conn,
389 struct iser_page_vec *page_vec, 399 struct iser_page_vec *page_vec,
390 struct iser_mem_reg *mem_reg); 400 struct iser_mem_reg *mem_reg);
391 401
392void iser_unreg_mem(struct iser_mem_reg *mem_reg); 402void iser_unreg_mem(struct iscsi_iser_task *iser_task,
403 enum iser_data_dir cmd_dir);
393 404
394int iser_post_recvl(struct iser_conn *ib_conn); 405int iser_post_recvl(struct iser_conn *ib_conn);
395int iser_post_recvm(struct iser_conn *ib_conn, int count); 406int iser_post_recvm(struct iser_conn *ib_conn, int count);
diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
index 5c2b142840de..bdc38f423ca2 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -49,6 +49,7 @@ static int iser_prepare_read_cmd(struct iscsi_task *task,
49 49
50{ 50{
51 struct iscsi_iser_task *iser_task = task->dd_data; 51 struct iscsi_iser_task *iser_task = task->dd_data;
52 struct iser_device *device = iser_task->iser_conn->ib_conn->device;
52 struct iser_regd_buf *regd_buf; 53 struct iser_regd_buf *regd_buf;
53 int err; 54 int err;
54 struct iser_hdr *hdr = &iser_task->desc.iser_header; 55 struct iser_hdr *hdr = &iser_task->desc.iser_header;
@@ -69,7 +70,7 @@ static int iser_prepare_read_cmd(struct iscsi_task *task,
69 return -EINVAL; 70 return -EINVAL;
70 } 71 }
71 72
72 err = iser_reg_rdma_mem(iser_task,ISER_DIR_IN); 73 err = device->iser_reg_rdma_mem(iser_task, ISER_DIR_IN);
73 if (err) { 74 if (err) {
74 iser_err("Failed to set up Data-IN RDMA\n"); 75 iser_err("Failed to set up Data-IN RDMA\n");
75 return err; 76 return err;
@@ -98,6 +99,7 @@ iser_prepare_write_cmd(struct iscsi_task *task,
98 unsigned int edtl) 99 unsigned int edtl)
99{ 100{
100 struct iscsi_iser_task *iser_task = task->dd_data; 101 struct iscsi_iser_task *iser_task = task->dd_data;
102 struct iser_device *device = iser_task->iser_conn->ib_conn->device;
101 struct iser_regd_buf *regd_buf; 103 struct iser_regd_buf *regd_buf;
102 int err; 104 int err;
103 struct iser_hdr *hdr = &iser_task->desc.iser_header; 105 struct iser_hdr *hdr = &iser_task->desc.iser_header;
@@ -119,7 +121,7 @@ iser_prepare_write_cmd(struct iscsi_task *task,
119 return -EINVAL; 121 return -EINVAL;
120 } 122 }
121 123
122 err = iser_reg_rdma_mem(iser_task,ISER_DIR_OUT); 124 err = device->iser_reg_rdma_mem(iser_task, ISER_DIR_OUT);
123 if (err != 0) { 125 if (err != 0) {
124 iser_err("Failed to register write cmd RDMA mem\n"); 126 iser_err("Failed to register write cmd RDMA mem\n");
125 return err; 127 return err;
@@ -253,8 +255,8 @@ int iser_alloc_rx_descriptors(struct iser_conn *ib_conn, struct iscsi_session *s
253 ib_conn->qp_max_recv_dtos_mask = session->cmds_max - 1; /* cmds_max is 2^N */ 255 ib_conn->qp_max_recv_dtos_mask = session->cmds_max - 1; /* cmds_max is 2^N */
254 ib_conn->min_posted_rx = ib_conn->qp_max_recv_dtos >> 2; 256 ib_conn->min_posted_rx = ib_conn->qp_max_recv_dtos >> 2;
255 257
256 if (iser_create_fmr_pool(ib_conn, session->scsi_cmds_max)) 258 if (device->iser_alloc_rdma_reg_res(ib_conn, session->scsi_cmds_max))
257 goto create_fmr_pool_failed; 259 goto create_rdma_reg_res_failed;
258 260
259 if (iser_alloc_login_buf(ib_conn)) 261 if (iser_alloc_login_buf(ib_conn))
260 goto alloc_login_buf_fail; 262 goto alloc_login_buf_fail;
@@ -293,8 +295,8 @@ rx_desc_dma_map_failed:
293rx_desc_alloc_fail: 295rx_desc_alloc_fail:
294 iser_free_login_buf(ib_conn); 296 iser_free_login_buf(ib_conn);
295alloc_login_buf_fail: 297alloc_login_buf_fail:
296 iser_free_fmr_pool(ib_conn); 298 device->iser_free_rdma_reg_res(ib_conn);
297create_fmr_pool_failed: 299create_rdma_reg_res_failed:
298 iser_err("failed allocating rx descriptors / data buffers\n"); 300 iser_err("failed allocating rx descriptors / data buffers\n");
299 return -ENOMEM; 301 return -ENOMEM;
300} 302}
@@ -308,6 +310,9 @@ void iser_free_rx_descriptors(struct iser_conn *ib_conn)
308 if (!ib_conn->rx_descs) 310 if (!ib_conn->rx_descs)
309 goto free_login_buf; 311 goto free_login_buf;
310 312
313 if (device && device->iser_free_rdma_reg_res)
314 device->iser_free_rdma_reg_res(ib_conn);
315
311 rx_desc = ib_conn->rx_descs; 316 rx_desc = ib_conn->rx_descs;
312 for (i = 0; i < ib_conn->qp_max_recv_dtos; i++, rx_desc++) 317 for (i = 0; i < ib_conn->qp_max_recv_dtos; i++, rx_desc++)
313 ib_dma_unmap_single(device->ib_device, rx_desc->dma_addr, 318 ib_dma_unmap_single(device->ib_device, rx_desc->dma_addr,
@@ -318,7 +323,6 @@ void iser_free_rx_descriptors(struct iser_conn *ib_conn)
318 323
319free_login_buf: 324free_login_buf:
320 iser_free_login_buf(ib_conn); 325 iser_free_login_buf(ib_conn);
321 iser_free_fmr_pool(ib_conn);
322} 326}
323 327
324static int iser_post_rx_bufs(struct iscsi_conn *conn, struct iscsi_hdr *req) 328static int iser_post_rx_bufs(struct iscsi_conn *conn, struct iscsi_hdr *req)
@@ -629,8 +633,8 @@ void iser_task_rdma_init(struct iscsi_iser_task *iser_task)
629 633
630void iser_task_rdma_finalize(struct iscsi_iser_task *iser_task) 634void iser_task_rdma_finalize(struct iscsi_iser_task *iser_task)
631{ 635{
636 struct iser_device *device = iser_task->iser_conn->ib_conn->device;
632 int is_rdma_aligned = 1; 637 int is_rdma_aligned = 1;
633 struct iser_regd_buf *regd;
634 638
635 /* if we were reading, copy back to unaligned sglist, 639 /* if we were reading, copy back to unaligned sglist,
636 * anyway dma_unmap and free the copy 640 * anyway dma_unmap and free the copy
@@ -644,17 +648,11 @@ void iser_task_rdma_finalize(struct iscsi_iser_task *iser_task)
644 iser_finalize_rdma_unaligned_sg(iser_task, ISER_DIR_OUT); 648 iser_finalize_rdma_unaligned_sg(iser_task, ISER_DIR_OUT);
645 } 649 }
646 650
647 if (iser_task->dir[ISER_DIR_IN]) { 651 if (iser_task->dir[ISER_DIR_IN])
648 regd = &iser_task->rdma_regd[ISER_DIR_IN]; 652 device->iser_unreg_rdma_mem(iser_task, ISER_DIR_IN);
649 if (regd->reg.is_fmr)
650 iser_unreg_mem(&regd->reg);
651 }
652 653
653 if (iser_task->dir[ISER_DIR_OUT]) { 654 if (iser_task->dir[ISER_DIR_OUT])
654 regd = &iser_task->rdma_regd[ISER_DIR_OUT]; 655 device->iser_unreg_rdma_mem(iser_task, ISER_DIR_OUT);
655 if (regd->reg.is_fmr)
656 iser_unreg_mem(&regd->reg);
657 }
658 656
659 /* if the data was unaligned, it was already unmapped and then copied */ 657 /* if the data was unaligned, it was already unmapped and then copied */
660 if (is_rdma_aligned) 658 if (is_rdma_aligned)
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
index 5e49a36c7274..5b5342895c05 100644
--- a/drivers/infiniband/ulp/iser/iser_verbs.c
+++ b/drivers/infiniband/ulp/iser/iser_verbs.c
@@ -74,6 +74,12 @@ static int iser_create_device_ib_res(struct iser_device *device)
74 int i, j; 74 int i, j;
75 struct iser_cq_desc *cq_desc; 75 struct iser_cq_desc *cq_desc;
76 76
77 /* Assign function handles */
78 device->iser_alloc_rdma_reg_res = iser_create_fmr_pool;
79 device->iser_free_rdma_reg_res = iser_free_fmr_pool;
80 device->iser_reg_rdma_mem = iser_reg_rdma_mem;
81 device->iser_unreg_rdma_mem = iser_unreg_mem;
82
77 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);
78 iser_info("using %d CQs, device %s supports %d vectors\n", 84 iser_info("using %d CQs, device %s supports %d vectors\n",
79 device->cqs_used, device->ib_device->name, 85 device->cqs_used, device->ib_device->name,
@@ -721,10 +727,15 @@ int iser_reg_page_vec(struct iser_conn *ib_conn,
721/** 727/**
722 * Unregister (previosuly registered) memory. 728 * Unregister (previosuly registered) memory.
723 */ 729 */
724void iser_unreg_mem(struct iser_mem_reg *reg) 730void iser_unreg_mem(struct iscsi_iser_task *iser_task,
731 enum iser_data_dir cmd_dir)
725{ 732{
733 struct iser_mem_reg *reg = &iser_task->rdma_regd[cmd_dir].reg;
726 int ret; 734 int ret;
727 735
736 if (!reg->is_fmr)
737 return;
738
728 iser_dbg("PHYSICAL Mem.Unregister mem_h %p\n",reg->mem_h); 739 iser_dbg("PHYSICAL Mem.Unregister mem_h %p\n",reg->mem_h);
729 740
730 ret = ib_fmr_pool_unmap((struct ib_pool_fmr *)reg->mem_h); 741 ret = ib_fmr_pool_unmap((struct ib_pool_fmr *)reg->mem_h);