Commit Graph

1350 Commits

Author SHA1 Message Date
Ben Walker
9ed75e4dab bdev: Rename rbuf to just buf
We plan to use these buffers for more than just reads.

Change-Id: I8fa6cb432a6cfe4406fbf240cd3aa2ae4ab5f3d5
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2017-05-09 08:14:31 -07:00
Ben Walker
ed159eae1b bdev: Eliminate spdk_bdev_io::ctx
The user can get there via the bdev, so this didn't
have a purpose.

Change-Id: I7f85bb71d5ee238d37ba3624d0ac68a161c95e49
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2017-05-09 08:14:31 -07:00
Ben Walker
3415ce1227 bdev: Pass correct channel to bdev modules
Change-Id: I38911e70303f66f479c1495d4dbe02b2205cab8a
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2017-05-09 08:14:31 -07:00
Daniel Verkamp
6d3a4cd2a4 vhost: define VIRTIO_F_VERSION_1 if it is missing
Older kernel headers don't have the definition of this macro, so define
it if necessary.

This is the same workaround as used in rte_vhost/vhost.h.

Change-Id: I01e0661db05de517adf8e24a47c63d32853cd385
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-08 20:12:19 -07:00
Pawel Wodkowski
8d7acdaaef vhost: upgrade SPDK vhost code to DPDK 17.05
Also replace the internal DPDK v17.02-based rte_vhost
library with the patched DPDK v17.05-based version.

Change-Id: Ibec0b0746592a1a3911c31642a945ab65495e33e
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2017-05-08 17:04:29 -07:00
Pawel Wodkowski
d391647bd0 vhost/rte_vhost: fix scan build and comment formatting issues
vhost_net.c file is not needed and fail scan build so remove it.

Change-Id: I5817201373f7253cc8bc1a9bdc5884197e166a14
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2017-05-08 17:04:29 -07:00
Daniel Verkamp
c2683a8e42 vhost_scsi: access VhostUsrMsg via packed struct
Fixes unaligned access to fields.

Change-Id: I43cff0c1cca7829da8f0d90774970e5feaa95515
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-05-08 17:04:29 -07:00
Dariusz Stojaczyk
0cf6cc7b54 vhost: free virtio_net::guest_pages in vhost_backend_cleanup()
guest_pages is being allocated in vhost_setup_mem_table(), reallocated
in add_one_guest_page(), but never freed. This patch fixes a memory
leak.

Change-Id: Ie381c43bafea5cdea2ac9f057c0282044a340dce
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-05-08 17:04:29 -07:00
Dariusz Stojaczyk
13657c7d75 vhost: fix malloc in rte_vhost_get_mem_table
Amount of allocated memory was too small, causing buffer overflow.

Change-Id: Ib43e0a9040f594fed0a8c5660a45aeb07e4400c7
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-05-08 17:04:29 -07:00
Dariusz Stojaczyk
2542779301 vhost: close callfd on VHOST_USER_GET_VRING_BASE message
This prevents from destroying & recreating user device in "incomplete"
vring state. virtio_is_ready() was returning true for devices with
vrings which did not have valid callfd (their VHOST_USER_SET_VRING_CALL
hasn't arrived yet)

Change-Id: Idc4b41efd544ff5c6b093a5a48798b41c55bbe06
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-05-08 17:04:29 -07:00
Dariusz Stojaczyk
52b10970c4 vhost: added API for getting/setting last descriptor indices of vrings
vhost-net devices might keep track of last descriptors indices by
themselves, and assuming they initially start at 0, but that is not the
case for vhost-scsi. Initial last descriptor indices are set via
VHOST_USER_SET_VRING_BASE message, and we cannot possibly predict what
will they be. Setting these to vqueue->used->idx is also not an option,
because there might be some yet unprocessed requests between these and
the actual last_idx. This patch adds API for getting/setting last
descriptor indices of vrings, so that they can be synchronized between
user-device and rte_vhost.

The last_idx flow could be as following:
 * vhost start
 * received SET_VRING_BASE msg, last_idx is set on rte_vhost side
 * created user-device, last_idx pulled from rte_vhost
 * requests are being processed by user-device, last_idx changes
 * destroyed user-device, last_idx pushed to rte_vhost
 * *at this point, vrings could be recreated and another SET_VRING_BASE
 message could arrive, so last_idx would be set*
 * recreated user-device, last_idx pulled from rte_vhost

Change-Id: I247ba4e461a2a2b524ccade364f5b7bf260f7538
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-05-08 17:04:29 -07:00
Dariusz Stojaczyk
8457b98cf2 vhost: defer setting up new mem table
There is an issue when QEMU sets new memory table just after guest OS
starts booting. Then, if guest OS tries to issue any I/O to device (e.g.
using BIOS INT13h - EDD) it will get stuck because previous addresses of
mmaped memory might change.

To fix this issue, defer using the new mem table until after we receive
the first SET_VRING_ADDR message. SET_VRING_ADDR will be sent by QEMU
when guest OS virtio (e.g. virtio-scsi) driver starts initialization.
At this point it is safe to invalidate the old mem tables because there
will be no more outstanding IO at this point.

Change-Id: I24772be87a8b6c8781868b9b7773317761499748
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-05-08 17:04:29 -07:00
Dariusz Stojaczyk
fab374a7c6 vhost: destroy vhost device before updating public vring data
For now DPDK assumes that callfd, kickfd and last_idx are being set just
once during vring initialization and device cannot be running while DPDK
receives SET_VRING_KICK, SET_VRING_CALL and SET_VRING_BASE messages.
However, that assumption is wrong. For Vhost SCSI messages might arrive
at any point of time, possibly multiple times, one after another.

QEMU issues SET_VRING_CALL once during device initialization, then again
during device start. The second message will close previous callfd,
which is still being used by the user-implementation of vhost device.
This results in writing to invalid (closed) callfd.

This patch destroys vhost device before setting callfd, kickfd and last
vring indices. It will be recreated right after (with updated vring
data).

Change-Id: I293bd91106f53f6c2f65d8b8a41f47ae7548cddc
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-05-08 17:04:29 -07:00
Jim Harris
a191eedb19 vhost: import copy of dpdk rte_vhost v17.05
This will be decoupled from the build to start.  Next
patches will modify this code to prepare it for use with
SPDK vhost-scsi.  The final patch will replace the existing
v17.02-based code with this version, and make the necessary
SPDK vhost changes to use it.

This enables to better track the differences between upstream
DPDK and our internal copy, while not breaking the build at
any point in the git history.

While here, expand the POSIX include file check to exclude
any directory starting with lib/vhost/rte_vhost (which would
include this new directory).

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Icf1202c1b7a898edff12aa226943a08b578cf962
2017-05-08 14:39:55 -07:00
Ben Walker
1b2764421c build: Automatically detect use of POSIX includes
Scan the source for POSIX includes outside of the
allowed locations in check_format.sh. This only
tests for POSIX headers - not Linux Standards Base.

Also, fix one bug that was caught by this addition.

Change-Id: Ib0ca93fe6ac552dc49d95b27b4803e40282027e8
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2017-05-08 13:20:37 -07:00
Ben Walker
b961d9cc12 include: Move the remainder of the code base to stdinc.h
Change-Id: I6a142feeaad3117bd3c75e7c5cb7231a1cfa78ae
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2017-05-08 13:20:36 -07:00
Ben Walker
ba1e1d5308 vhost: Rename LOG_DEBUG to VHOST_LOG_DEBUG
LOG_DEBUG is a symbol defined by POSIX, so if sys/log.h
is included the symbols conflict.

We'll need to push this patch to upstream DPDK too.

Change-Id: Ib263731864aca4791226ea6e3abb5ddfe42e97d8
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2017-05-08 13:19:20 -07:00
Dariusz Stojaczyk
328bc32f31 env/dpdk: allow compiling with DPDK 17.05-rc0 and rc1
FOREACH_DEVICE_ON_PCIBUS macro has been defined since rc2.

Change-Id: Iad61401520735dfde4e5715c32e74a54a2dff7da
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-05-08 13:01:53 -07:00
Vishal Verma
578c0d550d env: Adding socket variants for malloc and zmalloc
Signed-off-by: Vishal Verma <vishal4.verma@intel.com>
Change-Id: I2399842cf7bb80aefb6c511e167157502ba9018a
2017-05-08 09:41:47 -07:00
Ziye Yang
e48e569d83 nvmf/rdma: Replace the queue empty check
Replace with it with check the returned req
via spdk_unlikely macro

Change-Id: I1202b3955af9a68496d8ced7cf66c20cf26f7fff
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2017-05-08 09:40:15 -07:00
Daniel Verkamp
730a63d02b scsi: remove unreachable read iovec copy path
The SCSI layer always passes task->iovs to spdk_bdev_readv(), so there
is no way for task->iovs != bdev_io->u.read.iovs to be true.

Change-Id: I4c0a2075c6e50e4304d62707a29bededa37b4e5c
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-05 09:39:49 -07:00
Daniel Verkamp
15fcb1020c bdev: make struct spdk_bdev_io contents private
Change-Id: I24ff52a7375d54df06b9769bc53ddf84691e1cb1
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-05 09:39:49 -07:00
Daniel Verkamp
825379870b bdev: add accessor function to get an I/O's iovec
Change-Id: I09321abe93303d6225fbcce4065b0024dd541b19
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-05 09:39:49 -07:00
Daniel Verkamp
91b13bd105 scsi: don't change bdev_io status in spdk_scsi_task_put()
The SCSI task bdev I/O should never be pending when spdk_scsi_task_put()
is called, and just setting the status to failed is not correct (when
the bdev eventually completes the I/O, it will write into the now-freed
bdev_io, which may be reused by someone else).

Change-Id: Iaad6ce9ab41539652abc40147fed47c5012109dc
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-04 14:59:12 -07:00
Changpeng Liu
fa511620c4 vhost: eliminate loop log print when no available requests
Change-Id: I3cd72317392b15bad888391b7bc7e1bc5e69385c
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
2017-05-04 13:21:27 -07:00
Daniel Verkamp
2621c7bdc4 scsi: move bytes_completed to iSCSI task
Change-Id: Iff345f555f94a34fa4a6f86bc11efea704e39735
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-04 10:10:47 -07:00
Daniel Verkamp
7e7ed7ec10 scsi: move data_out_cnt to iSCSI task
Change-Id: I550de37d5088e2273b9d53ab8a2d6134c486fba0
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-04 10:10:47 -07:00
Daniel Verkamp
d4da788057 scsi: move desired_data_transfer_length to iSCSI task
Change-Id: I425f9cc7c572b4d819d0aae370f7a96c57d6eac1
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-04 10:10:47 -07:00
Daniel Verkamp
414b754579 scsi: remove SCSI task id and add iSCSI task tag
The SCSI layer was not using the task ID for anything; the iSCSI layer
was using it to store the task tag, so move it there and rename it to
"tag" to make its purpose clear.

Change-Id: Ibda4f4e215056116b9be4a3a0264f98bc4c29535
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-04 10:10:47 -07:00
Daniel Verkamp
4ccf74ab3b scsi: move subtask_list to spdk_iscsi_task
The SCSI layer doesn't use subtasks; these are an iSCSI layer concept.

Change-Id: I83871f02362f10fd4ecd4b2a1544eb76bfa53595
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-04 10:10:47 -07:00
Daniel Verkamp
7fb6b33488 bdev: convert set_scsi_status into a bdev_io completion function
In the pattern set by spdk_bdev_io_complete_nvme_status(), allow
blockdev modules to complete a bdev_io with a SCSI status code.

Also move it to the internal bdev header file, since only bdev modules
should be setting bdev_io status codes.

Change-Id: I8b6afad2c02d7c010c5e60f06a7c7e0785eb87ca
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-04 09:11:42 -07:00
Daniel Verkamp
dc9e11163e bdev: add API to translate to SCSI status
Move the scsi_nvme translation code from the SCSI library into bdev, and
provide a generic way to translate any bdev_io status into a SCSI
status.

Change-Id: Ib61a6209387c24543e31574e2b5ca249e2ac8b74
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-04 09:11:42 -07:00
Changpeng Liu
95d9ffc26a vhost/lib: remove dependency on DPDK vhost library
Since we keep a copy of DPDK vhost library, the header file don't
have dependency on DPDK vhost library.

Change-Id: I14d48e10227633547231e4f429e7375ffa76128d
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
2017-05-04 09:11:31 -07:00
Ziye Yang
08e6f94226 blobfs: separate cache tree related definitions into tree.h
The code will locks clear to put those definitions into tree.h header

Change-Id: Ib1a34f19d9849acd7ea979eb0a6e153b0e8e39de
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2017-05-04 09:11:28 -07:00
Daniel Verkamp
2990f869a1 scsi: make spdk_scsi_port definition private
Change-Id: Ib2c17a4dd4ce680161be92f76b831df792f9ff4d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-04 09:05:53 -07:00
Changpeng Liu
2eb9a35323 env/dpdk: remove rte_eal_device_remove API call since DPDK 17.05
Since DPDK 17.05 API rte_eal_device_insert is only used for
virtual device scan and initialization, for PCI devices
which use Domain:Bus:Dev:Function, this API is no longer
valid.

Change-Id: I1ab63dfc3af188d01836e67cd8db745e035fc450
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
2017-05-05 09:40:31 +08:00
Ben Walker
3d62b39b0d bdev: The bdev layer now generically creates io_channels
These channels can handle generic bdev context.

Change-Id: I61f41884ddf4cf86fa156e9051421b354bbb349d
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2017-05-03 15:16:02 -07:00
Jim Harris
5343c22f8d iscsi: do not free io channel refs if login failed
When destroying a connection, we need to check if we got to
full feature phase before freeing any io channels.  This is because
the io channels are only allocated as part of a successful login.

The Calsoft iSCSI test suite has tests which will fail login.
Since the test system was just using a malloc backend with memcpy,
so even though a channel was NULL in some cases, it was never used
since the memcpy engine doesn't need it.

This prepares for some future patches which extend the use
of io channels in the bdev layer.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I2fb7b18a781caa0aadca319aa1e61a6ccf2c55fd
2017-05-03 14:44:39 -07:00
Daniel Verkamp
a3738d9031 scsi: make spdk_scsi_dev definition private
Change-Id: I62b36a22e11e845045f190886ae00aa644f96ec6
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-03 12:34:57 -07:00
Daniel Verkamp
46af047ae7 json/util: simplify if (p) free(p) -> free(p)
Change-Id: I874b9893afcf2bdf333b14557feedcacad47d355
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-03 10:57:51 -07:00
Changpeng Liu
e9bfc11043 env/dpdk: additional library required for DPDK 17.05 ring based mempool
Change-Id: I2ef4a330a5628c84657f516cb2e4fad609b6c6d8
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
2017-05-02 15:18:15 -07:00
Daniel Verkamp
fa81bdb3fe iscsi: drop redundant parentheses in rsph casts
This allows astyle to format the cast of address-of operations
correctly.

Change-Id: I9c8a4545c44601e769acc712ec7acf3a96f45ebb
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-02 15:15:39 -07:00
Daniel Verkamp
cce22074a7 iscsi: fix ISID interpretation in login requests
The ISID field is a 6-byte field in network (big-endian) byte order.

The previous code was casting the uint8_t isid[6] value into uint64_t,
which was actually casting the address of the first byte of isid (not
the contents of the array), and it was also not correctly converting
byte order.

Change-Id: Idd114e06d30040cf28931d7da7ffdc8d6c45e82a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-02 15:15:39 -07:00
Liang Yan
b0091cfe5c bdev/nvme: Increase maximum controllers to 1024
Change-Id: I5a7a5f40b0d3c8c21e26f5358bc84f538a62bff4
Signed-off-by: Liang Yan <liang.z.yan@intel.com>
2017-05-02 13:51:39 -07:00
Daniel Verkamp
6b4da26449 bdev/nvme: dynamically allocate probe_ctx
Avoid allocating a large amount of stack space when increasing
NVME_MAX_CONTROLLERS.

Change-Id: I7017e5ed9f4d4f5c860dac608c3e5ae3c35864e7
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-02 13:51:39 -07:00
Daniel Verkamp
d0290b6525 scsi_internal.h: remove duplicated min/max macros
Use the ones from spdk/util.h instead.

Change-Id: Icd8416d1b3cb0cde35ac46ea8b1ba7a1ea8994c6
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-02 09:41:43 -07:00
Daniel Verkamp
12965bb6ce scsi: make spdk_scsi_lun definition private
The contents of struct spdk_scsi_lun don't need to be part of the public
API.

Change-Id: I101b77871054557380610fd901ab38bada463202
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-02 09:41:43 -07:00
Jim Harris
13f8cf1536 nvme: add NVME_QUIRK_DELAY_AFTER_QUEUE_ALLOC
The VirtualBox emulated NVMe device will intermittently
hang on the first read/write command after an I/O
qpair has been allocated.  The frequency of the hang
diminishes if a delay is added after allocating the I/O
qpair - until it disappears completely with a 100us delay.
So add a quirk to insert this delay.

Note - the 100us delay was tested by running
the hello_world example app 50000 times.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I237e31b1b8a1a1e28262851ae0a21cd7345f0f1a
2017-05-01 10:22:18 -07:00
Changpeng Liu
80e4f5ae8b env/dpdk: make SPDK can compile with DPDK 17.05
Change-Id: Id69a162b6f2abfdcd4d41b368cfcde52665eb904
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
2017-04-28 09:22:09 -07:00
Pawel Wodkowski
1bc2c5ab57 rpc: add bool-type decoder
Allow passing booleans in JSON.

Change-Id: I0b8f6c1579d8382b5b19a987ef5d913b4423c954
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2017-04-26 21:52:11 -07:00