Lines Matching +full:guest +full:- +full:side
1 /*-
4 * SPDX-License-Identifier: (BSD-2-Clause OR GPL-2.0)
76 *------------------------------------------------------------------------------
78 * vmci_queue_pair_alloc --
81 * real work is done in the host or guest specific function.
86 * Side effects:
89 *------------------------------------------------------------------------------
107 *------------------------------------------------------------------------------
109 * vmci_queue_pair_detach --
112 * Real work is done in the host or guest specific function.
117 * Side effects:
120 *------------------------------------------------------------------------------
134 *------------------------------------------------------------------------------
136 * queue_pair_list_init --
143 * Side effects:
146 *------------------------------------------------------------------------------
154 vmci_list_init(&qp_list->head); in queue_pair_list_init()
155 atomic_store_int(&qp_list->hibernate, 0); in queue_pair_list_init()
156 ret = vmci_mutex_init(&qp_list->mutex, "VMCI QP List lock"); in queue_pair_list_init()
161 *------------------------------------------------------------------------------
163 * queue_pair_list_destroy --
170 * Side effects:
173 *------------------------------------------------------------------------------
180 vmci_mutex_destroy(&qp_list->mutex); in queue_pair_list_destroy()
181 vmci_list_init(&qp_list->head); in queue_pair_list_destroy()
185 *------------------------------------------------------------------------------
187 * queue_pair_list_find_entry --
195 * Side effects:
198 *------------------------------------------------------------------------------
210 vmci_list_scan(next, &qp_list->head, list_item) { in queue_pair_list_find_entry()
211 if (VMCI_HANDLE_EQUAL(next->handle, handle)) in queue_pair_list_find_entry()
219 *------------------------------------------------------------------------------
221 * queue_pair_list_add_entry --
228 * Side effects:
231 *------------------------------------------------------------------------------
240 vmci_list_insert(&qp_list->head, entry, list_item); in queue_pair_list_add_entry()
244 *------------------------------------------------------------------------------
246 * queue_pair_list_remove_entry --
253 * Side effects:
256 *------------------------------------------------------------------------------
269 *------------------------------------------------------------------------------
271 * queue_pair_list_get_head --
279 * Side effects:
282 *------------------------------------------------------------------------------
289 return (vmci_list_first(&qp_list->head)); in queue_pair_list_get_head()
293 *------------------------------------------------------------------------------
295 * vmci_qp_guest_endpoints_init --
297 * Initalizes data structure state keeping track of queue pair guest
303 * Side effects:
306 *------------------------------------------------------------------------------
317 *------------------------------------------------------------------------------
319 * vmci_qp_guest_endpoints_exit --
321 * Destroys all guest queue pair endpoints. If active guest queue pairs
328 * Side effects:
331 *------------------------------------------------------------------------------
350 if (!(entry->qp.flags & VMCI_QPFLAG_LOCAL)) in vmci_qp_guest_endpoints_exit()
351 vmci_queue_pair_detach_hypercall(entry->qp.handle); in vmci_qp_guest_endpoints_exit()
355 entry->qp.ref_count = 0; in vmci_qp_guest_endpoints_exit()
356 queue_pair_list_remove_entry(&qp_guest_endpoints, &entry->qp); in vmci_qp_guest_endpoints_exit()
366 *------------------------------------------------------------------------------
368 * vmci_qp_guest_endpoints_sync --
376 * Side effects:
379 *------------------------------------------------------------------------------
391 *------------------------------------------------------------------------------
393 * qp_guest_endpoint_create --
403 * Side effects:
406 *------------------------------------------------------------------------------
452 * We wrapped around --- no rids were free. in qp_guest_endpoint_create()
462 entry->qp.handle = handle; in qp_guest_endpoint_create()
463 entry->qp.peer = peer; in qp_guest_endpoint_create()
464 entry->qp.flags = flags; in qp_guest_endpoint_create()
465 entry->qp.produce_size = produce_size; in qp_guest_endpoint_create()
466 entry->qp.consume_size = consume_size; in qp_guest_endpoint_create()
467 entry->qp.ref_count = 0; in qp_guest_endpoint_create()
468 entry->num_ppns = num_ppns; in qp_guest_endpoint_create()
469 memset(&entry->ppn_set, 0, sizeof(entry->ppn_set)); in qp_guest_endpoint_create()
470 entry->produce_q = produce_q; in qp_guest_endpoint_create()
471 entry->consume_q = consume_q; in qp_guest_endpoint_create()
477 *------------------------------------------------------------------------------
479 * qp_guest_endpoint_destroy --
486 * Side effects:
489 *------------------------------------------------------------------------------
497 ASSERT(entry->qp.ref_count == 0); in qp_guest_endpoint_destroy()
499 vmci_free_ppn_set(&entry->ppn_set); in qp_guest_endpoint_destroy()
500 vmci_free_queue(entry->produce_q, entry->qp.produce_size); in qp_guest_endpoint_destroy()
501 vmci_free_queue(entry->consume_q, entry->qp.consume_size); in qp_guest_endpoint_destroy()
506 *------------------------------------------------------------------------------
508 * vmci_queue_pair_alloc_hypercall --
511 * supporting a guest device.
516 * Side effects:
519 *------------------------------------------------------------------------------
528 if (!entry || entry->num_ppns <= 2) in vmci_queue_pair_alloc_hypercall()
531 ASSERT(!(entry->qp.flags & VMCI_QPFLAG_LOCAL)); in vmci_queue_pair_alloc_hypercall()
533 msg_size = sizeof(*alloc_msg) + (size_t)entry->num_ppns * sizeof(PPN); in vmci_queue_pair_alloc_hypercall()
538 alloc_msg->hdr.dst = VMCI_MAKE_HANDLE(VMCI_HYPERVISOR_CONTEXT_ID, in vmci_queue_pair_alloc_hypercall()
540 alloc_msg->hdr.src = VMCI_ANON_SRC_HANDLE; in vmci_queue_pair_alloc_hypercall()
541 alloc_msg->hdr.payload_size = msg_size - VMCI_DG_HEADERSIZE; in vmci_queue_pair_alloc_hypercall()
542 alloc_msg->handle = entry->qp.handle; in vmci_queue_pair_alloc_hypercall()
543 alloc_msg->peer = entry->qp.peer; in vmci_queue_pair_alloc_hypercall()
544 alloc_msg->flags = entry->qp.flags; in vmci_queue_pair_alloc_hypercall()
545 alloc_msg->produce_size = entry->qp.produce_size; in vmci_queue_pair_alloc_hypercall()
546 alloc_msg->consume_size = entry->qp.consume_size; in vmci_queue_pair_alloc_hypercall()
547 alloc_msg->num_ppns = entry->num_ppns; in vmci_queue_pair_alloc_hypercall()
549 sizeof(*alloc_msg), &entry->ppn_set); in vmci_queue_pair_alloc_hypercall()
558 *------------------------------------------------------------------------------
560 * vmci_queue_pair_alloc_guest_work --
562 * This functions handles the actual allocation of a VMCI queue pair guest
569 * Side effects:
572 *------------------------------------------------------------------------------
599 * While guest OS is in hibernate state, creating non-local in vmci_queue_pair_alloc_guest_work()
601 * guest driver converted the existing queue pairs to local in vmci_queue_pair_alloc_guest_work()
612 if (queue_pair_entry->qp.flags & VMCI_QPFLAG_LOCAL) { in vmci_queue_pair_alloc_guest_work()
614 if (queue_pair_entry->qp.ref_count > 1) { in vmci_queue_pair_alloc_guest_work()
621 if (queue_pair_entry->qp.produce_size != consume_size || in vmci_queue_pair_alloc_guest_work()
622 queue_pair_entry->qp.consume_size != produce_size || in vmci_queue_pair_alloc_guest_work()
623 queue_pair_entry->qp.flags != in vmci_queue_pair_alloc_guest_work()
638 my_produce_q = queue_pair_entry->consume_q; in vmci_queue_pair_alloc_guest_work()
639 my_consume_q = queue_pair_entry->produce_q; in vmci_queue_pair_alloc_guest_work()
672 my_consume_q, num_consume_pages, &queue_pair_entry->ppn_set); in vmci_queue_pair_alloc_guest_work()
682 if (queue_pair_entry->qp.flags & VMCI_QPFLAG_LOCAL) { in vmci_queue_pair_alloc_guest_work()
690 * context id) and the attach-only flag cannot exist during in vmci_queue_pair_alloc_guest_work()
694 if (queue_pair_entry->qp.handle.context != context_id || in vmci_queue_pair_alloc_guest_work()
695 (queue_pair_entry->qp.peer != VMCI_INVALID_ID && in vmci_queue_pair_alloc_guest_work()
696 queue_pair_entry->qp.peer != context_id)) { in vmci_queue_pair_alloc_guest_work()
701 if (queue_pair_entry->qp.flags & VMCI_QPFLAG_ATTACH_ONLY) { in vmci_queue_pair_alloc_guest_work()
715 queue_pair_list_add_entry(&qp_guest_endpoints, &queue_pair_entry->qp); in vmci_queue_pair_alloc_guest_work()
718 queue_pair_entry->qp.ref_count++; in vmci_queue_pair_alloc_guest_work()
719 *handle = queue_pair_entry->qp.handle; in vmci_queue_pair_alloc_guest_work()
725 * pair create. For non-local queue pairs, the hypervisor initializes in vmci_queue_pair_alloc_guest_work()
728 if ((queue_pair_entry->qp.flags & VMCI_QPFLAG_LOCAL) && in vmci_queue_pair_alloc_guest_work()
729 queue_pair_entry->qp.ref_count == 1) { in vmci_queue_pair_alloc_guest_work()
730 vmci_queue_header_init((*produce_q)->q_header, *handle); in vmci_queue_pair_alloc_guest_work()
731 vmci_queue_header_init((*consume_q)->q_header, *handle); in vmci_queue_pair_alloc_guest_work()
753 ASSERT(queue_pair_entry->qp.ref_count > 0); in vmci_queue_pair_alloc_guest_work()
759 *------------------------------------------------------------------------------
761 * vmci_queue_pair_detach_hypercall --
764 * a guest device.
769 * Side effects:
772 *------------------------------------------------------------------------------
790 *------------------------------------------------------------------------------
792 * vmci_queue_pair_detach_guest_work --
800 * Side effects:
803 *------------------------------------------------------------------------------
824 ASSERT(entry->qp.ref_count >= 1); in vmci_queue_pair_detach_guest_work()
826 if (entry->qp.flags & VMCI_QPFLAG_LOCAL) { in vmci_queue_pair_detach_guest_work()
829 if (entry->qp.ref_count > 1) { in vmci_queue_pair_detach_guest_work()
840 if (entry->hibernate_failure) { in vmci_queue_pair_detach_guest_work()
844 * hibernation, the guest driver and the device in vmci_queue_pair_detach_guest_work()
846 * out of hibernation. The guest driver will in vmci_queue_pair_detach_guest_work()
847 * regard it as a non-local queue pair, but in vmci_queue_pair_detach_guest_work()
854 ASSERT(entry->qp.ref_count == 1); in vmci_queue_pair_detach_guest_work()
860 * We failed to notify a non-local queuepair. That other in vmci_queue_pair_detach_guest_work()
878 entry->qp.ref_count--; in vmci_queue_pair_detach_guest_work()
879 if (entry->qp.ref_count == 0) in vmci_queue_pair_detach_guest_work()
880 queue_pair_list_remove_entry(&qp_guest_endpoints, &entry->qp); in vmci_queue_pair_detach_guest_work()
883 ref_count = entry ? entry->qp.ref_count : in vmci_queue_pair_detach_guest_work()
897 *------------------------------------------------------------------------------
899 * queue_pair_notify_peer_local --
907 * Side effects:
910 *------------------------------------------------------------------------------
926 e_msg->hdr.dst = VMCI_MAKE_HANDLE(context_id, VMCI_EVENT_HANDLER); in queue_pair_notify_peer_local()
927 e_msg->hdr.src = VMCI_MAKE_HANDLE(VMCI_HYPERVISOR_CONTEXT_ID, in queue_pair_notify_peer_local()
929 e_msg->hdr.payload_size = sizeof(*e_msg) + sizeof(*e_payload) - in queue_pair_notify_peer_local()
930 sizeof(e_msg->hdr); in queue_pair_notify_peer_local()
931 e_msg->event_data.event = attach ? VMCI_EVENT_QP_PEER_ATTACH : in queue_pair_notify_peer_local()
933 e_payload->peer_id = context_id; in queue_pair_notify_peer_local()
934 e_payload->handle = handle; in queue_pair_notify_peer_local()