From owner-svn-src-all@freebsd.org Sat May 27 02:05:23 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 14C90D8313E; Sat, 27 May 2017 02:05:23 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BDED814A6; Sat, 27 May 2017 02:05:22 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v4R25Leq038630; Sat, 27 May 2017 02:05:21 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4R25LWu038629; Sat, 27 May 2017 02:05:21 GMT (envelope-from np@FreeBSD.org) Message-Id: <201705270205.v4R25LWu038629@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Sat, 27 May 2017 02:05:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r318973 - head/contrib/ofed/libcxgb4/src X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 May 2017 02:05:23 -0000 Author: np Date: Sat May 27 02:05:21 2017 New Revision: 318973 URL: https://svnweb.freebsd.org/changeset/base/318973 Log: 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 Modified: head/contrib/ofed/libcxgb4/src/qp.c Modified: head/contrib/ofed/libcxgb4/src/qp.c ============================================================================== --- head/contrib/ofed/libcxgb4/src/qp.c Sat May 27 01:35:59 2017 (r318972) +++ head/contrib/ofed/libcxgb4/src/qp.c Sat May 27 02:05:21 2017 (r318973) @@ -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) { - u64 *src, *dst; - - src = (u64 *)wqe; - dst = (u64 *)((u8 *)wq->sq.queue + wq->sq.wq_pidx * T4_EQ_ENTRY_SIZE); + void *src, *dst; + uintptr_t end; + int total, len; + + src = &wqe->flits[0]; + dst = &wq->sq.queue->flits[wq->sq.wq_pidx * + (T4_EQ_ENTRY_SIZE / sizeof(__be64))]; if (t4_sq_onchip(wq)) { len16 = align(len16, 4); wc_wmb(); } - while (len16) { - *dst++ = *src++; - if (dst == (u64 *)&wq->sq.queue[wq->sq.size]) - dst = (u64 *)wq->sq.queue; - *dst++ = *src++; - if (dst == (u64 *)&wq->sq.queue[wq->sq.size]) - dst = (u64 *)wq->sq.queue; - len16--; + + total = len16 * 16; + end = (uintptr_t)&wq->sq.queue[wq->sq.size]; + if (__predict_true((uintptr_t)dst + total <= end)) { + /* Won't wrap around. */ + memcpy(dst, src, total); + } else { + 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) { - u64 *src, *dst; - - src = (u64 *)wqe; - dst = (u64 *)((u8 *)wq->rq.queue + wq->rq.wq_pidx * T4_EQ_ENTRY_SIZE); - while (len16) { - *dst++ = *src++; - if (dst >= (u64 *)&wq->rq.queue[wq->rq.size]) - dst = (u64 *)wq->rq.queue; - *dst++ = *src++; - if (dst >= (u64 *)&wq->rq.queue[wq->rq.size]) - dst = (u64 *)wq->rq.queue; - len16--; + void *src, *dst; + uintptr_t end; + int total, len; + + src = &wqe->flits[0]; + dst = &wq->rq.queue->flits[wq->rq.wq_pidx * + (T4_EQ_ENTRY_SIZE / sizeof(__be64))]; + + total = len16 * 16; + end = (uintptr_t)&wq->rq.queue[wq->rq.size]; + if (__predict_true((uintptr_t)dst + total <= end)) { + /* Won't wrap around. */ + memcpy(dst, src, total); + } else { + len = end - (uintptr_t)dst; + memcpy(dst, src, len); + memcpy(wq->rq.queue, src + len, total - len); } }