summaryrefslogtreecommitdiff
path: root/hw/rdma/rdma_utils.c
diff options
context:
space:
mode:
authorYuval Shaia <yuval.shaia@oracle.com>2019-03-11 03:29:11 -0700
committerMarcel Apfelbaum <marcel.apfelbaum@gmail.com>2019-03-16 15:52:44 +0200
commitbf4414515b468c0a4ca69f1450bfe65418022955 (patch)
treee0e2a604c711f0218376dd6285f638dfce85faaa /hw/rdma/rdma_utils.c
parentff30a446b1d13373d35417d77d80b11cfde3fc6c (diff)
downloadqemu-bf4414515b468c0a4ca69f1450bfe65418022955.zip
hw/rdma: Free all receive buffers when QP is destroyed
When QP is destroyed the backend QP is destroyed as well. This ensures we clean all received buffer we posted to it. However, a contexts of these buffers are still remain in the device. Fix it by maintaining a list of buffer's context and free them when QP is destroyed. Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com> Reviewed-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com> Message-Id: <1552300155-25216-8-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_utils.c')
-rw-r--r--hw/rdma/rdma_utils.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/hw/rdma/rdma_utils.c b/hw/rdma/rdma_utils.c
index 0a8abe572d..73f279104c 100644
--- a/hw/rdma/rdma_utils.c
+++ b/hw/rdma/rdma_utils.c
@@ -90,3 +90,32 @@ int64_t rdma_protected_qlist_pop_int64(RdmaProtectedQList *list)
return qnum_get_uint(qobject_to(QNum, obj));
}
+
+void rdma_protected_gslist_init(RdmaProtectedGSList *list)
+{
+ qemu_mutex_init(&list->lock);
+}
+
+void rdma_protected_gslist_destroy(RdmaProtectedGSList *list)
+{
+ if (list->list) {
+ g_slist_free(list->list);
+ list->list = NULL;
+ }
+}
+
+void rdma_protected_gslist_append_int32(RdmaProtectedGSList *list,
+ int32_t value)
+{
+ qemu_mutex_lock(&list->lock);
+ list->list = g_slist_prepend(list->list, GINT_TO_POINTER(value));
+ qemu_mutex_unlock(&list->lock);
+}
+
+void rdma_protected_gslist_remove_int32(RdmaProtectedGSList *list,
+ int32_t value)
+{
+ qemu_mutex_lock(&list->lock);
+ list->list = g_slist_remove(list->list, GINT_TO_POINTER(value));
+ qemu_mutex_unlock(&list->lock);
+}