Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_virtio_scsi.c
Show First 20 Lines • Show All 552 Lines • ▼ Show 20 Lines | pci_vtscsi_request_handle(struct pci_vtscsi_queue *q, struct iovec *iov_in, | ||||
return (nxferred); | return (nxferred); | ||||
} | } | ||||
static void | static void | ||||
pci_vtscsi_controlq_notify(void *vsc, struct vqueue_info *vq) | pci_vtscsi_controlq_notify(void *vsc, struct vqueue_info *vq) | ||||
{ | { | ||||
struct pci_vtscsi_softc *sc; | struct pci_vtscsi_softc *sc; | ||||
struct iovec iov[VTSCSI_MAXSEG]; | struct iovec iov[VTSCSI_MAXSEG]; | ||||
uint16_t idx, n; | struct vi_req req; | ||||
uint16_t n; | |||||
void *buf = NULL; | void *buf = NULL; | ||||
size_t bufsize; | size_t bufsize; | ||||
int iolen; | int iolen; | ||||
sc = vsc; | sc = vsc; | ||||
while (vq_has_descs(vq)) { | while (vq_has_descs(vq)) { | ||||
n = vq_getchain(vq, &idx, iov, VTSCSI_MAXSEG, NULL); | n = vq_getchain(vq, iov, VTSCSI_MAXSEG, &req); | ||||
bufsize = iov_to_buf(iov, n, &buf); | bufsize = iov_to_buf(iov, n, &buf); | ||||
iolen = pci_vtscsi_control_handle(sc, buf, bufsize); | iolen = pci_vtscsi_control_handle(sc, buf, bufsize); | ||||
buf_to_iov(buf + bufsize - iolen, iolen, iov, n, | buf_to_iov(buf + bufsize - iolen, iolen, iov, n, | ||||
bufsize - iolen); | bufsize - iolen); | ||||
/* | /* | ||||
* Release this chain and handle more | * Release this chain and handle more | ||||
*/ | */ | ||||
vq_relchain(vq, idx, iolen); | vq_relchain(vq, req.idx, iolen); | ||||
} | } | ||||
vq_endchains(vq, 1); /* Generate interrupt if appropriate. */ | vq_endchains(vq, 1); /* Generate interrupt if appropriate. */ | ||||
free(buf); | free(buf); | ||||
} | } | ||||
static void | static void | ||||
pci_vtscsi_eventq_notify(void *vsc, struct vqueue_info *vq) | pci_vtscsi_eventq_notify(void *vsc, struct vqueue_info *vq) | ||||
{ | { | ||||
vq_kick_disable(vq); | vq_kick_disable(vq); | ||||
} | } | ||||
static void | static void | ||||
pci_vtscsi_requestq_notify(void *vsc, struct vqueue_info *vq) | pci_vtscsi_requestq_notify(void *vsc, struct vqueue_info *vq) | ||||
{ | { | ||||
struct pci_vtscsi_softc *sc; | struct pci_vtscsi_softc *sc; | ||||
struct pci_vtscsi_queue *q; | struct pci_vtscsi_queue *q; | ||||
struct pci_vtscsi_request *req; | struct pci_vtscsi_request *req; | ||||
struct iovec iov[VTSCSI_MAXSEG]; | struct iovec iov[VTSCSI_MAXSEG]; | ||||
uint16_t flags[VTSCSI_MAXSEG]; | struct vi_req vireq; | ||||
uint16_t idx, n, i; | uint16_t n; | ||||
int readable; | |||||
sc = vsc; | sc = vsc; | ||||
q = &sc->vss_queues[vq->vq_num - 2]; | q = &sc->vss_queues[vq->vq_num - 2]; | ||||
while (vq_has_descs(vq)) { | while (vq_has_descs(vq)) { | ||||
readable = 0; | n = vq_getchain(vq, iov, VTSCSI_MAXSEG, &vireq); | ||||
n = vq_getchain(vq, &idx, iov, VTSCSI_MAXSEG, flags); | |||||
/* Count readable descriptors */ | |||||
for (i = 0; i < n; i++) { | |||||
if (flags[i] & VRING_DESC_F_WRITE) | |||||
break; | |||||
readable++; | |||||
} | |||||
req = calloc(1, sizeof(struct pci_vtscsi_request)); | req = calloc(1, sizeof(struct pci_vtscsi_request)); | ||||
req->vsr_idx = idx; | req->vsr_idx = vireq.idx; | ||||
req->vsr_queue = q; | req->vsr_queue = q; | ||||
req->vsr_niov_in = readable; | req->vsr_niov_in = vireq.readable; | ||||
req->vsr_niov_out = n - readable; | req->vsr_niov_out = vireq.writable; | ||||
memcpy(req->vsr_iov_in, iov, | memcpy(req->vsr_iov_in, iov, | ||||
req->vsr_niov_in * sizeof(struct iovec)); | req->vsr_niov_in * sizeof(struct iovec)); | ||||
memcpy(req->vsr_iov_out, iov + readable, | memcpy(req->vsr_iov_out, iov + vireq.readable, | ||||
req->vsr_niov_out * sizeof(struct iovec)); | req->vsr_niov_out * sizeof(struct iovec)); | ||||
pthread_mutex_lock(&q->vsq_mtx); | pthread_mutex_lock(&q->vsq_mtx); | ||||
STAILQ_INSERT_TAIL(&q->vsq_requests, req, vsr_link); | STAILQ_INSERT_TAIL(&q->vsq_requests, req, vsr_link); | ||||
pthread_cond_signal(&q->vsq_cv); | pthread_cond_signal(&q->vsq_cv); | ||||
pthread_mutex_unlock(&q->vsq_mtx); | pthread_mutex_unlock(&q->vsq_mtx); | ||||
DPRINTF(("virtio-scsi: request <idx=%d> enqueued", idx)); | DPRINTF(("virtio-scsi: request <idx=%d> enqueued", | ||||
vireq.idx)); | |||||
afedorov: enqueuedvi -> enqueued | |||||
} | } | ||||
} | } | ||||
static int | static int | ||||
pci_vtscsi_init_queue(struct pci_vtscsi_softc *sc, | pci_vtscsi_init_queue(struct pci_vtscsi_softc *sc, | ||||
struct pci_vtscsi_queue *queue, int num) | struct pci_vtscsi_queue *queue, int num) | ||||
{ | { | ||||
struct pci_vtscsi_worker *worker; | struct pci_vtscsi_worker *worker; | ||||
▲ Show 20 Lines • Show All 105 Lines • Show Last 20 Lines |
enqueuedvi -> enqueued