bdev_virtio: define virtio devs in separate config sections
This is required for adding optional params for vdevs. Since virtio-initiator README.md had to be changed, some outdated entries from TODO section has been removed as a part of this patch as well. Change-Id: I472a966d8e4166305fb19ad3ab20e53289a1e071 Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/382347 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
f062f79768
commit
201c0188ac
@ -23,8 +23,8 @@ Use the following configuration file snippet to enumerate a virtio-scsi PCI
|
||||
device and present its LUNs as bdevs.
|
||||
|
||||
~~~{.sh}
|
||||
[Virtio]
|
||||
Dev Pci
|
||||
[VirtioPci]
|
||||
Enable Yes
|
||||
~~~
|
||||
|
||||
Use the following configuration file snippet to enumerate an SPDK vhost-scsi
|
||||
@ -33,14 +33,11 @@ target has created an SPDK vhost-scsi controller which is accessible through
|
||||
the /tmp/vhost.0 domain socket.
|
||||
|
||||
~~~{.sh}
|
||||
[Virtio]
|
||||
Dev User /tmp/vhost.0
|
||||
[VirtioUser0]
|
||||
Path /tmp/vhost.0
|
||||
~~~
|
||||
|
||||
## Todo:
|
||||
* Support multiple PCI devices, including specifying the PCI device by PCI
|
||||
bus/domain/function.
|
||||
* Add unmap support.
|
||||
* Add I/O channel support. Includes requesting correct number of queues
|
||||
(based on core count). Fail device initialization if not enough queues
|
||||
can be allocated.
|
||||
@ -57,16 +54,7 @@ the /tmp/vhost.0 domain socket.
|
||||
scsi and blk. If these should be separate, then this driver should be
|
||||
renamed to something scsi specific.
|
||||
* Add reset support.
|
||||
* Finish cleaning up "eth" references. This includes filenames like
|
||||
virtio_ethdev.c and "eth" in various API calls.
|
||||
* Understand and handle queue full conditions.
|
||||
* Clear interrupt flag for completions - since we are polling, we do not
|
||||
need the virtio-scsi backend to signal completion.
|
||||
* Check interrupt flag for submission. If the backend requires an interrupt,
|
||||
we need to signal it.
|
||||
* Change read/write to use READ_16/WRITE_16 to handle LBA > 4G. We can add
|
||||
a basic check and bail during enumeration if INQUIRY indicates the LUN does
|
||||
not support >= SBC-3.
|
||||
* Automated test scripts for both PCI and vhost-user scenarios.
|
||||
* Document Virtio config file section in examples. Should wait on this until
|
||||
enough of the above items are implemented to consider this module as ready
|
||||
|
@ -599,47 +599,76 @@ scan_target(struct virtio_scsi_scan_base *base)
|
||||
virtio_xmit_pkts(base->vdev->vqs[2], vreq);
|
||||
}
|
||||
|
||||
static int
|
||||
bdev_virtio_process_config(void)
|
||||
{
|
||||
struct spdk_conf_section *sp;
|
||||
struct virtio_dev *vdev = NULL;
|
||||
char *path;
|
||||
unsigned vdev_num;
|
||||
bool enable_pci;
|
||||
int rc = 0;
|
||||
|
||||
for (sp = spdk_conf_first_section(NULL); sp != NULL; sp = spdk_conf_next_section(sp)) {
|
||||
if (!spdk_conf_section_match_prefix(sp, "VirtioUser")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sscanf(spdk_conf_section_get_name(sp), "VirtioUser%u", &vdev_num) != 1) {
|
||||
SPDK_ERRLOG("Section '%s' has non-numeric suffix.\n",
|
||||
spdk_conf_section_get_name(sp));
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
path = spdk_conf_section_get_val(sp, "Path");
|
||||
if (path == NULL) {
|
||||
SPDK_ERRLOG("VirtioUser%u: missing Path\n", vdev_num);
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
vdev = virtio_user_dev_init(path, 512);
|
||||
if (vdev == NULL) {
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
sp = spdk_conf_find_section(NULL, "VirtioPci");
|
||||
if (sp == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
enable_pci = spdk_conf_section_get_boolval(sp, "Enable", false);
|
||||
if (enable_pci) {
|
||||
rc = vtpci_enumerate_pci();
|
||||
}
|
||||
|
||||
return rc;
|
||||
out:
|
||||
if (vdev) {
|
||||
virtio_dev_free(vdev);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
bdev_virtio_initialize(void)
|
||||
{
|
||||
struct spdk_conf_section *sp = spdk_conf_find_section(NULL, "Virtio");
|
||||
struct virtio_scsi_scan_base *base;
|
||||
struct virtio_dev *vdev = NULL;
|
||||
char *type, *path;
|
||||
uint32_t i;
|
||||
int rc = 0;
|
||||
bool scan_pci = false;
|
||||
|
||||
if (sp == NULL) {
|
||||
rc = bdev_virtio_process_config();
|
||||
if (rc != 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (i = 0; spdk_conf_section_get_nval(sp, "Dev", i) != NULL; i++) {
|
||||
type = spdk_conf_section_get_nmval(sp, "Dev", i, 0);
|
||||
if (type == NULL) {
|
||||
SPDK_ERRLOG("No type specified for index %d\n", i);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp("User", type)) {
|
||||
path = spdk_conf_section_get_nmval(sp, "Dev", i, 1);
|
||||
if (path == NULL) {
|
||||
SPDK_ERRLOG("No path specified for index %d\n", i);
|
||||
continue;
|
||||
}
|
||||
vdev = virtio_user_dev_init(path, 512);
|
||||
if (vdev == NULL) {
|
||||
goto out;
|
||||
}
|
||||
} else if (!strcmp("Pci", type)) {
|
||||
scan_pci = true;
|
||||
} else {
|
||||
SPDK_ERRLOG("Invalid type %s specified for index %d\n", type, i);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (scan_pci) {
|
||||
vtpci_enumerate_pci();
|
||||
if (TAILQ_EMPTY(&g_virtio_driver.init_ctrlrs)) {
|
||||
spdk_bdev_module_init_done(SPDK_GET_BDEV_MODULE(virtio_scsi));
|
||||
return 0;
|
||||
}
|
||||
|
||||
TAILQ_FOREACH(vdev, &g_virtio_driver.init_ctrlrs, tailq) {
|
||||
@ -672,10 +701,6 @@ bdev_virtio_initialize(void)
|
||||
return 0;
|
||||
|
||||
out:
|
||||
if (vdev) {
|
||||
virtio_dev_free(vdev);
|
||||
}
|
||||
|
||||
spdk_bdev_module_init_done(SPDK_GET_BDEV_MODULE(virtio_scsi));
|
||||
return rc;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
[Virtio]
|
||||
Dev User /tmp/vhost.0
|
||||
[VirtioUser0]
|
||||
Path /tmp/vhost.0
|
||||
|
||||
[Rpc]
|
||||
Enable Yes
|
||||
|
Loading…
x
Reference in New Issue
Block a user