IB/iser: remove redundant macro definitions
authorMax Gurtovoy <maxg@mellanox.com>
Tue, 24 Sep 2019 21:05:48 +0000 (00:05 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 1 Oct 2019 14:27:13 +0000 (11:27 -0300)
Use the general linux definition for 4K and retrieve the rest from it.

Link: https://lore.kernel.org/r/1569359148-12312-1-git-send-email-maxg@mellanox.com
Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/ulp/iser/iscsi_iser.c
drivers/infiniband/ulp/iser/iscsi_iser.h
drivers/infiniband/ulp/iser/iser_memory.c
drivers/infiniband/ulp/iser/iser_verbs.c

index c4c015c..55f45ed 100644 (file)
@@ -653,7 +653,7 @@ iscsi_iser_session_create(struct iscsi_endpoint *ep,
                }
 
                if (!(ib_dev->attrs.device_cap_flags & IB_DEVICE_SG_GAPS_REG))
-                       shost->virt_boundary_mask = ~MASK_4K;
+                       shost->virt_boundary_mask = SZ_4K - 1;
 
                if (iscsi_host_add(shost, ib_dev->dev.parent)) {
                        mutex_unlock(&iser_conn->state_mutex);
index 52ce635..2500c0d 100644 (file)
 #define iser_err(fmt, arg...) \
        pr_err(PFX "%s: " fmt, __func__ , ## arg)
 
-#define SHIFT_4K       12
-#define SIZE_4K        (1ULL << SHIFT_4K)
-#define MASK_4K        (~(SIZE_4K-1))
-
 /* Default support is 512KB I/O size */
 #define ISER_DEF_MAX_SECTORS           1024
 #define ISCSI_ISER_DEF_SG_TABLESIZE                                            \
-       ((ISER_DEF_MAX_SECTORS * SECTOR_SIZE) >> SHIFT_4K)
+       ((ISER_DEF_MAX_SECTORS * SECTOR_SIZE) >> ilog2(SZ_4K))
 /* Maximum support is 16MB I/O size */
-#define ISCSI_ISER_MAX_SG_TABLESIZE    ((32768 * SECTOR_SIZE) >> SHIFT_4K)
+#define ISCSI_ISER_MAX_SG_TABLESIZE ((32768 * SECTOR_SIZE) >> ilog2(SZ_4K))
 
 #define ISER_DEF_XMIT_CMDS_DEFAULT             512
 #if ISCSI_DEF_XMIT_CMDS_MAX > ISER_DEF_XMIT_CMDS_DEFAULT
index 3a26e5b..0f74dc6 100644 (file)
@@ -237,7 +237,7 @@ int iser_fast_reg_fmr(struct iscsi_iser_task *iser_task,
        int ret, plen;
 
        page_vec->npages = 0;
-       page_vec->fake_mr.page_size = SIZE_4K;
+       page_vec->fake_mr.page_size = SZ_4K;
        plen = ib_sg_to_pages(&page_vec->fake_mr, mem->sg,
                              mem->dma_nents, NULL, iser_set_page);
        if (unlikely(plen < mem->dma_nents)) {
@@ -451,7 +451,7 @@ static int iser_fast_reg_mr(struct iscsi_iser_task *iser_task,
 
        ib_update_fast_reg_key(mr, ib_inc_rkey(mr->rkey));
 
-       n = ib_map_mr_sg(mr, mem->sg, mem->dma_nents, NULL, SIZE_4K);
+       n = ib_map_mr_sg(mr, mem->sg, mem->dma_nents, NULL, SZ_4K);
        if (unlikely(n != mem->dma_nents)) {
                iser_err("failed to map sg (%d/%d)\n",
                         n, mem->dma_nents);
index 94b5011..17f8e91 100644 (file)
@@ -180,7 +180,7 @@ int iser_alloc_fmr_pool(struct ib_conn *ib_conn,
 
        page_vec->pages = (u64 *)(page_vec + 1);
 
-       params.page_shift        = SHIFT_4K;
+       params.page_shift        = ilog2(SZ_4K);
        params.max_pages_per_fmr = size;
        /* make the pool size twice the max number of SCSI commands *
         * the ML is expected to queue, watermark for unmap at 50%  */
@@ -670,7 +670,7 @@ iser_calc_scsi_params(struct iser_conn *iser_conn,
        else
                max_num_sg = attr->max_fast_reg_page_list_len;
 
-       sg_tablesize = DIV_ROUND_UP(max_sectors * 512, SIZE_4K);
+       sg_tablesize = DIV_ROUND_UP(max_sectors * SECTOR_SIZE, SZ_4K);
        if (attr->device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS)
                sup_sg_tablesize =
                        min_t(