• Home
  • Raw
  • Download

Lines Matching refs:map

101 	struct sock_mapping *map;  in pvcalls_enter_sock()  local
107 map = (struct sock_mapping *)sock->sk->sk_send_head; in pvcalls_enter_sock()
108 if (map == NULL) in pvcalls_enter_sock()
112 atomic_inc(&map->refcount); in pvcalls_enter_sock()
113 return map; in pvcalls_enter_sock()
118 struct sock_mapping *map; in pvcalls_exit_sock() local
120 map = (struct sock_mapping *)sock->sk->sk_send_head; in pvcalls_exit_sock()
121 atomic_dec(&map->refcount); in pvcalls_exit_sock()
134 static bool pvcalls_front_write_todo(struct sock_mapping *map) in pvcalls_front_write_todo() argument
136 struct pvcalls_data_intf *intf = map->active.ring; in pvcalls_front_write_todo()
151 static bool pvcalls_front_read_todo(struct sock_mapping *map) in pvcalls_front_read_todo() argument
153 struct pvcalls_data_intf *intf = map->active.ring; in pvcalls_front_read_todo()
189 struct sock_mapping *map = (struct sock_mapping *)(uintptr_t) in pvcalls_front_event_handler() local
193 (void *)&map->passive.flags); in pvcalls_front_event_handler()
201 (void *)&map->passive.flags); in pvcalls_front_event_handler()
229 struct sock_mapping *map) in pvcalls_front_free_map() argument
233 unbind_from_irqhandler(map->active.irq, map); in pvcalls_front_free_map()
236 if (!list_empty(&map->list)) in pvcalls_front_free_map()
237 list_del_init(&map->list); in pvcalls_front_free_map()
241 gnttab_end_foreign_access(map->active.ring->ref[i], 0, 0); in pvcalls_front_free_map()
242 gnttab_end_foreign_access(map->active.ref, 0, 0); in pvcalls_front_free_map()
243 free_page((unsigned long)map->active.ring); in pvcalls_front_free_map()
245 kfree(map); in pvcalls_front_free_map()
250 struct sock_mapping *map = sock_map; in pvcalls_front_conn_handler() local
252 if (map == NULL) in pvcalls_front_conn_handler()
255 wake_up_interruptible(&map->active.inflight_conn_req); in pvcalls_front_conn_handler()
263 struct sock_mapping *map = NULL; in pvcalls_front_socket() local
284 map = kzalloc(sizeof(*map), GFP_KERNEL); in pvcalls_front_socket()
285 if (map == NULL) { in pvcalls_front_socket()
294 kfree(map); in pvcalls_front_socket()
306 sock->sk->sk_send_head = (void *)map; in pvcalls_front_socket()
307 list_add_tail(&map->list, &bedata->socket_mappings); in pvcalls_front_socket()
312 req->u.socket.id = (uintptr_t) map; in pvcalls_front_socket()
335 static void free_active_ring(struct sock_mapping *map) in free_active_ring() argument
337 if (!map->active.ring) in free_active_ring()
340 free_pages_exact(map->active.data.in, in free_active_ring()
341 PAGE_SIZE << map->active.ring->ring_order); in free_active_ring()
342 free_page((unsigned long)map->active.ring); in free_active_ring()
345 static int alloc_active_ring(struct sock_mapping *map) in alloc_active_ring() argument
349 map->active.ring = (struct pvcalls_data_intf *) in alloc_active_ring()
351 if (!map->active.ring) in alloc_active_ring()
354 map->active.ring->ring_order = PVCALLS_RING_ORDER; in alloc_active_ring()
360 map->active.data.in = bytes; in alloc_active_ring()
361 map->active.data.out = bytes + in alloc_active_ring()
367 free_active_ring(map); in alloc_active_ring()
371 static int create_active(struct sock_mapping *map, evtchn_port_t *evtchn) in create_active() argument
377 init_waitqueue_head(&map->active.inflight_conn_req); in create_active()
379 bytes = map->active.data.in; in create_active()
381 map->active.ring->ref[i] = gnttab_grant_foreign_access( in create_active()
385 map->active.ref = gnttab_grant_foreign_access( in create_active()
387 pfn_to_gfn(virt_to_pfn((void *)map->active.ring)), 0); in create_active()
393 0, "pvcalls-frontend", map); in create_active()
399 map->active.irq = irq; in create_active()
400 map->active_socket = true; in create_active()
401 mutex_init(&map->active.in_mutex); in create_active()
402 mutex_init(&map->active.out_mutex); in create_active()
416 struct sock_mapping *map = NULL; in pvcalls_front_connect() local
424 map = pvcalls_enter_sock(sock); in pvcalls_front_connect()
425 if (IS_ERR(map)) in pvcalls_front_connect()
426 return PTR_ERR(map); in pvcalls_front_connect()
429 ret = alloc_active_ring(map); in pvcalls_front_connect()
439 free_active_ring(map); in pvcalls_front_connect()
443 ret = create_active(map, &evtchn); in pvcalls_front_connect()
446 free_active_ring(map); in pvcalls_front_connect()
454 req->u.connect.id = (uintptr_t)map; in pvcalls_front_connect()
457 req->u.connect.ref = map->active.ref; in pvcalls_front_connect()
461 map->sock = sock; in pvcalls_front_connect()
535 struct sock_mapping *map; in pvcalls_front_sendmsg() local
543 map = pvcalls_enter_sock(sock); in pvcalls_front_sendmsg()
544 if (IS_ERR(map)) in pvcalls_front_sendmsg()
545 return PTR_ERR(map); in pvcalls_front_sendmsg()
547 mutex_lock(&map->active.out_mutex); in pvcalls_front_sendmsg()
548 if ((flags & MSG_DONTWAIT) && !pvcalls_front_write_todo(map)) { in pvcalls_front_sendmsg()
549 mutex_unlock(&map->active.out_mutex); in pvcalls_front_sendmsg()
558 sent = __write_ring(map->active.ring, in pvcalls_front_sendmsg()
559 &map->active.data, &msg->msg_iter, in pvcalls_front_sendmsg()
564 notify_remote_via_irq(map->active.irq); in pvcalls_front_sendmsg()
571 mutex_unlock(&map->active.out_mutex); in pvcalls_front_sendmsg()
629 struct sock_mapping *map; in pvcalls_front_recvmsg() local
634 map = pvcalls_enter_sock(sock); in pvcalls_front_recvmsg()
635 if (IS_ERR(map)) in pvcalls_front_recvmsg()
636 return PTR_ERR(map); in pvcalls_front_recvmsg()
638 mutex_lock(&map->active.in_mutex); in pvcalls_front_recvmsg()
642 while (!(flags & MSG_DONTWAIT) && !pvcalls_front_read_todo(map)) { in pvcalls_front_recvmsg()
643 wait_event_interruptible(map->active.inflight_conn_req, in pvcalls_front_recvmsg()
644 pvcalls_front_read_todo(map)); in pvcalls_front_recvmsg()
646 ret = __read_ring(map->active.ring, &map->active.data, in pvcalls_front_recvmsg()
650 notify_remote_via_irq(map->active.irq); in pvcalls_front_recvmsg()
656 mutex_unlock(&map->active.in_mutex); in pvcalls_front_recvmsg()
664 struct sock_mapping *map = NULL; in pvcalls_front_bind() local
671 map = pvcalls_enter_sock(sock); in pvcalls_front_bind()
672 if (IS_ERR(map)) in pvcalls_front_bind()
673 return PTR_ERR(map); in pvcalls_front_bind()
685 map->sock = sock; in pvcalls_front_bind()
687 req->u.bind.id = (uintptr_t)map; in pvcalls_front_bind()
691 init_waitqueue_head(&map->passive.inflight_accept_req); in pvcalls_front_bind()
693 map->active_socket = false; in pvcalls_front_bind()
709 map->passive.status = PVCALLS_STATUS_BIND; in pvcalls_front_bind()
717 struct sock_mapping *map; in pvcalls_front_listen() local
721 map = pvcalls_enter_sock(sock); in pvcalls_front_listen()
722 if (IS_ERR(map)) in pvcalls_front_listen()
723 return PTR_ERR(map); in pvcalls_front_listen()
726 if (map->passive.status != PVCALLS_STATUS_BIND) { in pvcalls_front_listen()
741 req->u.listen.id = (uintptr_t) map; in pvcalls_front_listen()
758 map->passive.status = PVCALLS_STATUS_LISTEN; in pvcalls_front_listen()
766 struct sock_mapping *map; in pvcalls_front_accept() local
772 map = pvcalls_enter_sock(sock); in pvcalls_front_accept()
773 if (IS_ERR(map)) in pvcalls_front_accept()
774 return PTR_ERR(map); in pvcalls_front_accept()
777 if (map->passive.status != PVCALLS_STATUS_LISTEN) { in pvcalls_front_accept()
788 (void *)&map->passive.flags)) { in pvcalls_front_accept()
789 req_id = READ_ONCE(map->passive.inflight_req_id); in pvcalls_front_accept()
792 map2 = map->passive.accept_map; in pvcalls_front_accept()
799 if (wait_event_interruptible(map->passive.inflight_accept_req, in pvcalls_front_accept()
801 (void *)&map->passive.flags))) { in pvcalls_front_accept()
810 (void *)&map->passive.flags); in pvcalls_front_accept()
817 (void *)&map->passive.flags); in pvcalls_front_accept()
826 (void *)&map->passive.flags); in pvcalls_front_accept()
839 (void *)&map->passive.flags); in pvcalls_front_accept()
849 req->u.accept.id = (uintptr_t) map; in pvcalls_front_accept()
853 map->passive.accept_map = map2; in pvcalls_front_accept()
862 WRITE_ONCE(map->passive.inflight_req_id, req_id); in pvcalls_front_accept()
880 map->passive.inflight_req_id = PVCALLS_INVALID_ID; in pvcalls_front_accept()
882 (void *)&map->passive.flags); in pvcalls_front_accept()
891 map->passive.inflight_req_id = PVCALLS_INVALID_ID; in pvcalls_front_accept()
893 clear_bit(PVCALLS_FLAG_ACCEPT_INFLIGHT, (void *)&map->passive.flags); in pvcalls_front_accept()
894 wake_up(&map->passive.inflight_accept_req); in pvcalls_front_accept()
902 struct sock_mapping *map, in pvcalls_front_poll_passive() argument
909 (void *)&map->passive.flags)) { in pvcalls_front_poll_passive()
910 uint32_t req_id = READ_ONCE(map->passive.inflight_req_id); in pvcalls_front_poll_passive()
916 poll_wait(file, &map->passive.inflight_accept_req, wait); in pvcalls_front_poll_passive()
921 (void *)&map->passive.flags)) in pvcalls_front_poll_passive()
931 (void *)&map->passive.flags)) { in pvcalls_front_poll_passive()
945 req->u.poll.id = (uintptr_t) map; in pvcalls_front_poll_passive()
959 struct sock_mapping *map, in pvcalls_front_poll_active() argument
964 struct pvcalls_data_intf *intf = map->active.ring; in pvcalls_front_poll_active()
969 poll_wait(file, &map->active.inflight_conn_req, wait); in pvcalls_front_poll_active()
970 if (pvcalls_front_write_todo(map)) in pvcalls_front_poll_active()
972 if (pvcalls_front_read_todo(map)) in pvcalls_front_poll_active()
984 struct sock_mapping *map; in pvcalls_front_poll() local
987 map = pvcalls_enter_sock(sock); in pvcalls_front_poll()
988 if (IS_ERR(map)) in pvcalls_front_poll()
992 if (map->active_socket) in pvcalls_front_poll()
993 ret = pvcalls_front_poll_active(file, bedata, map, wait); in pvcalls_front_poll()
995 ret = pvcalls_front_poll_passive(file, bedata, map, wait); in pvcalls_front_poll()
1003 struct sock_mapping *map; in pvcalls_front_release() local
1010 map = pvcalls_enter_sock(sock); in pvcalls_front_release()
1011 if (IS_ERR(map)) { in pvcalls_front_release()
1012 if (PTR_ERR(map) == -ENOTCONN) in pvcalls_front_release()
1031 req->u.release.id = (uintptr_t)map; in pvcalls_front_release()
1042 if (map->active_socket) { in pvcalls_front_release()
1047 map->active.ring->in_error = -EBADF; in pvcalls_front_release()
1048 wake_up_interruptible(&map->active.inflight_conn_req); in pvcalls_front_release()
1056 while (atomic_read(&map->refcount) > 1) in pvcalls_front_release()
1059 pvcalls_front_free_map(bedata, map); in pvcalls_front_release()
1062 wake_up(&map->passive.inflight_accept_req); in pvcalls_front_release()
1064 while (atomic_read(&map->refcount) > 1) in pvcalls_front_release()
1068 list_del(&map->list); in pvcalls_front_release()
1070 if (READ_ONCE(map->passive.inflight_req_id) != PVCALLS_INVALID_ID && in pvcalls_front_release()
1071 READ_ONCE(map->passive.inflight_req_id) != 0) { in pvcalls_front_release()
1073 map->passive.accept_map); in pvcalls_front_release()
1075 kfree(map); in pvcalls_front_release()
1091 struct sock_mapping *map = NULL, *n; in pvcalls_front_remove() local
1099 list_for_each_entry_safe(map, n, &bedata->socket_mappings, list) { in pvcalls_front_remove()
1100 map->sock->sk->sk_send_head = NULL; in pvcalls_front_remove()
1101 if (map->active_socket) { in pvcalls_front_remove()
1102 map->active.ring->in_error = -EBADF; in pvcalls_front_remove()
1103 wake_up_interruptible(&map->active.inflight_conn_req); in pvcalls_front_remove()
1110 list_for_each_entry_safe(map, n, &bedata->socket_mappings, list) { in pvcalls_front_remove()
1111 if (map->active_socket) { in pvcalls_front_remove()
1113 pvcalls_front_free_map(bedata, map); in pvcalls_front_remove()
1115 list_del(&map->list); in pvcalls_front_remove()
1116 kfree(map); in pvcalls_front_remove()