Commit 002f1567 authored by Bart Van Assche's avatar Bart Van Assche Committed by Doug Ledford

IB/srp: Introduce srp_device.use_fmr

Introduce the variable srp_device.use_fmr. Leave out the dev->has_fr /
dev->has_fmr and ch->fr_pool / ch->fmr_pool checks since these are
redundant. This patch does not change any functionality but makes the
source code easier to read.
Signed-off-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 3ae95da8
...@@ -546,7 +546,7 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch) ...@@ -546,7 +546,7 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch)
if (ret) if (ret)
goto err_qp; goto err_qp;
if (dev->use_fast_reg && dev->has_fr) { if (dev->use_fast_reg) {
fr_pool = srp_alloc_fr_pool(target); fr_pool = srp_alloc_fr_pool(target);
if (IS_ERR(fr_pool)) { if (IS_ERR(fr_pool)) {
ret = PTR_ERR(fr_pool); ret = PTR_ERR(fr_pool);
...@@ -557,7 +557,7 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch) ...@@ -557,7 +557,7 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch)
if (ch->fr_pool) if (ch->fr_pool)
srp_destroy_fr_pool(ch->fr_pool); srp_destroy_fr_pool(ch->fr_pool);
ch->fr_pool = fr_pool; ch->fr_pool = fr_pool;
} else if (!dev->use_fast_reg && dev->has_fmr) { } else if (dev->use_fmr) {
fmr_pool = srp_alloc_fmr_pool(target); fmr_pool = srp_alloc_fmr_pool(target);
if (IS_ERR(fmr_pool)) { if (IS_ERR(fmr_pool)) {
ret = PTR_ERR(fmr_pool); ret = PTR_ERR(fmr_pool);
...@@ -623,7 +623,7 @@ static void srp_free_ch_ib(struct srp_target_port *target, ...@@ -623,7 +623,7 @@ static void srp_free_ch_ib(struct srp_target_port *target,
if (dev->use_fast_reg) { if (dev->use_fast_reg) {
if (ch->fr_pool) if (ch->fr_pool)
srp_destroy_fr_pool(ch->fr_pool); srp_destroy_fr_pool(ch->fr_pool);
} else { } else if (dev->use_fmr) {
if (ch->fmr_pool) if (ch->fmr_pool)
ib_destroy_fmr_pool(ch->fmr_pool); ib_destroy_fmr_pool(ch->fmr_pool);
} }
...@@ -1085,7 +1085,7 @@ static void srp_unmap_data(struct scsi_cmnd *scmnd, ...@@ -1085,7 +1085,7 @@ static void srp_unmap_data(struct scsi_cmnd *scmnd,
if (req->nmdesc) if (req->nmdesc)
srp_fr_pool_put(ch->fr_pool, req->fr_list, srp_fr_pool_put(ch->fr_pool, req->fr_list,
req->nmdesc); req->nmdesc);
} else { } else if (dev->use_fmr) {
struct ib_pool_fmr **pfmr; struct ib_pool_fmr **pfmr;
for (i = req->nmdesc, pfmr = req->fmr_list; i > 0; i--, pfmr++) for (i = req->nmdesc, pfmr = req->fmr_list; i > 0; i--, pfmr++)
...@@ -1345,8 +1345,11 @@ static int srp_finish_mapping(struct srp_map_state *state, ...@@ -1345,8 +1345,11 @@ static int srp_finish_mapping(struct srp_map_state *state,
struct srp_rdma_ch *ch) struct srp_rdma_ch *ch)
{ {
struct srp_target_port *target = ch->target; struct srp_target_port *target = ch->target;
struct srp_device *dev = target->srp_host->srp_dev;
int ret = 0; int ret = 0;
WARN_ON_ONCE(!dev->use_fast_reg && !dev->use_fmr);
if (state->npages == 0) if (state->npages == 0)
return 0; return 0;
...@@ -1354,8 +1357,7 @@ static int srp_finish_mapping(struct srp_map_state *state, ...@@ -1354,8 +1357,7 @@ static int srp_finish_mapping(struct srp_map_state *state,
srp_map_desc(state, state->base_dma_addr, state->dma_len, srp_map_desc(state, state->base_dma_addr, state->dma_len,
target->rkey); target->rkey);
else else
ret = target->srp_host->srp_dev->use_fast_reg ? ret = dev->use_fast_reg ? srp_map_finish_fr(state, ch) :
srp_map_finish_fr(state, ch) :
srp_map_finish_fmr(state, ch); srp_map_finish_fmr(state, ch);
if (ret == 0) { if (ret == 0) {
...@@ -1417,21 +1419,18 @@ static int srp_map_sg(struct srp_map_state *state, struct srp_rdma_ch *ch, ...@@ -1417,21 +1419,18 @@ static int srp_map_sg(struct srp_map_state *state, struct srp_rdma_ch *ch,
struct srp_device *dev = target->srp_host->srp_dev; struct srp_device *dev = target->srp_host->srp_dev;
struct scatterlist *sg; struct scatterlist *sg;
int i, ret; int i, ret;
bool use_mr;
state->desc = req->indirect_desc; state->desc = req->indirect_desc;
state->pages = req->map_page; state->pages = req->map_page;
if (dev->use_fast_reg) { if (dev->use_fast_reg) {
state->fr.next = req->fr_list; state->fr.next = req->fr_list;
state->fr.end = req->fr_list + target->cmd_sg_cnt; state->fr.end = req->fr_list + target->cmd_sg_cnt;
use_mr = !!ch->fr_pool; } else if (dev->use_fmr) {
} else {
state->fmr.next = req->fmr_list; state->fmr.next = req->fmr_list;
state->fmr.end = req->fmr_list + target->cmd_sg_cnt; state->fmr.end = req->fmr_list + target->cmd_sg_cnt;
use_mr = !!ch->fmr_pool;
} }
if (use_mr) { if (dev->use_fast_reg || dev->use_fmr) {
for_each_sg(scat, sg, count, i) { for_each_sg(scat, sg, count, i) {
ret = srp_map_sg_entry(state, ch, sg, i); ret = srp_map_sg_entry(state, ch, sg, i);
if (ret) if (ret)
...@@ -3364,6 +3363,7 @@ static void srp_add_one(struct ib_device *device) ...@@ -3364,6 +3363,7 @@ static void srp_add_one(struct ib_device *device)
srp_dev->use_fast_reg = (srp_dev->has_fr && srp_dev->use_fast_reg = (srp_dev->has_fr &&
(!srp_dev->has_fmr || prefer_fr)); (!srp_dev->has_fmr || prefer_fr));
srp_dev->use_fmr = !srp_dev->use_fast_reg && srp_dev->has_fmr;
/* /*
* Use the smallest page size supported by the HCA, down to a * Use the smallest page size supported by the HCA, down to a
......
...@@ -102,6 +102,7 @@ struct srp_device { ...@@ -102,6 +102,7 @@ struct srp_device {
int max_pages_per_mr; int max_pages_per_mr;
bool has_fmr; bool has_fmr;
bool has_fr; bool has_fr;
bool use_fmr;
bool use_fast_reg; bool use_fast_reg;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment