aboutsummaryrefslogtreecommitdiff
path: root/hw/rdma/rdma_backend.c
diff options
context:
space:
mode:
authorYuval Shaia <yuval.shaia@oracle.com>2019-03-11 03:29:06 -0700
committerMarcel Apfelbaum <marcel.apfelbaum@gmail.com>2019-03-16 15:52:44 +0200
commitb20fc7951084bb77e867d114c916e409c3a6821a (patch)
treef170d8a7d802e848a88ef392431dea76a69541aa /hw/rdma/rdma_backend.c
parent4d71b38ae8fa436f1707fe98b469a9cea4079503 (diff)
hw/rdma: Introduce protected qlist
To make code more readable move handling of protected list to a rdma_utils Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com> Reviewed-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com> Message-Id: <1552300155-25216-3-git-send-email-yuval.shaia@oracle.com> Reviewed-by: Kamal Heib <kamalheib1@gmail.com> Signed-off-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Diffstat (limited to 'hw/rdma/rdma_backend.c')
-rw-r--r--hw/rdma/rdma_backend.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c
index d138591c86..37edf42215 100644
--- a/hw/rdma/rdma_backend.c
+++ b/hw/rdma/rdma_backend.c
@@ -527,9 +527,7 @@ static unsigned int save_mad_recv_buffer(RdmaBackendDev *backend_dev,
bctx->up_ctx = ctx;
bctx->sge = *sge;
- qemu_mutex_lock(&backend_dev->recv_mads_list.lock);
- qlist_append_int(backend_dev->recv_mads_list.list, bctx_id);
- qemu_mutex_unlock(&backend_dev->recv_mads_list.lock);
+ rdma_protected_qlist_append_int64(&backend_dev->recv_mads_list, bctx_id);
return 0;
}
@@ -913,23 +911,19 @@ static inline void build_mad_hdr(struct ibv_grh *grh, union ibv_gid *sgid,
static void process_incoming_mad_req(RdmaBackendDev *backend_dev,
RdmaCmMuxMsg *msg)
{
- QObject *o_ctx_id;
unsigned long cqe_ctx_id;
BackendCtx *bctx;
char *mad;
trace_mad_message("recv", msg->umad.mad, msg->umad_len);
- qemu_mutex_lock(&backend_dev->recv_mads_list.lock);
- o_ctx_id = qlist_pop(backend_dev->recv_mads_list.list);
- qemu_mutex_unlock(&backend_dev->recv_mads_list.lock);
- if (!o_ctx_id) {
+ cqe_ctx_id = rdma_protected_qlist_pop_int64(&backend_dev->recv_mads_list);
+ if (cqe_ctx_id == -ENOENT) {
rdma_warn_report("No more free MADs buffers, waiting for a while");
sleep(THR_POLL_TO);
return;
}
- cqe_ctx_id = qnum_get_uint(qobject_to(QNum, o_ctx_id));
bctx = rdma_rm_get_cqe_ctx(backend_dev->rdma_dev_res, cqe_ctx_id);
if (unlikely(!bctx)) {
rdma_error_report("No matching ctx for req %ld", cqe_ctx_id);
@@ -994,8 +988,7 @@ static int mad_init(RdmaBackendDev *backend_dev, CharBackend *mad_chr_be)
return -EIO;
}
- qemu_mutex_init(&backend_dev->recv_mads_list.lock);
- backend_dev->recv_mads_list.list = qlist_new();
+ rdma_protected_qlist_init(&backend_dev->recv_mads_list);
enable_rdmacm_mux_async(backend_dev);
@@ -1010,10 +1003,7 @@ static void mad_fini(RdmaBackendDev *backend_dev)
{
disable_rdmacm_mux_async(backend_dev);
qemu_chr_fe_disconnect(backend_dev->rdmacm_mux.chr_be);
- if (backend_dev->recv_mads_list.list) {
- qlist_destroy_obj(QOBJECT(backend_dev->recv_mads_list.list));
- qemu_mutex_destroy(&backend_dev->recv_mads_list.lock);
- }
+ rdma_protected_qlist_destroy(&backend_dev->recv_mads_list);
}
int rdma_backend_get_gid_index(RdmaBackendDev *backend_dev,