Deleted Added
full compact
virtio.h (256281) virtio.h (267393)
1/*-
2 * Copyright (c) 2013 Chris Torek <torek @ torek net>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2013 Chris Torek <torek @ torek net>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: stable/10/usr.sbin/bhyve/virtio.h 253440 2013-07-17 23:37:33Z grehan $
26 * $FreeBSD: stable/10/usr.sbin/bhyve/virtio.h 267393 2014-06-12 13:13:15Z jhb $
27 */
28
29#ifndef _VIRTIO_H_
30#define _VIRTIO_H_
31
32/*
33 * These are derived from several virtio specifications.
34 *

--- 288 unchanged lines hidden (view full) ---

323 uint32_t vs_negotiated_caps; /* negotiated capabilities */
324 struct vqueue_info *vs_queues; /* one per vc_nvq */
325 int vs_curq; /* current queue */
326 uint8_t vs_status; /* value from last status write */
327 uint8_t vs_isr; /* ISR flags, if not MSI-X */
328 uint16_t vs_msix_cfg_idx; /* MSI-X vector for config event */
329};
330
27 */
28
29#ifndef _VIRTIO_H_
30#define _VIRTIO_H_
31
32/*
33 * These are derived from several virtio specifications.
34 *

--- 288 unchanged lines hidden (view full) ---

323 uint32_t vs_negotiated_caps; /* negotiated capabilities */
324 struct vqueue_info *vs_queues; /* one per vc_nvq */
325 int vs_curq; /* current queue */
326 uint8_t vs_status; /* value from last status write */
327 uint8_t vs_isr; /* ISR flags, if not MSI-X */
328 uint16_t vs_msix_cfg_idx; /* MSI-X vector for config event */
329};
330
331#define VS_LOCK(vs) \
332do { \
333 if (vs->vs_mtx) \
334 pthread_mutex_lock(vs->vs_mtx); \
335} while (0)
336
337#define VS_UNLOCK(vs) \
338do { \
339 if (vs->vs_mtx) \
340 pthread_mutex_unlock(vs->vs_mtx); \
341} while (0)
342
331struct virtio_consts {
332 const char *vc_name; /* name of driver (for diagnostics) */
333 int vc_nvq; /* number of virtual queues */
334 size_t vc_cfgsize; /* size of dev-specific config regs */
335 void (*vc_reset)(void *); /* called on virtual device reset */
336 void (*vc_qnotify)(void *, struct vqueue_info *);
337 /* called on QNOTIFY if no VQ notify */
338 int (*vc_cfgread)(void *, int, int, uint32_t *);

--- 87 unchanged lines hidden (view full) ---

426/*
427 * Deliver an interrupt to guest on the given virtual queue
428 * (if possible, or a generic MSI interrupt if not using MSI-X).
429 */
430static inline void
431vq_interrupt(struct virtio_softc *vs, struct vqueue_info *vq)
432{
433
343struct virtio_consts {
344 const char *vc_name; /* name of driver (for diagnostics) */
345 int vc_nvq; /* number of virtual queues */
346 size_t vc_cfgsize; /* size of dev-specific config regs */
347 void (*vc_reset)(void *); /* called on virtual device reset */
348 void (*vc_qnotify)(void *, struct vqueue_info *);
349 /* called on QNOTIFY if no VQ notify */
350 int (*vc_cfgread)(void *, int, int, uint32_t *);

--- 87 unchanged lines hidden (view full) ---

438/*
439 * Deliver an interrupt to guest on the given virtual queue
440 * (if possible, or a generic MSI interrupt if not using MSI-X).
441 */
442static inline void
443vq_interrupt(struct virtio_softc *vs, struct vqueue_info *vq)
444{
445
434 if (vs->vs_flags & VIRTIO_USE_MSIX)
446 if (pci_msix_enabled(vs->vs_pi))
435 pci_generate_msix(vs->vs_pi, vq->vq_msix_idx);
436 else {
447 pci_generate_msix(vs->vs_pi, vq->vq_msix_idx);
448 else {
449 VS_LOCK(vs);
437 vs->vs_isr |= VTCFG_ISR_QUEUES;
438 pci_generate_msi(vs->vs_pi, 0);
450 vs->vs_isr |= VTCFG_ISR_QUEUES;
451 pci_generate_msi(vs->vs_pi, 0);
452 pci_lintr_assert(vs->vs_pi);
453 VS_UNLOCK(vs);
439 }
440}
441
442struct iovec;
443void vi_softc_linkup(struct virtio_softc *vs, struct virtio_consts *vc,
444 void *dev_softc, struct pci_devinst *pi,
445 struct vqueue_info *queues);
446int vi_intr_init(struct virtio_softc *vs, int barnum, int use_msix);

--- 13 unchanged lines hidden ---
454 }
455}
456
457struct iovec;
458void vi_softc_linkup(struct virtio_softc *vs, struct virtio_consts *vc,
459 void *dev_softc, struct pci_devinst *pi,
460 struct vqueue_info *queues);
461int vi_intr_init(struct virtio_softc *vs, int barnum, int use_msix);

--- 13 unchanged lines hidden ---