Commit Graph

450 Commits

Author SHA1 Message Date
Darek Stojaczyk
f08a6eebd3 vhost: don't lock global vhost mutex when waiting for device start/stop
This fixes a potential deadlock:

Thread 2
 * stop_device()
   * lock(&g_spdk_vhost_mutex)
   * _spdk_vhost_event_send
     * sem_wait <- waiting for pending I/O on Thread 1 to complete

Thread 1
 * spdk_rpc_construct_vhost_blk_controller
   * lock(&g_spdk_vhost_mutex) <- prevents this thread from
                                  completing any I/O

Fixes #437

Change-Id: I50ab7bc6dcd161881650ff30362127e0069a3939
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/396577
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-09-28 18:46:11 +00:00
Ni Xun
4ada23dbf4 vhost_blk: Add support for blk_request_queue_io in vhost_blk
according to commit:
     bdev: add spdk_bdev_queue_io_wait
This patch will make io_wait to support vhost_blk

Change-Id: I529001fc74427adda63d0d41901a98229364175d
Signed-off-by: Ni Xun <nixun@baidu.com>
Signed-off-by: Li Lin <lilin24@baidu.com>
Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Reviewed-on: https://review.gerrithub.io/425479
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Sun Zhenyuan <sunzhenyuan@baidu.com>
Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2018-09-25 03:46:22 +00:00
wuzhouhui
33aa994855 vhost: rpc: fix memory leak of spdk_rpc_get_vhost_controllers
spdk_rpc_get_vhost_controllers() forgot to free memory of w when ctx
allocation failed. Defering the invoke of spdk_jsonrpc_begin_result(),
so we can handle the failure conveniently.

Change-Id: I223f5b9a918b068922d5a68c8d688331ebf90e42
Signed-off-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-on: https://review.gerrithub.io/425358
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2018-09-17 22:12:42 +00:00
Pawel Wodkowski
43ab58b613 vhost: show failed taks status
Change-Id: Icc4f046a112dd0b3900bd7ebe803346f9b74c8e9
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/425213
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Seth Howell <seth.howell5141@gmail.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2018-09-12 04:19:46 +00:00
Seth Howell
bfcb7f64c1 vhost: Stop memory leak in external foreach loop
This is in response to a Scan-build issue reported on Clang 6.

Change-Id: I2edc853145762998db818cbbe0e9ca0d9b8c123d
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/424139
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-08-31 19:09:07 +00:00
wuzhouhui
3a70fc0d47 rte_vhost:rte_vhost_driver_register(): check if strdup succeeds
Change-Id: I95e10ca3f7a8e212b46a9c5a62d18cbf2b1fff45
Signed-off-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-on: https://review.gerrithub.io/423046
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
2018-08-24 03:58:31 +00:00
wuzhouhui
0309efde4c vhost/blk: fix error path of spdk_vhost_blk_start()
Change-Id: If0d5b409b508c59e1444b81f5862c1a7594c6b9d
Signed-off-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-on: https://review.gerrithub.io/423203
Chandler-Test-Pool: 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>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2018-08-23 19:30:57 +00:00
Maciej Szwed
039a4c6cb0 vhost-blk: put bdev IO channel on hot remove
On hot remove, before closing bdev, put its IO channel.
If we don't do this bdev won't be destroyed until controller
is removed.

This fixes GitHub issue #401.

Signed-off-by: Maciej Szwed <maciej.szwed@intel.com>
Change-Id: I92600c2f7136f56afd6593f663f2d2cf468a37dc

Reviewed-on: https://review.gerrithub.io/422258
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: 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>
2018-08-16 15:21:54 +00:00
wuzhouhui
3113b446f1 vhost: return more appropriate errno if controller is still in use
Change-Id: I7716f1748803872cac85e296d60747752ca046f4
Signed-off-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-on: https://review.gerrithub.io/422273
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
2018-08-16 01:42:39 +00:00
Changpeng Liu
376be52bb0 vhost: fix the coredump when perform live migration
QEMU will send SET_VRING_ADDR when perform live migration,
it's not correct to update the memory table while the device
is running.

Change-Id: I899d3a996355ab6aa69835d90da14a86f93240fa
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/420944
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: 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: Ben Walker <benjamin.walker@intel.com>
2018-08-15 17:25:33 +00:00
wuzhouhui
53f86e2412 vhost/blk: spdk_vhost_blk_construct(): do not override errno returned
We need these errno to make outputs more clear and make
spdk_vhost_blk_construct() conforms to it's declaration.

Change-Id: I1936e7393494a0344d97c8a920f3d719dee27002
Signed-off-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-on: https://review.gerrithub.io/421859
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
2018-08-13 17:38:21 +00:00
Pawel Wodkowski
9ffd5726ec vhost: fix coalescing time calculation
irq_delay must be not less than zero.

Change-Id: I22d8a7df453f07a44a32582d8e880949824bf868
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/421685
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-08-09 18:10:54 +00:00
Pawel Wodkowski
37e6827a85 vhost: clear desc, avail and used addresses on setting new mem table
This fixes queue handling for QEMU 2.12 which is sending new memory
table but resetting only some queues

Fixes #339

Change-Id: Ic971725261720d7459e49a4f14bc15c2f2a77b1a
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/420372
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Chen Wang <chenx.wang@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2018-07-26 05:29:28 +00:00
Pawel Wodkowski
fdd6dbc902 vhost: add socket path in info dump
This also save CWD on init so socket path is no longer relative.

Change-Id: I303401fe0340f0bc2ea5e4ba468361f68ea84c3d
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/419067
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-by: Paweł Niedźwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
2018-07-12 23:54:34 +00:00
Dariusz Stojaczyk
2470278c92 vhost/scsi: do not fail scsi_dev_add_tgt() if hotplug is not supported
Print an error message instead. The driver can still do
a manual rescan if it wants to see the new SCSI target.

Change-Id: Ieb76ada8625bf00ad068a791b860e4b08ad5cb83
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/417268
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@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>
2018-07-05 01:51:22 +00:00
Pawel Wodkowski
ca051264ae vhost: dump interrupt coalescing parameters in RPC info/config
Change-Id: I7fec9a5fe30bb64f6c76fc951a40e27cf86ecdee
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/415461
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-06-15 18:45:14 +00:00
Pawel Wodkowski
20553a1a0e vhost: switch to new API in JSON RPC info
Change-Id: I6640c1c3f01f9a0f2f783821355e2e949b72dcd2
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/415460
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>
2018-06-15 18:45:14 +00:00
Ben Walker
a83f91c29a thread: Replace #include of io_channel.h with thread.h
Change-Id: I6babd4cf990bf19b510db88bdfb0ca81e29d9252
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/414700
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Madhu Pai <mpai@netapp.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2018-06-12 15:24:07 +00:00
Ben Walker
99c8c6d8e1 nvme: Allow users to request which I/O command set they'd like to use
As of NVMe 1.3b, there is only one command set. But pipe
this through the driver per-spec anyway.

Change-Id: I4faf8596f5ce638e5e2a500b424e00ceb6e89edc
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/412102
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2018-05-24 22:42:38 +00:00
Changpeng Liu
f3165e3df3 vhost/scsi: remove the support of "Dev" for configuration file
"Dev" was deprecated since v18.01, now we have released v18.04,
so remove the "Dev" support from existing code.

Change-Id: I54c4cf83f78d3b0fdb13e625936c889d7bfaeba9
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/409989
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>
2018-05-10 19:39:45 +00:00
Chen Wang
6cfddbc71d vhost/nvme: release the dev before exit
Fix the memory leaks when construct the vhost nvme dev
using the error number of io queues.

Change-Id: Ie63e048b355d8a3d602e0da415dca279c0515a8b
Signed-off-by: Chen Wang <chenx.wang@intel.com>
Reviewed-on: https://review.gerrithub.io/410547
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Liang Yan <liang.z.yan@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2018-05-09 16:55:41 +00:00
Daniel Verkamp
1d168901c6 vhost/nvme: factor out task completion function
This clarifies the bdev_io completion callbacks, since they can now
assume that they always have a valid bdev_io. All call sites that
originally passed NULL for bdev_io now set an appropriate status code in
the task and complete it with the new spdk_vhost_nvme_task_complete()
function.

Change-Id: Id74aafb28e83e135bbb0a410ff9766dc1b9ece50
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/410080
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-05-07 20:11:02 +00:00
Changpeng Liu
24db7333d1 vhost/nvme: remove unused get/set features data buffer
Currently Get/Set features vhost messages use 4096 data buffer, but
it does need this buffer for real usage scenario.

Change-Id: If84f795209d771670449283cef3143f3019baee0
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/409613
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>
2018-05-04 16:44:03 +00:00
Changpeng Liu
2cd9f3959d vhost/nvme: move completion irq signal into IO poller context
Previously after IO is finished, we will put completion entry and
irq event notice at the same IO completion callback, for performance
consideration, move the irq event routine into IO poller context, this
can be used to implement interrupt coalescing feature in future.

Change-Id: Ic20b50af47b73ffcb91938802e18b316c07a4d11
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/408943
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-05-04 16:44:03 +00:00
Changpeng Liu
cb094a03f0 vhost/nvme: ensure the completion queue is not full before post cqes
Change-Id: Iadab3e8f1613a5e13e5a2712f30b714929637a30
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/408775
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>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2018-05-04 16:44:03 +00:00
Pawel Wodkowski
ebedb9fd25 vhost_nvme: fix info dump
For namespace we need to use array of objects. Remove useless check for
bdev != NULL as this is already guarded by ns_active.

As we are here also switch to new JSON named API.

Change-Id: If8ab15c63ea015731829276e06e5cb5a801620d2
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/409025
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2018-05-03 22:12:18 +00:00
Shuhei Matsumoto
e008db08e7 rpc: Add state_mask to each RPC method to make sets of RPCs
Add state_mask to each RPC method and state to RPC server, respectively.
State mask of RPC method is set at registration. State of RPC server
is changed according to the state of the SPDK.

When any RPC method is recieved, if the bit of the RPC server is on in
the state mask of the RPC method, it is allowed. Otherwise, it is
rejected.

When any RPC is rejected by state_mask control, the new error code
is returned to describe the error clearly.

Change-Id: I84e52b8725a286e9329d61c56f498aa2c8664ec1
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/407397
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2018-05-03 19:48:15 +00:00
Pawel Wodkowski
f23c48d59b vhost_nvme: add JSON config dump
Change-Id: Iaed49c2bef3f3f16e07c9a0c80106f3bec7cac09
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/409024
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>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-05-03 19:45:42 +00:00
Daniel Verkamp
e6acab9930 vhost: fix build with DPDK 17.02 and older
__rte_always_inline was added in DPDK 17.05; replace the single use with
a regular 'inline' to restore compatibility with older DPDK versions.

Change-Id: Ia8a0f729cc4c39a9aaab0700f3c827a9766d1dd0
Fixes: e30595fbe3 ("rte_vhost: introduce safe API for GPA translation")
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/409077
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-04-25 22:27:02 +00:00
Daniel Verkamp
130307862b vhost/nvme: fix doorbell buffer size calculation
The existing code was using sizeof() on a calculation that already
returned the right size, so this would originally just memset() 4 bytes
instead of the whole region.

The spec requires the doorbell buffer to be exactly one physical memory
page, and our controller emulation chooses MPS so that only 4096-byte
pages are supported, so just zero out the page and drop the calculation
entirely.

Change-Id: I71db1bebf0a4d5dbe55fd411786e19a8d6802c20
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/408730
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-04-25 02:38:30 +00:00
Daniel Verkamp
d2b764f4d7 vhost/nvme: return proper status for QID errors
If the user requests an invalid QID or CQID in Create I/O Completion
Queue or Create I/O Submission Queue, we need to return an error of
Invalid Queue Identifier as indicated by the spec.

Change-Id: I7467aa04da9e374bb596731f4e4174967d44cffb
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/408767
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
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>
2018-04-25 02:38:30 +00:00
Daniel Verkamp
a32ba31665 vhost/nvme: remove cmd and cqe magic numbers
Replace the hard-coded 64 and 16 constants, which are the size of the
submission queue entry and completion queue entry, with equivalent
sizeof expressions.

Change-Id: I5a9d8fc1ab98276312445f0699aae3d86beee705
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/408762
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
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>
2018-04-25 02:38:30 +00:00
Daniel Verkamp
80e7107811 vhost/nvme: replace asserts() with error checks
These assert() calls were all checking guest-provided data; it should
not be possible for a guest to trigger an assert(), so replace them with
actual runtime error checks (which won't get removed in release builds).

Change-Id: I0692dae0e8f6157fc04e88a3ed8087cce9367fe2
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/408761
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2018-04-25 02:38:30 +00:00
Changpeng Liu
c2b66a83bc vhost-nvme: reserve a bigger enough opcode to avoid conflict with QEMU
Currently QEMU vhost-nvme driver hasn't been pushed to QEMU community,
for vhost-user socket messages, QEMU can pick the opcode at any time,
QEMU 2.12 already picked 27-30 for other driver, for the purpose to
mitigate rebase work in future, while here, we reserve a bigger value
so that it will not conflict with QEMU for very long time.

Change-Id: Ic404bb14330c4acc484aa9c86983030803a31e77
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/408771
Tested-by: SPDK Automated Test System <sys_sgsw@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>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-04-24 16:41:40 +00:00
Daniel Verkamp
5d5e402810 vhost/nvme: remove unnecessary vva casts
Now that spdk_vhost_gpa_to_vva() is used in place of
rte_vhost_gpa_to_vva(), we can directly use the void * return value
instead of casting it via uintptr_t.

Change-Id: Ie063439def1eeeebc7a949ff67f14a80bfce6cd7
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/408760
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-04-24 16:02:58 +00:00
Daniel Verkamp
54f59263eb vhost/scsi: handle spdk_vhost_gpa_to_vva() failure
One call to spdk_vhost_gpa_to_vva() was missing a return code check.

Change-Id: I3581ade98f7fbf72419f8216718a17de50bac4b7
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/408759
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@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>
2018-04-24 16:02:58 +00:00
Changpeng Liu
a8884c5b7d vhost-lib: add virtio configuration protocol feature bit
QEMU added a protocol feature bit to indicate the slave
target can support GET/SET config messages, while here,
add it to SPDK vhost target so that it can work with
QEMU 2.12.

Change-Id: I41a813ef23fba4d3fdf7bb3e3617a9feb4209509
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/408416
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>
2018-04-23 20:38:39 +00:00
Dariusz Stojaczyk
1d74fea015 vhost_scsi: support initiators without eventq/controlq
Change-Id: I400edd6d6f71de005b3ccbe9968631a067226035
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/408611
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>
2018-04-23 20:23:30 +00:00
Changpeng Liu
8fdc3c0424 vhost-nvme: use the new vhost API for memory address translation
Change-Id: If8367f8d0bd5870c50f0f60df47c204a0c67ea1b
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/408723
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2018-04-23 18:29:42 +00:00
Dariusz Stojaczyk
364e0fa94d vhost: switch to the new rte_vhost API for GPA translation
DPDK will deprecate the old API soon.

Change-Id: I0522d47d9cc0b80fb0e2ceb9cc47c45ff51a5077
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/408722
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2018-04-23 18:29:42 +00:00
Dariusz Stojaczyk
bac6830a92 rte_vhost: ensure all range is mapped when translating QVAs
This patch ensures that all the address range is mapped
when translating addresses from master's addresses
(e.g. QEMU host addressess) to process VAs.

Change-Id: If141670951064a8d2b4b7343bf4cc9ca93fe2e6d
Reported-by: Yongji Xie <xieyongji@baidu.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/408721
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>
2018-04-23 18:29:42 +00:00
Dariusz Stojaczyk
e30595fbe3 rte_vhost: introduce safe API for GPA translation
This new rte_vhost_va_from_guest_pa API takes an extra len parameter,
used to specify the size of the range to be mapped.
Effective mapped range is returned via len parameter.

Change-Id: Ib3830e1da9e0cb477d99860a03684c665bb3f6ec
Reported-by: Yongji Xie <xieyongji@baidu.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/408720
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>
2018-04-23 18:29:42 +00:00
Changpeng Liu
ef4a5bc922 rpc/vhost_nvme: add rpc support for vhost-nvme target
Change-Id: I215bc269dee704e60a167023e2a6c24d3ae1fab0
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/395404
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>
2018-04-20 15:24:50 -04:00
Daniel Verkamp
f6fa387f5b vhost/nvme: remove pointless task NULL check
task must be non-NULL in blk_unmap_complete_cb - it is retrieved from
child->parent, which is always set to a known good task in the only
call site.

Change-Id: I28dce62d4cb586311dc87f988c01aa0e03665e4d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/408393
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>
2018-04-19 18:47:59 -04:00
Ben Walker
0692768e69 vhost: Fix negative array index use in spdk_vhost_set_socket_path
If basename was the string "", with length 0, it would have
resulted in accessing index -1 in dev_dirname.

Change-Id: Ib389f8fe220f5335a54f6a155a20fcca35b94e3e
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/408253
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2018-04-19 15:48:36 -04:00
Ben Walker
c1f7f02cfe vhost: Handle null pointer when dumping SCSI JSON config
Change-Id: I4bec75ee2965394edb294a163818925e6a26fb0c
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/408239
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>
2018-04-19 00:08:21 -04:00
Ben Walker
aa345078c1 vhost: Handle failed memory allocation when dumping config
Change-Id: I929e2a668189c36a8837ce8cb8731e394bcb6d9a
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/408238
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2018-04-19 00:08:21 -04:00
Ben Walker
b31d31b22b vhost: Check for null pointers in vhost_blk
This fixes two flagged Klocwork issues.

Change-Id: I98ac136995ebcdc89aa94c76fec095573e102674
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/408237
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2018-04-19 00:08:21 -04:00
Pawel Wodkowski
a3f8876777 vhost: add JSON config dump
Change-Id: If6c9ea6f9959b6c34ef90b8e382ceba9889040ee
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/404373
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2018-04-16 19:27:33 -04:00
Dariusz Stojaczyk
6820d312e1 vhost: move memory registration to DPDK thread
Moved it to the DPDK thread, so that we don't stress
SPDK I/O reactors on device start/stop. This is mandatory
if we want to maintain hundreds of simultaneous connections.

This patch also fixes various memory registrations leaks
in cases where further device initiation fails.

Change-Id: I435062108fe96d7e67e2a078a3547acb1f73ad11
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/406960
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>
2018-04-12 16:06:31 -04:00
Dariusz Stojaczyk
ffb4d54a79 vhost: unaffinitize rte_vhost thread
rte_vhost_driver_start() can start a new posix thread
that polls for incoming socket connections and calls
backend->start/stop_device. Soon we're going to put
more work on this thread, so we need to make sure it
doesn't collide with SPDK reactors.

This patch also fixes vdev memory leaks in case the
rte_vhost_driver_start() fails.

Change-Id: I16fdff228176a245c478251b39aa244a49bd124b
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/406959
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>
2018-04-11 16:49:57 -04:00
Daniel Verkamp
7bdd103b3d vhost: fix indentation in vhost_user.h
Change-Id: Ib77a219e02a5cde69293eb1f7002507cf4930ae3
Fixes: 90c0e24410 ("vhost_user_nvme: add vhost user nvme target to SPDK")
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/407193
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>
2018-04-10 15:43:26 -04:00
Ben Walker
96fcdf93e7 vhost/nvme: Check for NULL nvme on public functions
Due to the check on line 153 in t_nvme_dev, Klocwork
thinks nvme can be null. Therefore, we must check that
it isn't null before dereferencing it. We can either
solve this the way I have here, or remove check
that causes to_nvme_dev to return null.

Change-Id: I86d4939664704ff1117a7c1b7dada7e1ae479c6f
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/406992
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2018-04-10 12:58:34 -04:00
Daniel Verkamp
c27c2c0674 vhost: reduce log level of informational messages
SPDK_NOTICELOG should only be used for significant but non-warning/error
messages, such as notifications of deprecated config file sections.

Change-Id: I885dfe839c9cbc9eceabee234e4d0eb74c6910df
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/405923
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>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2018-04-05 12:06:45 -04:00
Changpeng Liu
90c0e24410 vhost_user_nvme: add vhost user nvme target to SPDK
Similar with exist vhost scsi/blk target, this commit introduces
a new target: vhost nvme I/O slave target, QEMU will present an
emulated NVMe controller to VM, the SPDK I/O slave target will
process the I/Os sent from Guest VM.

Users can follow the example configuation file to evaluate this
feature, refer to etc/spdk/vhost.conf.in [VhostNvme].

Change-Id: Ia2a8a3f719573f3268177234812bd28ed0082d5c
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/384213
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>
2018-04-03 15:01:24 -04:00
Dariusz Stojaczyk
3d220b925f vhost: cleanup, remove unused functions
Change-Id: I70b567de366cc89ef2682c5788c49865435337df
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/405551
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-03-30 12:50:27 -04:00
Roman Sudarikov
c3bc40a6ef io_channel: add return value to pollers
This will be used to track time used in pollers - each poller can now
indicate if it found any work to do or not.

For cases where it was obvious and the infrastructure was already in
place, existing pollers have been modified to return 0 or a positive
value to indicate whether work was done.  Other pollers have been
modified to return -1 by default, indicating that the poller isn't
indicating anything about whether work was performed.  This will allow
us to find un-annotated pollers easily in the future and fix them
incrementally.

Change-Id: Ifebfa56604a38434fac5c76ba7263267574ff199
Signed-off-by: Roman Sudarikov <roman.sudarikov@intel.com>
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/391042
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-03-13 11:16:20 -04:00
Daniel Verkamp
a0484cad21 vhost: merge spdk_vhost_startup() into spdk_vhost_init()
This allows vhost initialization to be fully handled in the event
framework subsystem.

Change-Id: Ic0ff11f3765cc553b7ca183027209fb6dd131364
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/403226
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2018-03-09 09:56:44 -05:00
Daniel Verkamp
fc0a23627e vhost: add API to set socket path
This lets us drop the basename parameter from spdk_vhost_startup(),
which is a step toward making vhost initialization happen as part of the
event subsystem instead of in the spdk_app_start() callback.

Change-Id: I4fe18c4c3f12b706e73ae74500be58f1582110fd
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/403225
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2018-03-09 09:56:44 -05:00
Pawel Wodkowski
1655fa48a8 vhost: always inline spdk_vhost_dev_has_feature
spdk_vhost_dev_has_feature() is internal function so we can move it's
declaration to header file. This remove function call overhead.

Change-Id: I1704e8279cd6720177047a1ae8818f68982998db
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/400241
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2018-02-20 12:35:21 -05:00
Dariusz Stojaczyk
20fbd09a78 vhost: reenable indirect descriptors
Patch 808a2b05 [1] fixed overflow of avail entries count,
also fixing indirect descriptors support. Without indirect
descriptors, we usually didn't manage to fill entire queue
- there were always a couple of descriptors left. A couple,
but not enough to form a vhost-scsi descriptor. Indirect
descriptors, however, are 1-descriptor long. They have higher
possibility to fill entire avail queue, and that's why they
used to fail more often. But we can safely reenable them now.

[1] 808a2b05 ("vhost: fix overflow of avail entries count")

Change-Id: Idec8568cdfc1255fb578e5d18f5c476a4c034d2d
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/396805
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>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-02-15 11:08:57 -05:00
Dariusz Stojaczyk
9f0a73d901 vhost: vhost_dev_get_cpumask now returns const spdk_cpuset *
The cpuset API is const-aware, so we can safely
return const cpuset here. This will simplify
future usages of this function - for now it remains
unused.

Change-Id: If849ed49056a54035fb7a6eccde84121630f9974
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/399457
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>
2018-02-14 15:34:06 -05:00
Dariusz Stojaczyk
b2847368cc vhost: add smp_wmb() before logging used->ring
This doesn't really fix anything as rte_vhost
logging functions are extremely poorly designed
and do smp_wmb() by themselves - but only if
logging is enabled...

Let's move the barrier in our vhost.c. This
doesn't change any behavior, but makes the code
more readable. It surely looked weird to update
the ring, log it, and then do smp_wmb().

Change-Id: I90827b14292b60bd5641a48d546e7249a0496a4b
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/398326
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
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>
2018-02-13 19:33:03 -05:00
Dariusz Stojaczyk
da78c67091 vhost: drop VIRTIO_F_NOTIFY_ON_EMPTY feature
This feature is not particularly useful for storage.
It forces us to read additional vq memory on each
I/O completion and that's quite expensive.

Quoting VIRTIO 1.0:

```
VIRTIO_F_NOTIFY_ON_EMPTY (24)
If this feature has been negotiated by driver, the device MUST issue an
interrupt if the device runs out of available descriptors on a
virtqueue, even though interrupts are suppressed using the
VIRTQ_AVAIL_F_NO_INTERRUPT flag or the used_event field.
```

Later on:

```
Note: An example of a driver using this feature is the legacy networking
driver: it doesn’t need to know every time a packet is transmitted, but
it does need to free the transmitted packets a finite time after they
are transmitted. It can avoid using a timer if the device interrupts it
when all the packets are transmitted.
```

Change-Id: I7f53293bf811a4cd5ae8e42e18f35042ea6f4ba8
Suggested-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/398325
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: Daniel Verkamp <daniel.verkamp@intel.com>
2018-02-13 19:33:03 -05:00
Dariusz Stojaczyk
d03cac1310 vhost: don't notify on last_used_idx overflow
This is required only for event index,
which we don't support for now. The whole
NOTIFY_ON_EMPTY feature is about to be removed
soon. See subsequent patches for details. If
necessary, this should be re-implemented in a
different way.

Change-Id: Idd0c1ab929eef46e692834ffdc62472fa0f6fb74
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/398324
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>
2018-02-13 19:33:03 -05:00
Dariusz Stojaczyk
19725e9764 vhost: change vdev global array to a linked list
Drop max vhost initiators limitation in SPDK (64).
We're still limited by rte_vhost limits, but
they're set to 1024 at the moment.

Change-Id: Ia1ad25665d6e798bc22709cdd43b72d60f1f4cf0
Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/389811
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>
2018-02-13 19:27:54 -05:00
Dariusz Stojaczyk
720c627a93 vhost: return proper rc on vhost_dev_register() alloc failure
This must've been overlooked in patch 601bcbcf.

Fixes: 601bcbcf66 ("util: extend cpumask to hold more than 64 cpus")
Change-Id: Ia7e06fcacba5cd99770b81542678550e9fbc3ca2
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/399455
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>
2018-02-12 18:22:29 -05:00
Dariusz Stojaczyk
ea6c27099c vhost: removed spdk_vhost_dev_find_id
This internal function was now being used in one
place only. Inlined it so there's less code.

Change-Id: Ide52494d0e0f9563ce35ef7bf9166f62734a8309
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/399440
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>
2018-02-12 14:07:58 -05:00
Dariusz Stojaczyk
cd0ef03b38 vhost: abstract away vhost device array
Added vdev->id field and refactored the hot
vhost external event code operating on
g_spdk_vhost_devices array, so that we will
be able to switch from that array to a linked
list with unlimited capacity more easily.
This patch does not change any functionality
on its own.

We would very willingly reuse vdev->vid here,
but it's available only on devices with active
connections.

Change-Id: Ife911a6ca1531aade374b99ef4502cf77f691fa2
Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/389071
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>
2018-02-12 14:07:58 -05:00
Dariusz Stojaczyk
33285599ef vhost: fix double module fini on vhost init failure
Doing a manual vhost module fini followed
by an spdk_app_stop is wrong, as the app_stop
will trigger the vhost module fini again.
This will potentially free the g_num_ctrlrs
twice. Doing just spdk_app_stop is enough.

Fixes #238

Fixes: 3fb4bc717b ("vhost: move app fini to the vhost subsystem")
Change-Id: I70f886f6792ffc5c499a8d8cb0b6ab01855f7e9b
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/399129
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: Daniel Verkamp <daniel.verkamp@intel.com>
2018-02-12 12:13:23 -05:00
Dariusz Stojaczyk
8f29093660 vhost/blk: set blkcfg->num_queues to the max available queues number
QEMU overrides this value anyway, but other
virtio implementation may not. Setting
blkcfg->num_queues to its target value
won't break anything, and will help out
SPDK virtio-blk driver implementation.

For equivalent field in virtio-scsi, the
Virtio 1.0 spec says:

```
num_queues
is the total number of request virtqueues exposed by the device. The
driver MAY use only one request queue, or it can use more to achieve
better performance.
```

Multiqueue for virtio-blk is oficially still
unsupported, so the blkcfg->num_queues remains
undocumented. Let's implement it adequately
to the virtio-scsi spec.

Change-Id: Ief520385997bb7e745ed17501a972c55955346d2
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/399121
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>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2018-02-09 13:14:43 -05:00
Changpeng Liu
1c164f117d vhost-blk: enable vhost block with new added get/set config messages
New vhost user messages GET_CONFIG/SET_CONFIG can be used for
vhost-blk for the purpose to get configuration parameter such
as: Capacity and block size. This commit enable this feature,
users don't need to append capacity any more when started
QEMU. Also event notifier is added for the purpose to change
capacity of block device while QEMU is running.

Also re-enable the vhost-blk tests.

Change-Id: I06ef697984eeea3abbbd655bdcaccaa3b7aa72d7
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/386546
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>
2018-02-09 13:14:43 -05:00
Daniel Verkamp
64465d0dc8 Remove trailing whitespace before \n in printf()
Tree-wide cleanup of all instances of printf()-style functions where a
format string contains a space before a newline character.

Change-Id: Ib5b5861e97bed9e9d62db03875547e3f771f4769
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/397031
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
2018-02-06 11:16:50 -05:00
Dariusz Stojaczyk
fa82f460d1 vhost: remove vdev->type field
This field was only required to check
if we can safely upcast vdev object.
We can just as well check vdev->backend
instead. The vdev->type is not needed here.

Change-Id: I525350957406d4299151e0557b9025ca7bea5371
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/396584
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-02-06 11:05:01 -05:00
Dariusz Stojaczyk
2307738334 vhost: remove all devices on shutdown
Fixes a memory leak on shutdown.

Change-Id: I1fb922374b98771858757c536ab45202283150f4
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/396576
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-02-06 11:05:01 -05:00
Dariusz Stojaczyk
483567b1ae vhost: don't hotremove luns if entire target is being removed
When a target is removed, spdk_scsi_dev_destruct
removes its luns, consequently closing bdev descriptors
and in vhost case - triggering target hotremove again.
This doesn't really have any negative consequences, as
the second hotremove just fails silently. But let's
cleanup this for sanity.

Change-Id: I47c76814696b49905b9fb00667e9529db3f58c12
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/396575
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
2018-02-06 11:05:01 -05:00
Dariusz Stojaczyk
672588d736 vhost: unify vdev removal
Instead of:

 * spdk_vhost_scsi_dev_remove(vdev)
 * spdk_vhost_blk_dev_remove(vdev)

we now have

 * spdk_vhost_dev_remove(vdev)

All the logic is already handled internally. This patch only
changes the API. Also, previous vhost_dev_construct()/remove()
functions have been renamed to vhost_dev_register()/unregister()
because that's what they really do.

Change-Id: I7dd0d77bc5b633bec075e0a71345ddbed62697b4
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/396574
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
2018-02-06 11:05:01 -05:00
Dariusz Stojaczyk
3fb4bc717b vhost: move app fini to the vhost subsystem
We already have a vhost subsystem and have to do
its fini anyway, so let's remove application fini.
Technically, any SPDK app can use vhost library
and create vhost devices, so we need to delete them
on shutdown in all cases - in module fini.

Change-Id: I013b45b4e73fd19288b9c10bc995dc24894ecf35
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/396573
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
2018-02-06 11:05:01 -05:00
Pawel Wodkowski
efb18b9b46 vhost: add live migration support
This patch adds support for live migration for vhost-scsi and vhost-blk
backends.

Change-Id: Ibfc8a713dbba14ba8cb38377a71e28fd340b1487
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/394203
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>
2018-01-30 15:42:40 -05:00
Pawel Wodkowski
f69503f155 rte_vhost: add offset while mmaping log base address.
QEMU always set offset to 0 but for sanity we should take the offset
into account.

Change-Id: I36213cd8fbeb85862b6de59c60bd6bcee7f9d1b2
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/395740
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2018-01-30 15:42:40 -05:00
Pawel Wodkowski
c1cfc10a59 rte_vhost: stop device before messages that can change something
Some messages like SET_FEATURES, SET_VRING_ADDR etc will change internal
state of VQ or device. To prevent race vs thread polling those queues
stop the device.

Change-Id: I15caf9da0decbaa660e9773c93d45ff148e5e9a8
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/395739
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-01-30 15:42:40 -05:00
Pawel Wodkowski
29181903ce vhost: prevent IO freeze by kicking all queues after starting device
See comment in vhost.c file for more details why this fix is needed.

Change-Id: I782119768fb200ad36f9253e704cc08a3be36ae6
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/395514
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
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>
2018-01-30 15:42:40 -05:00
Dariusz Stojaczyk
808a2b05c2 vhost: fix overflow of avail entries count
Virtio 1.0 says that the effective capacity of vrings
is equal to the virtqueue size. When avail ring was full,
we detected it as empty.

Change-Id: I72f5d45cdc14db6b934ce7780e603a3de3131594
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/396804
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>
2018-01-29 12:40:00 -05:00
Dariusz Stojaczyk
a78c896369 vhost: add a memory barrier after incrementing used->idx
Ensure the used->idx changes are visible to
the guest at the time of interrupt.

Change-Id: I245b91c7fbe2e21600aa94d8314271ea5b987343
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/396929
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>
2018-01-29 12:37:19 -05:00
Tomasz Kulasek
601bcbcf66 util: extend cpumask to hold more than 64 cpus
Fixes github issue #218.

This patch introduces spdk_cpuset object to store and manipulate
the set of individual CPUs. The main objective of this object is
to replace cpumask declared as uint64_t and extend the limitation
of supported CPUs (lcores) above 64 CPUs.

spdk_cpuset is always allocated dynamically and accessed by opaque
pointer, what makes it easier to extend in the future without
breaking API/ABI.

This patch also extends parsing function allowing to set cpumask
using a list of cpus e.g. "[0-4,10,12]" sets mask of 0,1,2,3,4,10,12
as well as hexadecimal string with and without "0x" prefix.

Change-Id: I475c3ba7fab629021a22e03176e57e400dd24a49
Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
Reviewed-on: https://review.gerrithub.io/390794
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>
2018-01-25 18:51:50 -05:00
Karol Latecki
f6f434b4b4 test/vhost: Update vhost test plan
Also move the test plan file to a more appropiate location.

Change-Id: I462058279d4d2dc03790657b82b3cfeb00c8a93a
Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.gerrithub.io/394180
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2018-01-25 13:59:47 -05:00
Changpeng Liu
53c24913f2 vhost_lib: enable virtio configuration space feature
New added vhost user messages: GET_CONFIG/SET_CONFIG are
used for get/set virtio device's configuration space, this
commit enable the new added vhost messages.

Change-Id: I5c3e3f8fb6ed55e99299323c39658765b1724bb8
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/386545
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-01-24 16:48:48 -05:00
Jim Harris
f570aa654a vhost: only split on 2MB boundaries when necessary
vhost I/O only need to be split on 2MB boundaries if
there is a break in the VM's memtable at that 2MB
boundary.

This should drastically reduce (if not eliminate)
the intermittent test pool failures seen recently.
virtio limits number of segments to 128, but this
2MB splitting could introduce additional segment
breaks which we do not allocate IOVs for.  In almost
all cases, there are no memtable breaks except at
low 2MB, so most of the extra segment breaks we are
adding are unnecessary.

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

Reviewed-on: https://review.gerrithub.io/396058
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2018-01-24 10:33:43 -05:00
Jim Harris
902f8719f2 vhost: bump SPDK_VHOST_IOVS_MAX to 129
Currently we test up to 512KB I/O sizes, and this I/O
size could fragment to 129 IOVs if split on 4KB
boundaries if the buffer start is not 4KB aligned.

This is likely the cause of a recent slew of failures
in the test pool which coincide with updating to
fio 3.3.

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

Reviewed-on: https://review.gerrithub.io/395872
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>
2018-01-22 23:19:43 -05:00
Shuhei Matsumoto
583e969922 scsi: remove lun name
There is no need to keep a lun name anymore - we always
use the bdev name as the lun name so it is not providing any
additional value. This also keeps us from associating
the same bdev with different LUNs on different iSCSI target
nodes or vhost-scsi controllers.

Side effect of this change is:

1) Use "bdev_name" across the APIs to make it more clear
   what these names refer to.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I3d42fde22087352ce1d5dc80178bd8c5cac8cb7c
Reviewed-on: https://review.gerrithub.io/390843
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-01-11 18:37:34 -05:00
Dariusz Stojaczyk
60c1cd75dc vhost_blk: set proper vring_used_elem->len
This `len` field describes the amount of bytes
*written* by the device. It is used to prevent
the driver from reading buffer memory that wasn't
really written to - it could contain either
leftover values from previous requests or even
be completely unitialized.

In a couple of invalid-request error conditions
we still write the VIRTIO_BLK_S_UNSUPP response while
returning used_len == 0, but that's fine. A properly
written driver will likely handle both of these cases
the same way.

Change-Id: I8e9f3a8051561096e2ee755122d534b4ffd94db1
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/393963
Reviewed-by: Pawel Kaminski <pawelx.kaminski@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>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-01-11 12:01:53 -05:00
Dariusz Stojaczyk
9605a2eace vhost_scsi: set proper vring_used_elem->len
This `len` field describes the amount of bytes
*written* by the device. It is used to prevent
the driver from reading buffer memory that wasn't
really written to - it could contain either
leftover values from previous requests or even
be completely unitialized.

Change-Id: I67aee5c8b9455fc86cdeb600ea3a051a7737c66f
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/393962
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: Jim Harris <james.r.harris@intel.com>
2018-01-11 12:01:53 -05:00
Dariusz Stojaczyk
c39eb080b3 vhost_scsi: removed duplicated check against VHOST_IOVS_MAX
The same check is done inside
spdk_vhost_vring_desc_to_iov.

Change-Id: Id93a05848ed69b8dd048ac490df2432b4252c6e0
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/394088
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>
2018-01-09 14:55:45 -05:00
Daniel Verkamp
e45437aba7 scsi, iscsi: move task->parent to iSCSI task
The SCSI layer no longer needs to know about the parent/subtask
relationship maintained by iSCSI.

Change-Id: Ia6f7c5367c5b656bd7521ed1abb6d0f713a0500b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/393697
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>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
2018-01-05 00:01:37 -05:00
Pawel Wodkowski
891c12a63c util: add spdk_strerror() wrapper with TLS support
This patch remove need for additional buffer when translating error code
to string.

Change-Id: Iaa60088b5c450581d3cdddbb425119b17d55a44b
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/386114
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-01-04 15:00:09 -05:00
Dariusz Stojaczyk
d1da24769f vhost: don't check HOTPLUG feature flag when not necessary
LUN hotremove callback can be triggered when
it's vhost-scsi controller is not started
yet. In such case it is not necessary to check
against HOTPLUG flag (if the controller doesn't
have any driver connected yet, there might be
no negotiated flags whatsoever).

Change-Id: Ic7c78e3bdf45fa4d5628cd19c4c5ad723699e45f
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/371864
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@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>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2018-01-03 12:15:30 -05:00
Daniel Verkamp
a7de1070c3 vhost: use task length rather than transfer_len
The SCSI task transfer_len field is only distinct from length in iSCSI;
vhost should always have length == transfer_len.

Change-Id: I37faec26f0f49c27019a965c1f1f48903ca54b58
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/393203
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-01-03 12:09:57 -05:00
Daniel Verkamp
591c31f717 vhost: fix pthread_create() error handling
pthread_create() returns error codes via its return value, not errno.

Change-Id: Iac0f2380dd4daf15dc48829a3b9b0a75aedd87d1
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/392984
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2017-12-29 13:48:29 -05:00
Shuhei Matsumoto
b29d208267 vhost: Replace RTE_MAX_LCORE by spdk_env_get_last_core()
Adopt two improvements for iSCSI by Ziye to VHOST.
- iscsi/conn: remove rte_config.h header
- env: export spdk_env_get_last_core function

Change-Id: I8f067093d593c8d483c52587669f8b0b706f497f
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/392910
Tested-by: SPDK Automated Test System <sys_sgsw@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-12-28 12:03:40 -05:00
Shuhei Matsumoto
0686f0381b vhost: Remove DPDK dependency and simplify load balancing
The latest patch for the iSCSI connection is applied to the vhost
too.

RTE_MAX_LCORE in the for loop is removed and the for loop is
replaced by SPDK_ENV_FOREACH_CORE().

When the cpumask is unexpectedly 0, not 0 but the first core is
returned.

Change-Id: I39cfc2219a3532eccc8c0ce59712102b947a76d7
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/392588
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ziye Yang <optimistyzy@gmail.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-12-28 12:03:40 -05:00
Shuhei Matsumoto
14797d839d vhost: Allow set cpumask more than active cores for vhost
The latest change for the portal group is applied to the vhost.
The following comment is quoted from it.

Currently the cpumask must be a subset of the reactor mask.

However, this is different from sched_setaffinity() function
and taskset command of FreeBSD and Linux.  The latter will
be familier for more people. Hence the later is adopted.

The following is quoted from the FreeBSD Man Page of taskset:

  The CPU affinity is represented as a bitmask, with the lowest
  order bit corresponding to the first logical CPU and the
  highest order bit corresponding to the last logical CPU.

  Not all CPUs may exist on a given system but a mask may specify
  more CPUs than are present.

  A retrieved mask will reflect only the bits that correspond to
  CPUs physically on the system.

  If an invalid mask is given (i.e., one that corresponds to no
  valid CPUs on the current system) an error is returned.

  The masks are typically given in hexadecimal.

Change-Id: Idcd72a12ef52e4ccec8476e7d54fab82867cf936
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/392587
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-12-21 13:32:31 -05:00
Changpeng Liu
4395093b97 vhost_blk: close the bdev in the hotplug callback
For normal exit logic, such as Ctrl+C, vhost blk will not
shutdown the backend device, e.g: NVMe controller.

Change-Id: I7fdf8687a2cfa6a8cc6a61428d722debfa9a2180
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/391348
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-12-19 14:54:51 -05:00
Pawel Niedzwiecki
804f6ce45a vhost/rpc: fix get_vhost_controllers
get_vhost_controllers was printing only one device of vhost
scsi controller with multiple devices

Change-Id: I392fc393d9e8f3d20c28139724d83b79d800456a
Signed-off-by: Pawel Niedzwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-on: https://review.gerrithub.io/391593
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-12-14 11:27:57 -05:00
Dariusz Stojaczyk
4910c0af95 vhost: use vdev->path where possible
We used to sprintf the path from
directory and socket name, while
the complete path was already held
in vdev->path.

Change-Id: I27bc71be52a805b39e083eb4f76947587c36a4ad
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/390411
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@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-12-12 15:42:03 -05:00
Daniel Verkamp
59970a89be astyle: enforce braces around single-line statements
Require braces around all conditional statements, e.g.:

    if (cond)
        statement();

becomes:

    if (cond) {
        statement();
    }

This is the style used through most of the SPDK code, but several
exceptions crept in over time.  Add the astyle option to make sure we
are consistent.

Change-Id: I5a71980147fe8dfb471ff42e8bc06db2124a1a7f
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/390914
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-12-11 11:19:32 -05:00
Sebastian Basierski
0709cc48c9 vhost: Switch "Dev" keyword to "Target"
Added new keyword 'Target' that will replace 'Dev'.
'Dev' is still usable, but deprecated and will be removed.

Change-Id: Iafd6114ef2cc5b2f8d58497e9fb454a3a237ed16
Signed-off-by: Sebastian Basierski <sebastianx.basierski@intel.com>
Reviewed-on: https://review.gerrithub.io/388568
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>
2017-12-08 09:25:49 -05:00
Daniel Verkamp
ea1c15791f log: rename SPDK_TRACE_* to SPDK_LOG_*
Disambiguate the log components from the trace functionality
(include/spdk/trace.h).

The internal spdk_trace_flag structure and related functions will be
renamed in a later commit - this is just a find and replace on
SPDK_TRACE_* and SPDK_LOG_REGISTER_TRACE_FLAG().

Change-Id: I617bd5a9fbe35ffb44ae6020b292658c094a0ad6
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/376421
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-12-07 12:23:19 -05:00
Changpeng Liu
d557196414 vhost: move spdk_vhost_init/fini to vhost library
Althrough the two functions are empty now, but they are not
vhost_scsi specific.

Change-Id: I331a455374f7dd92fd76cab255a43072baceb0dd
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/389477
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-12-01 17:07:45 -05:00
Sebastian Basierski
2b415f2c89 vhost: Reduces size of vhost app coredump file.
Fixes #215

Change-Id: Ib65d9479e87c6007fa903b02a37d82e3d319e290
Signed-off-by: Sebastian Basierski <sebastianx.basierski@intel.com>
Reviewed-on: https://review.gerrithub.io/388615
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-12-01 12:56:04 -05:00
Changpeng Liu
500f531200 vhost: free destroy context structure when stopping device
Change-Id: Ifd0cf56804df016c2d9b80a266f882eb8117083e
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/389220
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-11-29 13:03:07 -05:00
Ben Walker
9c35e39c54 event: Move spdk_poller_register to io_channel
Make this generic and not directly dependent on
the event framework. That way our libraries can
register pollers without adding a dependency.

Change-Id: I7ad7a7ddc131596ca1791a7b0f43dabfda050f5f
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/387690
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-11-28 12:30:37 -05:00
Xiaodong Liu
834a9bb7e8 vhost: remove needless if branch for bvdev/svdev
Change-Id: I362f748fa44fda8b574458cffa6f222d71e770b6
Signed-off-by: Xiaodong Liu <xiaodong.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/388348
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
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-11-21 16:10:09 -05:00
Dariusz Stojaczyk
414e6df7ff vhost: clarify some error messages
Change-Id: I761a599b993aab3b6df3189efaae15d9a2b0c8a0
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/387748
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>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2017-11-17 19:18:30 -05:00
Ben Walker
00b02039c5 event: Pollers must now be unregistered from the thread they run on.
Change-Id: I8ea8c59a0c67176c0c0c39abf807afad61ff3828
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/387689
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-11-17 11:11:23 -05:00
Ben Walker
fcb4776fe7 event: Pollers must now be registered from the thread they run on.
Change-Id: I864cd8a6c206dfbe62fcb3f72275c1ae51aa4ed7
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/387688
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-11-17 11:11:23 -05:00
Dariusz Stojaczyk
c138dfe229 dpdk: include rte_config.h where necessary
DPDK 17.11 removed all rte_config.h includes
from rte_*.h headers, meaning we should either
use gcc param -include rte_config.h (just
like DPDK does), or include this file before
each other rte_*.h include. Since we're using
the latter approach in many places already,
I decided to follow it.

While here, also removed rte_vdev.h dependency
from rte_virtio/virtio_user.c. It's not used
anyway.

Change-Id: I865ee9f828211c03a60fd0446f7a418d5dddd140
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/387653
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>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-11-15 17:52:05 -05:00
Dariusz Stojaczyk
2c4c7c8870 rte_vhost: mantain separate virtio features field in virtio_net
There are two separate abstraction layers:
* vsocket - which represents a unix domain socket
* virtio_net - which represents a vsocket connection

There can be many connections
on the same socket. vsocket
provides an API to enable/disable
particular virtio features on
the fly, but it's the virtio_net
that uses these features.
virtio_net used to rely on
vsocket->features during
feature negotiation, breaking
the layer encapsulation (and
yet causing a deadlock - two
locks were being locked in a
separate order). Now each
virtio_net device has it's own
copy of vsocket features, created
at the time of virtio_net creation.
vsocket->features have to be
still present, as features can be
enabled/disabled while no
virtio_net device has been
created yet.

Fixes #214

Change-Id: Ic4b2dd8cae6050813fc9a420b2ed30bc5ae60393
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/386294
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-11-14 15:39:49 -05:00
Changpeng Liu
d804492f02 vhost: exit the vhost app for error configuration
Change-Id: I56cc1df278a35bf40f3bb67d25af6dc3658aac82
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/382770
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
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>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-11-03 17:39:24 -04:00
Pawel Wodkowski
ff1863f428 vhost: interrupts coalescing
Virtio spec say that any IRQ requests are only hints. So try to limit
number of interrupts generated by vhost by defining minimum interval
between sending IRQ. Coalescing is disabled by default. Can be enabled
using RPC command 'set_vhost_controller_coalescing'.

Change-Id: I9b96014d004ea0ea022b4498c6b47d30d867091a
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/378130
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-10-27 13:06:40 -04:00
Pawel Kaminski
b84cf820af test/vhost: Test Plan for vhost initiator.
Change-Id: I51a45ef1d94de6324744af7801b59a6b73578dd2
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/377563
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
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-10-26 14:07:59 -04:00
Dariusz Stojaczyk
3788c907bb rte_vhost: fix double free on shutdown
The vhost connection can be closed
concurrently from 2 places:
 * the connection thread itself
 * rte_vhost_driver_unregister
The connection thread will terminate
the connection if any recv error
occured. The unregister function
will terminate the connection
together with the thread.
However, there is no sychronization
between those two. The connection
thread runs in the background
without any mutex.

The rte_vhost_driver_unregister
now signals the connection thread
to terminate itself and waits
until it's killed.

Change-Id: I012e97ebb8a79edcb2c17c28b2fc7e8041bf92b3
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/383085
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2017-10-23 15:35:25 -04:00
Pawel Niedzwiecki
97e82c0c06 vhost_scsi: validate length of virtio descriptors
Casting pointers without checking their length could
potentially lead to a crash

Change-Id: I7c61e5818ecfbf32bb363858965503341353c51e
Signed-off-by: Pawel Niedzwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-on: https://review.gerrithub.io/382420
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>
2017-10-23 11:53:55 -04:00
Dariusz Stojaczyk
04b2fee404 vhost: replaced tasks ring with dynamic array
Each virtqueue will now contain
it's own buffer for I/O tasks.

Some of the task struct fields
are now the same across subsequent
I/Os, so they can be now set
just once - at the vdev start/stop.

This simplifies the code, the
debugging process and also introduces
additional sanity check preventing
vhost from processing two requests
with the same id at the same time.

Change-Id: Idcf388e8bf7c92e5536199c35eb0eb6339c00d84
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/369114
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>
2017-10-17 13:37:56 -04:00
Pawel Wodkowski
3a33129a6d vhost: wrap rte_vhost_vring into spdk_vhost_vring
This enable storing SPDK specific stuff per queue. First use of
this will be event index feature.

Change-Id: Ieca6fa47a6f2e23bec73d2cda8b0ed8b9185bd28
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/376636
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-10-17 13:37:56 -04:00
Dariusz Stojaczyk
aab8511796 vhost_scsi: minor cleanup
Clarify some error messages
and simplify the code.

Change-Id: I586ea55a1d9fa10142d4a9d469b62f1b83076cd5
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/381925
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-10-13 19:13:00 -04:00
Pawel Niedzwiecki
c31fb325a7 vhost_scsi: fail requests to device marked for removal
Change-Id: Ie9eea844a64653cf9c016eb3ad96c80546600762
Signed-off-by: Pawel Niedzwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-on: https://review.gerrithub.io/382170
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>
2017-10-13 10:47:32 -04:00
Pawel Wodkowski
205a00d9fa vhost: disable indirect descriptors
Some problems with indirect descriptors shown. Disable it for now to
have time to investigate it.

Change-Id: I8c6cfff94dc2159ab01f72986a8ae7d42c353e8b
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/382301
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-10-12 14:21:43 -04:00
Tomasz Zawadzki
b1ccfaca01 subsystem: remove fini return code
Closing the framework has to go through all subsystems
without failure, so return codes are unnecessary.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I53c9b4df12d2357e641130869f398b18637e6ff7
Reviewed-on: https://review.gerrithub.io/381681
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2017-10-10 10:56:34 -04:00
Dariusz Stojaczyk
88f6b9a66e vhost_scsi: fix scsi_task leak
The task was being aborted before
setting it's free_cb. This
results in i.e. not allowing
vhost device to stop it's pollers,
as it would endlessly wait for
this task to finish.

Change-Id: I0de2d1f21da109db1045e433c07f153316e09997
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/381866
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-10-09 14:09:00 -04:00
Dariusz Stojaczyk
29a33dab93 vhost: implemented indirect descriptors
Every descriptor may now contain
a separate descriptor table.

This increases the maximum number
of concurrent IO in a virtqueue
from about (vq->size / 3) to
(vq->size * SPDK_VHOST_IOVS_MAX).

Knowing that SPDK_VHOST_IOVS_MAX
is 128, and assuming that vq->size
is 128 (current hardcoded limit
for QEMU), this gives us over 16k
concurrent possible iovectors
on the fly

Change-Id: I0853d80f6f90d53f8774231972b430a5bf05460e
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/373703
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-10-09 14:09:00 -04:00
Dariusz Stojaczyk
024e0e9095 vhost: check against virtio descriptor table overflow
Also squashed function has_next_desc
into get_next_desc to simplify the
code.

We can't just mask indexes with
(desc_table_size - 1), since in
indirect descriptors case
desc_table_size might not be a
power of 2.

Change-Id: I8053b0e37c553548d76c7a9cfe6b4dbc11c28cfc
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/373744
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-10-09 14:09:00 -04:00
Dariusz Stojaczyk
ae19c072e8 vhost: don't abort on event timeout
A single timeout error message is printed on the
screen already, so the user knows about the
timeout. Instead of aborting the app here, wait
endlessly for the event to complete. User
can kill the app any time if he wants to.

Change-Id: Ie1853e27b277d654a8e1099866d120f7a51638ba
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/381075
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-10-06 19:41:53 -04:00
Dariusz Stojaczyk
9df2ea9c27 vhost: rename new/destroy_dev() to start/stop_dev()
Previous names were highly misleading.

Change-Id: I30256da35da4b916f39982be134fa7128e81c914
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/381074
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-10-06 19:41:53 -04:00
Daniel Verkamp
df67486fa9 vhost/rpc: replace strerror with spdk_strerror_r
One instance of strerror() was introduced after the spdk_strerror_r()
function was introduced in commit 4d43844f4d.  Replace it with the
thread-safe version.

Change-Id: I83c6702f7965044ef5fa3577175f89a13dad833f
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/381601
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-10-06 17:47:42 -04:00
Tomasz Zawadzki
ba8515c61c vhost: allocate session_shutdown as spdk_event instead of pthread
This change allows for spdk_app_stop() to be executed on a DPDK lcore
instead outside of DPDK lcore range.

This is preparation for SPDK asynchronous finish, to assure
calling spdk_app_stop() from master core.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Iedc878346c74296b105f93507b2c858aedfbf16e
Reviewed-on: https://review.gerrithub.io/381535
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Maciej Szwed <maciej.szwed@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Piotr Pelpliński <piotr.pelplinski@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-10-06 13:28:21 -04:00
Dariusz Stojaczyk
1cd3705ecb vhost: removed unused and unsafe API from public headers
Change-Id: Ia254885e2603f3b10b92910b53ce0db9e95c22b5
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/373760
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2017-10-02 14:07:04 -04:00
Dariusz Stojaczyk
8323be7df8 vhost: use external event API in get_vhost_controllers RPC call
Added spdk_vhost_call_external_event_foreach.

Continuation of patch I689226c [1]

[1] vhost: added API to call external spdk_events on vdev reactor

Change-Id: I5a404ec9de586d197e84eeda82009a803b4fa623
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/373262
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>
2017-10-02 14:07:04 -04:00
Dariusz Stojaczyk
0d7e4b340d vhost_scsi: remove entire device on LUN hotremove
A device without LUNs can't be used at all,
so remove it automatically

Change-Id: Iefea73916c83dfddf0229bbfac5dacb23590d920
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/371299
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-09-29 11:43:50 -04:00
Dariusz Stojaczyk
2fe6947669 vhost: add vhost_dev_event_ctx->vdev_id
A vdev can change between the time the event
is enqueued and executed on proper reactor.
To detect this case, the event callback
was looking up vdev with the same name and
comparing it with old vdev pointer (from
the enqueue). This is now being simplified,
by looking up the current vdev just by
it's ID.

Change-Id: I33de03809b9d56840dd99caa8ccdf190a631ef31
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/380647
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-09-28 17:05:34 -04:00
Dariusz Stojaczyk
d4e19ecc1c vhost: use trylock inside async events body
This makes the async event body non-blocking
and also fixes potential deadlock scenario:
 * call_external_event() enqueues vhost_event
 * destroy_device() locks g_spdk_vhost_mutex
 * destroy_device() enqueues it's vhost_event
 * reactor dequeues events
  * cb from call_external_event is dequeued first
    * g_spdk_vhost_mutex is locked (deadlock)
 * destroy_device() times out, abort()

Change-Id: If8f51ada3ee5c47ba126f74187a40a285c001c77
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/380634
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-09-28 17:05:34 -04:00
Pawel Niedzwiecki
c63d9de433 rpc/vhost: unify RPC "remove_vhost_controller" for all backends
replaced "remove_vhost_scsi_controller" and "remove_vhost_blk_controller"
with "remove_vhost_controller".

Change-Id: I6f4b180054c13f25aae992e9be50375d3750a376
Signed-off-by: Pawel Niedzwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-on: https://review.gerrithub.io/377197
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-09-26 15:35:54 -04:00
Dariusz Stojaczyk
ad9a842c71 rpc/vhost_scsi: defer remove_scsi_dev RPC response
Defer writing RPC response until after the device has been hotremoved.

Change-Id: I052280b205415e4a2ffa1421653cc49b8e3b1445
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/371119
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-09-22 14:13:40 -04:00
Dariusz Stojaczyk
f61b71d71a vhost_scsi: implemented vhost device hot-attach
Devices can be added to a SCSI
vhost controller at any time now.

Change-Id: Ic5dd4b78465d3431479e0389b7ea902e1e25c337
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/371281
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-09-22 14:13:40 -04:00
Dariusz Stojaczyk
1112679f1a vhost_scsi: pass scsi_dev_num directly to eventq_enqueue
This simplifies eventq API greatly. Since vhost supports only a single
LUN per device, lun parameter in eventq isn't required for now.

Change-Id: I1c41a3f509aca96f2de8de6563a3cac5c4dd1b8b
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/371118
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-09-22 14:13:40 -04:00
Dariusz Stojaczyk
4c4492dcc4 vhost_scsi: removed internal eventq events ring
Since we are calling eventq_enqueue only from inside of the controller
reactor, such ring is not needed. Eventq events will now be sent
immediately. This simplifies the whole process greatly.

The abstract vhost event layer is being replaced with much simpler and
less error-prone vhost external spdk_event API.

This reverts commit 542b5415 [1] together with vhost scsi device
hot-attach feature. Hot-attach shall be reintroduced in upcoming
patches.

[1] 542b541588 ("vhost_scsi: implemented abstract vhost event layer")

Change-Id: I39a427332d573c4e0be548d1c8caf0cf2858f6a5
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/371117
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-09-22 14:13:40 -04:00
Tomasz Zawadzki
c0e6ecaa0b test/vhost: add vhost with lvol backends test
Script for testing vhost using lvols as backends for
virtual machines. Option for using nested lvol stores and
nested lvol bdevs also provided.

Change-Id: Iad8a196c97f292881a8b424b4433ec281f12aec6
Signed-off-by: Lukasz <lukaszx.galka@intel.com>
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.gerrithub.io/365798
Reviewed-by: Maciej Szwed <maciej.szwed@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-09-20 12:53:28 -04:00
Dariusz Stojaczyk
bb2523456c rpc/vhost: call RPC commands on controller's reactor
Used vhost external event API to call RPC commands on
controller's reactor. RPC call get_vhost_scsi_controllers
has been left unchanged as it requires special *foreach*
external event API. See next patches for details.

Change-Id: I1fd77c9af2606bbcea45cd0089015dd890b6e328
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/371279
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-09-15 14:18:46 -04:00
Dariusz Stojaczyk
a8599cd4f0 vhost: sync controller creation with g_spdk_vhost_mutex
Controller creation RPC can't be done on controller's reactor
(as there's obviously no controller yet...), so a special
set of vhost_mutex_lock/unlock() functions to has been added
to synchronise controller creation with the rest of
ctrlr-enumerating code.

Change-Id: Ib6e4b894a85ff1f70ebd047832c5a3568a00f1a7
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/377651
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-09-15 14:18:46 -04:00
Dariusz Stojaczyk
1fc1068049 vhost_scsi: vhost_scsi_dev_add_dev now takes vhost_dev param
Continuation of patch 94afad5a [1].
That function could be called from outside of the vhost reactor,
causing data races and possible segfaults.

Now, after this patch, all ctrlr-changing functions take spdk_vhost_dev
parameter, meaning they should be called via external event API [1],
which soon will be the only way of obtaining spdk_vhost_dev pointer.

[1] 94afad5a ("vhost: added external API to call spdk_events on vdev reactor")

Change-Id: I40ea66ad09fb5c433dd897a4e22aedeb423f9b4b
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/371013
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>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2017-09-15 14:18:46 -04:00
Dariusz Stojaczyk
2670503d46 vhost: readded return codes for dpdk callbacks
Added spdk_vhost_dev_backend_event_done function
that sets the return code for the callback and
transparently calls sem_post.

Change-Id: Iba27af780cd1753056c1607177c945e13c95c712
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/377585
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-09-15 14:18:46 -04:00
Dariusz Stojaczyk
34162e721b vhost: call new/destroy_device entirely on vhost reactor
DPDK is now fully synchronized with the rest of vhost.

This patch also removes timed_event API from vhost_internal.h.
It should only be used internally in vhost.c under g_spdk_vhost_mutex.

Also, this patch temporarily gets rid of return codes for
vhost_scsi/blk dpdk callbacks. -1 will be returned if the
call timed out, 0 otherwise. A patch reenabling this
functionality is on the way

Change-Id: Ifd9566ceb55a3c6dbe4bac013cc3b7600c834d17
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/372687
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-09-12 16:16:24 -04:00
Daniel Verkamp
7fb78765aa rte_vhost: fix numa_realloc() copy size
The rte_malloc_socket() call just above that allocates vq is only
allocating sizeof(*vq), but the memcpy() would have tried to copy
sizeof(*vq) * 2.

This code is under #ifdef RTE_LIBRTE_VHOST_NUMA, so it was not normally
enabled with DPDK 17.05, but it breaks when DPDK 17.08 turns on libnuma
support by default.

Change-Id: I75c0c8666a9147346038d313fb419350988d8187
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/377596
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: John Kariuki <John.K.Kariuki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-09-07 18:02:09 -04:00
Daniel Verkamp
96386d4d59 rte_vhost: include rte_config.h via compiler option
Some rte_vhost files use #ifdef RTE_LIBRTE_VHOST_NUMA, but they don't
explicitly include rte_config.h, which defines this macro.  Instruct
the compiler to pre-include rte_config.h in the same way DPDK's build
system does.

Change-Id: Iddde76b8c3d0956ccd5f481956cede650d858586
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/377595
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: John Kariuki <John.K.Kariuki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-09-07 18:02:09 -04:00
Daniel Verkamp
52ae747fe2 vhost: remove redundant NULL check in parse_core_mask
This is a private function that is only called in one place, and cpumask
is always provided.  Additionally, the code inside the mask == NULL ||
cpumask == NULL check always writes to *cpumask, so it was not possible
to pass NULL as cpumask anyway.

Change-Id: I2cde53dfeb07edc8a8f87f4ff485ec0c5c9ba7a8
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/376685
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-09-07 17:59:10 -04:00
Dariusz Stojaczyk
5d1a206663 vhost: added API to call external spdk_events on vdev reactor
The next step towards fixing synchronization issues between RPC and
vhost controller reactor.

The general idea is to hide spdk_vhost_dev_find declaration, so that
vdev-related functions can't be (incorrectly) called from outside of
the vhost controller reactor. The vdev pointer should only be acquired
via spdk_vhost_call_external_event.

Change-Id: I689226c2271f81624b2651bae3b960b7efb1c01b
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/371098
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-09-07 14:34:01 -04:00
Dariusz Stojaczyk
e28f3397c5 vhost: added spdk_vhost_event_fn
The next step towards fixing synchronization issues between RPC and
vhost controller reactor.

This patch makes changes to already present vhost timed event API
to conform it to the upcoming external spdk_events API. The timed_event
API shall be removed from headers in future. See next patch for details.

Change-Id: I31b0d7c383b39c32326daa750663ebdeb4edd562
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/377584
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-09-07 14:34:01 -04:00
Dariusz Stojaczyk
4f4f397502 vhost: use full path when unregistering sockets on shutdown
This patch properly closes sockets on shutdown.
Previous rte_vhost_driver_unregister calls were returning
immediately due to inexistent sockets at given paths.

Change-Id: I5e4d64f04fc8b6bef914c2eb4c4d2220be9ca9ec
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/377165
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-09-05 15:20:29 -04:00
Dariusz Stojaczyk
9f8efd8708 vhost: moved timed_event functions
In preparation to make them static

Change-Id: I086868aa88fa4f6f9f1c24b15a2e3cd0a04caab1
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/377096
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-09-05 15:19:16 -04:00
Dariusz Stojaczyk
d923a9eb2c vhost: simplified timed event code
Removed leftover code.

spdk_vhost_timed_event struct has been stripped from
spdk_event and timeout fields. The first one was not
required since vhost_timed_events are not reusable
anymore. The latter has been removed to prepare
vhost_timed_event struct to be expanded to generic
- also non-timing out - vhost_event struct.

Change-Id: Ifd22f59b2748752f2776700676f07e70b45957ed
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/377095
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-09-05 15:19:16 -04:00
Dariusz Stojaczyk
5ccd7974cc vhost: simplified timed_event API
Public API has been made smaller before refactoring timed_events
entirely.

Change-Id: Ie03bf5066582b6fd243229a9c8b1ceb77658dc2f
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/372686
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-09-05 15:19:16 -04:00
Dariusz Stojaczyk
211604b76c vhost: don't allow deleting vdev that has still open socket
Make use of new rte_vhost API.
vdev->vid is now set via new/destroy_connection(),
new/destroy_device sets vdev->lcore.
lcore != -1 implies vid != -1, hence some lcore checks have been
replaced with vid checks.

Change-Id: I08f4932ee7e6aeb3eba4874f2e94ad407764d9c2
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/372075
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-09-05 15:19:16 -04:00
Dariusz Stojaczyk
dde6213708 rte_vhost: added user callbacks for socket open/close
Added new callbacks to notify about socket connection status.
As destroy_device is used for virtqueue processing *pause* as well as
connection close, the user has no distinction between those.

Consider the following scenario:
rte_vhost: received SET_VRING_BASE message,
           calling destroy_device() as usual

user:  end-user asks to remove the device (together with socket file),
       OK, device is not *in use* - that's NOT the behavior we want
       calling rte_vhost_driver_unregister() etc.

Instead of changing new_device/destroy_device callbacks and breaking
the ABI, a set of new functions new_connection/destroy_connection
has been added.

Change-Id: I50a8ca4035045892d6c658da7df58c0c97025ec3
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/372074
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-09-01 15:34:24 -04:00
Ben Walker
3e084a34e1 env: Automatically register new memory with the IOMMU
If the IOMMU is enabled, automatically register memory
added by the user through spdk_mem_register().

Change-Id: Ie02c7bf445314da23e2efee9de9c187ed0773a9f
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/375249
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-09-01 15:25:24 -04:00
Dariusz Stojaczyk
1eac307937 rte_vhost: fix deadlock on rte_vhost_driver_unregister()
2 locks are executed in 2 places in opposite orders.
Consider the following scenario, threads A and B:
(A)
 * fdset_event_dispatch() start
   * pfdentry->busy = 1; (lock #1)
   * vhost_user_read_cb() start
     * vhost_destroy_device() start
(B)
 * rte_vhost_driver_unregister() start
   * pthread_mutex_lock(&vsocket->conn_mutex); (lock #2)
   * fdset_del()
     * endless loop, waiting for pfdentry->busy == 0 (lock #1)
(A)
     * vhost_destroy_device() end
     * pthread_mutex_lock(&vsocket->conn_mutex); (lock #2)
       (mutex already locked - deadlock at this point)

Thread B has locked vsocket->conn_mutex and is in while(1)
loop waiting for given fd to change it's busy flag to 0.
Thread A would have to finish vhost_user_read_cb() in order
to set busy flag back to 0, but that can't happen due to
the vsocket->conn_mutex lock.

This patch defers the fdset_del(), so that it's called outside of
vsocket->conn_mutex.

Change-Id: Ifb5d4699bdafe96a573444c11ad4eae3adc359f5
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/375910
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-08-31 19:16:06 -04:00
Dariusz Stojaczyk
3d8dbc69c1 Revert "vhost: wrap vhost_user_read_cb with vhost_user mutex"
This reverts commit 6973898164.
This solution was incomplete, see the next patch which properly
fixes the deadlock issue.

Change-Id: Ib3cc609814276f1c48b05280379b8c2849ad831f
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/375909
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-08-31 19:16:06 -04:00
Daniel Verkamp
932a186b4c log: remove uses of SPDK_TRACE_DEBUG
Replace SPDK_TRACE_DEBUG with component-specific flags.

Change-Id: Iee7eafab5e6ac8713f247323a18552b5afb0e86a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/375834
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-08-29 15:07:13 -04:00
Daniel Verkamp
d92f0f75ca log: rename SPDK_TRACELOG to SPDK_DEBUGLOG
This matches the name to the behavior and prepares for addition of a new
log macro for "info" log level.

Change-Id: I94ccd49face4309d3368e399528776ab140748c4
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/375833
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-08-29 13:25:58 -04:00
Dariusz Stojaczyk
5aaffa842e vhost: removed parse_core_mask function from public API
This function was unnecessarily exposed in public vhost headers.
Controller-constructing functions now take string cpumask param.

Change-Id: Ie97d218c525b1dfb11cfd7e7e13c1bf702b1a58d
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/373759
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-25 12:37:28 -04:00
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