Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_virtio_scsi.c
Show First 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | static int pci_vtscsi_an_handle(struct pci_vtscsi_softc *, | ||||
struct pci_vtscsi_ctrl_an *); | struct pci_vtscsi_ctrl_an *); | ||||
static int pci_vtscsi_request_handle(struct pci_vtscsi_queue *, struct iovec *, | static int pci_vtscsi_request_handle(struct pci_vtscsi_queue *, struct iovec *, | ||||
int, struct iovec *, int); | int, struct iovec *, int); | ||||
static void pci_vtscsi_controlq_notify(void *, struct vqueue_info *); | static void pci_vtscsi_controlq_notify(void *, struct vqueue_info *); | ||||
static void pci_vtscsi_eventq_notify(void *, struct vqueue_info *); | static void pci_vtscsi_eventq_notify(void *, struct vqueue_info *); | ||||
static void pci_vtscsi_requestq_notify(void *, struct vqueue_info *); | static void pci_vtscsi_requestq_notify(void *, struct vqueue_info *); | ||||
static int pci_vtscsi_init_queue(struct pci_vtscsi_softc *, | static int pci_vtscsi_init_queue(struct pci_vtscsi_softc *, | ||||
struct pci_vtscsi_queue *, int); | struct pci_vtscsi_queue *, int); | ||||
static int pci_vtscsi_init(struct vmctx *, struct pci_devinst *, nvlist_t *); | static int pci_vtscsi_init(struct vmctx *, struct pci_devinst *, config_node_t *); | ||||
static struct virtio_consts vtscsi_vi_consts = { | static struct virtio_consts vtscsi_vi_consts = { | ||||
"vtscsi", /* our name */ | "vtscsi", /* our name */ | ||||
VTSCSI_MAXQ, /* we support 2+n virtqueues */ | VTSCSI_MAXQ, /* we support 2+n virtqueues */ | ||||
sizeof(struct pci_vtscsi_config), /* config reg size */ | sizeof(struct pci_vtscsi_config), /* config reg size */ | ||||
pci_vtscsi_reset, /* reset */ | pci_vtscsi_reset, /* reset */ | ||||
NULL, /* device-wide qnotify */ | NULL, /* device-wide qnotify */ | ||||
pci_vtscsi_cfgread, /* read virtio config */ | pci_vtscsi_cfgread, /* read virtio config */ | ||||
▲ Show 20 Lines • Show All 396 Lines • ▼ Show 20 Lines | for (i = 0; i < VTSCSI_THR_PER_Q; i++) { | ||||
pthread_set_name_np(worker->vsw_thread, tname); | pthread_set_name_np(worker->vsw_thread, tname); | ||||
LIST_INSERT_HEAD(&queue->vsq_workers, worker, vsw_link); | LIST_INSERT_HEAD(&queue->vsq_workers, worker, vsw_link); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
pci_vtscsi_legacy_config(nvlist_t *nvl, const char *opts) | pci_vtscsi_legacy_config(config_node_t *node, const char *opts) | ||||
{ | { | ||||
char *cp, *devname; | char *cp, *devname; | ||||
cp = strchr(opts, ','); | cp = strchr(opts, ','); | ||||
if (cp == NULL) { | if (cp == NULL) { | ||||
set_config_value_node(nvl, "dev", opts); | set_config_value_node(node, "dev", opts); | ||||
return (0); | return (0); | ||||
} | } | ||||
devname = strndup(opts, cp - opts); | devname = strndup(opts, cp - opts); | ||||
set_config_value_node(nvl, "dev", devname); | set_config_value_node(node, "dev", devname); | ||||
free(devname); | free(devname); | ||||
return (pci_parse_legacy_config(nvl, cp + 1)); | return (pci_parse_legacy_config(node, cp + 1)); | ||||
} | } | ||||
static int | static int | ||||
pci_vtscsi_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) | pci_vtscsi_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) | ||||
{ | { | ||||
struct pci_vtscsi_softc *sc; | struct pci_vtscsi_softc *sc; | ||||
const char *devname, *value;; | const char *devname, *value;; | ||||
int i; | int i; | ||||
sc = calloc(1, sizeof(struct pci_vtscsi_softc)); | sc = calloc(1, sizeof(struct pci_vtscsi_softc)); | ||||
value = get_config_value_node(nvl, "iid"); | value = get_config_value_node(node, "iid"); | ||||
if (value != NULL) | if (value != NULL) | ||||
sc->vss_iid = strtoul(value, NULL, 10); | sc->vss_iid = strtoul(value, NULL, 10); | ||||
devname = get_config_value_node(nvl, "dev"); | devname = get_config_value_node(node, "dev"); | ||||
if (devname == NULL) | if (devname == NULL) | ||||
devname = "/dev/cam/ctl"; | devname = "/dev/cam/ctl"; | ||||
sc->vss_ctl_fd = open(devname, O_RDWR); | sc->vss_ctl_fd = open(devname, O_RDWR); | ||||
if (sc->vss_ctl_fd < 0) { | if (sc->vss_ctl_fd < 0) { | ||||
WPRINTF(("cannot open %s: %s", devname, strerror(errno))); | WPRINTF(("cannot open %s: %s", devname, strerror(errno))); | ||||
free(sc); | free(sc); | ||||
return (1); | return (1); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |