IB/iser: Move memory reg/dereg routines to iser_memory.c
authorSagi Grimberg <sagig@mellanox.com>
Tue, 14 Apr 2015 15:08:17 +0000 (18:08 +0300)
committerDoug Ledford <dledford@redhat.com>
Wed, 15 Apr 2015 20:07:12 +0000 (16:07 -0400)
As memory registration/de-registration methods, lets
move them to their natural location. While we're at it,
make iser_reg_page_vec routine static.

This patch does not change any functionality.

Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/ulp/iser/iscsi_iser.h
drivers/infiniband/ulp/iser/iser_memory.c
drivers/infiniband/ulp/iser/iser_verbs.c

index 5c7036c90766ff7db717fead41f2214c879044e2..d5e5288fe3dd4f929e40fcc7e1c75751087b5638 100644 (file)
@@ -632,10 +632,6 @@ int  iser_connect(struct iser_conn *iser_conn,
                  struct sockaddr *dst_addr,
                  int non_blocking);
 
-int  iser_reg_page_vec(struct ib_conn *ib_conn,
-                      struct iser_page_vec *page_vec,
-                      struct iser_mem_reg *mem_reg);
-
 void iser_unreg_mem_fmr(struct iscsi_iser_task *iser_task,
                        enum iser_data_dir cmd_dir);
 void iser_unreg_mem_fastreg(struct iscsi_iser_task *iser_task,
index 9c60ff1d82a2eba8ea8f8e09758201634c496a5c..4e0cbbb671ccf32ebe600b2f08202d5a0424c624 100644 (file)
@@ -361,6 +361,94 @@ static int fall_to_bounce_buf(struct iscsi_iser_task *iser_task,
        return 0;
 }
 
+/**
+ * iser_reg_page_vec - Register physical memory
+ *
+ * returns: 0 on success, errno code on failure
+ */
+static
+int iser_reg_page_vec(struct ib_conn *ib_conn,
+                     struct iser_page_vec *page_vec,
+                     struct iser_mem_reg  *mem_reg)
+{
+       struct ib_pool_fmr *mem;
+       u64                io_addr;
+       u64                *page_list;
+       int                status;
+
+       page_list = page_vec->pages;
+       io_addr   = page_list[0];
+
+       mem  = ib_fmr_pool_map_phys(ib_conn->fmr.pool,
+                                   page_list,
+                                   page_vec->length,
+                                   io_addr);
+
+       if (IS_ERR(mem)) {
+               status = (int)PTR_ERR(mem);
+               iser_err("ib_fmr_pool_map_phys failed: %d\n", status);
+               return status;
+       }
+
+       mem_reg->lkey  = mem->fmr->lkey;
+       mem_reg->rkey  = mem->fmr->rkey;
+       mem_reg->len   = page_vec->length * SIZE_4K;
+       mem_reg->va    = io_addr;
+       mem_reg->mem_h = (void *)mem;
+
+       mem_reg->va   += page_vec->offset;
+       mem_reg->len   = page_vec->data_size;
+
+       iser_dbg("PHYSICAL Mem.register, [PHYS p_array: 0x%p, sz: %d, "
+                "entry[0]: (0x%08lx,%ld)] -> "
+                "[lkey: 0x%08X mem_h: 0x%p va: 0x%08lX sz: %ld]\n",
+                page_vec, page_vec->length,
+                (unsigned long)page_vec->pages[0],
+                (unsigned long)page_vec->data_size,
+                (unsigned int)mem_reg->lkey, mem_reg->mem_h,
+                (unsigned long)mem_reg->va, (unsigned long)mem_reg->len);
+       return 0;
+}
+
+/**
+ * Unregister (previosuly registered using FMR) memory.
+ * If memory is non-FMR does nothing.
+ */
+void iser_unreg_mem_fmr(struct iscsi_iser_task *iser_task,
+                       enum iser_data_dir cmd_dir)
+{
+       struct iser_mem_reg *reg = &iser_task->rdma_regd[cmd_dir].reg;
+       int ret;
+
+       if (!reg->mem_h)
+               return;
+
+       iser_dbg("PHYSICAL Mem.Unregister mem_h %p\n", reg->mem_h);
+
+       ret = ib_fmr_pool_unmap((struct ib_pool_fmr *)reg->mem_h);
+       if (ret)
+               iser_err("ib_fmr_pool_unmap failed %d\n", ret);
+
+       reg->mem_h = NULL;
+}
+
+void iser_unreg_mem_fastreg(struct iscsi_iser_task *iser_task,
+                           enum iser_data_dir cmd_dir)
+{
+       struct iser_mem_reg *reg = &iser_task->rdma_regd[cmd_dir].reg;
+       struct iser_conn *iser_conn = iser_task->iser_conn;
+       struct ib_conn *ib_conn = &iser_conn->ib_conn;
+       struct fast_reg_descriptor *desc = reg->mem_h;
+
+       if (!desc)
+               return;
+
+       reg->mem_h = NULL;
+       spin_lock_bh(&ib_conn->lock);
+       list_add_tail(&desc->list, &ib_conn->fastreg.pool);
+       spin_unlock_bh(&ib_conn->lock);
+}
+
 /**
  * iser_reg_rdma_mem_fmr - Registers memory intended for RDMA,
  * using FMR (if possible) obtaining rkey and va
index 7ee4926925d3145797818645e52c47fd1e368f92..986b5f4823eacbef345d5ef0e9b2cf977b11eb26 100644 (file)
@@ -992,93 +992,6 @@ connect_failure:
        return err;
 }
 
-/**
- * iser_reg_page_vec - Register physical memory
- *
- * returns: 0 on success, errno code on failure
- */
-int iser_reg_page_vec(struct ib_conn *ib_conn,
-                     struct iser_page_vec *page_vec,
-                     struct iser_mem_reg  *mem_reg)
-{
-       struct ib_pool_fmr *mem;
-       u64                io_addr;
-       u64                *page_list;
-       int                status;
-
-       page_list = page_vec->pages;
-       io_addr   = page_list[0];
-
-       mem  = ib_fmr_pool_map_phys(ib_conn->fmr.pool,
-                                   page_list,
-                                   page_vec->length,
-                                   io_addr);
-
-       if (IS_ERR(mem)) {
-               status = (int)PTR_ERR(mem);
-               iser_err("ib_fmr_pool_map_phys failed: %d\n", status);
-               return status;
-       }
-
-       mem_reg->lkey  = mem->fmr->lkey;
-       mem_reg->rkey  = mem->fmr->rkey;
-       mem_reg->len   = page_vec->length * SIZE_4K;
-       mem_reg->va    = io_addr;
-       mem_reg->mem_h = (void *)mem;
-
-       mem_reg->va   += page_vec->offset;
-       mem_reg->len   = page_vec->data_size;
-
-       iser_dbg("PHYSICAL Mem.register, [PHYS p_array: 0x%p, sz: %d, "
-                "entry[0]: (0x%08lx,%ld)] -> "
-                "[lkey: 0x%08X mem_h: 0x%p va: 0x%08lX sz: %ld]\n",
-                page_vec, page_vec->length,
-                (unsigned long)page_vec->pages[0],
-                (unsigned long)page_vec->data_size,
-                (unsigned int)mem_reg->lkey, mem_reg->mem_h,
-                (unsigned long)mem_reg->va, (unsigned long)mem_reg->len);
-       return 0;
-}
-
-/**
- * Unregister (previosuly registered using FMR) memory.
- * If memory is non-FMR does nothing.
- */
-void iser_unreg_mem_fmr(struct iscsi_iser_task *iser_task,
-                       enum iser_data_dir cmd_dir)
-{
-       struct iser_mem_reg *reg = &iser_task->rdma_regd[cmd_dir].reg;
-       int ret;
-
-       if (!reg->mem_h)
-               return;
-
-       iser_dbg("PHYSICAL Mem.Unregister mem_h %p\n",reg->mem_h);
-
-       ret = ib_fmr_pool_unmap((struct ib_pool_fmr *)reg->mem_h);
-       if (ret)
-               iser_err("ib_fmr_pool_unmap failed %d\n", ret);
-
-       reg->mem_h = NULL;
-}
-
-void iser_unreg_mem_fastreg(struct iscsi_iser_task *iser_task,
-                           enum iser_data_dir cmd_dir)
-{
-       struct iser_mem_reg *reg = &iser_task->rdma_regd[cmd_dir].reg;
-       struct iser_conn *iser_conn = iser_task->iser_conn;
-       struct ib_conn *ib_conn = &iser_conn->ib_conn;
-       struct fast_reg_descriptor *desc = reg->mem_h;
-
-       if (!desc)
-               return;
-
-       reg->mem_h = NULL;
-       spin_lock_bh(&ib_conn->lock);
-       list_add_tail(&desc->list, &ib_conn->fastreg.pool);
-       spin_unlock_bh(&ib_conn->lock);
-}
-
 int iser_post_recvl(struct iser_conn *iser_conn)
 {
        struct ib_recv_wr rx_wr, *rx_wr_failed;