Commit db421a54 authored by Michael J. Ruhl's avatar Michael J. Ruhl Committed by Doug Ledford

IB/{hfi1, qib, rvt} Cleanup open coded sge usage

Several locations for manipulating sges use an open coded sequence
that is covered by helper functions.

Use the appropriate helper functions.
Signed-off-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 87fc34b5
...@@ -222,31 +222,11 @@ static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe) ...@@ -222,31 +222,11 @@ static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
ssge.num_sge = swqe->wr.num_sge; ssge.num_sge = swqe->wr.num_sge;
sge = &ssge.sge; sge = &ssge.sge;
while (length) { while (length) {
u32 len = sge->length; u32 len = rvt_get_sge_length(sge, length);
if (len > length)
len = length;
if (len > sge->sge_length)
len = sge->sge_length;
WARN_ON_ONCE(len == 0); WARN_ON_ONCE(len == 0);
rvt_copy_sge(qp, &qp->r_sge, sge->vaddr, len, true, false); rvt_copy_sge(qp, &qp->r_sge, sge->vaddr, len, true, false);
sge->vaddr += len; rvt_update_sge(&ssge, len, false);
sge->length -= len;
sge->sge_length -= len;
if (sge->sge_length == 0) {
if (--ssge.num_sge)
*sge = *ssge.sg_list++;
} else if (sge->length == 0 && sge->mr->lkey) {
if (++sge->n >= RVT_SEGSZ) {
if (++sge->m >= sge->mr->mapsz)
break;
sge->n = 0;
}
sge->vaddr =
sge->mr->map[sge->m]->segs[sge->n].vaddr;
sge->length =
sge->mr->map[sge->m]->segs[sge->n].length;
}
length -= len; length -= len;
} }
rvt_put_ss(&qp->r_sge); rvt_put_ss(&qp->r_sge);
......
...@@ -565,13 +565,8 @@ int qib_sdma_verbs_send(struct qib_pportdata *ppd, ...@@ -565,13 +565,8 @@ int qib_sdma_verbs_send(struct qib_pportdata *ppd,
sge = &ss->sge; sge = &ss->sge;
while (dwords) { while (dwords) {
u32 dw; u32 dw;
u32 len; u32 len = rvt_get_sge_length(sge, dwords << 2);
len = dwords << 2;
if (len > sge->length)
len = sge->length;
if (len > sge->sge_length)
len = sge->sge_length;
dw = (len + 3) >> 2; dw = (len + 3) >> 2;
addr = dma_map_single(&ppd->dd->pcidev->dev, sge->vaddr, addr = dma_map_single(&ppd->dd->pcidev->dev, sge->vaddr,
dw << 2, DMA_TO_DEVICE); dw << 2, DMA_TO_DEVICE);
...@@ -594,24 +589,7 @@ int qib_sdma_verbs_send(struct qib_pportdata *ppd, ...@@ -594,24 +589,7 @@ int qib_sdma_verbs_send(struct qib_pportdata *ppd,
descqp = &ppd->sdma_descq[0].qw[0]; descqp = &ppd->sdma_descq[0].qw[0];
++ppd->sdma_generation; ++ppd->sdma_generation;
} }
sge->vaddr += len; rvt_update_sge(ss, len, false);
sge->length -= len;
sge->sge_length -= len;
if (sge->sge_length == 0) {
if (--ss->num_sge)
*sge = *ss->sg_list++;
} else if (sge->length == 0 && sge->mr->lkey) {
if (++sge->n >= RVT_SEGSZ) {
if (++sge->m >= sge->mr->mapsz)
break;
sge->n = 0;
}
sge->vaddr =
sge->mr->map[sge->m]->segs[sge->n].vaddr;
sge->length =
sge->mr->map[sge->m]->segs[sge->n].length;
}
dwoffset += dw; dwoffset += dw;
dwords -= dw; dwords -= dw;
} }
......
...@@ -2986,34 +2986,12 @@ void rvt_ruc_loopback(struct rvt_qp *sqp) ...@@ -2986,34 +2986,12 @@ void rvt_ruc_loopback(struct rvt_qp *sqp)
sge = &sqp->s_sge.sge; sge = &sqp->s_sge.sge;
while (sqp->s_len) { while (sqp->s_len) {
u32 len = sqp->s_len; u32 len = rvt_get_sge_length(sge, sqp->s_len);
if (len > sge->length)
len = sge->length;
if (len > sge->sge_length)
len = sge->sge_length;
WARN_ON_ONCE(len == 0); WARN_ON_ONCE(len == 0);
rvt_copy_sge(qp, &qp->r_sge, sge->vaddr, rvt_copy_sge(qp, &qp->r_sge, sge->vaddr,
len, release, copy_last); len, release, copy_last);
sge->vaddr += len; rvt_update_sge(&sqp->s_sge, len, !release);
sge->length -= len;
sge->sge_length -= len;
if (sge->sge_length == 0) {
if (!release)
rvt_put_mr(sge->mr);
if (--sqp->s_sge.num_sge)
*sge = *sqp->s_sge.sg_list++;
} else if (sge->length == 0 && sge->mr->lkey) {
if (++sge->n >= RVT_SEGSZ) {
if (++sge->m >= sge->mr->mapsz)
break;
sge->n = 0;
}
sge->vaddr =
sge->mr->map[sge->m]->segs[sge->n].vaddr;
sge->length =
sge->mr->map[sge->m]->segs[sge->n].length;
}
sqp->s_len -= len; sqp->s_len -= len;
} }
if (release) if (release)
......
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