Commit 321aebb8 authored by Doug Ledford's avatar Doug Ledford

Merge branches 'mlx5-1' and 'srp-1' into k.o/for-4.7

parents 80835cba 3849e44d
...@@ -316,7 +316,7 @@ static struct ib_fmr_pool *srp_alloc_fmr_pool(struct srp_target_port *target) ...@@ -316,7 +316,7 @@ static struct ib_fmr_pool *srp_alloc_fmr_pool(struct srp_target_port *target)
struct ib_fmr_pool_param fmr_param; struct ib_fmr_pool_param fmr_param;
memset(&fmr_param, 0, sizeof(fmr_param)); memset(&fmr_param, 0, sizeof(fmr_param));
fmr_param.pool_size = target->scsi_host->can_queue; fmr_param.pool_size = target->mr_pool_size;
fmr_param.dirty_watermark = fmr_param.pool_size / 4; fmr_param.dirty_watermark = fmr_param.pool_size / 4;
fmr_param.cache = 1; fmr_param.cache = 1;
fmr_param.max_pages_per_fmr = dev->max_pages_per_mr; fmr_param.max_pages_per_fmr = dev->max_pages_per_mr;
...@@ -441,8 +441,7 @@ static struct srp_fr_pool *srp_alloc_fr_pool(struct srp_target_port *target) ...@@ -441,8 +441,7 @@ static struct srp_fr_pool *srp_alloc_fr_pool(struct srp_target_port *target)
{ {
struct srp_device *dev = target->srp_host->srp_dev; struct srp_device *dev = target->srp_host->srp_dev;
return srp_create_fr_pool(dev->dev, dev->pd, return srp_create_fr_pool(dev->dev, dev->pd, target->mr_pool_size,
target->scsi_host->can_queue,
dev->max_pages_per_mr); dev->max_pages_per_mr);
} }
...@@ -1112,7 +1111,7 @@ static struct scsi_cmnd *srp_claim_req(struct srp_rdma_ch *ch, ...@@ -1112,7 +1111,7 @@ static struct scsi_cmnd *srp_claim_req(struct srp_rdma_ch *ch,
} }
/** /**
* srp_free_req() - Unmap data and add request to the free request list. * srp_free_req() - Unmap data and adjust ch->req_lim.
* @ch: SRP RDMA channel. * @ch: SRP RDMA channel.
* @req: Request to be freed. * @req: Request to be freed.
* @scmnd: SCSI command associated with @req. * @scmnd: SCSI command associated with @req.
...@@ -1316,9 +1315,6 @@ static int srp_map_finish_fr(struct srp_map_state *state, ...@@ -1316,9 +1315,6 @@ static int srp_map_finish_fr(struct srp_map_state *state,
WARN_ON_ONCE(!dev->use_fast_reg); WARN_ON_ONCE(!dev->use_fast_reg);
if (sg_nents == 0)
return 0;
if (sg_nents == 1 && target->global_mr) { if (sg_nents == 1 && target->global_mr) {
srp_map_desc(state, sg_dma_address(state->sg), srp_map_desc(state, sg_dma_address(state->sg),
sg_dma_len(state->sg), sg_dma_len(state->sg),
...@@ -1398,7 +1394,7 @@ static int srp_map_sg_entry(struct srp_map_state *state, ...@@ -1398,7 +1394,7 @@ static int srp_map_sg_entry(struct srp_map_state *state,
/* /*
* If the last entry of the MR wasn't a full page, then we need to * If the last entry of the MR wasn't a full page, then we need to
* close it out and start a new one -- we can only merge at page * close it out and start a new one -- we can only merge at page
* boundries. * boundaries.
*/ */
ret = 0; ret = 0;
if (len != dev->mr_page_size) if (len != dev->mr_page_size)
...@@ -1413,7 +1409,6 @@ static int srp_map_sg_fmr(struct srp_map_state *state, struct srp_rdma_ch *ch, ...@@ -1413,7 +1409,6 @@ static int srp_map_sg_fmr(struct srp_map_state *state, struct srp_rdma_ch *ch,
struct scatterlist *sg; struct scatterlist *sg;
int i, ret; int i, ret;
state->desc = req->indirect_desc;
state->pages = req->map_page; state->pages = req->map_page;
state->fmr.next = req->fmr_list; state->fmr.next = req->fmr_list;
state->fmr.end = req->fmr_list + ch->target->cmd_sg_cnt; state->fmr.end = req->fmr_list + ch->target->cmd_sg_cnt;
...@@ -1428,8 +1423,6 @@ static int srp_map_sg_fmr(struct srp_map_state *state, struct srp_rdma_ch *ch, ...@@ -1428,8 +1423,6 @@ static int srp_map_sg_fmr(struct srp_map_state *state, struct srp_rdma_ch *ch,
if (ret) if (ret)
return ret; return ret;
req->nmdesc = state->nmdesc;
return 0; return 0;
} }
...@@ -1442,6 +1435,9 @@ static int srp_map_sg_fr(struct srp_map_state *state, struct srp_rdma_ch *ch, ...@@ -1442,6 +1435,9 @@ static int srp_map_sg_fr(struct srp_map_state *state, struct srp_rdma_ch *ch,
state->fr.end = req->fr_list + ch->target->cmd_sg_cnt; state->fr.end = req->fr_list + ch->target->cmd_sg_cnt;
state->sg = scat; state->sg = scat;
if (count == 0)
return 0;
while (count) { while (count) {
int i, n; int i, n;
...@@ -1454,8 +1450,6 @@ static int srp_map_sg_fr(struct srp_map_state *state, struct srp_rdma_ch *ch, ...@@ -1454,8 +1450,6 @@ static int srp_map_sg_fr(struct srp_map_state *state, struct srp_rdma_ch *ch,
state->sg = sg_next(state->sg); state->sg = sg_next(state->sg);
} }
req->nmdesc = state->nmdesc;
return 0; return 0;
} }
...@@ -1475,8 +1469,6 @@ static int srp_map_sg_dma(struct srp_map_state *state, struct srp_rdma_ch *ch, ...@@ -1475,8 +1469,6 @@ static int srp_map_sg_dma(struct srp_map_state *state, struct srp_rdma_ch *ch,
target->global_mr->rkey); target->global_mr->rkey);
} }
req->nmdesc = state->nmdesc;
return 0; return 0;
} }
...@@ -1534,6 +1526,15 @@ static int srp_map_idb(struct srp_rdma_ch *ch, struct srp_request *req, ...@@ -1534,6 +1526,15 @@ static int srp_map_idb(struct srp_rdma_ch *ch, struct srp_request *req,
return 0; return 0;
} }
/**
* srp_map_data() - map SCSI data buffer onto an SRP request
* @scmnd: SCSI command to map
* @ch: SRP RDMA channel
* @req: SRP request
*
* Returns the length in bytes of the SRP_CMD IU or a negative value if
* mapping failed.
*/
static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch, static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch,
struct srp_request *req) struct srp_request *req)
{ {
...@@ -1601,11 +1602,14 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch, ...@@ -1601,11 +1602,14 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch,
memset(&state, 0, sizeof(state)); memset(&state, 0, sizeof(state));
if (dev->use_fast_reg) if (dev->use_fast_reg)
srp_map_sg_fr(&state, ch, req, scat, count); ret = srp_map_sg_fr(&state, ch, req, scat, count);
else if (dev->use_fmr) else if (dev->use_fmr)
srp_map_sg_fmr(&state, ch, req, scat, count); ret = srp_map_sg_fmr(&state, ch, req, scat, count);
else else
srp_map_sg_dma(&state, ch, req, scat, count); ret = srp_map_sg_dma(&state, ch, req, scat, count);
req->nmdesc = state.nmdesc;
if (ret < 0)
goto unmap;
/* We've mapped the request, now pull as much of the indirect /* We've mapped the request, now pull as much of the indirect
* descriptor table as we can into the command buffer. If this * descriptor table as we can into the command buffer. If this
...@@ -1628,7 +1632,8 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch, ...@@ -1628,7 +1632,8 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch,
!target->allow_ext_sg)) { !target->allow_ext_sg)) {
shost_printk(KERN_ERR, target->scsi_host, shost_printk(KERN_ERR, target->scsi_host,
"Could not fit S/G list into SRP_CMD\n"); "Could not fit S/G list into SRP_CMD\n");
return -EIO; ret = -EIO;
goto unmap;
} }
count = min(state.ndesc, target->cmd_sg_cnt); count = min(state.ndesc, target->cmd_sg_cnt);
...@@ -1646,7 +1651,7 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch, ...@@ -1646,7 +1651,7 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch,
ret = srp_map_idb(ch, req, state.gen.next, state.gen.end, ret = srp_map_idb(ch, req, state.gen.next, state.gen.end,
idb_len, &idb_rkey); idb_len, &idb_rkey);
if (ret < 0) if (ret < 0)
return ret; goto unmap;
req->nmdesc++; req->nmdesc++;
} else { } else {
idb_rkey = cpu_to_be32(target->global_mr->rkey); idb_rkey = cpu_to_be32(target->global_mr->rkey);
...@@ -1672,6 +1677,12 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch, ...@@ -1672,6 +1677,12 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch,
cmd->buf_fmt = fmt; cmd->buf_fmt = fmt;
return len; return len;
unmap:
srp_unmap_data(scmnd, ch, req);
if (ret == -ENOMEM && req->nmdesc >= target->mr_pool_size)
ret = -E2BIG;
return ret;
} }
/* /*
...@@ -3218,6 +3229,7 @@ static ssize_t srp_create_target(struct device *dev, ...@@ -3218,6 +3229,7 @@ static ssize_t srp_create_target(struct device *dev,
} }
target_host->sg_tablesize = target->sg_tablesize; target_host->sg_tablesize = target->sg_tablesize;
target->mr_pool_size = target->scsi_host->can_queue;
target->indirect_size = target->sg_tablesize * target->indirect_size = target->sg_tablesize *
sizeof (struct srp_direct_buf); sizeof (struct srp_direct_buf);
target->max_iu_len = sizeof (struct srp_cmd) + target->max_iu_len = sizeof (struct srp_cmd) +
......
...@@ -202,6 +202,7 @@ struct srp_target_port { ...@@ -202,6 +202,7 @@ struct srp_target_port {
char target_name[32]; char target_name[32];
unsigned int scsi_id; unsigned int scsi_id;
unsigned int sg_tablesize; unsigned int sg_tablesize;
int mr_pool_size;
int queue_size; int queue_size;
int req_ring_size; int req_ring_size;
int comp_vector; int comp_vector;
......
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