Lines Matching refs:vser

39 static VirtIOSerialPort *find_port_by_id(VirtIOSerial *vser, uint32_t id)  in find_port_by_id()  argument
47 QTAILQ_FOREACH(port, &vser->ports, next) { in find_port_by_id()
54 static VirtIOSerialPort *find_port_by_vq(VirtIOSerial *vser, VirtQueue *vq) in find_port_by_vq() argument
58 QTAILQ_FOREACH(port, &vser->ports, next) { in find_port_by_vq()
67 VirtIOSerial *vser; in find_port_by_name() local
69 QLIST_FOREACH(vser, &vserdevices.devices, next) { in find_port_by_name()
72 QTAILQ_FOREACH(port, &vser->ports, next) { in find_port_by_name()
81 static VirtIOSerialPort *find_first_connected_console(VirtIOSerial *vser) in find_first_connected_console() argument
85 QTAILQ_FOREACH(port, &vser->ports, next) { in find_first_connected_console()
94 static bool use_multiport(VirtIOSerial *vser) in use_multiport() argument
96 VirtIODevice *vdev = VIRTIO_DEVICE(vser); in use_multiport()
129 virtio_notify(VIRTIO_DEVICE(port->vser), vq); in write_to_port()
221 do_flush_queued_data(port, port->ovq, VIRTIO_DEVICE(port->vser)); in flush_queued_data()
224 static size_t send_control_msg(VirtIOSerial *vser, void *buf, size_t len) in send_control_msg() argument
229 vq = vser->c_ivq; in send_control_msg()
243 virtio_notify(VIRTIO_DEVICE(vser), vq); in send_control_msg()
249 static size_t send_control_event(VirtIOSerial *vser, uint32_t port_id, in send_control_event() argument
252 VirtIODevice *vdev = VIRTIO_DEVICE(vser); in send_control_event()
260 return send_control_msg(vser, &cpkt, sizeof(cpkt)); in send_control_event()
272 send_control_event(port->vser, port->id, VIRTIO_CONSOLE_PORT_OPEN, 1); in virtio_serial_open()
286 discard_vq_data(port->ovq, VIRTIO_DEVICE(port->vser)); in virtio_serial_close()
288 send_control_event(port->vser, port->id, VIRTIO_CONSOLE_PORT_OPEN, 0); in virtio_serial_close()
309 VirtIODevice *vdev = VIRTIO_DEVICE(port->vser); in virtio_serial_guest_ready()
318 if (use_multiport(port->vser) && !port->guest_connected) { in virtio_serial_guest_ready()
347 static void handle_control_message(VirtIOSerial *vser, void *buf, size_t len) in handle_control_message() argument
349 VirtIODevice *vdev = VIRTIO_DEVICE(vser); in handle_control_message()
371 vser->bus.qbus.name); in handle_control_message()
378 QTAILQ_FOREACH(port, &vser->ports, next) { in handle_control_message()
379 send_control_event(vser, port->id, VIRTIO_CONSOLE_PORT_ADD, 1); in handle_control_message()
384 port = find_port_by_id(vser, virtio_ldl_p(vdev, &gcpkt->id)); in handle_control_message()
387 virtio_ldl_p(vdev, &gcpkt->id), vser->bus.qbus.name); in handle_control_message()
399 port->id, vser->bus.qbus.name); in handle_control_message()
410 send_control_event(vser, port->id, VIRTIO_CONSOLE_CONSOLE_PORT, 1); in handle_control_message()
425 send_control_msg(vser, buffer, buffer_len); in handle_control_message()
430 send_control_event(vser, port->id, VIRTIO_CONSOLE_PORT_OPEN, 1); in handle_control_message()
461 VirtIOSerial *vser; in control_out() local
465 vser = VIRTIO_SERIAL(vdev); in control_out()
490 handle_control_message(vser, buf, cur_len); in control_out()
501 VirtIOSerial *vser; in handle_output() local
504 vser = VIRTIO_SERIAL(vdev); in handle_output()
505 port = find_port_by_vq(vser, vq); in handle_output()
531 VirtIOSerial *vser; in handle_input() local
535 vser = VIRTIO_SERIAL(vdev); in handle_input()
536 port = find_port_by_vq(vser, vq); in handle_input()
556 VirtIOSerial *vser; in get_features() local
558 vser = VIRTIO_SERIAL(vdev); in get_features()
560 features |= vser->host_features; in get_features()
561 if (vser->bus.max_nr_ports > 1) { in get_features()
570 VirtIOSerial *vser = VIRTIO_SERIAL(vdev); in get_config() local
577 vser->serial.max_virtserial_ports); in get_config()
583 VirtIOSerial *vser = VIRTIO_SERIAL(vdev); in set_config() local
586 VirtIOSerialPort *port = find_first_connected_console(vser); in set_config()
590 if (!virtio_has_feature(vser->host_features, in set_config()
606 static void guest_reset(VirtIOSerial *vser) in guest_reset() argument
611 QTAILQ_FOREACH(port, &vser->ports, next) { in guest_reset()
627 VirtIOSerial *vser; in set_status() local
630 vser = VIRTIO_SERIAL(vdev); in set_status()
631 port = find_port_by_id(vser, 0); in set_status()
633 if (port && !use_multiport(port->vser) in set_status()
644 guest_reset(vser); in set_status()
647 QTAILQ_FOREACH(port, &vser->ports, next) { in set_status()
657 VirtIOSerial *vser; in vser_reset() local
659 vser = VIRTIO_SERIAL(vdev); in vser_reset()
660 guest_reset(vser); in vser_reset()
869 static uint32_t find_free_port_id(VirtIOSerial *vser) in find_free_port_id() argument
873 max_nr_ports = vser->serial.max_virtserial_ports; in find_free_port_id()
877 map = vser->ports_map[i]; in find_free_port_id()
886 static void mark_port_added(VirtIOSerial *vser, uint32_t port_id) in mark_port_added() argument
891 vser->ports_map[i] |= 1U << (port_id % 32); in mark_port_added()
894 static void add_port(VirtIOSerial *vser, uint32_t port_id) in add_port() argument
896 mark_port_added(vser, port_id); in add_port()
897 send_control_event(vser, port_id, VIRTIO_CONSOLE_PORT_ADD, 1); in add_port()
900 static void remove_port(VirtIOSerial *vser, uint32_t port_id) in remove_port() argument
913 vser->ports_map[i] &= ~(1U << (port_id % 32)); in remove_port()
916 port = find_port_by_id(vser, port_id); in remove_port()
925 discard_vq_data(port->ovq, VIRTIO_DEVICE(port->vser)); in remove_port()
927 send_control_event(vser, port->id, VIRTIO_CONSOLE_PORT_REMOVE, 1); in remove_port()
939 port->vser = bus->vser; in virtser_port_device_realize()
948 plugging_port0 = vsc->is_console && !find_port_by_id(port->vser, 0); in virtser_port_device_realize()
950 if (find_port_by_id(port->vser, port->id)) { in virtser_port_device_realize()
966 port->id = find_free_port_id(port->vser); in virtser_port_device_realize()
975 max_nr_ports = port->vser->serial.max_virtserial_ports; in virtser_port_device_realize()
997 QTAILQ_INSERT_TAIL(&port->vser->ports, port, next); in virtser_port_device_plug()
998 port->ivq = port->vser->ivqs[port->id]; in virtser_port_device_plug()
999 port->ovq = port->vser->ovqs[port->id]; in virtser_port_device_plug()
1001 add_port(port->vser, port->id); in virtser_port_device_plug()
1011 VirtIOSerial *vser = port->vser; in virtser_port_device_unrealize() local
1014 remove_port(port->vser, port->id); in virtser_port_device_unrealize()
1016 QTAILQ_REMOVE(&vser->ports, port, next); in virtser_port_device_unrealize()
1026 VirtIOSerial *vser = VIRTIO_SERIAL(dev); in virtio_serial_device_realize() local
1030 if (!vser->serial.max_virtserial_ports) { in virtio_serial_device_realize()
1038 if (vser->serial.max_virtserial_ports > max_supported_ports) { in virtio_serial_device_realize()
1043 if (!virtio_has_feature(vser->host_features, in virtio_serial_device_realize()
1050 qbus_init(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS, in virtio_serial_device_realize()
1052 qbus_set_hotplug_handler(BUS(&vser->bus), OBJECT(vser)); in virtio_serial_device_realize()
1053 vser->bus.vser = vser; in virtio_serial_device_realize()
1054 QTAILQ_INIT(&vser->ports); in virtio_serial_device_realize()
1056 vser->bus.max_nr_ports = vser->serial.max_virtserial_ports; in virtio_serial_device_realize()
1057 vser->ivqs = g_new(VirtQueue *, vser->serial.max_virtserial_ports); in virtio_serial_device_realize()
1058 vser->ovqs = g_new(VirtQueue *, vser->serial.max_virtserial_ports); in virtio_serial_device_realize()
1061 vser->ivqs[0] = virtio_add_queue(vdev, 128, handle_input); in virtio_serial_device_realize()
1063 vser->ovqs[0] = virtio_add_queue(vdev, 128, handle_output); in virtio_serial_device_realize()
1072 vser->c_ivq = virtio_add_queue(vdev, 32, control_in); in virtio_serial_device_realize()
1074 vser->c_ovq = virtio_add_queue(vdev, 32, control_out); in virtio_serial_device_realize()
1076 for (i = 1; i < vser->bus.max_nr_ports; i++) { in virtio_serial_device_realize()
1078 vser->ivqs[i] = virtio_add_queue(vdev, 128, handle_input); in virtio_serial_device_realize()
1080 vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output); in virtio_serial_device_realize()
1083 vser->ports_map = g_malloc0((DIV_ROUND_UP(vser->serial.max_virtserial_ports, 32)) in virtio_serial_device_realize()
1084 * sizeof(vser->ports_map[0])); in virtio_serial_device_realize()
1089 mark_port_added(vser, 0); in virtio_serial_device_realize()
1091 vser->post_load = NULL; in virtio_serial_device_realize()
1093 QLIST_INSERT_HEAD(&vserdevices.devices, vser, next); in virtio_serial_device_realize()
1119 VirtIOSerial *vser = VIRTIO_SERIAL(dev); in virtio_serial_device_unrealize() local
1122 QLIST_REMOVE(vser, next); in virtio_serial_device_unrealize()
1124 virtio_delete_queue(vser->c_ivq); in virtio_serial_device_unrealize()
1125 virtio_delete_queue(vser->c_ovq); in virtio_serial_device_unrealize()
1126 for (i = 0; i < vser->bus.max_nr_ports; i++) { in virtio_serial_device_unrealize()
1127 virtio_delete_queue(vser->ivqs[i]); in virtio_serial_device_unrealize()
1128 virtio_delete_queue(vser->ovqs[i]); in virtio_serial_device_unrealize()
1131 g_free(vser->ivqs); in virtio_serial_device_unrealize()
1132 g_free(vser->ovqs); in virtio_serial_device_unrealize()
1133 g_free(vser->ports_map); in virtio_serial_device_unrealize()
1134 if (vser->post_load) { in virtio_serial_device_unrealize()
1135 g_free(vser->post_load->connected); in virtio_serial_device_unrealize()
1136 timer_free(vser->post_load->timer); in virtio_serial_device_unrealize()
1137 g_free(vser->post_load); in virtio_serial_device_unrealize()
1140 qbus_set_hotplug_handler(BUS(&vser->bus), NULL); in virtio_serial_device_unrealize()