diff options
author | br <br@FreeBSD.org> | 2014-12-09 16:39:21 +0000 |
---|---|---|
committer | br <br@FreeBSD.org> | 2014-12-09 16:39:21 +0000 |
commit | b236515e576a2b357f81501447abca80378b78b9 (patch) | |
tree | ec0ca7ea2c56ce51a7ed2ce107232ed71f45d159 /sys/dev/beri/virtio/virtio_mmio_platform.c | |
parent | 165484e7cf652fb6fb45c78f7430db2b37d513e7 (diff) | |
download | FreeBSD-src-b236515e576a2b357f81501447abca80378b78b9.zip FreeBSD-src-b236515e576a2b357f81501447abca80378b78b9.tar.gz |
o Add BERI Virtio Networking Frontend (if_vtbe)
o Move similar block/networking methods to common file
o Follow r275640 and correct MMIO registers width
o Pass value to MMIO platform_note method.
Sponsored by: DARPA, AFRL
Diffstat (limited to 'sys/dev/beri/virtio/virtio_mmio_platform.c')
-rw-r--r-- | sys/dev/beri/virtio/virtio_mmio_platform.c | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/sys/dev/beri/virtio/virtio_mmio_platform.c b/sys/dev/beri/virtio/virtio_mmio_platform.c index 41c50f8..0c58747d 100644 --- a/sys/dev/beri/virtio/virtio_mmio_platform.c +++ b/sys/dev/beri/virtio/virtio_mmio_platform.c @@ -149,20 +149,49 @@ virtio_mmio_platform_attach(device_t dev) } static int -platform_note(device_t dev, size_t offset) +platform_note(device_t dev, size_t offset, int val) { struct virtio_mmio_platform_softc *sc; + int note; + int i; sc = device_get_softc(dev); - if (offset == VIRTIO_MMIO_QUEUE_NOTIFY) { - mips_dcache_wbinv_all(); - PIO_SET(sc->pio_send, Q_NOTIFY, 1); + switch (offset) { + case (VIRTIO_MMIO_QUEUE_NOTIFY): + if (val == 0) + note = Q_NOTIFY; + else if (val == 1) + note = Q_NOTIFY1; + break; + case (VIRTIO_MMIO_QUEUE_PFN): + note = Q_PFN; + break; + case (VIRTIO_MMIO_QUEUE_SEL): + note = Q_SEL; + break; + default: + note = 0; } - if (offset == VIRTIO_MMIO_QUEUE_PFN) { + if (note) { mips_dcache_wbinv_all(); - PIO_SET(sc->pio_send, Q_PFN, 1); + + PIO_SET(sc->pio_send, note, 1); + + /* + * Wait until host ack the request. + * Usually done within few cycles. + * TODO: bad + */ + + for (i = 100; i > 0; i--) { + if (PIO_READ(sc->pio_send) == 0) + break; + } + + if (i == 0) + device_printf(sc->dev, "Warning: host busy\n"); } return (0); |