Commit Graph

51 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
Darek Stojaczyk
6c17f696c1 vhost: allocate device objects with regular calloc
spdk_dma_malloc() is not required here, as the device
object is neither DMA-able nor shared between processes.

The device structures used to be aligned to cache line
size, but that's just a leftover from before sessions
were introduced. The device object is just a generic
device information that can be accessed from any thread
holding the proper mutex. The hot data used in the I/O
path sits in the session structure, which is now allocated
with posix_memalloc() to ensure proper alignment.

Vhost NVMe is an exception, as the device struct is used
as hot I/O data for the one and only session it supports,
so it's also allocated with posix_memalloc().

While here, also allocate various vhost buffers using
spdk_zmalloc() instead of spdk_dma_zmalloc(), as
spdk_dma_*malloc() is about to be deprecated.

Change-Id: Ic7f63185639b7b98dc1ef756166c826a0af87b44
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450551
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>
2019-04-22 16:50:37 +00:00
Darek Stojaczyk
23d7ff31fc vhost: change vsession->lcore only within that lcore
There is currently a small window after we stop
session's pollers and before we mark the session
as stopped (by setting vsession->lcore to -1). If
spdk_vhost_dev_foreach_session() is called within
this window, its callback could assume the session
is still running and for example in vhost scsi
target hotremove case, could destroy an io_channel
for the second time - as it'd first done when the
session was stopped. That's a bug.

A similar case exists for session start.

We fix the above by setting vsession->lcore directly
after starting or stopping the session, hence
eliminating the possible window for data races.

This has a few implications:
 * spdk_vhost_session_send_event() called before
   session start can't operate on vsession->lcore,
   so it needs to be provided with the lcore as
   an additional parameter now.
 * the vsession->lcore can't be accessed until
   spdk_vhost_session_start_done() is called, so
   its existing usages were replaced with
   spdk_env_get_current_core()
 * active_session_num is decremented right after
   spdk_vhost_session_stop_done() is called and
   before spdk_vhost_session_send_event() returns,
   so some active_session_num == 1 checks meaning
   "the last session gets stopped now" needed to be
   changed to check against == 0, as if "the last
   session has been just stopped"

Change-Id: I5781bb0ce247425130c9672e0df27d06b6234317
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448229
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>
2019-03-28 14:16:56 +00:00
Darek Stojaczyk
2cddd571ee vhost: add spdk_vhost_session_start_done/stop_done
Split spdk_vhost_session_event_done() into two separate
functions. This is just a preparation for the next patch.

Change-Id: I05e046e4b963387f058d2b822d7493c761eebbbb
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448228
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>
2019-03-28 14:16:56 +00:00
Darek Stojaczyk
64d76e50cc vhost: call session_event_done() always under the global vhost lock
In the next patch we will put much more responsibility
on spdk_vhost_session_event_done(), so here we make
sure it's always called under the global vhost mutex.

Specifically, spdk_vhost_session_event_done() will set
vsession->lcore, which any other thread might try to
concurrently access via spdk_vhost_dev_foreach_session().

Change-Id: I7a5fde4be4e8bdfdbbb24ac955af964f516bdb68
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448227
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>
2019-03-28 14:16:56 +00:00
Darek Stojaczyk
6e9eca7874 virtio: switch to spdk_*malloc().
spdk_dma_*malloc() is about to be deprecated.

Change-Id: Iacf9f6536ba5baca7b245e639d0d42a89720ba58
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448173
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>
2019-03-28 07:39:31 +00:00
Darek Stojaczyk
72fa59f497 vhost: remove struct spdk_vhost_dev_destroy_ctx
First of all, this struct was used when stopping
a session and wasn't directly related to any vhost
device despite its name.

Second, the struct contained just a single poller.

Instead of renaming it, we remove it. We can use
that poller pointer directly.

Change-Id: I66ad0826f7e809365c07662e59979b1942243c2e
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448225
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-03-19 17:09:08 +00:00
Darek Stojaczyk
b4abd4c9d9 vhost/nvme: generic cleanup
* don't iterate through g_nvme_ctrlrs when it's unnecessary
* fixup a potential deadlock on session stop error
  (which can't practically happen unless the SPDK generic
   vhost layer is malfunctioning)
* add a FIXME note to wait for pending I/Os before putting
  bdev io channels and stopping the vhost pollers.

Change-Id: I576c4771f51e432fbbab244fd1b91668436004bf
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448224
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>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-03-19 17:09:08 +00:00
Darek Stojaczyk
3b760a4d09 vhost: encapsulate synchronous event ctx within the generic vhost layer
The context had to be previously carried around by
particular vhost backend code and now it's embedded
inside the generic vsession struct. This serves mostly
as a cleanup.

Change-Id: I7b6ac2c3cb5d60a035d56affbf42fe5d4697f0f6
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448223
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: Changpeng Liu <changpeng.liu@intel.com>
2019-03-19 17:09:08 +00:00
Changpeng Liu
f2b480cc24 vhost/nvme: fix vhost-nvme target with session feature
Existing specific vhost socket messages for vhost-nvme target
will get some information from backend target before start_session
call, so we should iterate the associated nvme controller by vid
but not session.

Fix issue #628.

Change-Id: Ia400bf33895a0feee0058a870f26b0ff72b7556f
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/442498
Reviewed-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-by: Liang Yan <liang.z.yan@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-01-29 06:47:18 +00:00
Darek Stojaczyk
9cddfc0bbf vhost: move lcore management to the device backend
Although Vhost SCSI code is technically capable
of polling different sessions on different lcores,
the underlying SCSI API won't allow allocating
io_channels on more than one lcore.

That's why we will now let device backends assign
lcores by themselves.

The first Vhost SCSI session will now choose one
core from the available ones, and any subsequent
sessions will stick to the same one.

Change-Id: I616cd195a919960dff68508473cea236abf8d6a3
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/441581
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: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-01-25 09:28:42 +00:00
Darek Stojaczyk
d010fe2602 vhost: allow multiple sessions per device
With all the patches in place, we can finally
enable having more than one simultaneous sessions
to a single vhost device.

This patch adds a unique id to the session structure,
similar to the one in a vhost device and also fills in
the implementation holes in foreach_session().

Vhost-NVMe can support only one session per device
and now has an additional check that prevents it from
starting more than one at a time.

Vhost-SCSI also has the same check now since it needs
additional work on the lcore assignment policy. The
check will be removed once the required work is done.

Change-Id: I13a32c7a0eae808e9bec63a7b8c15ec0bc2e36ed
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/439324
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-01-24 17:37:03 +00:00
Darek Stojaczyk
14a6ca08db vhost: call start/stop backend callbacks directly on the DPDK thread
Particular backends will now be responsible for sending
events to vsession->lcore. This was previously done by
the generic vhost layer, but since some backends will
need different lcore assignment policies soon, we need
to give them more power now.

Change-Id: I72cbbccb9d5a5b2358acca6d4b6bb882131937af
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/441580
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
2019-01-24 17:37:03 +00:00
Darek Stojaczyk
6307086792 vhost: untie devices from lcores
It's sessions that are tied with the lcores now.
This makes the vhost devices accessible by any
thread that only locks the global vhost mutex.

The mechanism used for external device events was
refactored to serve for foreach_session() API.

Additionally, since we don't want to handle cases
where the entire vhost device gets removed while
an asynchronous foreach_session chain is pending,
a new per-vdev counter of pending async operations
was added. We'll fail the device removal request
if there are any pending operations. Eventually
we would like the device removal to be asynchronous,
but that's a todo for later.

The external events are still there, although
they only lock the mutex and call the provided
function now.

Change-Id: I20618f9420a9bc04270373469deaad8fb2049c7c
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/439323
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>
2019-01-24 17:37:03 +00:00
Arshad Hussain
4cec12f208 lib: Fix spelling error in vhost_nvme.c
This patch fixes spelling error while printing
error message using SPDK_ERRLOG under file
lib/vhost/vhost_nvme.c

Signed-off-by: Arshad Hussain <arshad.super@gmail.com>
Change-Id: I295c603d5e07935b200669f3c870c6e7d1136936
Reviewed-on: https://review.gerrithub.io/c/441255
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>
2019-01-22 08:54:10 +00:00
Darek Stojaczyk
0e46c8f638 vhost: allow allocating per-session context data
Sessions are allocated internally by the core vhost
library whenever DPDK accepts a new connection, so
the only reasonable way to store additional per-sesion
data is to tell the core vhost library how much extra
memory it needs to allocate. Hence, we add a new field
to the vhost device backend struct.

Change-Id: Id6c8285505b2e610e28e5d985aceb271ed232555
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/437778
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: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2019-01-15 18:48:14 +00:00
Darek Stojaczyk
f82a175706 vhost: separate sessions from devices
Session struct will be now allocated inside the
`new_connection` rte_vhost callback. There can be
still only one connection per device, but this
change brings us one step towards supporting more.

Besides the obvious pointer changes, we'll now also
use the session pointer to check if the connection
actually exists. We used to set device vid to -1
when there was no connection but we no longer have
to do that.

Change-Id: I4d062c0b5f093fef132a6a2c9cc29458cbaad414
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/437776
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: 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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-01-13 00:46:28 +00:00
Darek Stojaczyk
edaea9164d vhost: move vid to session struct
Each connection is created with the `new_connection`
rte_vhost callback with a unique vid parameter. Storing
the vid inside the device struct was sufficient until
we wanted to have multiple connections per device.

Change-Id: Ic730d3377e1410499bdc163ce961863c530b880d
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/437775
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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2018-12-23 00:42:54 +00:00
Darek Stojaczyk
73844cccf4 vhost: introduce device sessions
Grouped a few spdk_vhost_dev struct fields into a new
struct spdk_vhost_session. A session will represent the
connection between SPDK vhost device (vhost-user slave)
and QEMU (vhost-user master).

This essentially serves two purposes. The first is to
allow multiple simultaneous connections to a single
vhost device. Each connection (session) will have access
to the same storage, but will use separate virtqueues,
separate features and possibly different memory. For
Vhost-SCSI, this could be used together with the upcoming
SCSI reservations feature.

The other purpose is to untie devices from lcores and tie
sessions instead. This will potentially allow us to modify
the device struct from any thread, meaning we'll be able
to get rid of the external events API and simplify a lot
of the code that manages vhost - vhost RPC for instance.
Device backends themselves would be responsible for
propagating all device events to each session, but it could
be completely transparent to the upper layers.

Change-Id: I39984cc0a3ae2e76e0817d48fdaa5f43d3339607
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/437774
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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2018-12-23 00:42:54 +00:00
Changpeng Liu
fbc53ae3fb vhost/nvme: add shared BAR space to enable old Guest kernel
For some old Linux Guest kernels, the new NVMe 1.3 feature: shadow
doorbell buffer is not enabled, while here, make a dummy BAR region
inside slave target, when Guest submits a new request, the doorbell
value will be write to the shared memory between Guest and vhost
target, so that the existing vhost target can support both new
Linux Guest kernel(newer than 4.12) and old Guest kernel.

Also, the shared BAR space can be used in future which we can move
ADMIN queue processing into SPDK vhost target, with this feature,
the QEMU driver will become very small and easy for upstreaming.

Change-Id: I9463e9f13421368f43bfe4076facddd119f4552e
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/419157
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: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2018-11-27 13:24:42 +00:00
Ni Xun
b65b033758 vhost_nvme: add support for bdev_io_wait implement
according to commit:
     bdev: add spdk_bdev_queue_io_wait
This patch will make io_wait to support vhost_nvme

Change-Id: I20f7c9f2005a0d4140db9ff2d522fb5e15356cd5
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/425884
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2018-10-04 21:57:09 +00:00
wuzhouhui
97c45f5631 vhost: embed destroy ctx into vhost dev struct
So we don't need to do extra memory allocation when stop vhost device.
This makes code more clean.

Change-Id: I27a1b446621ce4f452fee62acd634737b4ffe174
Signed-off-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-on: https://review.gerrithub.io/427336
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@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>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2018-10-03 18:43:54 +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
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
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
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
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
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
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
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
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
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