Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/virtio/virtqueue.c
Show First 20 Lines • Show All 598 Lines • ▼ Show 20 Lines | virtqueue_dequeue(struct virtqueue *vq, uint32_t *len) | ||||
cookie = vq->vq_descx[desc_idx].cookie; | cookie = vq->vq_descx[desc_idx].cookie; | ||||
VQASSERT(vq, cookie != NULL, "no cookie for index %d", desc_idx); | VQASSERT(vq, cookie != NULL, "no cookie for index %d", desc_idx); | ||||
vq->vq_descx[desc_idx].cookie = NULL; | vq->vq_descx[desc_idx].cookie = NULL; | ||||
return (cookie); | return (cookie); | ||||
} | } | ||||
void * | void * | ||||
virtqueue_poll(struct virtqueue *vq, uint32_t *len) | virtqueue_poll_timeout(struct virtqueue *vq, uint32_t *len, sbintime_t sbt) | ||||
{ | { | ||||
void *cookie; | void *cookie; | ||||
sbintime_t timeout_at; | |||||
timeout_at = sbt == 0 ? 0 : getsbinuptime() + sbt; | |||||
VIRTIO_BUS_POLL(vq->vq_dev); | VIRTIO_BUS_POLL(vq->vq_dev); | ||||
while ((cookie = virtqueue_dequeue(vq, len)) == NULL) { | while ((cookie = virtqueue_dequeue(vq, len)) == NULL && | ||||
(timeout_at == 0 || getsbinuptime() < timeout_at)) { | |||||
cpu_spinwait(); | cpu_spinwait(); | ||||
VIRTIO_BUS_POLL(vq->vq_dev); | VIRTIO_BUS_POLL(vq->vq_dev); | ||||
} | } | ||||
return (cookie); | |||||
} | |||||
void * | |||||
virtqueue_poll(struct virtqueue *vq, uint32_t *len) | |||||
{ | |||||
void *cookie; | |||||
cookie = virtqueue_poll_timeout(vq, len, 0); | |||||
/* No reason for this to have failed. */ | |||||
MPASS(cookie != NULL); | |||||
jrtc27: Maybe VQASSERT like the other assertions in this file? | |||||
return (cookie); | return (cookie); | ||||
} | } | ||||
void * | void * | ||||
virtqueue_drain(struct virtqueue *vq, int *last) | virtqueue_drain(struct virtqueue *vq, int *last) | ||||
{ | { | ||||
void *cookie; | void *cookie; | ||||
int idx; | int idx; | ||||
▲ Show 20 Lines • Show All 259 Lines • Show Last 20 Lines |
Maybe VQASSERT like the other assertions in this file?