Commit Graph

545 Commits

Author SHA1 Message Date
Shuhei Matsumoto
ab0bc5c254 lib/thread: Use function name as poller name by using macro SPDK_POLLER_REGISTER
We will be create fine name for each poller but it will need large
effort. Replacing spdk_poller_register by the macro SPDK_POLLER_REGISTER
will provide better name than function address with minimum effort.

Following patches may improve function name for clarification.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: If862a274c5879065c3f7cb04dcb5ca7844523e68
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1781
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>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Maciej Szwed <maciej.szwed@intel.com>
Community-CI: Broadcom CI
2020-04-15 07:23:09 +00:00
Jin Yu
2eabc71518 vhost: add packed ring support
Update vhost blk contruct rpc, make it enable to
support packed ring feature.

Change-Id: Ia1f75e72e8441e8d82fad89073e4875f89e5b9cd
Signed-off-by: Jin Yu <jin.yu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1567
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2020-04-15 03:55:59 +00:00
JinYu
cbfc8b2d48 vhost: add the packed ring support for the blk backend
Support the packed ring for the blk backend.The relative
APIs has been submitted to the DPDK upstream and merged.

About the packed ring see below:
https://docs.oasis-open.org/virtio/virtio/v1.1/csprd01/virtio-v1.1-csprd01.html#x1-610007

Change-Id: I43488604bf18d40a14c76b95206e07db76a14c0d
Signed-off-by: JinYu <jin.yu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/759
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2020-04-15 03:55:59 +00:00
Jin Yu
7ebdb90298 vhost: add the packed ring operations
Add the packed ring operations in spdk vhost.

Change-Id: I25c9701aadbb283f8f3ecccf599a863395d1c7f0
Signed-off-by: Jin Yu <jin.yu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/758
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-04-15 03:55:59 +00:00
Jin Yu
39276ee82c vhost: negotiate the packed ring feature
Add the packed ring support in spdk vhost.
Negotiate packed ring feature when start device.

Change-Id: Idef50a1426b6e38d789d8c6982a3ed7594e32cf5
Signed-off-by: Jin Yu <jin.yu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/672
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2020-04-15 03:55:59 +00:00
Jin Yu
c8bdbc12c3 vhost: refactor vhost scsi process_vq
Add scsi_blk_init function to replace the common
code of task initlization. The same to process_vq
function.

Change-Id: Ied0582ad7f087990c581e6e7aacde6ec201964dc
Signed-off-by: Jin Yu <jin.yu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1613
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-04-13 02:11:40 +00:00
Shuhei Matsumoto
e9aec6746a lib/thread: thread_poll() polls until the exiting thread is exited
Extract _spdk_thread_exit() from spdk_thread_exit() and
_spdk_thread_poll() calls _spdk_thread_exit() if the thread is in
the exiting state. spdk_thread_exit() changes to move the state to
the exiting state. The spdk_thread_poll() loop will end after the
thread moves to the exited state because the caller of
spdk_thread_poll() will check if the thread is in the exited state,
and break the loop if true.

If the user does not call spdk_thread_exit() explicitly, the reactor
has to terminate all existing threads at its shutdown. In this case,
multiple threads may have some dependency to release I/O channels or
unregister pollers. So the reactor has the large two loops, the first
loop calls spdk_thread_exit() on all threads, the second loop calls
spdk_thread_destroy() if exited or spdk_thread_poll() otherwise for
each thread until all threads are destroyed.

Besides, change the return value of spdk_thread_exit() to return
always 0. Keep it for ABI compatibility. Change ERRLOG to INFOLOG
for _spdk_thread_exit() because it is called repeatedly now. Remove
the check of I/O reference count from _spdk_thread_exit() because
_free_thread() cannot free I/O channel. Refine the unit test
accordingly.

Fixes issue #1288.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Iee5fb984a96bfac53110fe991dd994ded31dffa4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1423
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-04-09 13:44:14 +00:00
Jin Yu
ab23eb6565 vhost: refactor process_vq
Add process_blk_task to replace the common codes
of the process_vq and submit_inflight_desc for making
code simple.

Change-Id: I5ff146e904874714dd59249f5191a3606e523c3e
Signed-off-by: Jin Yu <jin.yu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1348
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-03-26 08:12:35 +00:00
Jin Yu
3de6a9c57a vhost: fix print error
Fix the vdev->name to vsession->name for making it
same with the process_vq.

Change-Id: Ie0e9733bdbfbddbbf7e665b8c9431bfdbcb8a569
Signed-off-by: Jin Yu <jin.yu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1367
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2020-03-25 07:54:12 +00:00
Shuhei Matsumoto
0a992c64c7 lib/vhost: Fix passing wrong data to callback to vhost_dev_foreach_session()
Not context passed to vhost_dev_for_each_session() but struct
spdk_vhost_session had been passed to the callback to
vhost_dev_for_each_session() by mistake.

This patch fixes the bug. Besides, rename ctx by ev_ctx to avoid
potential future degradation.

Fixes issue #1306.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I8ceed4e1bb7c0c27fb75516527e3bad91a054b02
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1432
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2020-03-25 07:53:58 +00:00
Darek Stojaczyk
e03861f138 memory.h: move to public headers
There's no reason not to publish those. Especially if
they're needed in other public headers.

Change-Id: I7dfc6922fcc0dfc46822ad8a16a375f997b98e84
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1041
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-03-19 08:50:45 +00:00
Seth Howell
193927830d make: rev SO versions individually for libraries.
This will allow us to keep track of compatibility issues on a
per-library basis.

Change-Id: Ib0c796adb1efe1570212a503ed660bef6f142b6e
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1067
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>
2020-03-18 08:02:30 +00:00
Ben Walker
49e70693c6 nvme: Move prp map code from vhost to nvme driver
This will be re-used in the muser transport of nvmf.

Change-Id: If00e6ea79ffdc0c3bda0402f39c5f9f4f411788b
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/425
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2020-03-10 09:12:29 +00:00
Shuhei Matsumoto
34f53ab7cc lib/vhost: Simplify vhost_dev_foreach_session()
By sending message to the thread with which controller is associated,
we can simplify vhost_dev_foreach_session(). We can iterate
sessions list and we do not have to differentiate if session is
started or not.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I59767a5788c190545a81976e75871609da703f45
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1147
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2020-03-10 09:12:12 +00:00
Shuhei Matsumoto
baf3e12c09 lib/vhost: Replace poll group per session by thread per controller
Currently each controller is associated with one of the poll groups.
For each controller, all sessions are associated with the poll
groups with which the corresponding controller is associated.

Vhost poll group does not have any polling loop but its usage was
very complex.

Association of controller with poll group is done based on the
specified cpumask, and poll group is created per CPU core.

This is as same as association of thread with CPU core.

So in this patch, replace poll group per session by thread per
controller.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ifa1e136caae11959f7b097b06a22910bc2169b30
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1146
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2020-03-10 09:12:12 +00:00
Shuhei Matsumoto
d07e392f08 lib/vhost: Simplfy error paths in vhost_dev_register()
The next patch will create a SPDK thread in vhost_dev_register()
and exit the SPDK thread in vhost_dev_unregister().

As a preparation, simplify error paths in vhost_dev_register()
by changing some gotos to return, moving free after the out label,
and moving insertion after succeeding vhost_register_unix_socket().

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Id1a2a50b4ba5732f91598a326a08de5c652fd136
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1145
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2020-03-10 09:12:12 +00:00
Shuhei Matsumoto
c688f5e93e lib/vhost: Replace global cpuset by local one in vhost_get_poll_group()
Replace g_tmp_cpuset by tmp_cpuset local in vhost_get_poll_group()
without any side effect.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ibb01d2c77d6d82d7cc81df722e7848b357d4e9e7
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/840
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2020-03-05 13:35:54 +00:00
Jin Yu
a8bdd24bc2 vhost: split desc_to_iovs function
Use the payload to construct iovs so that split desc
or packed desc can both work.

Change-Id: Ib2c60b6eb53d0d615594e97b3d3ae1a365908b6c
Signed-off-by: Jin Yu <jin.yu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1000
Tested-by: SPDK CI Jenkins <sys_sgci@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>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2020-03-02 10:38:17 +00:00
suhua
9c6d4649eb vhost: Fix the issue of virtual machine device parameter max_segments always equal to 1
Solve the problem that the /sys/block/vd../max_segments is always 1 in the virtual
machine,and avoid the problem of low sequential read and write performance caused
by this limitation in the general block device layer of some lower kernels.

Signed-off-by: suhua <suhua1@kingsoft.com>
Change-Id: I3289b4c6c74d9225f34e117f444f310bf8bc8ea2
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/975
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2020-02-26 09:25:32 +00:00
zhangjf
2a00a12892 vhost_blk: need init task when resubmit the blk request
Change-Id: I10fca86be6a2834fe3238d8881a4645ac810a201
Signed-off-by: zhangjf <zjfhappy@126.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/482346
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-01-24 08:07:13 +00:00
Changpeng Liu
5e8a3a77b6 vhost: make SPDK internal vhost library can work compatible with live recovery
We will not enable the live recovery feature for SPDK internal vhost library,
so we unmask the protocol flag for internal vhost library.

For the purpose to make it can be compiled with latest DPDK version, some
mandatory APIs are required, so add them here.

Change-Id: I34fab7ed90c86a0fb612852a47f6cadeb8a072f3
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/482069
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-01-22 13:54:19 +00:00
Changpeng Liu
2020418f2b vhost_nvme: fix one compilation issue
Commit 1a1cbdf30 changed the struct spdk_vhost_dev to have static
cpumask variable which broke the complilation.  This patch will
fix that.

Change-Id: I8d0ef90f491e4fc4f0fae6faff2909fd3bd68053
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/479500
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
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>
2020-01-13 12:43:16 +00:00
dongx.yi
3cf37bbfbc vhost: Inline the calculation of vhost session memory region.
There are for loops to do these calculations for vhost session memory region.
we can inline these for both in vhost_session_mem_register and
vhost_session_mem_unregister.

It not only removed the duplicated codes but also reduced the stack consumption.

Signed-off-by: dongx.yi <dongx.yi@intel.com>
Change-Id: Idb9f5ea13e09aef6b24fa27a2bb809b15ece50e2
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478820
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2020-01-07 12:17:55 +00:00
Shuhei Matsumoto
87a4630b96 lib/vhost: Allocate cpumask statically for poll group assignment
Following the recent effort and the last patch, allocate g_tmp_cpuset
statically in lib/vhost/vhost.c.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I5ed6179f9d5942cd868be008c3be6c35d755b455
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478579
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>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
2020-01-03 08:32:38 +00:00
Shuhei Matsumoto
1a1cbdf303 lib/vhost: Allocate cpumask statically for struct spdk_vhost_dev
Following the recent effort, allocate struct spdk_cpuset statically
for struct spdk_vhost_dev. In vhost_dev_register(), a dynamically
allocated  cpumask had been set to spdk_vhost_dev, but change it
to spdk_cpuset_copy().  So use local cpuset instance in vhost_dev_register()
accordingly.

To reduce the size of patch, this patch doesn't include the change
for g_tmp_cpuset. This will be done by the next patch.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ic97753d1f470cbfd9ae7fc7f2af8ced5a31c8477
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478578
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>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
2020-01-03 08:32:38 +00:00
Jin Yu
b8d72590b3 vhost: spdk live recovery from crash or killing
This patch is for the vhost-blk live recovery feature
which can make spdk recover from crash or killing.
The relate rte_xx functions are in the the shared memory
protocol patches which have been merged in DPDK 19.11.

Change-Id: Ia0ac99f8ba0bd66dc9f525f2c72bd1de141ec596
Signed-off-by: Li Lin <lilin24@baidu.com>
Signed-off-by: Ni Xun <nixun@baidu.com>
Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Signed-off-by: Jin Yu <jin.yu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471235
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
2019-12-30 11:46:24 +00:00
Jin Yu
f29d20a21e vhost: add a protocol_features parameter in vdev
Add the protocol_features in vdev. There are two features
would be used in vhost device one is the virtio_features
the other is the vhost-user protocol_features. For different
vhost device, the supported features are different so we can
separate them.
Another reason is that I tested the VHOST_USER_PROTOCOL_F_
INFLIGHT_SHMFD in vhost-scsi with QEMU(version:4.0) and found
that Qemu can not boot up. After investigating found that inflight
flag is negotiated but the Qemu doesn't support this feature
and in DPDK function it is handled as an error and disconnect
with Qemu. It's a bug in DPDK and will fix it.

Change-Id: I72e418cb1885bf7dcbd0285d9cec1ad6af0665de
Signed-off-by: Jin Yu <jin.yu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478814
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: GangCao <gang.cao@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-12-30 11:46:24 +00:00
Vitaliy Mysak
dda7375177 vhost: set supported features based on backend
In vhost-blk, choose supported features based on what
 backend bdev supports instead of disabling not supported features.
This will prevent from enabling not supported feature in runtime.

Change-Id: Ie9453c7c02eb6d0a0ff0f1887048f4092cb7b14f
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476617
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-12-20 10:07:16 +00:00
Vitaliy Mysak
5ffe337846 vhost: change features initialization for vhost-blk
Replace usage of rte_vhost_driver_enable_features() by
 setting disabled_features field dynamically.

This patch doesn't change functionality, but simplifies
 initialization and removes usage of socket operation.
Call to drive_enable_features() had to be done when
 features field was static, but now it is mutable so
 the call became redundant.

Change-Id: I6efc63883773e4ba6d931efd057a38a705c53217
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476616
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
2019-12-20 10:07:16 +00:00
Vitaliy Mysak
576dba8835 vhost: move feature fields from backend to vdev structure
This will enable us to make features dynamic, dependent on underlying
backend device, and to remove usage of rte_vhost functions in
vhost-blk implementation which will improve encapsulation
and enable us to write tests that use vhost-blk functions directly.

Dynamic features are used in vhost_blk, but backend structure is
assumed to be static, so we had to call
rte_vhost_driver_enable_features() after registering it with
some features initially disabled.
This patch moves feature fields to vdev structure where it
can be set dynamically.

Change-Id: Icd76bdd76a3d67ec74e0ac992d8da639beead593
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470460
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
2019-12-20 10:07:16 +00:00
Changpeng Liu
f198b8ca20 vhost: make g_spdk_vhost_ops as static variable
Change-Id: Ifee31e73aadea770b84d29ef8a569282d2b1cbb9
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477391
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-12-17 09:30:03 +00:00
Changpeng Liu
65506d5116 util: add SPDK_CACHE_LINE_SIZE macro definition
For now we don't provide #ifdef to users, SPDK_CACHE_LINE_SIZE is defined with 64 bytes.

Change-Id: I8ddb01a382008a3e333967650200c5aa8b93e09e
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477385
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
2019-12-17 09:30:03 +00:00
Changpeng Liu
164151c727 vhost: fix the compilation when enable VHOST_INTERNAL_LIB
SPDK has swithed to DPDK rte_vhost library since 19.04 release, the internal
rte_vhost library is not recommended any more, but we still would like to
use it for vhost_nvme until we can switch to the new NVMe virtualization
solution.  Fix the compilation issue here, the internal SPDK rte_vhost
library can still work well with vhost blk/scsi/nvme target for now.

Change-Id: I665ccee3e652c318b414dcdc20aab6cdbf7fac3d
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477231
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-12-13 11:04:03 +00:00
Changpeng Liu
e4836026ab vhost: remove VIRTIO_F_VERSION_1 definition from vhost_internal.h
VIRTIO_F_VERSION_1 is defined in system header file <linux/virtio_config.h> and
SPDK already included a copy of it.

Change-Id: I88d5206c7b0984382b3fed1d062d971a014a85a8
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477224
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: 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>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
2019-12-13 11:04:03 +00:00
Changpeng Liu
d71334f6ca vhost: remove VIRTIO_BLK_F_* feature bits from vhost_inernal.h
VIRTIO_BLK_F_* feature bits is defined by virtio_blk specification and
SPDK already has a copy of the system file header <linux/virtio_blk.h>
in the header directory, so just remove it.

Change-Id: I672335218abc8375610a368d84b1a005463a741a
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477223
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: 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>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
2019-12-13 11:04:03 +00:00
Changpeng Liu
4674a6b8f8 vhost: move VHOST_USER_F_PROTOCOL_FEATURES to vhost_user.h
We defined vhost user protocol in vhost_user.h file, so just
remove it to where it should belong to.

Change-Id: I3e9c6eece1db2a8eb739254608816ef9a4dd9993
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477222
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: 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>
2019-12-13 11:04:03 +00:00
Vitaliy Mysak
506a90a90b vhost: wrap some of rte_vhost functions
This patch introduces indirection layer for session management
functions that makes it possible to switch their underlying implementation
if we want to (in unit tests for example).

Change-Id: I563c97bc65d55cc42fecbd1b7eb6679e394784a2
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470459
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-11-20 09:33:43 +00:00
Vitaliy Mysak
0a089121f6 vhost: move memory registration functions to vhost_compat.c
This change will allow us to move other DPDK specific functions
to rte_vhost_compat.c, such as session callbacks which are
the only consumers of these memory management functions.

Change-Id: Ieb7b3f08ddf2e7cf04ecf18e8af4ad04124ccfea
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470458
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-11-20 09:33:43 +00:00
Vitaliy Mysak
3f7e2ba18e vhost: move global definitions to common header
Move FLOOR_2MB() and CEIL_2MB() definitions to spdk_internal/memory.h
because that is where common memory functions are located.

Change-Id: I0d366686f86520e5564be07254d98a579faa3650
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471713
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-11-20 09:33:43 +00:00
Darek Stojaczyk
6231a197f5 vhost: simplify memory registration functions
Make them accept a struct rte_vhost_memory * param
instead of a full spdk session object.

Change-Id: Ibe12f29146d2e971ef58fd5f7366cb059123224d
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470457
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: John Kariuki <John.K.Kariuki@intel.com>
2019-11-20 09:33:43 +00:00
Vitaliy Mysak
30998f9b1f vhost: return error codes for all session callbacks
Change type of `vhost_stop_device_cb()` and `vhost_destroy_connection_cb()`
to return response code instead of "void".

While DPDK callbacks `stop_device()` and `destroy_connection()`
do not have response code, it does make sense to have them in
our VHOST wrappers because those actions can fail.

Practical benefit we get by adopting this change is that we can
now use high level `vhost_stop_device_cb()` and `vhost_destroy_connection_cb()`
in unittests and check if they succeeded or not.

Change-Id: I2cd1886728b1edce7946e87db7ca0ac435e83a41
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471712
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-11-20 09:33:43 +00:00
Vitaliy Mysak
0e96d724d8 vhost: move session callbacks to rte_vhost_compat
This will allow us to write some more interesting unit tests
  because we can now mock high level callbacks instead of
  low level DPDK API and also, in future, we won't have to deal with sem_wait()
  in our mocked implementation since it's a DPDK specific thing.

Change-Id: I9ed5cff216e750685c00e718025ff1802fbe32c8
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470456
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-11-20 09:33:43 +00:00
Darek Stojaczyk
1dae563373 vhost: move rte_vhost socket creation to rte_vhost_compat.c
rte_vhost_compat.c will now not only handle vhost-user
messages over the unix domain socket, but also setup
that unix domain socket with rte_vhost's APIs.

What was previously called vhost_dev_install_rte_compat_hooks()
is now called vhost_register_unix_socket() and is responsible
for creating the entire unix domain socket.

This enables us to write more advanced unit tests for vhost.
Instead of mocking low-level rte_vhost APIs, we could
now potentially mock vhost_register_unix_socket() and
create vhost devices and sessions without any actual
unix domain sockets involved.

Change-Id: Ifb18b92b37915c3f683b6d4fcdcc9259a3770561
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470455
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-11-20 09:33:43 +00:00
Darek Stojaczyk
8e68dfd99f rte_vhost: unaffinitize the thread inside rte_vhost API function
We used to call rte_vhost_driver_start() under
spdk_call_unaffinitized() because that function could
spawn a new pthread and we didn't want to to be pinned
to the one single cpu of the current SPDK reactor.

New DPDK versions (>= 19.05) already unaffinitize the
pthread by themselves, so our spdk_call_unaffinitized()
was only required for the legacy, internal rte_vhost fork
in SPDK. To clean up SPDK code, move the un-affinitization
down to the rte_vhost fork.

Change-Id: I53836517e9ec2ff366b509f00e1403845e3c3172
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466746
Tested-by: SPDK CI Jenkins <sys_sgci@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>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-11-20 09:33:43 +00:00
Liu Xiaodong
6a382b9860 vhost: delete vhost_put_poll_group declaration
Function vhost_put_poll_group is already removed. There
is no implementation for vhost_put_poll_group, so delete
its declaration.

Change-Id: Ib4766fca93329c4f4faab48857d1ac2eaa268300
Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472513
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>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-11-14 03:44:32 +00:00
Michael Haeuptle
53b92a6c18 nvme: allow setting of completion queue CDW0
This change allows setting of the NVMe completion queue
CDW0 in spdk_bdev_io_complete_nvme_status.

Before that change, handling of vendor specific NVMe IO
commands was limited since there wasn't a way to return
command specific info back to the initiator.

Change-Id: I250d5df3bd1e62ddb89a011503d42bd4c8390f9b
Signed-off-by: Michael Haeuptle <michael.haeuptle@hpe.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470678
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-10-24 18:02:38 +00:00
Shuhei Matsumoto
1dc9a7627f lib/scsi: Check pending tasks for the SCSI device only from the specific initiator
Refine the public helper function spdk_scsi_dev_has_pending_tasks to
be able to check tasks only from the specific initiator.

Then use the function in iSCSI target to fix the issue.

Besides add UT code to test the updated spdk_scsi_dev_has_pending_tasks().
Automated multi hosts test is much better but some UT code will be of any
help to mitigate the risk of degradation.

Fixes #985

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I50afb940de7174360c8a30479450850002a3e525
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471337
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>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-10-18 17:30:13 +00:00
yidong0635
b0400403af vhost_rpc: Fix function typo error.
Compiling reports this issue.
Analyzer checks this with ASAN.

Change-Id: Ia01a700b6b3b77dc9e0657fc3d8b28089997a626
Signed-off-by: yidong0635 <dongx.yi@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470807
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-10-10 16:52:44 +00:00
Pawel Kaminski
d7c00c1725 rpc: Rename construct_vhost_blk_controller to vhost_create_blk_controller
Change-Id: I49e5a24f89566ecf95e2df15e43d589f7ef3badb
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469861
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-10-10 16:19:56 +00:00
Pawel Kaminski
2976fbd2a3 rpc: rename get_vhost_controllers to vhost_get_controllers
Change-Id: I597da89241c221e82f11cf843d1e726613b9a768
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469869
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-10-09 14:36:41 +00:00
Darek Stojaczyk
606b453fcd vhost/nvme: fix error handling of session start
Session start callbacks have technically two ways
of returning an error code:
 a) as the callback return value, e.g. return -1
 b) via vhost_session_start_done(int rc)

The former doesn't have any effect as that return value
is not checked anywhere. It's only present because we
wanted to use the same function signature as for the
foreach_session() callbacks. It's going to be cleaned
up in subsequent patches, but before that happens we
have to fix vhost_nvme. With vhost_session_start_done(-1)
called, DPDK will terminate the entire socket connection.

Change-Id: Ib1eff17a67eef055b0dc89fa13d1fed2f8a1fbf0
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/467230
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-10-09 02:28:17 +00:00
Darek Stojaczyk
81883ec5a7 vhost: factor out semaphore usage
We'll start using the same code in even more places soon,
so put in a function.

Change-Id: Iee2e091009b14e9d8b56ec8f0d4a86094f7c9727
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/467229
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-10-09 02:28:17 +00:00
Darek Stojaczyk
2072d16e94 vhost: assign poll group in vhost_session_start_done
Threads were assigned to sessions inside
vhost_session_send_event() so far, but even the doxygen
comments say that sessions would be assigned to the thread
which called vhost_session_start_done(). Currently, Vhost
uses only vhost_session_send_event() to schedule starting
the session on some thread, so the code ends up working.
We're about to remove vhost_session_send_event(), so move
the thread (poll group) assignment to start_done().

While here, publish the vhost_poll_group struct definition
via vhost_internal.h. As a replacement for
vhost_session_send_event() we would like to use
spdk_thread_send_msg() which a requires a thread object -
one of the struct fields inside vhost_poll_group.

The code for starting a session could look as follows:

pg = vhost_get_poll_group(cpumask);
spdk_thread_send_msg(pg->thread, cb);
...
cb:
  // start_pollers
  vhost_session_start_done(0);

Change-Id: I563f61509674768c1dea0b03767e9f39a9fb0069
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/467228
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
2019-10-09 02:28:17 +00:00
Darek Stojaczyk
fa282f6cb9 vhost/scsi: don't clear svdev->poll_group
Don't unset svdev->poll_group when the last session is
stopped, just keep the old reference in there. When
a session is started, a new poll group will be picked
and svdev->poll_group will get overwritten anyway.

This is just a cleanup that aligns the code for
making vhost_session_send_event() asynchronous.

Change-Id: Ibf145603fd7525a65c4304b0bb1828dcbe2b52cf
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/467227
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-10-09 02:28:17 +00:00
Pawel Kaminski
5f6f7eddcc rpc: Rename add_vhost_nvme_ns to vhost_nvme_controller_add_ns
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Change-Id: I769271d0f8043ce4bdaf9a1c4799537e99e3876b
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470399
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@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>
2019-10-08 15:50:14 +00:00
Pawel Kaminski
ca731a6a55 rpc: Rename construct_vhost_nvme_controller to vhost_create_nvme_controller
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Change-Id: I3237352097cd78679ef95c519f970693a15c0c50
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470395
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-10-08 15:50:14 +00:00
Pawel Kaminski
36e04eb4ca rpc: Rename remove_vhost_scsi_target to vhost_scsi_controller_remove_target
Change-Id: If0abef6746f9dad9f146d4f6127dad65ac070620
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469760
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Maciej Wawryk <maciejx.wawryk@intel.com>
2019-10-07 15:08:18 +00:00
Pawel Kaminski
d4245df913 rpc: Rename add_vhost_scsi_lun to vhost_scsi_controller_add_target
Change-Id: I77334712524f454bb1f7270d5684053c7fd2e24c
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469759
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>
2019-10-07 15:08:18 +00:00
Pawel Kaminski
c7e05d839a rpc: Rename construct_vhost_scsi_controller
to vhost_create_scsi_controller

Change-Id: I17919e0808241954f5584b7fa74913b24d5635fa
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469260
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-10-07 15:08:18 +00:00
Pawel Kaminski
bf15f51cef rpc: Rename set_vhost_controller_coalescing to vhost_controller_set_coalescing
Change-Id: Ic775a2397a2177c72ed8c42edf9ac0456a8aea1f
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469872
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
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>
2019-10-03 23:00:40 +00:00
Pawel Kaminski
edb1897147 rpc: Rename remove_vhost_controller to vhost_delete_controller
Change-Id: I819cecbd8456f3f978cc3560f31e285bb2cbbe5d
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469863
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
2019-10-03 23:00:25 +00:00
JinYu
d81721df65 vhost: fix the reuse of free memory issue in scsi
In the spdk_vhost_scsi_dev_remove() it takes a period of time
to remove all the tgts but before it is completed the scsi dev
has been freed. So don't free the scsi dev until all the tgts
have been removed.

Fix Github issue #932

Change-Id: Idf9293c70b8d5f82091db6dd5e018a5cb40eea36
Signed-off-by: JinYu <jin.yu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/464654
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
2019-09-19 01:34:07 +00:00
Seth Howell
28099e0ed9 make: add dependencies for the rte_vhost build.
The dependencies between vhost and rte_vhost were not added during
earlier changes. This change moves the rte_vhost directory up to the
level of the other libraries and adds the proper dependencies for when
it is linked.

Change-Id: I089de1cd945062b64975a0011887700c0e38bb0f
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/467700
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-09-09 22:15:24 +00:00
Darek Stojaczyk
f94be73dc9 vhost: explicitly set VRING_USED_F_NO_NOTIFY
We used to call a dpdk function to do it, but using
a function for something that simple doesn't make sense.
The function also does its internal queue lookup by vid
and queue number, which could potentially fail, return an
error and technically require SPDK to handle it.

The function makes some sense for vhost-net applications
which don't touch vrings directly but rely on rte_vhost's
API for enqueueing/dequeuing mbufs. SPDK touches DPDK's
rings directly for the entire I/O handling, so it might
just as well for initialization.

This serves as cleanup.

Change-Id: Ifb44fa22ea5fc3633aa85f075aa1a5cd02f5423c
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466745
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-09-09 05:41:56 +00:00
Darek Stojaczyk
6e77b0b68d vhost: make poll group refcount per-session
Change the way we increase poll group reference counts
for round-robin scheduling.

So far we used to increase them whenever someone called
vhost_get_poll_group() and this worked fine for Vhost-Block
which picks a new poll group for each session. Vhost-SCSI,
however, picks only one poll group for all sessions on
a vhost device. This means that some threads will have
multiple Vhost-SCSI pollers but will still appear to the
vhost scheduler as if they had only one.

To fix it, increase poll group refcnt only when sessions
are really being started - in vhost_session_start_done().

Change-Id: I60f0d2101239e5a91138a5afd30c51dc1ccf7c2e
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466733
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-09-09 01:39:41 +00:00
Darek Stojaczyk
1eba43239e vhost: add a separate cpl cb to foreach_session()
Currently vhost_dev_foreach_session() accepts a single
callback function for both iterating through all active
sessions and for signaling the end of iteration (called
last time with vsession param == NULL). Now that the
final signal has completely different semantics and is
called on a specific thread, it makes sense to put it in
a separate function.

While here, remove the one-line description of
spdk_vhost_session_fn typepef. It wasn't helpful anyway.

Change-Id: I56b97180110874a813e666f964bb51c39a8ce6bb
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466732
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>
2019-09-09 01:39:41 +00:00
Darek Stojaczyk
880ddb7436 vhost: prepare to add a separate cpl cb to foreach_session()
Currently vhost_dev_foreach_session() accepts a single
callback function for both iterating through all active
sessions and for signaling the end of iteration (called
last time with vsession param == NULL). Now that the
final signal has completely different semantics and is
called on a specific thread, it makes sense to put in
a separate function.

In this patch we prepare separate functions for the final
call, but still call them in the original callback. In
a separate patch we'll start passing both functions
directly to foreach_session().

Change-Id: I9f4338d9696f7bd15ca2d6655c6a3851569aff75
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466731
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-09-09 01:39:41 +00:00
Darek Stojaczyk
5d6361b5dd vhost/scsi: remove return code from remove_scsi_tgt()
The function could never fail, so make it return void
rather than int. This serves as cleanup.

Change-Id: I16a857ecee8d162f546fd097acaa2e66d51ebffa
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466730
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-09-09 01:39:41 +00:00
Darek Stojaczyk
d4f7bf9cdd vhost: remove redundant vdev == NULL checks in foreach_session()
Historically the callbacks from vhost_dev_foreach_session()
could be called with vdev argument == NULL, which would
mean that device was removed after enqueuing the event
and before consuming it. Now we keep track of pending
asynchronous operations on each vhost device and don't
allow removing it if there are any unconsumed events,
so the the vdev == NULL checks are redundant. Remove them.

Change-Id: I7aa3785080d20ed06e008c081d3f37a949228f5a
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466729
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-09-09 01:39:41 +00:00
Darek Stojaczyk
0cf5d5160b vhost: remove spdk_ prefix from private functions
Remove them all at once. spdk_ prefix should be
only applied to publicly exported functions.

Change-Id: Ib6d2bd0954ec5cb7c8cf253d79b9d3cd8aa0eeef
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466728
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-09-09 01:39:41 +00:00
Darek Stojaczyk
d1d69a169c vhost: remove session type checks
When rte_vhost tells us to start a session with given
vid, we lookup the corresponsing session object from
an spdk-internal session list and tell it to start
polling without even specifying any backend. The vsession->vdev->type
checks could only fail as a result of some spdk data
corruption, so replace those with just asserts now. This
code path could have never been hit in our tests anyway.

Change-Id: I97c6cbe7088f338b684d291c93cbc59c44cfdc4e
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466042
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-08-26 17:24:04 +00:00
Darek Stojaczyk
bfaa737dff vhost/blk: unify error message format
Error messages are extremely chaotic, so unify them to
a single format:

<session name>: <error string>

Change-Id: I9b4c29321700b485e0e7eb71a73ea094cf02f000
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466041
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-08-26 17:24:04 +00:00
Darek Stojaczyk
cf86621327 vhost/scsi: unify error message format
Error messages are extremely chaotic, so unify them to
a single format:

<session name>: <error string>

Some messages were slightly reworded to make them more clear.
I believe it would make sense to replace some of those ERRLOGs
with TRACELOGs, but that's not going to change now.

Change-Id: I32fa38b3bf26998b418b8b9e68c88ec5022c973f
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466040
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-08-26 17:24:04 +00:00
Darek Stojaczyk
e5d7a44581 vhost: introduce session names
We currently don't have any way to differentiate different
sessions e.g. in error messages. Whenever there's an error
in some session, we just print the device name.

We now introduce vsession->name with the following format:
<device name>s<dpdk connection id>

Note that it's still impossible to know exactly which
qemu process corresponds to which session in spdk, but
there's not much we could do in that matter right now.
In spdk we don't even have the accepted connection fd.

Change-Id: I666aa60c5e36bf3d56f68133042af2afc8cc5e85
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466039
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-08-26 17:24:04 +00:00
Darek Stojaczyk
f12ac17189 vhost: change vsession->id to uint64_t
This id is assigned from a global increment-only counter
whose type is uint64_t. I believe the original intent
was to use uint64_t for vsession->id as well, let's fix
it now to avoid wrapping errors.

Change-Id: I9cae87e6c74400590a1dc1b1f91d51e4a4c13499
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Acked-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466038
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@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>
2019-08-23 22:34:02 +00:00
Darek Stojaczyk
3b6f69c8f5 vhost: remove unnecessary membarrier on I/O completion
We've recently switched from manually calling eventfd_write()
to rte_vhost_vring_call(), which besides writing to the
eventfd, always calls a full memory barrier in the upstream
rte_vhost lib. With upstream rte_vhost we're actually
calling two memory barriers on I/O completion - one in
spdk code, one inside rte_vhost_vring_call().

The spdk barrier was only required for our internal rte_vhost
lib, whose rte_vhost_vring_call() implementation (that we
wrote) did not have such membarrier inside. So now we'll
add this membarrier there, and remove the same barrier
from spdk code.

This doesn't change any code flow for the internal rte_vhost
lib, but optimizes I/O path for the upstream version.

Change-Id: I68738d7feb9159f718b0e60ac7eed1fafd4836b9
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466037
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-08-23 22:34:02 +00:00
Darek Stojaczyk
3d23defba4 Remove remaining spdk_jsonrpc_begin_result() NULL checks
After recent changes, that function can not return
NULL anymore, so remove all redundant checks from
various SPDK libraries.

Change-Id: If80344b6fa81ad5f87a7086804dba221522cd7e2
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/464175
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Seth Howell <seth.howell@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-08-09 16:35:00 +00:00
Pawel Kaminski
de1d0f8fe9 jsonrpc: don't check returned value from spdk_jsonrpc_begin_result()
As spdk_jsonrpc_begin_result() is not allowed to return NULL we can
remove these checks. We didn't have any tests cases that goes this path
anyway.

Change-Id: I0894e76c0162591e550e70b172566b9060a6dd5f
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459199
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-07-22 05:13:30 +00:00
Darek Stojaczyk
feaf45d31a vhost: allocate just one ctx per foreach_session chain
We used to allocate a ctx whenever new event had to
be sent, but since all events in foreach_session are
always called in a chain, we could allocate one ctx
at the start and then re-initialize it before sending
each msg.

Change-Id: Ie5477b07242f0c6eb6dc2160055a829da8ba5d11
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459167
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-07-16 10:57:46 +00:00
Darek Stojaczyk
3fb1a9565e vhost: finish foreach_session chain always on the init thread
foreach_session() is used to e.g. close a bdev, where
for each session we close any io_channels and then,
on the final "finish" call, close the bdev descriptor.

The vhost init thread is the one that called
spdk_vhost_init() and also the same one that calls
all management APIs. One of those is for hotplugging
LUNs to vhost scsi targets, which practically results
in opening bdev descriptors.

By always scheduling that final foreach_session()
callback to the init thread, we end up with calling
spdk_bdev_close() always on the same thread which
called spdk_bdev_open(), which is actually a bdev
layer requirement.

Change-Id: I2338e15c63f93ef37dd4412dd677dee40d272ec2
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459166
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-07-16 10:57:46 +00:00
Darek Stojaczyk
4b60bd1b59 vhost: don't setup session coalescing on vdev init
We used to call potentially-asynchronous foreach_session()
in vdev initialization path and that was perfectly
fine because at that time there were no sessions created
and foreach_session() was always finishing synchronously.
We're about to refactor it to be always asynchronous, and
for this coalescing case it could complicate the init
error path. Once asynchronous thread msg is sent, we would
need to wait for it to complete and we just don't want to
do that. We want error handling to be simple.

Since we know there are no sessions at the time of vdev
creation, we just add a new function for setting coalescing
params just for vdev (and not for its sessions) and we
use that function in vdev init code.

Change-Id: I44d204d03b5040525e4871693678d4b4a0204e63
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459196
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-07-16 10:57:46 +00:00
Darek Stojaczyk
d476d10665 vhost: reorder foreach_sesion_continue
Put it next to other functions in this call chain.

Change-Id: Ic621855b028f9bd110cdcda86b3a182369ec5e90
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459165
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-07-16 10:57:46 +00:00
Darek Stojaczyk
74243e36b9 vhost: reorder spdk_vhost_session_send_event
Put it next to other functions in this call chain.

Change-Id: Ieafd91c6cfefec134594aec8671eb4efdac15dfe
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459164
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-07-16 10:57:46 +00:00
Darek Stojaczyk
5e63804146 vhost: remove spdk_ prefix from some static function
spdk_ prefix should be only used on public API functions.

Change-Id: I663b107bd6b1c92c2c6263f2ec7c763d9812e7fe
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459163
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-07-16 10:57:46 +00:00
Darek Stojaczyk
4de67bbf6d vhost: inline spdk_vhost_event_async_send_foreach_continue
Despite its name, this function is defined as static
and is only used in one place, so inline it.

Change-Id: I4e217b3baae9b735761f5497f06b681a118860e9
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459162
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-07-16 10:57:46 +00:00
Darek Stojaczyk
98af6aba4d vhost: remove vsession->ev_ctx
It's no longer used.

Change-Id: Iffa385e18ba7a979d7a384f420f546207774dea3
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459161
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-07-16 10:57:46 +00:00
Darek Stojaczyk
dad4c43a88 vhost: add a single dpdk semaphore
The semaphore was a part of struct spdk_vhost_session_fn_ctx
so far, but since there's only one pthread waiting on that
semaphore and hence only one event using it, we could just
use a single global sem_t. Same thing with response code
for those callbacks - there's only one needed.

Going a step further, the function complete_session_event()
was removed - it would only operate on global variables now,
and its signature wouldn't make much sense after this
refactor, so it's been inlined.

This serves as cleanup.

Change-Id: I63ef41d7e1564fff5e785de101d887bc1014aad9
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459160
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-07-01 12:50:57 +00:00
Darek Stojaczyk
5fb7330151 vhost: introduce g_vhost_init_thread
Enforce spdk_vhost_fini() to be called on the same
thread which called spdk_vhost_init(). We'll also use
the newly added g_vhost_init_thread for other purposes
later on.

Change-Id: I99aebeda2d8ddaf42554aa422c32ed935634595f
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459159
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-07-01 12:50:57 +00:00
Darek Stojaczyk
ccdc0b615f vhost: operate on poll groups instead of lcores
With all the pieces in place we can finally remove
the legacy cross thread messages from vhost.

We replace spdk_vhost_allocate_reactor() with
spdk_vhost_get_poll_group(). The returned poll_group
has to be passed to spdk_vhost_session_send_event(),
where it will be assigned to the session. After the
session it started, that poll group will be used for
all the internal vhost cross-thread messaging.

Change-Id: I17f13d3cc6e2b64e4b614c3ceb1eddb31056669b
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452207
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-07-01 12:50:57 +00:00
Wojciech Malikowski
5089a9c5f9 lib/vhost: Fix unaligned pointer value error
Reported by clang:

rte_vhost_compat.c:114:36: error: taking address
of packed member 'payload' of class or structure
'vhost_user_msg' may result in an unaligned
pointer value.

To fix it, just remove the extra unaligned pointer
and inline all its accesses.

Change-Id: I7e4ab536b87ab02a4ea12c55d55a6e495c3091ca
Signed-off-by: Wojciech Malikowski <wojciech.malikowski@intel.com>
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457559
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-06-17 07:18:48 +00:00
Darek Stojaczyk
1a8ee925b0 rte_vhost: fix compilation against dpdk master
struct ether_addr was renamed to struct rte_ether_addr
in latest DPDK master, but our internal fork of rte_vhost
still used the old name, which can be now a non-defined type.

Together with the struct, the RTE_ETHER_ADDR_LEN define
was renamed as well, so we'll now check if it's defined and
we'll manually define struct ether_addr to keep the old
rte_vhost working.

Change-Id: I78b8104ed3bfe03397881a94f0f8bee14f9efae8
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457609
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-06-12 05:29:02 +00:00
Darek Stojaczyk
4fcec18d38 vhost: don't interrupt uninitialized virtqueues
rte_vhost_vring_call() from upstream DPDK can read some
unitialized memory and crash if it's called on invalid
queue ids. The implementation in our internal rte_vhost
fork ends up wiritng to a random descriptor number, which
doesn't cause any crashes but is a bug nevertheless.

To fix it, just check if the queue is initialized before
interrupting it during the session start. It's not a hot
I/O path and there's no performance impact.

Change-Id: I830c1be98ef00d4ece9a6bd88cf79b9dfe29d2a9
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457247
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-06-11 01:14:45 +00:00
Changpeng Liu
cf680fe47e vhost_blk: set the maximum supported data segment based on bdev
AIO backend requires aligned data buffers, and the maximum
IOVs supported in bdev module is defined to 32, there are
cases for Windows Guest which will send data segments more
than 32, SPDK can't process such cases, so here we can set
the 'seg_max' parameter based on bdev module capability.
Also set the maximum segment size for those requests.

Fix issue #625.

Change-Id: I0ff61e55872af17115c0b6b28425e70cb8769790
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452378
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-06-07 05:05:22 +00:00
Nikos Dragazis
c8202a4d79 vhost: fix vhost memory registration in case of vvu transport
The memory API has been refactored. It is not possible anymore to
register a memory region more than once. This has been introduced in
this patch: https://review.gerrithub.io/426085

In case of vhost with vvu transport, it often happens that two
consequtive vhost memory regions are mapped to virtual addresses that
lie within the same 2MB address range. This means that the vhost memory
regions may not be 2MB-aligned in the process virtual address space. As
a result, the `FLOOR_2MB()` of those addresses gives the same address.
Thus, we end up trying to register the same 2MB memory range twice.

This issue does not appear in case of AF_UNIX transport. Vhost memory
regions in case of AF_UNIX transport are hugepage backed. Therefore, the
mmapped virtual addresses of those memory regions are always
2MB-aligned. On the contrary, in case of vvu transport, the vhost memory
regions are segments of the PCI memory address space of the
virtio-vhost-user PCI device. This MMIO space is mapped in its entirety
by the DPDK vfio interface along with the other PCI BARs.  Ultimately,
the vhost memory regions correspond to offsets in this mmapped PCI
memory region and thus there is no warranty that the mmapped virtual
addresses are 2MB-aligned.

This issue is fixed by skipping the already-registered 2MB memory
regions.

Change-Id: I62c9c257e6f172c894cd3454d2cbeee1986e6189
Signed-off-by: Nikos Dragazis <ndragazis@arrikto.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/441057
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2019-06-05 06:43:01 +00:00
Nikos Dragazis
5f4e42b80b vhost: abstract vring call mechanism as it is transport-specific
vring notification mechanism is transport-specific.  At present, vhost
dataplane code in `lib/vhost/vhost.c` triggers guest notifications with
`eventfd_write()` system call. But this is an AF_UNIX specific
notification mechanism. This patch replaces `eventfd_write()` with the
existing generic `rte_vhost_vring_call()` function that is part of
DPDK's librte_vhost public API.

`rte_vhost_vring_call()` takes a vring_idx as an argument to associate
the `struct spdk_vhost_virtqueue` instance with the relevant `struct
vhost_virtqueue` instance. We introduce a new `vring_idx` field in
`struct spdk_vhost_virtqueue` to enable this association. This field is
initialized in `start_device()`. In addition, a stub for
`rte_vhost_vring_call()` is added in the vhost unit test file.

SPDK's internal `rte_vhost` copy will not be updated in order to support
the virtio-vhost-user transport. However, an `rte_vhost_vring_call()`
function is introduced in SPDK's `rte_vhost` in order to have a solid
API. This function is just a wrapper of `eventfd_write()`.

Change-Id: Ic93e25cd3f06e92f04766521bc850f1ee80b8ec8
Signed-off-by: Nikos Dragazis <ndragazis@arrikto.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454373
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2019-06-03 20:14:08 +00:00
Tianyu yang
151a357ca3 rte_vhost: fix deadlock on rte_vhost_driver_unregister()
when qemu connect to vhost, but don't send msg to vhost. We use
kill -15 to destroy vhost process. it will lead to deadlock.
(A)
* rte_vhost_driver_unregister()
 * pthread_mutex_lock hold vhost_user.mutex (1)
 * wait TAILQ_FIRST(&vsocket->conn_list) is NULL
(B)
* fdset_event_dispatch()
 * vhost_user_read_cb() start
   * vhost_user_msg_handler() start
   * dev->notify_ops is NULL because qemu just connect, no message recv.
   * vhost_driver_callback_get()
     * pthread_mutex_lock hold vhost_user.mutex (2)

(A) & (B) deadlock

To avoid this scenes, when qemu connect in vhost_new_device()
initialize dev->notify_ops

Change-Id: Iaf699da41dfa3088cfc0f09688b50fada6b2c8d6
Signed-off-by: Tianyu yang <yangtianyu2@huawei.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454832
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-05-24 00:53:42 +00:00
Darek Stojaczyk
3a0627f069 vhost: remove 2MB memory region size restriction
We no longer have any assumptions about vhost memory regions
size being a 2MB multiple, so we can get rid of the security
check preventing some vhost sessions from being initialized.

It will be necessary for virtio-vhost-user, whose memory comes
from PCI BARs and its size may not be a 2MB multiple.

Change-Id: I48f9bc20f4c61aefdddf39ade875867148f0ed75
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454879
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-05-22 00:53:08 +00:00
Darek Stojaczyk
ac498fa31c vhost: use DPDK APIs to split non-contiguous virtual memory buffers
Currently, we translate each 2MB chunk to manually check
if it's contiguous with the previous one, but there are
rte_vhost APIs that do it way more efficiently.

rte_vhost_va_from_guest_pa() was introduced in DPDK 18.02,
but was backported to 17.11 as well, so we don't even need
any RTE_VERSION ifdefs to use it now. This function
calculates the remaining region size instead of trying to
translate subsequent 2MB chunks over and over.

The previous rte_vhost_gpa_to_vva() was deprecated a long
time ago and after this patch we no longer make any use of
it.

DPDK usages of this new function check if the translated
memory region has 0 length, which seems very silly, but
let's just do it in SPDK as well.

Change-Id: Ifae8daa5f810b5a2ba1524958ad2399af700b532
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454878
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-05-22 00:53:08 +00:00
Darek Stojaczyk
1234a3e52a vhost: set lcore from the DPDK thread
Now that sessions have a separate flag to check if the
pollers are started, we can set the lcore field on any
thread we want. We currently assign it from within the
session thread to spdk_env_get_current_core(), but we
won't be able to use an equivalent get_current_poll_group()
function after we switch to poll groups. We will only
have a poll group object inside spdk_vhost_session_send_event(),
so that's where we move the lcore assignment for now.

Change-Id: Ib5fb37ec488de80e9d79432120c81500c297b608
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452395
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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-05-10 22:31:41 +00:00
Darek Stojaczyk
376d893a20 vhost: introduce vsession->started
We used to rely on lcore >= 0 for sessions that are
started (have their pollers running) and in order to
prevent data races, that lcore field had to be set from
the same thread that runs the pollers, directly after
registering/unregistering them. The lcore was always
set to spdk_env_get_current_core(), but we won't be able
to use an equivalent get_current_poll_group() function
after we switch to poll groups. We will have a poll group
object only inside spdk_vhost_session_send_event() that's
called from the DPDK rte_vhost thread.

In order to change the lcore field (or a poll group one)
from spdk_vhost_session_send_event(), we'll need a separate
field to maintain the started/stopped status that's only
going to be modified from the session's thread.

Change-Id: Idb09cae3c4715eebb20282aad203987b26be707b
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452394
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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-05-10 22:31:41 +00:00