Commit Graph

182 Commits

Author SHA1 Message Date
Jim Harris
1b67738c65 vhost: move linux virtio headers to include/
These headers are needed on systems that have old
kernels without virtio_scsi.h and virtio_types.h.
Move them out of the vhost directory and into include
so that they can be used by an upcoming virtio-scsi
initiator bdev module.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ie6614b8845568729a38665c4c1a366b97978e315

Reviewed-on: https://review.gerrithub.io/374548
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-08-18 18:57:21 -04:00
Dariusz Stojaczyk
2705f6f10d Fixed all SPDK_LOG() calls without newline char
Change-Id: Ib9a6b3e7584c5edd8f8c0f8cd20349d86651a5a2
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/374780
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-08-18 18:56:51 -04:00
Dariusz Stojaczyk
9291b2e0d7 vhost: added generic vhost mutex
Added mutex to synchronize vdev access from external threads.
This is the next step towards fixing synchronization issues
between vhost reactor, RPC, and DPDK.

Change-Id: Id4b52658e05d02c479618ae0e5b5e58af2f02789
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/371175
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-08-17 12:50:17 -04:00
Dariusz Stojaczyk
10b1a4a9a3 vhost: added new/destroy_device callback layer
new/destroy_device implementations in particular backends now take
spdk_vhost_dev pointer.

This patch is a first step towards fixing synchronization issues between
RPC and vhost reactor. See the next patch which introduces generic
vhost mutex in vhost.c.

Change-Id: I448492330734726c21189f71ec7a9a8ed81c8195
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/372073
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-08-17 12:50:17 -04:00
Pawel Wodkowski
551b0e9128 vhost: bring back interrupt suppressing hints
Try to do the same as DPDK does: volatile write on used->idx and memory
barier before reading avail->flags.

Change-Id: Ibe4629a8228a02088913593ac9b32de56a60b062
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/373578
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2017-08-17 12:47:52 -04:00
Pawel Wodkowski
dd3ec6e6b5 vhost: pull out common features to vhost_internal.h
Change-Id: Ie247d7a0266d253769d7bd7d9fa60227749bd502
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/373577
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-08-17 12:47:52 -04:00
Seth Howell
4d43844f4d lib: replace strerror with strerror_r
replaces all references to strerror in the spdk lib directory with
references to the thread safe strerror_r

Change-Id: I80d946cce3299007ee10500b93f7e1c8e503ee41
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/374012
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>
2017-08-15 16:47:01 -04:00
Dariusz Stojaczyk
ddcc31d645 vhost: added spdk_vhost_dev_has_feature
Added helper function to check if vhost controller supports given
feature.

Change-Id: If20883f5dd6d5fedf7fc253239961fdb55ca51fd
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/373702
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-08-15 15:28:17 -04:00
Pawel Wodkowski
df3fc4fdd9 vhost_blk: enable multiqueue
Enable multiqueue for vhost blk.

Change-Id: Ia28cf680402568b19d4afe757b1db3337441ebad
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/373272
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>
2017-08-15 15:27:59 -04:00
Dariusz Stojaczyk
8123aef784 vhost: don't abort on mem region registration failure
A single warning message is printed instead.
This is required for VMs which have memory mapped virtual devices. (e.g
NVDIMM in Clear Containers). This memory won't ever be used by guest
kernel for IO processing.

Change-Id: Ie24501acbdb3ba0d67bd29b146a09b222451427d
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/373224
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2017-08-10 13:32:36 -04:00
Pawel
83c2b65a4f vhost: RPC: unify RPC "get_vhost_controllers" for all backends
replaced "get_vhost_scsi_controllers" and "get_vhost_blk_controllers"
with "get_vhost_controllers"

Change-Id: I4988313e311e5b66632d8e216bde209c8ea5e318
Signed-off-by: Pawel Niedzwiecki<pawelx.niedzwiecki@intel.com>
Reviewed-on: https://review.gerrithub.io/369399
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-08-10 13:31:20 -04:00
Pawel Wodkowski
2dab00ee03 vhost_scsi: use proper socket id for allocated tasks
Change-Id: I25b65e057cef076be4849ee0242f7979e5e290f7
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/373274
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Paweł Niedźwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-08-10 13:09:52 -04:00
Jim Harris
76414a00c6 vhost: increase max number of vhost devices
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I9f2debc0a9404f4fc36ab307c73ead95a41cbd75

Reviewed-on: https://review.gerrithub.io/371021
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-08-01 16:06:34 -04:00
Jim Harris
bab34df6ca vhost: split iovs which span hugepage boundaries
A virtio descriptor may specify a buffer that spans
a huge page boundary or even a vhost memory region.
So modify spdk_vhost_vring_desc_to_iov() to take this
into account.

While here, also change spdk_vhost_vring_desc_to_iov
to return int instead of bool.  int return with -1 is
most standard to indicate failure.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I71faefce0367dc9e44d70ea4429a28dd64f04c10

Reviewed-on: https://review.gerrithub.io/371756
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Piotr Pelpliński <piotr.pelplinski@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-07-31 13:10:52 -04:00
Jim Harris
1238cfb95a vhost: use SPDK_VHOST_IOVS_MAX for scsi and blk
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I19e9ea2682c75bcee096dbcdbb9447c7144427e8

Reviewed-on: https://review.gerrithub.io/371734
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-07-31 13:10:52 -04:00
Pawel Wodkowski
71904d7f4d vhost: don't use interrupt suppressing hints on avail ring
Randomly we loose some interrupts. This stop IO in guest till next
request is issued which is abort

Change-Id: I1a0b6391a324cabb0df17d2704126d161b1868f7
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/370248
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-07-27 12:25:43 -04:00
Karol Latecki
522944bb26 test/vhost: Update test plan for vhost
Update exisitng tests with vhost blk information
Add tests for scsi/blk hot-attach, hot-detach and hot-plug

Change-Id: I95dad5986d3795430fea304712a6491dfef712d0
Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.gerrithub.io/369168
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-07-25 15:48:46 -04:00
Pawel Niedzwiecki
80ff6c059e vhost_scsi: update code comments
- task_data_setup() - value of 1 is no loger returned
- task_submit() -removed outdated comment

Change-Id: I523a465eba7af93535e2dc3a583abb315950f4b3
Signed-off-by: Pawel Niedzwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-on: https://review.gerrithub.io/371154
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-07-25 15:48:33 -04:00
Pawel Wodkowski
b368258bb3 vhost-blk: fix error reporting on bdev hot-removal
blk_iovs_setup() error code was missinterpeted and no error returned for
IO that was directed to removed bdev.

Change-Id: Iec5ebef20734cca07f20f068b83b74b189cdcb66
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/370711
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Lukasz Galka <lukaszx.galka@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-07-25 14:25:40 -04:00
Dariusz Stojaczyk
542b541588 vhost_scsi: implemented abstract vhost event layer
Implemented abstract vhost event layer on top of virtio eventq.
This allows us to defer virtio-event-related actions to be called from
the vhost poller thread. This is required for hot-attach, for which
io_channels have to be created on the I/O thread.

This adds full support for hot-attaching and hot-detaching vhost scsi
devices. They can be now attached to a controller via RPC at any time.

Change-Id: Icf353bfcf69c83ef16b8fc771ea4c487002094f9
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/370016
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-07-20 13:19:26 -04:00
Paweł Niedźwiecki
6bd54f1bf1 vhost: Make JSON-RPC parameter names as consistent as possible
-changed "cpu_mask" to "cpumask"
 -changed "name" to "lun_name"
 -changed "bdev" to "dev_name"

Change-Id: I52b77fa01384df8e6e725f236f23cb568b35f189
Signed-off-by: Paweł Niedźwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-on: https://review.gerrithub.io/368774
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-07-14 15:54:28 -04:00
Jim Harris
be9a3b9f69 bdev: pass descriptors for I/O operations
This enables checking permissions - for example,
spdk_bdev_write will fail if the descriptor was not
created with write permissions.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I68b65a560f471f2e0f71a7f42cfa6689b911110f

Reviewed-on: https://review.gerrithub.io/369493
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-07-14 13:31:30 -04:00
Daniel Verkamp
684dd86f34 vhost_iommu: handle realloc() failure
Change-Id: I50203e0e02d2201fea5112789c1fd84b9a61417a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/369283
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-07-13 15:47:33 -04:00
Pawel Wodkowski
7f6b78611a vhost_blk: don't abort on bdev hotremove
Virtio block doesn't know how to handle hot-remove so no way of
informing guest when that happen but at least we don't crash.

Change-Id: I54576bc0693c2e706ef3c45b0de313e9beb2a2c7
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/368789
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-07-12 13:21:50 -04:00
Dariusz Stojaczyk
fa15dc611a scsi: removed dev->maxlun field
This variable was misleading and unnecessary. Replaced all it's
occurences with SPDK_SCSI_DEV_MAX_LUN.

Change-Id: Iaaf9ed5efb60f9a89585121d2fbec7b43c3723e9
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/368115
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-07-12 13:16:55 -04:00
Dariusz Stojaczyk
e2f42584b0 vhost: renamed MAX_VRINGS define to MAX_VQUEUES
Renamed it to avoid misconceptions.
Struct rte_vhost_vring describes a virtqueue, not a vring.

Change-Id: I89b94c8d78052b1a4796a9b74653237e5f8b6f52
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/368720
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-07-12 13:14:26 -04:00
Daniel Verkamp
0bb3618a99 vhost_scsi: check for task allocation failure
Change-Id: I03e63985907d7330373b1883652cd27a0cf466db
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/369081
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-07-12 12:20:56 -04:00
Pawel Wodkowski
1eaba102ed vhost_blk: fix error code in IO path and simplify process_blk_request
Failures in IO path should return VIRTIO_BLK_S_IOERR instead
VIRTIO_BLK_S_UNSUPP.

Change-Id: Ic0a36ae95b16e15c1e0c67e9e5c848b14ad0ba75
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/368788
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-07-11 18:34:17 -04:00
Daniel Verkamp
a3fd882901 vhost_scsi: fix build error after last merge
struct spdk_vhost_task was renamed to spdk_vhost_scsi_task in commit
68f0c87e64, but this was rebased without
adjusting the spdk_vhost_task introduced by commit
05fd28399a.

Change-Id: I7046d04d3ce56d62fdfb1166f8b4c5676bc7397b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/369080
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2017-07-11 17:53:44 -04:00
Paweł Niedźwiecki
68f0c87e64 vhost_scsi: renamed "vhost_task" to "vhost_scsi_task"
Change-Id: I76f3468aab3213594db6c3242166e00926c95575
Signed-off-by: Paweł Niedźwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-on: https://review.gerrithub.io/368781
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-07-11 17:28:25 -04:00
Pawel Wodkowski
05fd28399a vhost_scsi: fix bug with tasks enqueue/dequeue
We need MP MC ring for tasks. So instead implementing this add per
controller ring to avoid this issue.

Change-Id: I5926ad7866ab28251aeebd163917de2df2b44a22
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/368547
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-07-11 17:23:25 -04:00
Fam Zheng
ee263a80fc vhost: Fix spdk_iommu_mem_unregister
The function body uses VFIO_IOMMU_MAP_DMA which appears to be a
copy&paste mistake, make it VFIO_IOMMU_UNMAP_DMA because we are doing
the opposite of spdk_iommu_mem_register.

Change-Id: If9f3b188178e71ff71221c77c1680b679fec1df0
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-on: https://review.gerrithub.io/368551
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-07-10 20:27:28 -04:00
Daniel Verkamp
2bdec64fbf jsonrpc: modify API to pass request to handler
This will enable asynchronous request handling in a future patch, and it
also removes the need for the RPC handlers to know about request id and
the JSON-RPC rules about notification-only requests.

Change-Id: I25aaa8e48bff8d5594ffcccecb61842b1e31ec3c
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/368225
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-07-06 13:48:12 -04:00
Pawel Niedzwiecki
a264d9d2a3 Vhost: add support of VITRIO_BLK_F_RO
-Add a configuration option: Read-only flag

Vhost block controller can be set in read-only mode.
Option can be enabled in config file or in RPC call:
'construct_vhost_block_controllerr' with '-r' option

Change-Id: I7e58243be00d33bc04120d573fd4ed7775bb9b2c
Signed-off-by: Pawel Niedzwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-on: https://review.gerrithub.io/366086
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-07-06 12:55:49 -04:00
Jim Harris
57d174ff67 bdev: add spdk_bdev_open/close
Retire the old claim/unclaim semantics in favor of
open/close.  Clients must now open a bdev to get
an spdk_bdev_desc, then pass this desc to get an
I/O channel.

This allows multiple clients to open a bdev,
although only one may open a bdev with write
access.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I4d319f1278170124169a8a75fd791e926b3f7171

Reviewed-on: https://review.gerrithub.io/367611
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-07-05 18:04:28 -04:00
Dariusz Stojaczyk
76e5900d50 vhost_scsi: implemented vhost device hotremove
Vhost devices can now be removed via RPC at any time.

Change-Id: Ib91dd6eb11ae8c777e8b9498d140e89a3fe382db
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/366726
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-07-05 17:11:55 -04:00
Pawel Niedzwiecki
ff88449d6e vhost-block: add RPC calls
Following RPC calls are added
-add/remove controller
-list controllers

Change-Id: Idba407a61640de32875f7c347d609b6b9137dd63
Signed-off-by: Pawel Niedzwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-on: https://review.gerrithub.io/363688
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-07-05 14:33:28 -04:00
Seth Howell
82cc48c862 vhost/vhost_internal: Add VIRTIO_BLOCK_F_CONFIG_WCE definition
This flag is needed for compatibility with older versions of the virtio_blk library.

Change-Id: I8243d51a39971dd37d0c65b29bd976b5b84978aa
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/367612
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-06-30 16:54:03 -04:00
Dariusz Stojaczyk
c6703d8d6e vhost_scsi: replaced DPDK's RTE_DIM and unlikely() with SPDK alternatives
Removed yet another direct DPDK dependencies.

Change-Id: I4df3cb8975bb7a00b1316ef7ed449248f28ab7ee
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/366724
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-30 16:32:47 -04:00
Dariusz Stojaczyk
67cd059c11 vhost_scsi: moved spdk_scsi_task_construct() out of spdk_vhost_get_tasks()
spdk_vhost_get_tasks() is now fully generic function for getting tasks,
which have to be specifically initialized *later*.
This allows us to remove extra loop inside spdk_vhost_get_tasks().

Change-Id: I9a9155189599cbae1b2eb94f64fba29a3e2d010b
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/366723
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-30 16:32:47 -04:00
Dariusz Stojaczyk
d3d4a688cd vhost_scsi: added spdk_vhost_task_init_target()
Removed get_scsi_dev and get_scsi_lun functions, moved virtio lun field
parsing into a single function.

Change-Id: I2d1588491e0aee523b053d8ea49fdc6bb7f90613
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/366721
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-30 16:32:47 -04:00
Dariusz Stojaczyk
62eb231574 vhost: removed task.h/task.c
Vhost scsi tasks aren't complicated enough to have their own files.
Also used spdk_ring instead of rte_membuf for task management.
This patch is a first step towards making vhost task pool
queue-specific, so that it can be single-producer, single-consumer.

Change-Id: I181417f49ccd9a5b8f53d4b96c9fefddca087692
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/366720
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-30 16:32:47 -04:00
Dariusz Stojaczyk
b3ecb4c45c vhost_scsi: get vhost tasks in bulks
Instead of getting tasks from mempool 1 by 1, prefetch a whole chunk.

Change-Id: I17f61e3de9b081b61af7a2a8568681aafe26ab0a
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/366719
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-30 16:32:47 -04:00
Dariusz Stojaczyk
475d400394 vhost: removed spdk_vhost_dev_task_ref/unref
Removed these functions in preperation to removing task.h/task.c.

Change-Id: I84b3c81505c0b8a7d08e2ca803aada1d20bc518e
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/366718
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-30 16:32:47 -04:00
Dariusz Stojaczyk
b93a37a8fb rte_vhost: added error log in vhost_user_set_features
Since vhost_user_set_features failure is not handled in any way, a
single error log has been added to at least to let the user know that
something has gone wrong.

Change-Id: Ifcf27320af75ba74347b742643b23e43b7c01149
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/365807
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-30 16:32:47 -04:00
Dariusz Stojaczyk
0c471fd668 vhost_scsi: enable VIRTIO_SCSI_F_CHANGE flag
As of virtio spec 1.0, driver must not accept flags which the device
did not offer (section 2.2). However, that flag is apparently being
accepted, causing silent exception to be triggered in rte_vhost. This
results in all negotiated features to be rejected in rte_vhost.

This patch is a workaround. Enabling that flag does not enforce us to do
any additional actions.

Change-Id: Iede0c0360de33d438f109442c7a83231e9d4479e
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/365806
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-30 16:32:47 -04:00
Dariusz Stojaczyk
5160ffaff5 vhost_scsi: fixed unsafe type conversion from vdev to svdev
A vhost_dev had been explicitly converted to vhost_scsi_dev in a
following manner:
vhost_dev* -> void* -> vhost_scsi_dev*

Change-Id: Idfd4307bfea7385d71e67f140554dfc2e86447b5
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/367310
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-30 16:32:47 -04:00
Dariusz Stojaczyk
3c497395cc vhost_scsi: implemented eventq hotremove
Implemented eventq. For now only hotremove is supported.

Change-Id: I1ec7aa2137173b5dfb30e9906dd41707e371b7a8
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/364285
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-30 16:32:47 -04:00
Dariusz Stojaczyk
f168e45283 vhost_scsi: renamed controlq poller to mgmt poller
Renamed it in preparation for handling eventq & hotremove in the very
same poller. It would only complicate code to handle all of these in
separate pollers.
This patch does not change any functionality on it's own.

Change-Id: I321e2ced0d6afb3ccb66a13bc25bbf42da20417b
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/367528
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-30 16:32:47 -04:00
Dariusz Stojaczyk
72343bcf23 scsi: added lun hotremove callback
Added optional callback inside scsi lun hotremove, so that higher-level
abstraction can be notified about hotremove.

Change-Id: I5f1bd8160e3d770a484068dd73928bc2b64c876f
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/367309
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-30 16:32:47 -04:00
Pawel Wodkowski
0d7e2b6416 vhost: basic virtio block implementation
Change-Id: Ie48f4acf9aa724256f0a1f67b38c334c43b3e946
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/363090
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-28 21:37:56 -04:00
Changpeng Liu
c9a97addeb vhost: don't start device before got valid descriptor
For each virt queue's kickfd and callfd, there are 2 invalid
status: VIRTIO_UNINITIALIZED_EVENTFD and VIRTIO_INVALID_EVENTFD.
Don't set the virt queue to ready status until got the valid
descriptor.

This is safe for polling mode drivers in Guest OS, the backend
vhost process will not post notification to interrupt vector for
PMD mode in Guest, but the interrupt vector still valid.

Change-Id: Icdf1e67f3c4e8da221843eb1383469ca1fba485c
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/365327
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-06-28 17:56:02 -04:00
Ben Walker
4185205540 scsi: Remove cb_event. It is no longer necessary.
This is an artifact from a past design. There is no longer
any reason to create an event here - the bdev layer will
correctly queue events and call completions on the correct
thread.

Change-Id: I145dab4046899834c0449ec7380dcbb28215b493
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/364831
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>
2017-06-22 10:47:31 -04:00
Karol Latecki
293f920158 test: add vhost test plan
Change-Id: I9a38111eea5ea71f3084642f6b6fe284d981978d
Signed-off-by: Karol Latecki <karolx.latecki@intel.com>
Reviewed-on: https://review.gerrithub.io/362667
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-06-21 19:55:13 -04:00
Ben Walker
aacd61d54a vhost: Move subsystem initialization to event_vhost
This removes one dependency on the event framework.

Change-Id: Ib9c8160b1704a15b662a35d5ad1f32c0b745485c
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/365729
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>
2017-06-20 16:58:35 -04:00
Dariusz Stojaczyk
bc70a4d63f vhost_scsi: properly handle requests to unsupported lun
Fixes vhost crash on null lun target.
Added extra check in vhost IO path.

Change-Id: Ia6aa29cce41c2fc74e0a8eec545e6675858a28e3
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/365196
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-20 15:25:39 -04:00
Dariusz Stojaczyk
6bd3e2a0a7 vhost_scsi: do not abort on unfinished scsi tasks in destroy_device
Replaced rte_panic with SPDK_ERRLOG (for now).

Change-Id: I7ca012368ba6a49cbbf0397b3750a86da4ab776a
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/365026
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-06-20 15:25:39 -04:00
Dariusz Stojaczyk
db751c1625 Revert "vhost: Don't panic if the task count isn't 0"
This reverts commit 86f215f38d.

Change-Id: Id3d18ffb44586ac38c5bc080a0550e5825d5ef3a
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/364947
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-06-20 15:25:39 -04:00
Ben Walker
8fbaa73e69 vhost: Add a separate subsystem library
This separates the vhost library from the event
framework's subsystem mechanism

Change-Id: I8206fcf0d55bee71c70482d989318e9d118f710a
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/365286
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-16 13:10:26 -04:00
Daniel Verkamp
dcb7abc717 vhost_iommu: handle opendir() failure
Change-Id: I82ce702ab1af83c2f5c0197a9766437f0f728dce
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/365067
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-15 13:51:54 -04:00
Dariusz Stojaczyk
3bfecec994 vhost_scsi: added "SCSI" keyword to trace flags
To differ them from upcoming VHOST_BLK trace flags

Change-Id: I1e82fb3430a6533cb9980b430d144ea28d269d59
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/363583
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-06-09 20:18:19 -04:00
Dariusz Stojaczyk
bfd1361714 vhost_scsi: removed deferred tasks
Removed deferred tasks and dynamic memory management in task processing
in vhost_scsi. Each vhost task will now have it's own iovec array

Change-Id: Ie51a2404e9cd3c4e03bcea5a8d5b16498dd4d093
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/363342
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-06-08 16:36:09 -04:00
Daniel Verkamp
7c418a74cb vhost: avoid use-after-free of vhost task
Change-Id: Ifd4f717ea6e12769c845e10578517da0a28dca11
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/364669
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2017-06-08 13:35:21 -04:00
Ben Walker
86f215f38d vhost: Don't panic if the task count isn't 0
Instead of crashing if the task count isn't 0 when
shutting down, just print an error and allow the
tasks to leak.

This isn't the long term solution, but it's a lot better than
crashing.

Change-Id: I5d388c759b563953dce8239e9a4e62c3e3db16c4
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/364490
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-06-07 17:31:02 -04:00
Pawel Wodkowski
8f371c7d64 vhost: introduce spdk_vhost_vring_desc_to_iov
Extract vring_dev to iovec translation logic to common place.


Change-Id: I0c6fc5582dfe341e867ce6749ff29d14a9d12d94
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/363582
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-06-07 14:28:54 -04:00
Pawel Wodkowski
1b93872dbb vhost: don't expose backend structures outside backend implementation
Theres no need to have vhost SCSI (and incoming vhost block) structures
available in public API. Generic spdk_vhost_dev might be used to
communicate with backedns. Backends are responsible to check if type of
passed vdev valid.

Change-Id: I850a1cc661166ee146d513b0069bb40edc9a761a
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/363581
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-06-07 14:28:54 -04:00
Pawel Wodkowski
329d5510e9 vhost: move not SCSI specific parts to internal header
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Change-Id: Id17bf80c19ab05e42db094d4901b06a9bdbe7560
Reviewed-on: https://review.gerrithub.io/363089
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Piotr Pelpliński <piotr.pelplinski@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-06-07 14:28:54 -04:00
Pawel Wodkowski
ae4796ae02 vhost: generalized vhost events
Rework reactor<->pthread comunication logic, so we can reuse it in other
backends.

Change-Id: Id0f02fc9e1e0d9540f8efebdb515384b5714c966
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/362548
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Piotr Pelpliński <piotr.pelplinski@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-06-07 14:28:54 -04:00
Dariusz Stojaczyk
dd071569e9 vhost: expand spdk_vhost_dev_register functionality
Moved vdev initialization inside spdk_vhost_dev_register, so that
particular virtio device implementations don't have to e.g.
manage socket path.

spdk_vhost_dev_unregister was renamed to spdk_vhost_dev_remove

Change-Id: I240385ba25278c056737fed77f21695b2e787c6b
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/363584
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-06-07 14:28:54 -04:00
Daniel Verkamp
adf3cc2bc8 vhost: add fallback if linux/vfio.h is missing
On older kernels that don't have VFIO, stub out the vhost IOMMU
functions.

Fixes build on older distributions (e.g. CentOS 6).

Change-Id: Icda9998e494c24d252511a4da93ecb56502fe5a7
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/363473
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-06-02 19:47:09 -04:00
Changpeng Liu
0a49531fab vhost: remove direct DPDK API call from vhost library
Change-Id: I5bad83197824dfb9042540c573134962a917b8bd
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/363152
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2017-06-02 12:04:15 -04:00
Dariusz Stojaczyk
7d42767817 vhost: removed redundant check in get_scsi_lun()
Each call to get_scsi_lun is preceeded with the same check.

Change-Id: I4597674f0024e923908d85bbfbd5404c500fddb1
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/363172
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-06-01 14:15:50 -04:00
Tomasz Zawadzki
5e132b6b7a scsi: Set proper transport protocol id
This patch adds property of transport protocol id to spdk_scsi_dev.
This allows to change it depending on which appliation is using
the device. Previously only iSCSI was used for all.

Setting protocol id is done at the time when device is added to
vhost controller (vhost) or target node (iSCSI).

Please note that for SPDK vhost SAS protocol id is used,
as that is what kernel vhost reports as well.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I455a856c5d7796a749b6650fee0218d526e094ed
Reviewed-on: https://review.gerrithub.io/362864
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-06-01 12:10:22 -04:00
Pawel Wodkowski
0888dd4cc6 vhost: add device type field
Change-Id: I848c8c5dcf837c11e052bb03cba962a843f28778
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/363088
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-31 20:25:45 -04:00
Dariusz Stojaczyk
3671543a5b vhost: changed dev_construct()/destruct() to dev_load()/unload()
Since vhost_scsi::new_device() would look mostly the same in vhost_blk,
most of it's logic has been moved into spdk_vhost_dev_construct(),
which is now renamed to spdk_vhost_dev_load().

Change-Id: Ic6db93273f916bd021c2ff68946706d055a514d6
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/362547
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-31 20:25:45 -04:00
Pawel Wodkowski
d7054e23b7 vhost: move VM memory register/unregister to vhost.c
It is not vhost SCSI specific.


Change-Id: I7eff272fcd1aa47135de7178d0763b1793b298ec
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/363087
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-31 20:25:45 -04:00
Pawel Wodkowski
c190dcd767 vhost: move gpa_to_vva to vhost.c
This function is not vhost SCSI specific and can be reused. Also change
type of returned value to 'void *' so no explicit cast is needed.

Change-Id: I33a37856903dacdddae9e73e695cc66465ade089
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/363086
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-31 20:25:45 -04:00
Dariusz Stojaczyk
7a9af3963e vhost: moved vqueue/vring management to vhost.c
vqueue/vring management shouldn't differ between vhost-blk and
vhost-scsi, so it has been moved to vhost.c/vhost_internal.h

Change-Id: I5ecf2f7a34ec28deb94c7abef4225038913edf0d
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/362505
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-31 20:25:45 -04:00
Ziye Yang
6e0d1dcdfa subsystem: make subsystem init in async manner
The next patch will make bdev modules init
in the async manner.

Change-Id: I4909c80510d786daf54003b99a5925428cf37373
Signed-off-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/362110
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-31 15:30:58 -04:00
John Meneghini
8a44220b1a env: Rename spdk_malloc/zmalloc/realloc/free to spdk_dma_(func)
- rename spdk_malloc_socket to spdk_dma_malloc_socket
  - rename spdk_malloc to spdk_dma_malloc
  - rename spdk_zmalloc to spdk_dma_zmalloc
  - rename spdk_realloc to spdk_dma_realloc
  - rename spdk_free to spdk_dma_free

Change-Id: I52a11b7a4243281f9c56f503e826fd7c4a1fd883
Signed-off-by: John Meneghini <johnm@netapp.com>
Reviewed-on: https://review.gerrithub.io/362604
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-05-31 15:30:27 -04:00
Dariusz Stojaczyk
d5b6b1880e vhost: reordered functions in vhost_scsi.c
General cleanup.

Change-Id: I31083a7210634b8fc9d1336aff08f9793b249930
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/362296
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2017-05-25 18:30:44 -04:00
Dariusz Stojaczyk
d237aba3b9 vhost: separated scsi layer from vhost.c
Implemented vhost abstraction layer in preparations for vhost-blk.
Generalized vhost interface and separated vhost-scsi code.

Code placement:
vhost.h
 * vhost_startup() & shutdown()
 * public generic controller API

vhost_internal.h
 * includes rte_vhost.h from DPDK
 * struct spdk_vhost_dev (it has to be inherited by vhost_scsi)
 * vhost_dev management
   * register/unregister() to be used in new_device()/destroy_device()
   * construct/destruct() to be used on permanent creation/destruction.
 * reactor core management

vhost_scsi.h
 * spdk_vhost_scsi_dev management
   * reading VhostScsi section of vhost config file
   * creating/removing controllers
   * adding/removing devices to controllers

vhost_scsi.c
 * virtio scsi logic
 * new_device(), destroy_device()

Change-Id: Iaf661b14eba034593bef24853c525935d9b18e46
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/361963
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2017-05-25 18:30:44 -04:00
Dariusz Stojaczyk
fb4b23b50b vhost: introduced spdk_vhost_free_reactor()
g_num_ctrlrs can now be fully encapsulated in vhost.c

Change-Id: I812c9ec0a21fec37025665104172ff5ac71ff3bc
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/361951
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2017-05-25 18:30:44 -04:00
Dariusz Stojaczyk
aa72cafd8b vhost: introduced spdk_vhost_dev_unregister()
Separated new function spdk_vhost_dev_unregister() out of
spdk_vhost_scsi_dev_remove().

Change-Id: Ic604f10233ca3f7998774595c10d6c120dd43e2e
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/361948
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2017-05-25 18:30:44 -04:00
Dariusz Stojaczyk
2f1cfc7be0 vhost: introduced spdk_vhost_dev_backend struct
Added new struct and separated new function spdk_vhost_dev_register()
out of spdk_vhost_scsi_dev_construct().

Change-Id: I97c303e40759426fa68a097c7ba47c62fbc97bd0
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/361882
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2017-05-25 18:30:44 -04:00
Dariusz Stojaczyk
53a452d228 vhost: removed dpdk_vid_mapping
As a consequence MAX_VHOST_DEVICE define was removed, which was a
copy of a private DPDK define. Using it was more likely a hack.
Also renamed MAX_SCSI_CTRLRS to MAX_VHOST_DEVICES.

Instead of dpdk_vid_mapping, a new function
spdk_vhost_dev_find_by_vid is used. It simply iterates through
all the controllers.

Since this patch required to move the definition of spdk_vhost_ctrlrs
array, it has been renamed to g_spdk_vhost_devices.

Change-Id: I9b70ccb97ffaa90a22c6a1c90850b3205a9b9b27
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/361881
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2017-05-25 18:30:44 -04:00
Dariusz Stojaczyk
c6745bc2b8 vhost: generalized spdk_vhost_dev struct
Moved controller-related variables from spdk_vhost_scsi_controller to
spdk_vhost_dev. Generalized vhost to operate on non scsi-specific
controller struct.

Now spdk_vhost_scsi_dev contains direct spdk_vhost_dev field instead
of a pointer. This means there is no more allocation/deallocation
on poller start/stop.

Change-Id: I99739d58833ee023a75cb530cc80294e02f28090
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/361880
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2017-05-25 18:30:44 -04:00
Dariusz Stojaczyk
78360d5646 vhost: extracted alloc/free out of vhost_dev constructor/destructor
* spdk_vhost_dev_create() operates on **existing** vhost_devs, rather
than allocates and returns them.
 * spdk_vhost_dev_destruct() no longer deallocates devices

This is a preparation for making vhost_dev a direct field of
vhost_scsi_dev (no longer a pointer). That patch would be too massive
to contain this one.

Change-Id: Idec84cee22795ad88e8499eb933664c4b8c7d101
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/362187
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2017-05-25 18:30:44 -04:00
Tomasz Zawadzki
216901dbd7 vhost: close remaining memory region FDs during backend cleanup
After changes done in commit f325e71c, closing old FD is delayed until
VHOST_USER_SET_VRING_ADDR. If VM is closed before this call, original FDs
remain during vhost_backend_cleanup. This resolves issue #162.

This patch closes second set of FDs during vhost backend cleanup.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ieb9d123c987009ac451b6214bb74d2720d852781
Reviewed-on: https://review.gerrithub.io/361787
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Piotr Pelpliński <piotr.pelplinski@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2017-05-24 11:53:47 -04:00
Pawel Wodkowski
5b392ecdd1 vhost: fix deadlock on VFIO registration failure
Move mutext locking to API functions to prevent deadlock when memory
registration fail. Fixes #163.

Change-Id: I4804f671ed9d82ede87bc9439c36368b94e2d636
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/361934
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>
2017-05-24 11:49:11 -04:00
Daniel Verkamp
f66a0c9e34 scsi: pass management function as a parameter
Specify the function as a parameter to spdk_scsi_dev_queue_mgmt_task.
This makes the API clearer by making it explicit that the management
function is required for management tasks.

Change-Id: I92d893aadb6faebea81dd79729894d2c2fddf088
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-18 13:47:42 -07:00
Daniel Verkamp
1e7e6a618b scsi: automatically set spdk_scsi_task::type field
The type of a task is known due to the function used to submit it:
- spdk_scsi_dev_queue_task() for normal SCSI command tasks
- spdk_scsi_dev_queue_mgmt_task() for management tasks

Change-Id: I183a1f89ab85f3fce1de2491e77d95d4b147fd72
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-18 13:47:42 -07:00
Dariusz Stojaczyk
679e2831bd vhost: added rpc commands to remove vhost controllers and devices
Added new rpc commands together with underlying vhost API and tests.

Change-Id: Ib9c6a530d0909193ea5115aaac4920c44f39613c
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-05-18 01:01:46 -07:00
Pawel Wodkowski
82d26c4f20 vhost: track VFIO mappings
If more than one controller is added to guest the same memory table is
set multiple times making VFIO registration/unregistration failures

Change-Id: Ib55c38e292495e549c070beb0234e73f269e63d5
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2017-05-18 00:47:55 -07:00
Dariusz Stojaczyk
709d5453a3 vhost: obey VIRTIO_F_NOTIFY_ON_EMPTY
It'll trigger interrupts even if VRING_AVAIL_F_NO_INTERRUPT is present.
Also delegate notifying check to separate function vq_should_notify. It
will be expanded even more once we implement VIRTIO_RING_F_EVENT_IDX
support.

Change-Id: Ic41fd18c9c005c6266b109b0eda4a6dfaef5f06a
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-05-17 10:24:48 -07:00
Dariusz Stojaczyk
7463bf6d2a vhost: add negotiated_features field in spdk_vhost_dev
Added new struct field and an rte_vhost_get_negotiated_features() call.

Change-Id: I5937026720b5341c7377c27fee682996b51e836e
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-05-17 10:24:48 -07:00
Daniel Verkamp
19a9871495 scsi: remove spdk_scsi_task::owner_task_ctr
The SCSI library already provides a callback when the task is released
(free_fn), so the user can update their own task counter.

Change-Id: I7fb13f6fff66dbba2315fd03fb06e49f793be123
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-15 10:12:42 -07:00
Daniel Verkamp
7145cf62c6 scsi: set free_fn in spdk_scsi_task_construct()
The task free callback function is required, so make its assignment part
of task construction.

Change-Id: I2f5fdf73b064653ee85b4e7961cb1653a0a4107d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-15 10:12:42 -07:00
Dariusz Stojaczyk
6973898164 vhost: wrap vhost_user_read_cb with vhost_user mutex
This fixes spontaneous vhost hangs on SIGINT shutdown.
Apperently during vhost_destroy_device(conn->vid) from
line #284 another QEMU message might arrive, causing
vsocket->conn_mutex deadlock. (line #286)

Change-Id: I4f1c31a52facffd1eb1e1192591095f00da55031
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-05-12 08:05:37 -07:00
Pawel Wodkowski
66894635fa vhost: obey VRING_AVAIL_F_NO_INTERRUPT
If VRING_AVAIL_F_NO_INTERRUPT flag for queue is negotiated, guest can
set this flag in avail ring to suppress interrupts from host.

Change-Id: I2043067de33da009a974be5915ae81b1343fc424
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2017-05-12 07:53:59 -07:00