Lines Matching +full:virtio +full:- +full:pci

1 /*-
27 * The Virtio 9P transport driver. This file contains all functions related to
49 #include <dev/virtio/virtio.h>
50 #include <dev/virtio/virtqueue.h>
51 #include <dev/virtio/virtio_ring.h>
52 #include <dev/virtio/p9fs/virtio_p9fs.h>
54 #define VT9P_MTX(_sc) (&(_sc)->vt9p_mtx)
58 "VIRTIO 9P CHAN lock", NULL, MTX_DEF)
87 /* We don't currently allow canceling of virtio requests */
113 KASSERT(req->tc->tag != req->rc->tag,
125 KASSERT(req->tc->tag == req->rc->tag,
148 sg = chan->vt9p_sglist;
149 vq = chan->vt9p_vq;
157 /* Handle out VirtIO ring buffers */
158 error = sglist_append(sg, req->tc->sdata, req->tc->size);
164 readable = sg->sg_nseg;
166 error = sglist_append(sg, req->rc->sdata, req->rc->capacity);
172 writable = sg->sg_nseg - readable;
181 cv_wait(&chan->submit_cv, VT9P_MTX(chan));
182 P9_DEBUG(TRANS, "%s: retry virtio request\n", __func__);
185 P9_DEBUG(ERROR, "%s: virtio enuqueue failed \n", __func__);
202 P9_DEBUG(TRANS, "%s: virtio request kicked\n", __func__);
220 vq = chan->vt9p_vq;
227 curreq->rc->tag = curreq->tc->tag;
234 cv_signal(&chan->submit_cv);
247 dev = sc->vt9p_dev;
249 VQ_ALLOC_INFO_INIT(&vq_info, sc->max_nsegs,
250 vt9p_intr_complete, sc, &sc->vt9p_vq,
256 /* Probe for existence of 9P virtio channels */
261 /* If the virtio device type is a 9P device, then we claim and attach it */
264 device_set_desc(dev, "VirtIO 9P Transport");
274 virtqueue_disable_intr(sc->vt9p_vq);
275 virtio_stop(sc->vt9p_dev);
278 /* Detach the 9P virtio PCI device */
289 if (sc->vt9p_sglist) {
290 sglist_free(sc->vt9p_sglist);
291 sc->vt9p_sglist = NULL;
293 if (sc->mount_tag) {
294 free(sc->mount_tag, M_P9FS_MNTTAG);
295 sc->mount_tag = NULL;
302 cv_destroy(&sc->submit_cv);
307 /* Attach the 9P virtio PCI device */
319 chan->vt9p_dev = dev;
324 cv_init(&chan->submit_cv, "Conditional variable for submit queue" );
325 chan->max_nsegs = MAX_SUPPORTED_SGS;
326 chan->vt9p_sglist = sglist_alloc(chan->max_nsegs, M_WAITOK);
354 chan->mount_tag_len = mount_tag_len;
355 chan->mount_tag = mount_tag;
360 CTLFLAG_RD, chan->mount_tag, 0, "Mount tag");
373 error = virtqueue_enable_intr(chan->vt9p_vq);
392 * Allocate a new virtio channel. This sets up a transport channel
408 if (!strcmp(sc->mount_tag, mount_tag)) {
419 if (chan && chan->busy) {
420 //p9_debug(TRANS, "Channel busy: used by clnt=%p\n", chan->client);
427 chan->busy = true;
442 chan->busy = false;
446 .name = "virtio",
493 MODULE_DEPEND(virtio_p9fs, virtio, 1, 1, 1);