Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_virtio_9p.c
Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | static struct virtio_consts vt9p_vi_consts = { | ||||
"vt9p", /* our name */ | "vt9p", /* our name */ | ||||
1, /* we support 1 virtqueue */ | 1, /* we support 1 virtqueue */ | ||||
VT9P_CONFIGSPACESZ, /* config reg size */ | VT9P_CONFIGSPACESZ, /* config reg size */ | ||||
pci_vt9p_reset, /* reset */ | pci_vt9p_reset, /* reset */ | ||||
pci_vt9p_notify, /* device-wide qnotify */ | pci_vt9p_notify, /* device-wide qnotify */ | ||||
pci_vt9p_cfgread, /* read virtio config */ | pci_vt9p_cfgread, /* read virtio config */ | ||||
NULL, /* write virtio config */ | NULL, /* write virtio config */ | ||||
pci_vt9p_neg_features, /* apply negotiated features */ | pci_vt9p_neg_features, /* apply negotiated features */ | ||||
(1 << 0), /* our capabilities */ | (1 << 0), /* our capabilities (legacy) */ | ||||
(1 << 0), /* our capabilities (modern) */ | |||||
true, /* Enable legacy */ | |||||
true, /* Enable modern */ | |||||
2, /* PCI BAR# for modern */ | |||||
}; | }; | ||||
static void | static void | ||||
pci_vt9p_reset(void *vsc) | pci_vt9p_reset(void *vsc) | ||||
{ | { | ||||
struct pci_vt9p_softc *sc; | struct pci_vt9p_softc *sc; | ||||
▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | pci_vt9p_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) | ||||
sc->vsc_conn->lc_lt.lt_send_response = pci_vt9p_send; | sc->vsc_conn->lc_lt.lt_send_response = pci_vt9p_send; | ||||
sc->vsc_conn->lc_lt.lt_drop_response = pci_vt9p_drop; | sc->vsc_conn->lc_lt.lt_drop_response = pci_vt9p_drop; | ||||
vi_softc_linkup(&sc->vsc_vs, &vt9p_vi_consts, sc, pi, &sc->vsc_vq); | vi_softc_linkup(&sc->vsc_vs, &vt9p_vi_consts, sc, pi, &sc->vsc_vq); | ||||
sc->vsc_vs.vs_mtx = &sc->vsc_mtx; | sc->vsc_vs.vs_mtx = &sc->vsc_mtx; | ||||
sc->vsc_vq.vq_qsize = VT9P_RINGSZ; | sc->vsc_vq.vq_qsize = VT9P_RINGSZ; | ||||
/* initialize config space */ | /* initialize config space */ | ||||
pci_set_cfgdata16(pi, PCIR_DEVICE, VIRTIO_DEV_9P); | pci_set_cfgdata16(pi, PCIR_DEVICE, sc->vsc_vs.vs_vc->vc_en_legacy ? | ||||
VIRTIO_DEV_9P : vi_get_modern_pci_devid(VIRTIO_ID_9P)); | |||||
pci_set_cfgdata16(pi, PCIR_VENDOR, VIRTIO_VENDOR); | pci_set_cfgdata16(pi, PCIR_VENDOR, VIRTIO_VENDOR); | ||||
pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_STORAGE); | pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_STORAGE); | ||||
pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_ID_9P); | pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_ID_9P); | ||||
pci_set_cfgdata16(pi, PCIR_SUBVEND_0, VIRTIO_VENDOR); | pci_set_cfgdata16(pi, PCIR_SUBVEND_0, VIRTIO_VENDOR); | ||||
if (vi_intr_init(&sc->vsc_vs, 1, fbsdrun_virtio_msix())) | if (vi_intr_init(&sc->vsc_vs, 1, fbsdrun_virtio_msix())) | ||||
return (1); | return (1); | ||||
vi_set_io_bar(&sc->vsc_vs, 0); | vi_setup_pci_bar(&sc->vsc_vs); | ||||
return (0); | return (0); | ||||
} | } | ||||
struct pci_devemu pci_de_v9p = { | struct pci_devemu pci_de_v9p = { | ||||
.pe_emu = "virtio-9p", | .pe_emu = "virtio-9p", | ||||
.pe_legacy_config = pci_vt9p_legacy_config, | .pe_legacy_config = pci_vt9p_legacy_config, | ||||
.pe_init = pci_vt9p_init, | .pe_init = pci_vt9p_init, | ||||
.pe_cfgwrite = vi_pci_cfgwrite, | |||||
.pe_cfgread = vi_pci_cfgread, | |||||
.pe_barwrite = vi_pci_write, | .pe_barwrite = vi_pci_write, | ||||
.pe_barread = vi_pci_read | .pe_barread = vi_pci_read | ||||
}; | }; | ||||
PCI_EMUL_SET(pci_de_v9p); | PCI_EMUL_SET(pci_de_v9p); |