Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 34328
b: refs/heads/master
c: 8dfa087
h: refs/heads/master
v: v3
  • Loading branch information
Erez Zilber authored and Roland Dreier committed Sep 22, 2006
1 parent 725ad13 commit 964c060
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8072ec2f8f6790df91e85d833e672c9c30a7ab3c
refs/heads/master: 8dfa0876d3dde5f9c1818a4c35caaabc3ddba78b
6 changes: 5 additions & 1 deletion trunk/drivers/infiniband/ulp/iser/iscsi_iser.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@
__func__ , ## arg); \
} while (0)

#define SHIFT_4K 12
#define SIZE_4K (1UL << SHIFT_4K)
#define MASK_4K (~(SIZE_4K-1))

/* support upto 512KB in one RDMA */
#define ISCSI_ISER_SG_TABLESIZE (0x80000 >> PAGE_SHIFT)
#define ISCSI_ISER_SG_TABLESIZE (0x80000 >> SHIFT_4K)
#define ISCSI_ISER_MAX_LUN 256
#define ISCSI_ISER_MAX_CMD_LEN 16

Expand Down
31 changes: 20 additions & 11 deletions trunk/drivers/infiniband/ulp/iser/iser_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "iscsi_iser.h"

#define ISER_KMALLOC_THRESHOLD 0x20000 /* 128K - kmalloc limit */

/**
* Decrements the reference count for the
* registered buffer & releases it
Expand Down Expand Up @@ -239,38 +240,46 @@ static int iser_sg_to_page_vec(struct iser_data_buf *data,
int i;

/* compute the offset of first element */
page_vec->offset = (u64) sg[0].offset;
page_vec->offset = (u64) sg[0].offset & ~MASK_4K;

for (i = 0; i < data->dma_nents; i++) {
total_sz += sg_dma_len(&sg[i]);

first_addr = sg_dma_address(&sg[i]);
last_addr = first_addr + sg_dma_len(&sg[i]);

start_aligned = !(first_addr & ~PAGE_MASK);
end_aligned = !(last_addr & ~PAGE_MASK);
start_aligned = !(first_addr & ~MASK_4K);
end_aligned = !(last_addr & ~MASK_4K);

/* continue to collect page fragments till aligned or SG ends */
while (!end_aligned && (i + 1 < data->dma_nents)) {
i++;
total_sz += sg_dma_len(&sg[i]);
last_addr = sg_dma_address(&sg[i]) + sg_dma_len(&sg[i]);
end_aligned = !(last_addr & ~PAGE_MASK);
end_aligned = !(last_addr & ~MASK_4K);
}

first_addr = first_addr & PAGE_MASK;

for (page = first_addr; page < last_addr; page += PAGE_SIZE)
page_vec->pages[cur_page++] = page;
/* handle the 1st page in the 1st DMA element */
if (cur_page == 0) {
page = first_addr & MASK_4K;
page_vec->pages[cur_page] = page;
cur_page++;
page += SIZE_4K;
} else
page = first_addr;

for (; page < last_addr; page += SIZE_4K) {
page_vec->pages[cur_page] = page;
cur_page++;
}

}
page_vec->data_size = total_sz;
iser_dbg("page_vec->data_size:%d cur_page %d\n", page_vec->data_size,cur_page);
return cur_page;
}

#define MASK_4K ((1UL << 12) - 1) /* 0xFFF */
#define IS_4K_ALIGNED(addr) ((((unsigned long)addr) & MASK_4K) == 0)
#define IS_4K_ALIGNED(addr) ((((unsigned long)addr) & ~MASK_4K) == 0)

/**
* iser_data_buf_aligned_len - Tries to determine the maximal correctly aligned
Expand Down Expand Up @@ -352,7 +361,7 @@ static void iser_page_vec_build(struct iser_data_buf *data,

page_vec->length = page_vec_len;

if (page_vec_len * PAGE_SIZE < page_vec->data_size) {
if (page_vec_len * SIZE_4K < page_vec->data_size) {
iser_err("page_vec too short to hold this SG\n");
iser_data_buf_dump(data);
iser_dump_page_vec(page_vec);
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/infiniband/ulp/iser/iser_verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static int iser_create_ib_conn_res(struct iser_conn *ib_conn)
}
ib_conn->page_vec->pages = (u64 *) (ib_conn->page_vec + 1);

params.page_shift = PAGE_SHIFT;
params.page_shift = SHIFT_4K;
/* when the first/last SG element are not start/end *
* page aligned, the map whould be of N+1 pages */
params.max_pages_per_fmr = ISCSI_ISER_SG_TABLESIZE + 1;
Expand Down Expand Up @@ -604,7 +604,7 @@ int iser_reg_page_vec(struct iser_conn *ib_conn,

mem_reg->lkey = mem->fmr->lkey;
mem_reg->rkey = mem->fmr->rkey;
mem_reg->len = page_vec->length * PAGE_SIZE;
mem_reg->len = page_vec->length * SIZE_4K;
mem_reg->va = io_addr;
mem_reg->mem_h = (void *)mem;

Expand Down

0 comments on commit 964c060

Please sign in to comment.