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:
Dariusz Stojaczyk 2017-10-12 20:48:18 +02:00 committed by Jim Harris
parent f062f79768
commit 201c0188ac
3 changed files with 66 additions and 53 deletions

View File

@ -23,8 +23,8 @@ Use the following configuration file snippet to enumerate a virtio-scsi PCI
device and present its LUNs as bdevs. device and present its LUNs as bdevs.
~~~{.sh} ~~~{.sh}
[Virtio] [VirtioPci]
Dev Pci Enable Yes
~~~ ~~~
Use the following configuration file snippet to enumerate an SPDK vhost-scsi 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. the /tmp/vhost.0 domain socket.
~~~{.sh} ~~~{.sh}
[Virtio] [VirtioUser0]
Dev User /tmp/vhost.0 Path /tmp/vhost.0
~~~ ~~~
## Todo: ## 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 * Add I/O channel support. Includes requesting correct number of queues
(based on core count). Fail device initialization if not enough queues (based on core count). Fail device initialization if not enough queues
can be allocated. 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 scsi and blk. If these should be separate, then this driver should be
renamed to something scsi specific. renamed to something scsi specific.
* Add reset support. * 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. * 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. * Automated test scripts for both PCI and vhost-user scenarios.
* Document Virtio config file section in examples. Should wait on this until * 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 enough of the above items are implemented to consider this module as ready

View File

@ -600,46 +600,75 @@ scan_target(struct virtio_scsi_scan_base *base)
} }
static int static int
bdev_virtio_initialize(void) bdev_virtio_process_config(void)
{ {
struct spdk_conf_section *sp = spdk_conf_find_section(NULL, "Virtio"); struct spdk_conf_section *sp;
struct virtio_scsi_scan_base *base;
struct virtio_dev *vdev = NULL; struct virtio_dev *vdev = NULL;
char *type, *path; char *path;
uint32_t i; unsigned vdev_num;
bool enable_pci;
int rc = 0; int rc = 0;
bool scan_pci = false;
if (sp == NULL) { 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; goto out;
} }
for (i = 0; spdk_conf_section_get_nval(sp, "Dev", i) != NULL; i++) { path = spdk_conf_section_get_val(sp, "Path");
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) { if (path == NULL) {
SPDK_ERRLOG("No path specified for index %d\n", i); SPDK_ERRLOG("VirtioUser%u: missing Path\n", vdev_num);
continue; rc = -1;
goto out;
} }
vdev = virtio_user_dev_init(path, 512); vdev = virtio_user_dev_init(path, 512);
if (vdev == NULL) { if (vdev == NULL) {
rc = -1;
goto out; 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) { sp = spdk_conf_find_section(NULL, "VirtioPci");
vtpci_enumerate_pci(); 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 virtio_scsi_scan_base *base;
struct virtio_dev *vdev = NULL;
int rc = 0;
rc = bdev_virtio_process_config();
if (rc != 0) {
goto out;
}
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) { TAILQ_FOREACH(vdev, &g_virtio_driver.init_ctrlrs, tailq) {
@ -672,10 +701,6 @@ bdev_virtio_initialize(void)
return 0; return 0;
out: out:
if (vdev) {
virtio_dev_free(vdev);
}
spdk_bdev_module_init_done(SPDK_GET_BDEV_MODULE(virtio_scsi)); spdk_bdev_module_init_done(SPDK_GET_BDEV_MODULE(virtio_scsi));
return rc; return rc;
} }

View File

@ -1,5 +1,5 @@
[Virtio] [VirtioUser0]
Dev User /tmp/vhost.0 Path /tmp/vhost.0
[Rpc] [Rpc]
Enable Yes Enable Yes