Commit Graph

169 Commits

Author SHA1 Message Date
Daniel Verkamp
376d117c90 jsonrpc: add JSON-RPC 2.0 library
Change-Id: I4f58792c3af1f85f55144717478f868ebe5b1700
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-23 10:28:58 -07:00
Daniel Verkamp
4957d2642a nvme: return NSID from spdk_nvme_ctrlr_create_ns()
Previously, there was no way to determine what namespace ID was assigned
when a namespace was created via the NVMe library interface.

Also drop the incorrect comment about calling
spdk_nvme_ctrlr_process_admin_completions(), since
spdk_nvme_ctrlr_create_ns() checks the admin queue internally.

Change-Id: If90a6e9fc773aefa220ebbf6effc2d033c9f20cc
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-18 17:06:09 -07:00
Daniel Verkamp
790b99e863 nvme: reorder qprio in spdk_nvme_qpair for packing
This lets spdk_nvme_qpair fit in 128 bytes exactly.

Change-Id: I7c42582f22ece72a7f1d651468e63d4fe05babd6
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-17 14:17:20 -07:00
Daniel Verkamp
59ae518add nvme: set qpair fields to NULL during destruct
Avoid potential double free cases.

This fixes a clang warning during scan-build.

Change-Id: I487d6fcd485d1f8ebb96b6f8cb54511628461f39
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-16 10:52:51 -07:00
Daniel Verkamp
dfc4b030b1 nvme: assert that outstanding_tr request is valid
All trackers in outstanding_tr should have a non-NULL request.  Add an
assert to verify this.

Fixes a clang warning during scan-build.

Change-Id: I0ac4d2bad17449f684808cbb98777627d890b65b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-16 10:45:40 -07:00
Daniel Verkamp
4a36aabd0c nvme_qpair: add sanity-check asserts to print_command
Document the requirement that qpair and cmd can't be NULL.

This placates clang, which previously generated a warning
during scan-build.

Change-Id: Ic2d5e808faee0028c890ce1312444fb3dc95f223
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-16 10:39:35 -07:00
Ben Walker
20f59ee12e conf: Add configuration file iteration functions
These allow linear searches of the configuration file
sections.

Change-Id: I8d8b9594bc8a974c16d999689a6195434c1efac8
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-05-13 09:51:37 -07:00
Daniel Verkamp
97421601b7 cunit: add test result JSON formatting
Change-Id: I3ccafd2f22447dbb178c7627352a4ced0d25b73f
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-12 15:42:09 -07:00
Daniel Verkamp
cd8e9833f9 nvme: remove unused CMB_SQ_SUPPORTED flag
The user can determine whether submission queues will be placed in the
controller memory buffer by checking the controller options use_cmb_sqs
flag in the attach callback.

Change-Id: I8a925ef99a48665a0e2ffaa90d9ff2b79b90b2fa
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-12 13:20:10 -07:00
Daniel Verkamp
8f4ef2a843 log: allow setting all trace flags at once
Add a special "all" trace flag name to set or clear all registered trace
flags.

Change-Id: Ib579df7c41ce4aca72174e04734df20f2752035c
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-12 09:47:57 -07:00
Changpeng Liu
ca3d1c5b45 spdk: add controller memory buffer support in driver
The D3700/D3600 series support Controller Memory Buffer(CMB) feature,
CMB is available for holding submission queues, for those controllers
which can support submission queues in CMB, user can set the option
whether to enable it or not.

Change-Id: I8b0dc9e28dd6f5bb01bee99a532087212c04e492
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
2016-05-13 08:14:10 +08:00
Daniel Verkamp
bdece622f5 trace: add tracepoint library and app
Change-Id: I472fb7e7a82e1337c6c06b1d3bb4e8a2a13d884a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-11 10:43:09 -07:00
Daniel Verkamp
ed694026b8 json: fix spdk_json_write_val with nested objects
When recursively calling spdk_json_write_val() on another object or
array, the child call will handle printing out the whole
subobject/array, so the parent call should skip over all of its values.

Also fix the return value for the array/object case - if we get to the
end of the array or object, we should return 0 for success.

Change-Id: I1da80c88ab8759620114c1ab141baaaaf9f0023a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-11 10:43:02 -07:00
Cunyin Chang
f2168e1d73 nvme: Add firmware upgrade interface and unit test suite
Change-Id: If66e5f97f6793df0388629fab7c3d0e9f9d5eb67
Signed-off-by: Cunyin Chang <cunyin.chang@intel.com>
2016-05-11 10:18:33 -07:00
Daniel Verkamp
aaa533adc7 log: add SPDK logging library
Change-Id: I3d4060b619a3976ffff75c05f86214e3fcd18fb5
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-09 15:54:49 -07:00
Daniel Verkamp
cd48a01fcb build: wrap $(CURDIR) relative paths in $(abspath)
Resolve relative paths before using them to clean up command lines.

This should also help shorten the overall command line length that gets
embedded in the binary and used when locating the executable from a
coredump.

Change-Id: Ibff9849ede198bb04313496c8b7131485ffaf14f
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-09 13:56:07 -07:00
Daniel Verkamp
f9193f4ce7 json: add JSON parser and encoder libraries
Change-Id: Id73fb7e300d66d31a7c3986c0334b6f56e284905
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-09 13:30:02 -07:00
Daniel Verkamp
3a94688d8e build: add spdk.lib.mk for common library rules
Change-Id: I0547554c010b0eaa6e98c843e7d9eb78c90f76d5
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-09 11:24:58 -07:00
Daniel Verkamp
e42620be57 conf: add configuration file parsing library
Originally based on code from istgt.

Change-Id: Ie789ba511332528aa29f13428d95306253c2ceb5
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-09 10:43:47 -07:00
Cunyin Chang
10f0f4b0e9 spdk: Add Intel specific log page.
This patch add support for Intel specific log pages :
marketing description page.

Change-Id: I87bccb2af286279598c9dd3c870094b384a0d2f7
Signed-off-by: Cunyin Chang <cunyin.chang@intel.com>
2016-05-05 13:39:14 +08:00
Daniel Verkamp
8eafb6546c doc: add Doxygen file marker to all public headers
For existing \file markers, move them to the top of the header and tweak
the wording for consistency.

Change-Id: Icce748effe4dbe97d79a8c87d31caf0ee5797058
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-04 11:17:17 -07:00
Daniel Verkamp
d0cbec4a19 lib/util: add spdk_str_trim()
Function to trim leading and trailing whitespace from a string.

Originally based on code imported from istgt.

Change-Id: I87abe584130bdf4930098fadb8e57291f18eda7f
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-04 11:17:00 -07:00
Daniel Verkamp
e56aab98ac lib/util: add spdk_strsepq()
Parsing function for delimited strings with embedded quotes.

Originally based on code imported from istgt.

Change-Id: I448feb53ea232048ed8c68738e12bc3660eb4235
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-04 11:17:00 -07:00
Daniel Verkamp
c5611b26b3 lib/util: add spdk_strlwr()
Add function to convert string to lowercase in place.

Originally based on code imported from istgt.

Change-Id: Ica9fe2208e6ee09b22c9a652a33c5affe5be23cc
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-04 11:17:00 -07:00
Changpeng Liu
784182ed47 SPDK: Add end-to-end data protection support in driver
For those controllers which can support end-to-end data protection
feature, add the support in the driver layer.

Change-Id: Ifac3dd89dec9860773c850416a6116113a6ce22a
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
2016-04-28 15:46:13 -07:00
Liang Yan
b2db4f94ec nvme/test: Add hw sgl request unit test
Change-Id: I1364a6634b9be25ff647eee56c91e312ae3d004e
Signed-off-by: Liang Yan <liangx.yan@intel.com>
2016-04-28 14:26:24 +08:00
Li Peng
33b46ee9a8 nvme: fix typos
Signed-off-by: Li Peng <lip@dtdream.com>
2016-04-26 15:49:42 +08:00
Daniel Verkamp
e175af8879 nvme: add workaround for VFIO initialization issue
When using DPDK PCI support via VFIO, the PCI device is reset
immediately before calling the PCI driver's init function.  In some
cases, the device seems to not be ready to handle MMIO accesses right
away.  Until the cause of this issue is fully understood, add a 500 ms
sleep as a workaround.

Change-Id: Ic893080a6f34d57eee80df3e6aa68c220c08df3e
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-04-14 14:24:27 -07:00
Daniel Verkamp
cf368b5e5b nvme: add sanity check to nvme_free_request()
All children must be removed from a parent request before the parent is
freed.

Change-Id: I073ff0e9c5bcdd6181d90b918bfe4cce054f6c0b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-04-08 16:51:15 -07:00
Daniel Verkamp
73de52e9ae nvme: add sanity checks to remove_child
Change-Id: Id212700459901c3f7bb6cd2f63ba1b88a7417ac2
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-04-08 16:51:15 -07:00
Daniel Verkamp
2cf675bb29 nvme: rename remove_child_request for consistency
Rename nvme_remove_child_request() to nvme_request_remove_child() and
move it next to nvme_request_add_child() to make the symmetry clear.

Change-Id: I78747c44ab3db1a656b33555a45f634dc5a55b31
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-04-08 16:51:15 -07:00
Daniel Verkamp
1f19be6515 nvme: destroy I/O queues before shutdown
The NVMe specification recommends destroying all I/O submission and
completion queues before setting CC.SHN.

Change-Id: Iad71dd3fe03d897858034f3ca6ee02e0c55cc2b0
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-04-08 16:47:49 -07:00
Daniel Verkamp
2f7d4bee02 nvme: do not set EN=0 during shutdown
The NVMe specification recommends that orderly shutdown should just
write CC.SHN while the controller is still enabled rather than writing
CC.EN = 0 first.

This also allows removal of the now-unused nvme_ctrlr_disable() and
nvme_ctrlr_wait_for_ready() functions.

Change-Id: I4702ffda153f218ebb8ed92f0e36144b7ceded93
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-04-08 16:47:43 -07:00
Daniel Verkamp
87a3244f97 nvme: handle CC.EN = 0 && CSTS.RDY = 1 on startup
This can happen if the controller is still resetting as the SPDK NVMe
driver takes control.

Change-Id: I263ae8f2e7b271e0448450557452a115c90c4fb6
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-04-08 16:47:25 -07:00
Ziye Yang
20f92ad45a SPDK: Handle the memory leak issue for nvme_request free
This patch is used to handle the memory leak issue when
a parent nvme_request is free. In our current code,
we did not free the nvme_request allocated by the children
in the exceptional case.

Change-Id: Iabd1f1c3594af60c38e74e3d96c14f78d1aa1aed
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2016-04-08 09:40:07 -07:00
Ziye Yang
deb90a93de SPDK: add nvme_remove_child_request helper function
This patch is used to add a nvme_request remove child
helpler function

Change-Id: I1e5bb228d53333ca3601f4ae30fcd801ea39e532
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2016-04-08 09:36:57 -07:00
Daniel Verkamp
2c4476560b nvme: simplify SGL length calculation
Drop the "data_transfered" variable and just update length, since length
was not used otherwise after this point in the loop.

Change-Id: Icd2991e4e85de7e8c951ba14c441434e871ea4ef
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-03-30 10:45:08 -07:00
Daniel Verkamp
3cec6c846b nvme: clarify single SGL descriptor case
If only one descriptor is needed, there is a special case in the spec for
SGL1 using the Data Block descriptor type.  Add a comment to make it
clear what is going on.

Also tweak the SGL1 setup to copy from the first SGL descriptor list
element instead of relying on the last value from the loop above, since
that could be easily broken by accident.

Change-Id: I49ef97fe5bf18d2bf1d86b4310a7d3abdfd03e57
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-03-30 10:45:08 -07:00
Daniel Verkamp
1524f2935c nvme: remove unnecessary cast
tr->u.sgl is already a struct spdk_nvme_sgl_descriptor pointer.

Change-Id: Ie2c8c052fc28e6369d1d095b8d566acae47975d1
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-03-30 10:45:08 -07:00
Daniel Verkamp
bf6477ccab nvme: remove dead code for zero-length SGL request
_nvme_qpair_build_hw_sgl_request() will only be called for payload_size
!= 0, so every SGL will have at least one segment.  Drop the 'else' that
was handling nseg == 0, and add an assert to document the payload_size
requirement.

Change-Id: I48e2a862a7657ba85605c0d35c0b65dfac072167
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-03-30 10:45:08 -07:00
Daniel Verkamp
69f9796482 nvme: move assert out of SGL loop
The assert is checking a variable that is invariant within the loop, so
move the assert up to the top of the function.

Change-Id: Iee7eea1736bc7f953665feb390c3d6340dbeffbc
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-03-30 10:44:34 -07:00
Daniel Verkamp
149ee30ee8 doc/nvme: move pages to separate text files
This makes it easier to find the larger doc comments that produce separate
pages.

It also allows removing the lib/nvme directory from the Doxyfile, so
only the public API headers are used to generate documentation.

Change-Id: I8c46edb8067a91dda5b23fb0864efd3dd8aaeba5
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-03-29 10:49:06 -07:00
Daniel Verkamp
7d74bd7072 nvme: remove duplicated doc comment
spdk_nvme_qpair_process_completions() is already documented in
spdk/nvme.h, so merge the doc comment from nvme_qpair.c into the public
header.

Change-Id: Id7722d99d209852ee64286e0a3fa127b863e10aa
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-03-29 10:27:55 -07:00
Daniel Verkamp
90095a79fe nvme: enforce minimum and maximum I/O queues
Don't allow the user to request more than the valid maximum number of
I/O queues (65535) or 0 I/O queues, since this can't be encoded.

Change-Id: I2d6e0bba03476085842bad683b273cdf9d6e6d5e
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-03-28 15:34:29 -07:00
Daniel Verkamp
4671dbd53f nvme: add compile-time assert for SGL alignment
Per the NVMe spec, SGL segments must be Qword (8-byte) aligned.  Add a
static assert to make sure this is true for the sgl member of struct
nvme_tracker (assuming the whole nvme_tracker is at least 8-byte aligned).

Change-Id: I827aa40b56de648d83f524a4f1e79c3202b676be
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-03-23 10:39:30 -07:00
Cunyin Chang
db3fda2e68 nvme: handle NULL ioq array in nvme_ctrlr_destruct()
Fix a potential segmentation fault issue.

Change-Id: I39d2cd1850265ca0dfa987995011563cadeb5bb5
Signed-off-by: Cunyin Chang <cunyin.chang@intel.com>
2016-03-23 09:37:02 -07:00
Cunyin Chang
eae688576a spdk: Add nvme format interface and unit tests.
Change-Id: Ie0506debf547a5fc011e116421387a5adb7abf0e
Signed-off-by: Cunyin Chang <cunyin.chang@intel.com>
2016-03-17 13:37:20 -07:00
Daniel Verkamp
eb555b139e nvme: add return code to nvme_qpair_submit_request
If the controller is failed, attempting to submit additional I/O is
futile - it will be immediately failed using the completion callback,
which can result in infinite recursion if the application code resubmits
I/Os on failure.

Instead, provide a way for request submission to indicate failure, and
use it to exit early if the controller is failed; this can only happen
when a reset failed (timed out).

If a request is submitted directly by the user when the controller has
failed, we can return an error code directly.  For the case where I/O
was queued and is being resubmitted after a reset, we still need to call
the completion handler via _nvme_fail_request_ctrlr_failed().

Change-Id: I9e144328d524b25db2acf48e923b584746e8d0b6
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-03-16 12:16:47 -07:00
Daniel Verkamp
4ad99808f2 nvme: allow user to override controller defaults
Provide a new structure, spdk_nvme_ctrlr_opts, to let the user modify
the default controller initialization options during probe/attach.

Currently, only the number of queue pairs can be modified in this way;
other options will be added later.

Change-Id: Ie27b9429291d93a9353c0d820f0ad467d3b0e7cb
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-03-16 08:14:15 -07:00
Daniel Verkamp
cf0871a57e ioat: make channel allocation explicit
Add a parameter to each I/OAT library function that requires a channel
instead of implicitly using the thread-local channel registration model.

I/OAT channels are already reported by the spdk_ioat_probe() attach
callback, so no infrastructure for channel allocation is necessary.

Change-Id: I8731126fcaea9fe2bafc41a3f75c969a100ef8f0
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-03-15 09:50:17 -07:00