Lines Matching refs:vq

174 	struct vhost_virtqueue vq;  member
256 struct vhost_virtqueue *vq; in vhost_scsi_init_inflight() local
260 vq = &vs->vqs[i].vq; in vhost_scsi_init_inflight()
262 mutex_lock(&vq->mutex); in vhost_scsi_init_inflight()
275 mutex_unlock(&vq->mutex); in vhost_scsi_init_inflight()
280 vhost_scsi_get_inflight(struct vhost_virtqueue *vq) in vhost_scsi_get_inflight() argument
285 svq = container_of(vq, struct vhost_scsi_virtqueue, vq); in vhost_scsi_get_inflight()
331 struct vhost_scsi_virtqueue, vq); in vhost_scsi_release_cmd_res()
366 struct vhost_virtqueue *vq = &tmf->svq->vq; in vhost_scsi_release_cmd() local
368 vhost_vq_work_queue(vq, &tmf->vwork); in vhost_scsi_release_cmd()
373 struct vhost_scsi_virtqueue, vq); in vhost_scsi_release_cmd()
376 vhost_vq_work_queue(&svq->vq, &svq->completion_work); in vhost_scsi_release_cmd()
423 struct vhost_virtqueue *vq = &vs->vqs[VHOST_SCSI_VQ_EVT].vq; in vhost_scsi_allocate_evt() local
433 vq_err(vq, "Failed to allocate vhost_scsi_evt\n"); in vhost_scsi_allocate_evt()
438 evt->event.event = cpu_to_vhost32(vq, event); in vhost_scsi_allocate_evt()
439 evt->event.reason = cpu_to_vhost32(vq, reason); in vhost_scsi_allocate_evt()
453 struct vhost_virtqueue *vq = &vs->vqs[VHOST_SCSI_VQ_EVT].vq; in vhost_scsi_do_evt_work() local
459 if (!vhost_vq_get_backend(vq)) { in vhost_scsi_do_evt_work()
465 vhost_disable_notify(&vs->dev, vq); in vhost_scsi_do_evt_work()
466 head = vhost_get_vq_desc(vq, vq->iov, in vhost_scsi_do_evt_work()
467 ARRAY_SIZE(vq->iov), &out, &in, in vhost_scsi_do_evt_work()
473 if (head == vq->num) { in vhost_scsi_do_evt_work()
474 if (vhost_enable_notify(&vs->dev, vq)) in vhost_scsi_do_evt_work()
480 if ((vq->iov[out].iov_len != sizeof(struct virtio_scsi_event))) { in vhost_scsi_do_evt_work()
481 vq_err(vq, "Expecting virtio_scsi_event, got %zu bytes\n", in vhost_scsi_do_evt_work()
482 vq->iov[out].iov_len); in vhost_scsi_do_evt_work()
488 event->event |= cpu_to_vhost32(vq, VIRTIO_SCSI_T_EVENTS_MISSED); in vhost_scsi_do_evt_work()
492 eventp = vq->iov[out].iov_base; in vhost_scsi_do_evt_work()
495 vhost_add_used_and_signal(&vs->dev, vq, head, 0); in vhost_scsi_do_evt_work()
497 vq_err(vq, "Faulted on vhost_scsi_send_event\n"); in vhost_scsi_do_evt_work()
502 struct vhost_virtqueue *vq = &vs->vqs[VHOST_SCSI_VQ_EVT].vq; in vhost_scsi_complete_events() local
506 mutex_lock(&vq->mutex); in vhost_scsi_complete_events()
513 mutex_unlock(&vq->mutex); in vhost_scsi_complete_events()
597 vhost_signal(&svq->vs->dev, &svq->vq); in vhost_scsi_complete_cmd_work()
601 vhost_scsi_get_cmd(struct vhost_virtqueue *vq, struct vhost_scsi_tpg *tpg, in vhost_scsi_get_cmd() argument
605 struct vhost_scsi_virtqueue *svq = container_of(vq, in vhost_scsi_get_cmd()
606 struct vhost_scsi_virtqueue, vq); in vhost_scsi_get_cmd()
642 cmd->inflight = vhost_scsi_get_inflight(vq); in vhost_scsi_get_cmd()
923 struct vhost_virtqueue *vq, in vhost_scsi_send_bad_target() argument
932 resp = vq->iov[out].iov_base; in vhost_scsi_send_bad_target()
935 vhost_add_used_and_signal(&vs->dev, vq, head, 0); in vhost_scsi_send_bad_target()
941 vhost_scsi_get_desc(struct vhost_scsi *vs, struct vhost_virtqueue *vq, in vhost_scsi_get_desc() argument
946 vc->head = vhost_get_vq_desc(vq, vq->iov, in vhost_scsi_get_desc()
947 ARRAY_SIZE(vq->iov), &vc->out, &vc->in, in vhost_scsi_get_desc()
958 if (vc->head == vq->num) { in vhost_scsi_get_desc()
959 if (unlikely(vhost_enable_notify(&vs->dev, vq))) { in vhost_scsi_get_desc()
960 vhost_disable_notify(&vs->dev, vq); in vhost_scsi_get_desc()
970 vc->out_size = iov_length(vq->iov, vc->out); in vhost_scsi_get_desc()
971 vc->in_size = iov_length(&vq->iov[vc->out], vc->in); in vhost_scsi_get_desc()
983 iov_iter_init(&vc->out_iter, ITER_SOURCE, vq->iov, vc->out, vc->out_size); in vhost_scsi_get_desc()
991 vhost_scsi_chk_size(struct vhost_virtqueue *vq, struct vhost_scsi_ctx *vc) in vhost_scsi_chk_size() argument
994 vq_err(vq, in vhost_scsi_chk_size()
999 vq_err(vq, in vhost_scsi_chk_size()
1009 vhost_scsi_get_req(struct vhost_virtqueue *vq, struct vhost_scsi_ctx *vc, in vhost_scsi_get_req() argument
1016 vq_err(vq, "Faulted on copy_from_iter_full\n"); in vhost_scsi_get_req()
1019 vq_err(vq, "Illegal virtio-scsi lun: %u\n", *vc->lunp); in vhost_scsi_get_req()
1025 vs_tpg = vhost_vq_get_backend(vq); in vhost_scsi_get_req()
1028 vq_err(vq, "Target 0x%x does not exist\n", *vc->target); in vhost_scsi_get_req()
1047 vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) in vhost_scsi_handle_vq() argument
1060 bool t10_pi = vhost_has_feature(vq, VIRTIO_SCSI_F_T10_PI); in vhost_scsi_handle_vq()
1063 mutex_lock(&vq->mutex); in vhost_scsi_handle_vq()
1068 vs_tpg = vhost_vq_get_backend(vq); in vhost_scsi_handle_vq()
1075 vhost_disable_notify(&vs->dev, vq); in vhost_scsi_handle_vq()
1078 ret = vhost_scsi_get_desc(vs, vq, &vc); in vhost_scsi_handle_vq()
1103 ret = vhost_scsi_chk_size(vq, &vc); in vhost_scsi_handle_vq()
1107 ret = vhost_scsi_get_req(vq, &vc, &tpg); in vhost_scsi_handle_vq()
1138 iov_iter_init(&in_iter, ITER_DEST, &vq->iov[vc.out], vc.in, in vhost_scsi_handle_vq()
1154 vq_err(vq, "Received non zero pi_bytesout," in vhost_scsi_handle_vq()
1158 prot_bytes = vhost32_to_cpu(vq, v_req_pi.pi_bytesout); in vhost_scsi_handle_vq()
1161 vq_err(vq, "Received non zero pi_bytesin," in vhost_scsi_handle_vq()
1165 prot_bytes = vhost32_to_cpu(vq, v_req_pi.pi_bytesin); in vhost_scsi_handle_vq()
1181 tag = vhost64_to_cpu(vq, v_req_pi.tag); in vhost_scsi_handle_vq()
1186 tag = vhost64_to_cpu(vq, v_req.tag); in vhost_scsi_handle_vq()
1199 vq_err(vq, "Received SCSI CDB with command_size: %d that" in vhost_scsi_handle_vq()
1204 cmd = vhost_scsi_get_cmd(vq, tpg, cdb, tag, lun, task_attr, in vhost_scsi_handle_vq()
1208 vq_err(vq, "vhost_scsi_get_cmd failed %ld\n", in vhost_scsi_handle_vq()
1213 cmd->tvc_vq = vq; in vhost_scsi_handle_vq()
1215 cmd->tvc_resp_iov[i] = vq->iov[vc.out + i]; in vhost_scsi_handle_vq()
1227 vq_err(vq, "Failed to map iov to sgl\n"); in vhost_scsi_handle_vq()
1250 vhost_scsi_send_bad_target(vs, vq, vc.head, vc.out); in vhost_scsi_handle_vq()
1251 } while (likely(!vhost_exceeds_weight(vq, ++c, 0))); in vhost_scsi_handle_vq()
1253 mutex_unlock(&vq->mutex); in vhost_scsi_handle_vq()
1257 vhost_scsi_send_tmf_resp(struct vhost_scsi *vs, struct vhost_virtqueue *vq, in vhost_scsi_send_tmf_resp() argument
1273 vhost_add_used_and_signal(&vs->dev, vq, vq_desc, 0); in vhost_scsi_send_tmf_resp()
1282 struct vhost_virtqueue *ctl_vq, *vq; in vhost_scsi_tmf_resp_work() local
1290 ctl_vq = &tmf->vhost->vqs[VHOST_SCSI_VQ_CTL].vq; in vhost_scsi_tmf_resp_work()
1292 vq = &tmf->vhost->vqs[i].vq; in vhost_scsi_tmf_resp_work()
1294 if (vhost_vq_is_setup(vq) && in vhost_scsi_tmf_resp_work()
1295 vq->worker != ctl_vq->worker) in vhost_scsi_tmf_resp_work()
1296 vhost_vq_flush(vq); in vhost_scsi_tmf_resp_work()
1304 vhost_scsi_send_tmf_resp(tmf->vhost, &tmf->svq->vq, tmf->in_iovs, in vhost_scsi_tmf_resp_work()
1311 struct vhost_virtqueue *vq, in vhost_scsi_handle_tmf() argument
1315 struct vhost_scsi_virtqueue *svq = container_of(vq, in vhost_scsi_handle_tmf()
1316 struct vhost_scsi_virtqueue, vq); in vhost_scsi_handle_tmf()
1319 if (vhost32_to_cpu(vq, vtmf->subtype) != in vhost_scsi_handle_tmf()
1335 tmf->resp_iov = vq->iov[vc->out]; in vhost_scsi_handle_tmf()
1338 tmf->inflight = vhost_scsi_get_inflight(vq); in vhost_scsi_handle_tmf()
1351 vhost_scsi_send_tmf_resp(vs, vq, vc->in, vc->head, &vq->iov[vc->out], in vhost_scsi_handle_tmf()
1357 struct vhost_virtqueue *vq, in vhost_scsi_send_an_resp() argument
1368 iov_iter_init(&iov_iter, ITER_DEST, &vq->iov[vc->out], vc->in, sizeof(rsp)); in vhost_scsi_send_an_resp()
1372 vhost_add_used_and_signal(&vs->dev, vq, vc->head, 0); in vhost_scsi_send_an_resp()
1378 vhost_scsi_ctl_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) in vhost_scsi_ctl_handle_vq() argument
1390 mutex_lock(&vq->mutex); in vhost_scsi_ctl_handle_vq()
1395 if (!vhost_vq_get_backend(vq)) in vhost_scsi_ctl_handle_vq()
1400 vhost_disable_notify(&vs->dev, vq); in vhost_scsi_ctl_handle_vq()
1403 ret = vhost_scsi_get_desc(vs, vq, &vc); in vhost_scsi_ctl_handle_vq()
1416 vq_err(vq, "Faulted on copy_from_iter tmf type\n"); in vhost_scsi_ctl_handle_vq()
1426 switch (vhost32_to_cpu(vq, v_req.type)) { in vhost_scsi_ctl_handle_vq()
1443 vq_err(vq, "Unknown control request %d", v_req.type); in vhost_scsi_ctl_handle_vq()
1452 ret = vhost_scsi_chk_size(vq, &vc); in vhost_scsi_ctl_handle_vq()
1462 ret = vhost_scsi_get_req(vq, &vc, &tpg); in vhost_scsi_ctl_handle_vq()
1467 vhost_scsi_handle_tmf(vs, tpg, vq, &v_req.tmf, &vc); in vhost_scsi_ctl_handle_vq()
1469 vhost_scsi_send_an_resp(vs, vq, &vc); in vhost_scsi_ctl_handle_vq()
1480 vhost_scsi_send_bad_target(vs, vq, vc.head, vc.out); in vhost_scsi_ctl_handle_vq()
1481 } while (likely(!vhost_exceeds_weight(vq, ++c, 0))); in vhost_scsi_ctl_handle_vq()
1483 mutex_unlock(&vq->mutex); in vhost_scsi_ctl_handle_vq()
1488 struct vhost_virtqueue *vq = container_of(work, struct vhost_virtqueue, in vhost_scsi_ctl_handle_kick() local
1490 struct vhost_scsi *vs = container_of(vq->dev, struct vhost_scsi, dev); in vhost_scsi_ctl_handle_kick()
1493 vhost_scsi_ctl_handle_vq(vs, vq); in vhost_scsi_ctl_handle_kick()
1497 vhost_scsi_send_evt(struct vhost_scsi *vs, struct vhost_virtqueue *vq, in vhost_scsi_send_evt() argument
1521 if (!vhost_vq_work_queue(vq, &vs->vs_event_work)) in vhost_scsi_send_evt()
1527 struct vhost_virtqueue *vq = container_of(work, struct vhost_virtqueue, in vhost_scsi_evt_handle_kick() local
1529 struct vhost_scsi *vs = container_of(vq->dev, struct vhost_scsi, dev); in vhost_scsi_evt_handle_kick()
1531 mutex_lock(&vq->mutex); in vhost_scsi_evt_handle_kick()
1532 if (!vhost_vq_get_backend(vq)) in vhost_scsi_evt_handle_kick()
1536 vhost_scsi_send_evt(vs, vq, NULL, NULL, VIRTIO_SCSI_T_NO_EVENT, in vhost_scsi_evt_handle_kick()
1539 mutex_unlock(&vq->mutex); in vhost_scsi_evt_handle_kick()
1544 struct vhost_virtqueue *vq = container_of(work, struct vhost_virtqueue, in vhost_scsi_handle_kick() local
1546 struct vhost_scsi *vs = container_of(vq->dev, struct vhost_scsi, dev); in vhost_scsi_handle_kick()
1548 vhost_scsi_handle_vq(vs, vq); in vhost_scsi_handle_kick()
1575 static void vhost_scsi_destroy_vq_cmds(struct vhost_virtqueue *vq) in vhost_scsi_destroy_vq_cmds() argument
1577 struct vhost_scsi_virtqueue *svq = container_of(vq, in vhost_scsi_destroy_vq_cmds()
1578 struct vhost_scsi_virtqueue, vq); in vhost_scsi_destroy_vq_cmds()
1599 static int vhost_scsi_setup_vq_cmds(struct vhost_virtqueue *vq, int max_cmds) in vhost_scsi_setup_vq_cmds() argument
1601 struct vhost_scsi_virtqueue *svq = container_of(vq, in vhost_scsi_setup_vq_cmds()
1602 struct vhost_scsi_virtqueue, vq); in vhost_scsi_setup_vq_cmds()
1657 vhost_scsi_destroy_vq_cmds(vq); in vhost_scsi_setup_vq_cmds()
1676 struct vhost_virtqueue *vq; in vhost_scsi_set_endpoint() local
1685 if (!vhost_vq_access_ok(&vs->vqs[index].vq)) { in vhost_scsi_set_endpoint()
1748 vq = &vs->vqs[i].vq; in vhost_scsi_set_endpoint()
1749 if (!vhost_vq_is_setup(vq)) in vhost_scsi_set_endpoint()
1752 ret = vhost_scsi_setup_vq_cmds(vq, vq->num); in vhost_scsi_set_endpoint()
1758 vq = &vs->vqs[i].vq; in vhost_scsi_set_endpoint()
1759 mutex_lock(&vq->mutex); in vhost_scsi_set_endpoint()
1760 vhost_vq_set_backend(vq, vs_tpg); in vhost_scsi_set_endpoint()
1761 vhost_vq_init_access(vq); in vhost_scsi_set_endpoint()
1762 mutex_unlock(&vq->mutex); in vhost_scsi_set_endpoint()
1780 if (!vhost_vq_get_backend(&vs->vqs[i].vq)) in vhost_scsi_set_endpoint()
1781 vhost_scsi_destroy_vq_cmds(&vs->vqs[i].vq); in vhost_scsi_set_endpoint()
1807 struct vhost_virtqueue *vq; in vhost_scsi_clear_endpoint() local
1815 if (!vhost_vq_access_ok(&vs->vqs[index].vq)) { in vhost_scsi_clear_endpoint()
1853 vq = &vs->vqs[i].vq; in vhost_scsi_clear_endpoint()
1854 mutex_lock(&vq->mutex); in vhost_scsi_clear_endpoint()
1855 vhost_vq_set_backend(vq, NULL); in vhost_scsi_clear_endpoint()
1856 mutex_unlock(&vq->mutex); in vhost_scsi_clear_endpoint()
1862 vq = &vs->vqs[i].vq; in vhost_scsi_clear_endpoint()
1863 vhost_scsi_destroy_vq_cmds(vq); in vhost_scsi_clear_endpoint()
1907 struct vhost_virtqueue *vq; in vhost_scsi_set_features() local
1921 vq = &vs->vqs[i].vq; in vhost_scsi_set_features()
1922 mutex_lock(&vq->mutex); in vhost_scsi_set_features()
1923 vq->acked_features = features; in vhost_scsi_set_features()
1924 mutex_unlock(&vq->mutex); in vhost_scsi_set_features()
1970 vqs[VHOST_SCSI_VQ_CTL] = &vs->vqs[VHOST_SCSI_VQ_CTL].vq; in vhost_scsi_open()
1971 vqs[VHOST_SCSI_VQ_EVT] = &vs->vqs[VHOST_SCSI_VQ_EVT].vq; in vhost_scsi_open()
1972 vs->vqs[VHOST_SCSI_VQ_CTL].vq.handle_kick = vhost_scsi_ctl_handle_kick; in vhost_scsi_open()
1973 vs->vqs[VHOST_SCSI_VQ_EVT].vq.handle_kick = vhost_scsi_evt_handle_kick; in vhost_scsi_open()
1977 vqs[i] = &svq->vq; in vhost_scsi_open()
1982 svq->vq.handle_kick = vhost_scsi_handle_kick; in vhost_scsi_open()
2033 struct vhost_virtqueue *vq = &vs->vqs[VHOST_SCSI_VQ_EVT].vq; in vhost_scsi_ioctl() local
2057 mutex_lock(&vq->mutex); in vhost_scsi_ioctl()
2059 mutex_unlock(&vq->mutex); in vhost_scsi_ioctl()
2062 mutex_lock(&vq->mutex); in vhost_scsi_ioctl()
2064 mutex_unlock(&vq->mutex); in vhost_scsi_ioctl()
2143 struct vhost_virtqueue *vq; in vhost_scsi_do_plug() local
2154 vq = &vs->vqs[VHOST_SCSI_VQ_EVT].vq; in vhost_scsi_do_plug()
2155 mutex_lock(&vq->mutex); in vhost_scsi_do_plug()
2160 if (!vhost_vq_get_backend(vq)) in vhost_scsi_do_plug()
2163 if (vhost_has_feature(vq, VIRTIO_SCSI_F_HOTPLUG)) in vhost_scsi_do_plug()
2164 vhost_scsi_send_evt(vs, vq, tpg, lun, in vhost_scsi_do_plug()
2167 mutex_unlock(&vq->mutex); in vhost_scsi_do_plug()