Lines Matching refs:vu_dev
77 #define vu_err(vu_dev, ...) dev_err(&(vu_dev)->pdev->dev, ##__VA_ARGS__) argument
125 static int vhost_user_recv(struct virtio_uml_device *vu_dev, in vhost_user_recv() argument
149 if (rc == -ECONNRESET && vu_dev->registered) { in vhost_user_recv()
152 pdata = vu_dev->pdev->dev.platform_data; in vhost_user_recv()
154 virtio_break_device(&vu_dev->vdev); in vhost_user_recv()
165 static int vhost_user_recv_resp(struct virtio_uml_device *vu_dev, in vhost_user_recv_resp() argument
169 int rc = vhost_user_recv(vu_dev, vu_dev->sock, msg, in vhost_user_recv_resp()
181 static int vhost_user_recv_u64(struct virtio_uml_device *vu_dev, in vhost_user_recv_u64() argument
185 int rc = vhost_user_recv_resp(vu_dev, &msg, in vhost_user_recv_u64()
196 static int vhost_user_recv_req(struct virtio_uml_device *vu_dev, in vhost_user_recv_req() argument
200 int rc = vhost_user_recv(vu_dev, vu_dev->req_fd, msg, in vhost_user_recv_req()
213 static int vhost_user_send(struct virtio_uml_device *vu_dev, in vhost_user_send() argument
230 if (!(vu_dev->protocol_features & in vhost_user_send()
237 spin_lock_irqsave(&vu_dev->sock_lock, flags); in vhost_user_send()
238 rc = full_sendmsg_fds(vu_dev->sock, msg, size, fds, num_fds); in vhost_user_send()
245 rc = vhost_user_recv_u64(vu_dev, &status); in vhost_user_send()
250 vu_err(vu_dev, "slave reports error: %llu\n", status); in vhost_user_send()
257 spin_unlock_irqrestore(&vu_dev->sock_lock, flags); in vhost_user_send()
261 static int vhost_user_send_no_payload(struct virtio_uml_device *vu_dev, in vhost_user_send_no_payload() argument
268 return vhost_user_send(vu_dev, need_response, &msg, NULL, 0); in vhost_user_send_no_payload()
271 static int vhost_user_send_no_payload_fd(struct virtio_uml_device *vu_dev, in vhost_user_send_no_payload_fd() argument
278 return vhost_user_send(vu_dev, false, &msg, &fd, 1); in vhost_user_send_no_payload_fd()
281 static int vhost_user_send_u64(struct virtio_uml_device *vu_dev, in vhost_user_send_u64() argument
290 return vhost_user_send(vu_dev, false, &msg, NULL, 0); in vhost_user_send_u64()
293 static int vhost_user_set_owner(struct virtio_uml_device *vu_dev) in vhost_user_set_owner() argument
295 return vhost_user_send_no_payload(vu_dev, false, VHOST_USER_SET_OWNER); in vhost_user_set_owner()
298 static int vhost_user_get_features(struct virtio_uml_device *vu_dev, in vhost_user_get_features() argument
301 int rc = vhost_user_send_no_payload(vu_dev, true, in vhost_user_get_features()
306 return vhost_user_recv_u64(vu_dev, features); in vhost_user_get_features()
309 static int vhost_user_set_features(struct virtio_uml_device *vu_dev, in vhost_user_set_features() argument
312 return vhost_user_send_u64(vu_dev, VHOST_USER_SET_FEATURES, features); in vhost_user_set_features()
315 static int vhost_user_get_protocol_features(struct virtio_uml_device *vu_dev, in vhost_user_get_protocol_features() argument
318 int rc = vhost_user_send_no_payload(vu_dev, true, in vhost_user_get_protocol_features()
323 return vhost_user_recv_u64(vu_dev, protocol_features); in vhost_user_get_protocol_features()
326 static int vhost_user_set_protocol_features(struct virtio_uml_device *vu_dev, in vhost_user_set_protocol_features() argument
329 return vhost_user_send_u64(vu_dev, VHOST_USER_SET_PROTOCOL_FEATURES, in vhost_user_set_protocol_features()
333 static void vhost_user_reply(struct virtio_uml_device *vu_dev, in vhost_user_reply() argument
347 rc = full_sendmsg_fds(vu_dev->req_fd, &reply, size, NULL, 0); in vhost_user_reply()
350 vu_err(vu_dev, in vhost_user_reply()
357 struct virtio_uml_device *vu_dev = data; in vu_req_interrupt() local
366 rc = vhost_user_recv_req(vu_dev, &msg.msg, in vu_req_interrupt()
375 virtio_config_changed(&vu_dev->vdev); in vu_req_interrupt()
379 virtio_device_for_each_vq((&vu_dev->vdev), vq) { in vu_req_interrupt()
392 vu_err(vu_dev, "unexpected slave request %d\n", in vu_req_interrupt()
397 vhost_user_reply(vu_dev, &msg.msg, response); in vu_req_interrupt()
402 static int vhost_user_init_slave_req(struct virtio_uml_device *vu_dev) in vhost_user_init_slave_req() argument
410 vu_dev->req_fd = req_fds[0]; in vhost_user_init_slave_req()
412 rc = um_request_irq(VIRTIO_IRQ, vu_dev->req_fd, IRQ_READ, in vhost_user_init_slave_req()
414 vu_dev->pdev->name, vu_dev); in vhost_user_init_slave_req()
418 rc = vhost_user_send_no_payload_fd(vu_dev, VHOST_USER_SET_SLAVE_REQ_FD, in vhost_user_init_slave_req()
426 um_free_irq(VIRTIO_IRQ, vu_dev); in vhost_user_init_slave_req()
435 static int vhost_user_init(struct virtio_uml_device *vu_dev) in vhost_user_init() argument
437 int rc = vhost_user_set_owner(vu_dev); in vhost_user_init()
441 rc = vhost_user_get_features(vu_dev, &vu_dev->features); in vhost_user_init()
445 if (vu_dev->features & BIT_ULL(VHOST_USER_F_PROTOCOL_FEATURES)) { in vhost_user_init()
446 rc = vhost_user_get_protocol_features(vu_dev, in vhost_user_init()
447 &vu_dev->protocol_features); in vhost_user_init()
450 vu_dev->protocol_features &= VHOST_USER_SUPPORTED_PROTOCOL_F; in vhost_user_init()
451 rc = vhost_user_set_protocol_features(vu_dev, in vhost_user_init()
452 vu_dev->protocol_features); in vhost_user_init()
457 if (vu_dev->protocol_features & in vhost_user_init()
459 rc = vhost_user_init_slave_req(vu_dev); in vhost_user_init()
467 static void vhost_user_get_config(struct virtio_uml_device *vu_dev, in vhost_user_get_config() argument
476 if (!(vu_dev->protocol_features & in vhost_user_get_config()
488 rc = vhost_user_send(vu_dev, true, msg, NULL, 0); in vhost_user_get_config()
490 vu_err(vu_dev, "sending VHOST_USER_GET_CONFIG failed: %d\n", in vhost_user_get_config()
495 rc = vhost_user_recv_resp(vu_dev, msg, msg_size); in vhost_user_get_config()
497 vu_err(vu_dev, in vhost_user_get_config()
506 vu_err(vu_dev, in vhost_user_get_config()
518 static void vhost_user_set_config(struct virtio_uml_device *vu_dev, in vhost_user_set_config() argument
526 if (!(vu_dev->protocol_features & in vhost_user_set_config()
539 rc = vhost_user_send(vu_dev, false, msg, NULL, 0); in vhost_user_set_config()
541 vu_err(vu_dev, "sending VHOST_USER_SET_CONFIG failed: %d\n", in vhost_user_set_config()
569 static int vhost_user_set_mem_table(struct virtio_uml_device *vu_dev) in vhost_user_set_mem_table() argument
629 return vhost_user_send(vu_dev, false, &msg, fds, in vhost_user_set_mem_table()
633 static int vhost_user_set_vring_state(struct virtio_uml_device *vu_dev, in vhost_user_set_vring_state() argument
643 return vhost_user_send(vu_dev, false, &msg, NULL, 0); in vhost_user_set_vring_state()
646 static int vhost_user_set_vring_num(struct virtio_uml_device *vu_dev, in vhost_user_set_vring_num() argument
649 return vhost_user_set_vring_state(vu_dev, VHOST_USER_SET_VRING_NUM, in vhost_user_set_vring_num()
653 static int vhost_user_set_vring_base(struct virtio_uml_device *vu_dev, in vhost_user_set_vring_base() argument
656 return vhost_user_set_vring_state(vu_dev, VHOST_USER_SET_VRING_BASE, in vhost_user_set_vring_base()
660 static int vhost_user_set_vring_addr(struct virtio_uml_device *vu_dev, in vhost_user_set_vring_addr() argument
674 return vhost_user_send(vu_dev, false, &msg, NULL, 0); in vhost_user_set_vring_addr()
677 static int vhost_user_set_vring_fd(struct virtio_uml_device *vu_dev, in vhost_user_set_vring_fd() argument
690 return vhost_user_send(vu_dev, false, &msg, NULL, 0); in vhost_user_set_vring_fd()
692 return vhost_user_send(vu_dev, false, &msg, &fd, 1); in vhost_user_set_vring_fd()
695 static int vhost_user_set_vring_call(struct virtio_uml_device *vu_dev, in vhost_user_set_vring_call() argument
698 return vhost_user_set_vring_fd(vu_dev, VHOST_USER_SET_VRING_CALL, in vhost_user_set_vring_call()
702 static int vhost_user_set_vring_kick(struct virtio_uml_device *vu_dev, in vhost_user_set_vring_kick() argument
705 return vhost_user_set_vring_fd(vu_dev, VHOST_USER_SET_VRING_KICK, in vhost_user_set_vring_kick()
709 static int vhost_user_set_vring_enable(struct virtio_uml_device *vu_dev, in vhost_user_set_vring_enable() argument
712 if (!(vu_dev->features & BIT_ULL(VHOST_USER_F_PROTOCOL_FEATURES))) in vhost_user_set_vring_enable()
715 return vhost_user_set_vring_state(vu_dev, VHOST_USER_SET_VRING_ENABLE, in vhost_user_set_vring_enable()
731 struct virtio_uml_device *vu_dev; in vu_notify() local
733 vu_dev = to_virtio_uml_device(vq->vdev); in vu_notify()
735 return vhost_user_set_vring_state(vu_dev, VHOST_USER_VRING_KICK, in vu_notify()
766 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_get() local
768 vhost_user_get_config(vu_dev, offset, buf, len); in vu_get()
774 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_set() local
776 vhost_user_set_config(vu_dev, offset, buf, len); in vu_set()
781 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_get_status() local
783 return vu_dev->status; in vu_get_status()
788 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_set_status() local
790 vu_dev->status = status; in vu_set_status()
795 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_reset() local
797 vu_dev->status = 0; in vu_reset()
818 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_del_vqs() local
824 WARN_ON(vhost_user_set_vring_enable(vu_dev, vq->index, false)); in vu_del_vqs()
827 WARN_ON(vhost_user_get_features(vu_dev, &features)); in vu_del_vqs()
833 static int vu_setup_vq_call_fd(struct virtio_uml_device *vu_dev, in vu_setup_vq_call_fd() argument
841 if (vu_dev->protocol_features & in vu_setup_vq_call_fd()
843 vu_dev->protocol_features & in vu_setup_vq_call_fd()
860 rc = vhost_user_set_vring_call(vu_dev, vq->index, call_fds[1]); in vu_setup_vq_call_fd()
898 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_setup_vq() local
899 struct platform_device *pdev = vu_dev->pdev; in vu_setup_vq()
938 if (vu_dev->protocol_features & in vu_setup_vq()
948 rc = vu_setup_vq_call_fd(vu_dev, vq); in vu_setup_vq()
952 rc = vhost_user_set_vring_num(vu_dev, index, num); in vu_setup_vq()
956 rc = vhost_user_set_vring_base(vu_dev, index, 0); in vu_setup_vq()
960 rc = vhost_user_set_vring_addr(vu_dev, index, in vu_setup_vq()
991 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_find_vqs() local
995 rc = vhost_user_set_mem_table(vu_dev); in vu_find_vqs()
1017 rc = vhost_user_set_vring_kick(vu_dev, vq->index, in vu_find_vqs()
1023 rc = vhost_user_set_vring_enable(vu_dev, vq->index, true); in vu_find_vqs()
1037 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_get_features() local
1039 return vu_dev->features; in vu_get_features()
1044 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_finalize_features() local
1048 vu_dev->features = vdev->features | supported; in vu_finalize_features()
1050 return vhost_user_set_features(vu_dev, vu_dev->features); in vu_finalize_features()
1055 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_bus_name() local
1057 return vu_dev->pdev->name; in vu_bus_name()
1077 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in virtio_uml_release_dev() local
1080 if (vu_dev->req_fd >= 0) { in virtio_uml_release_dev()
1081 um_free_irq(VIRTIO_IRQ, vu_dev); in virtio_uml_release_dev()
1082 os_close_file(vu_dev->req_fd); in virtio_uml_release_dev()
1085 os_close_file(vu_dev->sock); in virtio_uml_release_dev()
1093 struct virtio_uml_device *vu_dev; in virtio_uml_probe() local
1099 vu_dev = devm_kzalloc(&pdev->dev, sizeof(*vu_dev), GFP_KERNEL); in virtio_uml_probe()
1100 if (!vu_dev) in virtio_uml_probe()
1103 vu_dev->vdev.dev.parent = &pdev->dev; in virtio_uml_probe()
1104 vu_dev->vdev.dev.release = virtio_uml_release_dev; in virtio_uml_probe()
1105 vu_dev->vdev.config = &virtio_uml_config_ops; in virtio_uml_probe()
1106 vu_dev->vdev.id.device = pdata->virtio_device_id; in virtio_uml_probe()
1107 vu_dev->vdev.id.vendor = VIRTIO_DEV_ANY_ID; in virtio_uml_probe()
1108 vu_dev->pdev = pdev; in virtio_uml_probe()
1109 vu_dev->req_fd = -1; in virtio_uml_probe()
1116 vu_dev->sock = rc; in virtio_uml_probe()
1118 spin_lock_init(&vu_dev->sock_lock); in virtio_uml_probe()
1120 rc = vhost_user_init(vu_dev); in virtio_uml_probe()
1124 platform_set_drvdata(pdev, vu_dev); in virtio_uml_probe()
1126 rc = register_virtio_device(&vu_dev->vdev); in virtio_uml_probe()
1128 put_device(&vu_dev->vdev.dev); in virtio_uml_probe()
1129 vu_dev->registered = 1; in virtio_uml_probe()
1133 os_close_file(vu_dev->sock); in virtio_uml_probe()
1139 struct virtio_uml_device *vu_dev = platform_get_drvdata(pdev); in virtio_uml_remove() local
1141 unregister_virtio_device(&vu_dev->vdev); in virtio_uml_remove()