pci_virtio_block.c (257128) | pci_virtio_block.c (267393) |
---|---|
1/*- 2 * Copyright (c) 2011 NetApp, Inc. 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) 2011 NetApp, Inc. 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/pci_virtio_block.c 257128 2013-10-25 18:39:01Z grehan $ | 26 * $FreeBSD: stable/10/usr.sbin/bhyve/pci_virtio_block.c 267393 2014-06-12 13:13:15Z jhb $ |
27 */ 28 29#include <sys/cdefs.h> | 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: stable/10/usr.sbin/bhyve/pci_virtio_block.c 257128 2013-10-25 18:39:01Z grehan $"); | 30__FBSDID("$FreeBSD: stable/10/usr.sbin/bhyve/pci_virtio_block.c 267393 2014-06-12 13:13:15Z jhb $"); |
31 32#include <sys/param.h> 33#include <sys/linker_set.h> 34#include <sys/stat.h> 35#include <sys/uio.h> 36#include <sys/ioctl.h> 37#include <sys/disk.h> 38 --- 73 unchanged lines hidden (view full) --- 112#define DPRINTF(params) if (pci_vtblk_debug) printf params 113#define WPRINTF(params) printf params 114 115/* 116 * Per-device softc 117 */ 118struct pci_vtblk_softc { 119 struct virtio_softc vbsc_vs; | 31 32#include <sys/param.h> 33#include <sys/linker_set.h> 34#include <sys/stat.h> 35#include <sys/uio.h> 36#include <sys/ioctl.h> 37#include <sys/disk.h> 38 --- 73 unchanged lines hidden (view full) --- 112#define DPRINTF(params) if (pci_vtblk_debug) printf params 113#define WPRINTF(params) printf params 114 115/* 116 * Per-device softc 117 */ 118struct pci_vtblk_softc { 119 struct virtio_softc vbsc_vs; |
120 pthread_mutex_t vsc_mtx; |
|
120 struct vqueue_info vbsc_vq; 121 int vbsc_fd; 122 struct vtblk_config vbsc_cfg; 123 char vbsc_ident[VTBLK_BLK_ID_BYTES]; 124}; 125 126static void pci_vtblk_reset(void *); 127static void pci_vtblk_notify(void *, struct vqueue_info *); --- 171 unchanged lines hidden (view full) --- 299 } 300 301 sc = malloc(sizeof(struct pci_vtblk_softc)); 302 memset(sc, 0, sizeof(struct pci_vtblk_softc)); 303 304 /* record fd of storage device/file */ 305 sc->vbsc_fd = fd; 306 | 121 struct vqueue_info vbsc_vq; 122 int vbsc_fd; 123 struct vtblk_config vbsc_cfg; 124 char vbsc_ident[VTBLK_BLK_ID_BYTES]; 125}; 126 127static void pci_vtblk_reset(void *); 128static void pci_vtblk_notify(void *, struct vqueue_info *); --- 171 unchanged lines hidden (view full) --- 300 } 301 302 sc = malloc(sizeof(struct pci_vtblk_softc)); 303 memset(sc, 0, sizeof(struct pci_vtblk_softc)); 304 305 /* record fd of storage device/file */ 306 sc->vbsc_fd = fd; 307 |
308 pthread_mutex_init(&sc->vsc_mtx, NULL); 309 |
|
307 /* init virtio softc and virtqueues */ 308 vi_softc_linkup(&sc->vbsc_vs, &vtblk_vi_consts, sc, pi, &sc->vbsc_vq); | 310 /* init virtio softc and virtqueues */ 311 vi_softc_linkup(&sc->vbsc_vs, &vtblk_vi_consts, sc, pi, &sc->vbsc_vq); |
312 sc->vbsc_vs.vs_mtx = &sc->vsc_mtx; 313 |
|
309 sc->vbsc_vq.vq_qsize = VTBLK_RINGSZ; 310 /* sc->vbsc_vq.vq_notify = we have no per-queue notify */ 311 312 /* 313 * Create an identifier for the backing file. Use parts of the 314 * md5 sum of the filename 315 */ 316 MD5Init(&mdctx); --- 17 unchanged lines hidden (view full) --- 334 * have the device, class, and subdev_0 as fields in 335 * the virtio constants structure. 336 */ 337 pci_set_cfgdata16(pi, PCIR_DEVICE, VIRTIO_DEV_BLOCK); 338 pci_set_cfgdata16(pi, PCIR_VENDOR, VIRTIO_VENDOR); 339 pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_STORAGE); 340 pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_TYPE_BLOCK); 341 | 314 sc->vbsc_vq.vq_qsize = VTBLK_RINGSZ; 315 /* sc->vbsc_vq.vq_notify = we have no per-queue notify */ 316 317 /* 318 * Create an identifier for the backing file. Use parts of the 319 * md5 sum of the filename 320 */ 321 MD5Init(&mdctx); --- 17 unchanged lines hidden (view full) --- 339 * have the device, class, and subdev_0 as fields in 340 * the virtio constants structure. 341 */ 342 pci_set_cfgdata16(pi, PCIR_DEVICE, VIRTIO_DEV_BLOCK); 343 pci_set_cfgdata16(pi, PCIR_VENDOR, VIRTIO_VENDOR); 344 pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_STORAGE); 345 pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_TYPE_BLOCK); 346 |
347 pci_lintr_request(pi); 348 |
|
342 if (vi_intr_init(&sc->vbsc_vs, 1, fbsdrun_virtio_msix())) 343 return (1); 344 vi_set_io_bar(&sc->vbsc_vs, 0); 345 return (0); 346} 347 348static int 349pci_vtblk_cfgwrite(void *vsc, int offset, int size, uint32_t value) --- 25 unchanged lines hidden --- | 349 if (vi_intr_init(&sc->vbsc_vs, 1, fbsdrun_virtio_msix())) 350 return (1); 351 vi_set_io_bar(&sc->vbsc_vs, 0); 352 return (0); 353} 354 355static int 356pci_vtblk_cfgwrite(void *vsc, int offset, int size, uint32_t value) --- 25 unchanged lines hidden --- |