summaryrefslogtreecommitdiffstats
path: root/hw/rdma
diff options
context:
space:
mode:
authorYuval Shaia2020-03-20 15:34:28 +0100
committerMarcel Apfelbaum2020-03-21 18:16:02 +0100
commitf23601515b61ffe23398079cbfd6be0b9b99ec02 (patch)
treeb1b08c3c9d6465c87e926851dd0383e6b9ccc97a /hw/rdma
parenthw/rdma/vmw/pvrdma_dev_ring: Replace strncpy with pstrcpy (diff)
downloadqemu-f23601515b61ffe23398079cbfd6be0b9b99ec02.tar.gz
qemu-f23601515b61ffe23398079cbfd6be0b9b99ec02.tar.xz
qemu-f23601515b61ffe23398079cbfd6be0b9b99ec02.zip
hw/rdma: Cosmetic change - no need for two sge arrays
The function build_host_sge_array uses two sge arrays, one for input and one for output. Since the size of the two arrays is the same, the function can write directly to the given source array (i.e. input/output argument). Signed-off-by: Yuval Shaia <yuval.shaia.ml@gmail.com> Reviewed-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com> Message-Id: <20200320143429.9490-2-yuval.shaia.ml@gmail.com> Signed-off-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Diffstat (limited to 'hw/rdma')
-rw-r--r--hw/rdma/rdma_backend.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c
index c346407cd3..b7ffbef9c0 100644
--- a/hw/rdma/rdma_backend.c
+++ b/hw/rdma/rdma_backend.c
@@ -378,30 +378,25 @@ static void ah_cache_init(void)
}
static int build_host_sge_array(RdmaDeviceResources *rdma_dev_res,
- struct ibv_sge *dsge, struct ibv_sge *ssge,
- uint8_t num_sge, uint64_t *total_length)
+ struct ibv_sge *sge, uint8_t num_sge,
+ uint64_t *total_length)
{
RdmaRmMR *mr;
- int ssge_idx;
+ int idx;
- for (ssge_idx = 0; ssge_idx < num_sge; ssge_idx++) {
- mr = rdma_rm_get_mr(rdma_dev_res, ssge[ssge_idx].lkey);
+ for (idx = 0; idx < num_sge; idx++) {
+ mr = rdma_rm_get_mr(rdma_dev_res, sge[idx].lkey);
if (unlikely(!mr)) {
- rdma_error_report("Invalid lkey 0x%x", ssge[ssge_idx].lkey);
- return VENDOR_ERR_INVLKEY | ssge[ssge_idx].lkey;
+ rdma_error_report("Invalid lkey 0x%x", sge[idx].lkey);
+ return VENDOR_ERR_INVLKEY | sge[idx].lkey;
}
#ifdef LEGACY_RDMA_REG_MR
- dsge->addr = (uintptr_t)mr->virt + ssge[ssge_idx].addr - mr->start;
-#else
- dsge->addr = ssge[ssge_idx].addr;
+ sge[idx].addr = (uintptr_t)mr->virt + sge[idx].addr - mr->start;
#endif
- dsge->length = ssge[ssge_idx].length;
- dsge->lkey = rdma_backend_mr_lkey(&mr->backend_mr);
-
- *total_length += dsge->length;
+ sge[idx].lkey = rdma_backend_mr_lkey(&mr->backend_mr);
- dsge++;
+ *total_length += sge[idx].length;
}
return 0;
@@ -484,7 +479,6 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev,
void *ctx)
{
BackendCtx *bctx;
- struct ibv_sge new_sge[MAX_SGE];
uint32_t bctx_id;
int rc;
struct ibv_send_wr wr = {}, *bad_wr;
@@ -518,7 +512,7 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev,
rdma_protected_gslist_append_int32(&qp->cqe_ctx_list, bctx_id);
- rc = build_host_sge_array(backend_dev->rdma_dev_res, new_sge, sge, num_sge,
+ rc = build_host_sge_array(backend_dev->rdma_dev_res, sge, num_sge,
&backend_dev->rdma_dev_res->stats.tx_len);
if (rc) {
complete_work(IBV_WC_GENERAL_ERR, rc, ctx);
@@ -538,7 +532,7 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev,
wr.num_sge = num_sge;
wr.opcode = IBV_WR_SEND;
wr.send_flags = IBV_SEND_SIGNALED;
- wr.sg_list = new_sge;
+ wr.sg_list = sge;
wr.wr_id = bctx_id;
rc = ibv_post_send(qp->ibqp, &wr, &bad_wr);
@@ -601,7 +595,6 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
struct ibv_sge *sge, uint32_t num_sge, void *ctx)
{
BackendCtx *bctx;
- struct ibv_sge new_sge[MAX_SGE];
uint32_t bctx_id;
int rc;
struct ibv_recv_wr wr = {}, *bad_wr;
@@ -635,7 +628,7 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
rdma_protected_gslist_append_int32(&qp->cqe_ctx_list, bctx_id);
- rc = build_host_sge_array(backend_dev->rdma_dev_res, new_sge, sge, num_sge,
+ rc = build_host_sge_array(backend_dev->rdma_dev_res, sge, num_sge,
&backend_dev->rdma_dev_res->stats.rx_bufs_len);
if (rc) {
complete_work(IBV_WC_GENERAL_ERR, rc, ctx);
@@ -643,7 +636,7 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
}
wr.num_sge = num_sge;
- wr.sg_list = new_sge;
+ wr.sg_list = sge;
wr.wr_id = bctx_id;
rc = ibv_post_recv(qp->ibqp, &wr, &bad_wr);
if (rc) {
@@ -671,7 +664,6 @@ void rdma_backend_post_srq_recv(RdmaBackendDev *backend_dev,
uint32_t num_sge, void *ctx)
{
BackendCtx *bctx;
- struct ibv_sge new_sge[MAX_SGE];
uint32_t bctx_id;
int rc;
struct ibv_recv_wr wr = {}, *bad_wr;
@@ -688,7 +680,7 @@ void rdma_backend_post_srq_recv(RdmaBackendDev *backend_dev,
rdma_protected_gslist_append_int32(&srq->cqe_ctx_list, bctx_id);
- rc = build_host_sge_array(backend_dev->rdma_dev_res, new_sge, sge, num_sge,
+ rc = build_host_sge_array(backend_dev->rdma_dev_res, sge, num_sge,
&backend_dev->rdma_dev_res->stats.rx_bufs_len);
if (rc) {
complete_work(IBV_WC_GENERAL_ERR, rc, ctx);
@@ -696,7 +688,7 @@ void rdma_backend_post_srq_recv(RdmaBackendDev *backend_dev,
}
wr.num_sge = num_sge;
- wr.sg_list = new_sge;
+ wr.sg_list = sge;
wr.wr_id = bctx_id;
rc = ibv_post_srq_recv(srq->ibsrq, &wr, &bad_wr);
if (rc) {