libcxgb4: Use memcpy instead of copying WRs 8B at a time in the userspace
RDMA library for cxgbe(4). MFC after: 3 days Sponsored by: Chelsio Communications
This commit is contained in:
parent
41cf0d54a2
commit
7de5a71e79
@ -47,39 +47,49 @@ struct c4iw_stats c4iw_stats;
|
|||||||
|
|
||||||
static void copy_wr_to_sq(struct t4_wq *wq, union t4_wr *wqe, u8 len16)
|
static void copy_wr_to_sq(struct t4_wq *wq, union t4_wr *wqe, u8 len16)
|
||||||
{
|
{
|
||||||
u64 *src, *dst;
|
void *src, *dst;
|
||||||
|
uintptr_t end;
|
||||||
|
int total, len;
|
||||||
|
|
||||||
src = (u64 *)wqe;
|
src = &wqe->flits[0];
|
||||||
dst = (u64 *)((u8 *)wq->sq.queue + wq->sq.wq_pidx * T4_EQ_ENTRY_SIZE);
|
dst = &wq->sq.queue->flits[wq->sq.wq_pidx *
|
||||||
|
(T4_EQ_ENTRY_SIZE / sizeof(__be64))];
|
||||||
if (t4_sq_onchip(wq)) {
|
if (t4_sq_onchip(wq)) {
|
||||||
len16 = align(len16, 4);
|
len16 = align(len16, 4);
|
||||||
wc_wmb();
|
wc_wmb();
|
||||||
}
|
}
|
||||||
while (len16) {
|
|
||||||
*dst++ = *src++;
|
total = len16 * 16;
|
||||||
if (dst == (u64 *)&wq->sq.queue[wq->sq.size])
|
end = (uintptr_t)&wq->sq.queue[wq->sq.size];
|
||||||
dst = (u64 *)wq->sq.queue;
|
if (__predict_true((uintptr_t)dst + total <= end)) {
|
||||||
*dst++ = *src++;
|
/* Won't wrap around. */
|
||||||
if (dst == (u64 *)&wq->sq.queue[wq->sq.size])
|
memcpy(dst, src, total);
|
||||||
dst = (u64 *)wq->sq.queue;
|
} else {
|
||||||
len16--;
|
len = end - (uintptr_t)dst;
|
||||||
|
memcpy(dst, src, len);
|
||||||
|
memcpy(wq->sq.queue, src + len, total - len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copy_wr_to_rq(struct t4_wq *wq, union t4_recv_wr *wqe, u8 len16)
|
static void copy_wr_to_rq(struct t4_wq *wq, union t4_recv_wr *wqe, u8 len16)
|
||||||
{
|
{
|
||||||
u64 *src, *dst;
|
void *src, *dst;
|
||||||
|
uintptr_t end;
|
||||||
|
int total, len;
|
||||||
|
|
||||||
src = (u64 *)wqe;
|
src = &wqe->flits[0];
|
||||||
dst = (u64 *)((u8 *)wq->rq.queue + wq->rq.wq_pidx * T4_EQ_ENTRY_SIZE);
|
dst = &wq->rq.queue->flits[wq->rq.wq_pidx *
|
||||||
while (len16) {
|
(T4_EQ_ENTRY_SIZE / sizeof(__be64))];
|
||||||
*dst++ = *src++;
|
|
||||||
if (dst >= (u64 *)&wq->rq.queue[wq->rq.size])
|
total = len16 * 16;
|
||||||
dst = (u64 *)wq->rq.queue;
|
end = (uintptr_t)&wq->rq.queue[wq->rq.size];
|
||||||
*dst++ = *src++;
|
if (__predict_true((uintptr_t)dst + total <= end)) {
|
||||||
if (dst >= (u64 *)&wq->rq.queue[wq->rq.size])
|
/* Won't wrap around. */
|
||||||
dst = (u64 *)wq->rq.queue;
|
memcpy(dst, src, total);
|
||||||
len16--;
|
} else {
|
||||||
|
len = end - (uintptr_t)dst;
|
||||||
|
memcpy(dst, src, len);
|
||||||
|
memcpy(wq->rq.queue, src + len, total - len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user