Lines Matching refs:vu_dev

62 #define vu_err(vu_dev, ...)	dev_err(&(vu_dev)->pdev->dev, __VA_ARGS__)  argument
124 static int vhost_user_recv_resp(struct virtio_uml_device *vu_dev, in vhost_user_recv_resp() argument
128 int rc = vhost_user_recv(vu_dev->sock, msg, max_payload_size); in vhost_user_recv_resp()
139 static int vhost_user_recv_u64(struct virtio_uml_device *vu_dev, in vhost_user_recv_u64() argument
143 int rc = vhost_user_recv_resp(vu_dev, &msg, in vhost_user_recv_u64()
154 static int vhost_user_recv_req(struct virtio_uml_device *vu_dev, in vhost_user_recv_req() argument
158 int rc = vhost_user_recv(vu_dev->req_fd, msg, max_payload_size); in vhost_user_recv_req()
170 static int vhost_user_send(struct virtio_uml_device *vu_dev, in vhost_user_send() argument
186 if (!(vu_dev->protocol_features & in vhost_user_send()
193 rc = full_sendmsg_fds(vu_dev->sock, msg, size, fds, num_fds); in vhost_user_send()
200 rc = vhost_user_recv_u64(vu_dev, &status); in vhost_user_send()
205 vu_err(vu_dev, "slave reports error: %llu\n", status); in vhost_user_send()
213 static int vhost_user_send_no_payload(struct virtio_uml_device *vu_dev, in vhost_user_send_no_payload() argument
220 return vhost_user_send(vu_dev, need_response, &msg, NULL, 0); in vhost_user_send_no_payload()
223 static int vhost_user_send_no_payload_fd(struct virtio_uml_device *vu_dev, in vhost_user_send_no_payload_fd() argument
230 return vhost_user_send(vu_dev, false, &msg, &fd, 1); in vhost_user_send_no_payload_fd()
233 static int vhost_user_send_u64(struct virtio_uml_device *vu_dev, in vhost_user_send_u64() argument
242 return vhost_user_send(vu_dev, false, &msg, NULL, 0); in vhost_user_send_u64()
245 static int vhost_user_set_owner(struct virtio_uml_device *vu_dev) in vhost_user_set_owner() argument
247 return vhost_user_send_no_payload(vu_dev, false, VHOST_USER_SET_OWNER); in vhost_user_set_owner()
250 static int vhost_user_get_features(struct virtio_uml_device *vu_dev, in vhost_user_get_features() argument
253 int rc = vhost_user_send_no_payload(vu_dev, true, in vhost_user_get_features()
258 return vhost_user_recv_u64(vu_dev, features); in vhost_user_get_features()
261 static int vhost_user_set_features(struct virtio_uml_device *vu_dev, in vhost_user_set_features() argument
264 return vhost_user_send_u64(vu_dev, VHOST_USER_SET_FEATURES, features); in vhost_user_set_features()
267 static int vhost_user_get_protocol_features(struct virtio_uml_device *vu_dev, in vhost_user_get_protocol_features() argument
270 int rc = vhost_user_send_no_payload(vu_dev, true, in vhost_user_get_protocol_features()
275 return vhost_user_recv_u64(vu_dev, protocol_features); in vhost_user_get_protocol_features()
278 static int vhost_user_set_protocol_features(struct virtio_uml_device *vu_dev, in vhost_user_set_protocol_features() argument
281 return vhost_user_send_u64(vu_dev, VHOST_USER_SET_PROTOCOL_FEATURES, in vhost_user_set_protocol_features()
285 static void vhost_user_reply(struct virtio_uml_device *vu_dev, in vhost_user_reply() argument
299 rc = full_sendmsg_fds(vu_dev->req_fd, &reply, size, NULL, 0); in vhost_user_reply()
302 vu_err(vu_dev, in vhost_user_reply()
309 struct virtio_uml_device *vu_dev = data; in vu_req_interrupt() local
317 rc = vhost_user_recv_req(vu_dev, &msg.msg, in vu_req_interrupt()
326 virtio_config_changed(&vu_dev->vdev); in vu_req_interrupt()
334 vu_err(vu_dev, "unexpected slave request %d\n", in vu_req_interrupt()
339 vhost_user_reply(vu_dev, &msg.msg, response); in vu_req_interrupt()
344 static int vhost_user_init_slave_req(struct virtio_uml_device *vu_dev) in vhost_user_init_slave_req() argument
352 vu_dev->req_fd = req_fds[0]; in vhost_user_init_slave_req()
354 rc = um_request_irq(VIRTIO_IRQ, vu_dev->req_fd, IRQ_READ, in vhost_user_init_slave_req()
356 vu_dev->pdev->name, vu_dev); in vhost_user_init_slave_req()
360 rc = vhost_user_send_no_payload_fd(vu_dev, VHOST_USER_SET_SLAVE_REQ_FD, in vhost_user_init_slave_req()
368 um_free_irq(VIRTIO_IRQ, vu_dev); in vhost_user_init_slave_req()
377 static int vhost_user_init(struct virtio_uml_device *vu_dev) in vhost_user_init() argument
379 int rc = vhost_user_set_owner(vu_dev); in vhost_user_init()
383 rc = vhost_user_get_features(vu_dev, &vu_dev->features); in vhost_user_init()
387 if (vu_dev->features & BIT_ULL(VHOST_USER_F_PROTOCOL_FEATURES)) { in vhost_user_init()
388 rc = vhost_user_get_protocol_features(vu_dev, in vhost_user_init()
389 &vu_dev->protocol_features); in vhost_user_init()
392 vu_dev->protocol_features &= VHOST_USER_SUPPORTED_PROTOCOL_F; in vhost_user_init()
393 rc = vhost_user_set_protocol_features(vu_dev, in vhost_user_init()
394 vu_dev->protocol_features); in vhost_user_init()
399 if (vu_dev->protocol_features & in vhost_user_init()
401 rc = vhost_user_init_slave_req(vu_dev); in vhost_user_init()
409 static void vhost_user_get_config(struct virtio_uml_device *vu_dev, in vhost_user_get_config() argument
418 if (!(vu_dev->protocol_features & in vhost_user_get_config()
430 rc = vhost_user_send(vu_dev, true, msg, NULL, 0); in vhost_user_get_config()
432 vu_err(vu_dev, "sending VHOST_USER_GET_CONFIG failed: %d\n", in vhost_user_get_config()
437 rc = vhost_user_recv_resp(vu_dev, msg, msg_size); in vhost_user_get_config()
439 vu_err(vu_dev, in vhost_user_get_config()
448 vu_err(vu_dev, in vhost_user_get_config()
460 static void vhost_user_set_config(struct virtio_uml_device *vu_dev, in vhost_user_set_config() argument
468 if (!(vu_dev->protocol_features & in vhost_user_set_config()
481 rc = vhost_user_send(vu_dev, false, msg, NULL, 0); in vhost_user_set_config()
483 vu_err(vu_dev, "sending VHOST_USER_SET_CONFIG failed: %d\n", in vhost_user_set_config()
511 static int vhost_user_set_mem_table(struct virtio_uml_device *vu_dev) in vhost_user_set_mem_table() argument
571 return vhost_user_send(vu_dev, false, &msg, fds, in vhost_user_set_mem_table()
575 static int vhost_user_set_vring_state(struct virtio_uml_device *vu_dev, in vhost_user_set_vring_state() argument
585 return vhost_user_send(vu_dev, false, &msg, NULL, 0); in vhost_user_set_vring_state()
588 static int vhost_user_set_vring_num(struct virtio_uml_device *vu_dev, in vhost_user_set_vring_num() argument
591 return vhost_user_set_vring_state(vu_dev, VHOST_USER_SET_VRING_NUM, in vhost_user_set_vring_num()
595 static int vhost_user_set_vring_base(struct virtio_uml_device *vu_dev, in vhost_user_set_vring_base() argument
598 return vhost_user_set_vring_state(vu_dev, VHOST_USER_SET_VRING_BASE, in vhost_user_set_vring_base()
602 static int vhost_user_set_vring_addr(struct virtio_uml_device *vu_dev, in vhost_user_set_vring_addr() argument
616 return vhost_user_send(vu_dev, false, &msg, NULL, 0); in vhost_user_set_vring_addr()
619 static int vhost_user_set_vring_fd(struct virtio_uml_device *vu_dev, in vhost_user_set_vring_fd() argument
632 return vhost_user_send(vu_dev, false, &msg, NULL, 0); in vhost_user_set_vring_fd()
634 return vhost_user_send(vu_dev, false, &msg, &fd, 1); in vhost_user_set_vring_fd()
637 static int vhost_user_set_vring_call(struct virtio_uml_device *vu_dev, in vhost_user_set_vring_call() argument
640 return vhost_user_set_vring_fd(vu_dev, VHOST_USER_SET_VRING_CALL, in vhost_user_set_vring_call()
644 static int vhost_user_set_vring_kick(struct virtio_uml_device *vu_dev, in vhost_user_set_vring_kick() argument
647 return vhost_user_set_vring_fd(vu_dev, VHOST_USER_SET_VRING_KICK, in vhost_user_set_vring_kick()
651 static int vhost_user_set_vring_enable(struct virtio_uml_device *vu_dev, in vhost_user_set_vring_enable() argument
654 if (!(vu_dev->features & BIT_ULL(VHOST_USER_F_PROTOCOL_FEATURES))) in vhost_user_set_vring_enable()
657 return vhost_user_set_vring_state(vu_dev, VHOST_USER_SET_VRING_ENABLE, in vhost_user_set_vring_enable()
697 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_get() local
699 vhost_user_get_config(vu_dev, offset, buf, len); in vu_get()
705 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_set() local
707 vhost_user_set_config(vu_dev, offset, buf, len); in vu_set()
712 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_get_status() local
714 return vu_dev->status; in vu_get_status()
719 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_set_status() local
721 vu_dev->status = status; in vu_set_status()
726 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_reset() local
728 vu_dev->status = 0; in vu_reset()
746 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_del_vqs() local
752 WARN_ON(vhost_user_set_vring_enable(vu_dev, vq->index, false)); in vu_del_vqs()
755 WARN_ON(vhost_user_get_features(vu_dev, &features)); in vu_del_vqs()
761 static int vu_setup_vq_call_fd(struct virtio_uml_device *vu_dev, in vu_setup_vq_call_fd() argument
779 rc = vhost_user_set_vring_call(vu_dev, vq->index, call_fds[1]); in vu_setup_vq_call_fd()
800 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_setup_vq() local
801 struct platform_device *pdev = vu_dev->pdev; in vu_setup_vq()
829 rc = vu_setup_vq_call_fd(vu_dev, vq); in vu_setup_vq()
833 rc = vhost_user_set_vring_num(vu_dev, index, num); in vu_setup_vq()
837 rc = vhost_user_set_vring_base(vu_dev, index, 0); in vu_setup_vq()
841 rc = vhost_user_set_vring_addr(vu_dev, index, in vu_setup_vq()
869 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_find_vqs() local
873 rc = vhost_user_set_mem_table(vu_dev); in vu_find_vqs()
894 rc = vhost_user_set_vring_kick(vu_dev, vq->index, in vu_find_vqs()
899 rc = vhost_user_set_vring_enable(vu_dev, vq->index, true); in vu_find_vqs()
913 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_get_features() local
915 return vu_dev->features; in vu_get_features()
920 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_finalize_features() local
924 vu_dev->features = vdev->features | supported; in vu_finalize_features()
926 return vhost_user_set_features(vu_dev, vu_dev->features); in vu_finalize_features()
931 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in vu_bus_name() local
933 return vu_dev->pdev->name; in vu_bus_name()
953 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev); in virtio_uml_release_dev() local
956 if (vu_dev->req_fd >= 0) { in virtio_uml_release_dev()
957 um_free_irq(VIRTIO_IRQ, vu_dev); in virtio_uml_release_dev()
958 os_close_file(vu_dev->req_fd); in virtio_uml_release_dev()
961 os_close_file(vu_dev->sock); in virtio_uml_release_dev()
974 struct virtio_uml_device *vu_dev; in virtio_uml_probe() local
980 vu_dev = devm_kzalloc(&pdev->dev, sizeof(*vu_dev), GFP_KERNEL); in virtio_uml_probe()
981 if (!vu_dev) in virtio_uml_probe()
984 vu_dev->vdev.dev.parent = &pdev->dev; in virtio_uml_probe()
985 vu_dev->vdev.dev.release = virtio_uml_release_dev; in virtio_uml_probe()
986 vu_dev->vdev.config = &virtio_uml_config_ops; in virtio_uml_probe()
987 vu_dev->vdev.id.device = pdata->virtio_device_id; in virtio_uml_probe()
988 vu_dev->vdev.id.vendor = VIRTIO_DEV_ANY_ID; in virtio_uml_probe()
989 vu_dev->pdev = pdev; in virtio_uml_probe()
990 vu_dev->req_fd = -1; in virtio_uml_probe()
997 vu_dev->sock = rc; in virtio_uml_probe()
999 rc = vhost_user_init(vu_dev); in virtio_uml_probe()
1003 platform_set_drvdata(pdev, vu_dev); in virtio_uml_probe()
1005 rc = register_virtio_device(&vu_dev->vdev); in virtio_uml_probe()
1007 put_device(&vu_dev->vdev.dev); in virtio_uml_probe()
1011 os_close_file(vu_dev->sock); in virtio_uml_probe()
1017 struct virtio_uml_device *vu_dev = platform_get_drvdata(pdev); in virtio_uml_remove() local
1019 unregister_virtio_device(&vu_dev->vdev); in virtio_uml_remove()