Commit Graph

65 Commits

Author SHA1 Message Date
Changpeng Liu
9f860cc4b4 nvme: replace trace log with error log for error conditions
Change-Id: I634573f8d9b5ed05d850960f8c45c10d96fa3a7a
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
2016-11-02 10:31:23 -07:00
GangCao
075ba523bd nvme: set the qprio when constructing the qpair
Change-Id: Id5b35c023b975cc07fe721e4749bac6a0c803719
Signed-off-by: GangCao <gang.cao@intel.com>
2016-10-31 13:41:22 -07:00
Daniel Verkamp
b33e29efd3 nvme: split out transport-specific qpair structure
Change-Id: I45c6b8a92389e3dc7fd5d9862ef165fd16f6253e
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-10-21 09:06:29 -07:00
Daniel Verkamp
03aead3903 nvme: add qpair operations to transport
Change-Id: Id354ba13515d54bb54a8293569ee83ea72111183
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-10-18 10:13:37 -07:00
Daniel Verkamp
d7b7dbfb78 nvme: introduce transport abstraction
This will allow factoring out PCIe-specific code into a swappable
transport so that NVMe over Fabrics host support can be added.

Change-Id: I4df74dd268d655e3b36e8d6114ebe7d79a24844d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-10-14 12:46:58 -07:00
Pawel Wodkowski
0bd08c4536 nvme: don't call request callback if it is inactive
Change-Id: I150ed2dc7cea91f262ee0773c892069a56b68902
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2016-10-14 11:07:50 -07:00
Jim Harris
de16fcca32 nvme: fix sgl processing for single sge payloads > 4KB
For the nvme readv/writev APIs, the PRP checking logic was
incorrectly failing single SGE payloads that were larger
than 4KB.  This patch adds a test case for this scenario,
and fixes the PRP checking logic.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I6357d620599666046d2cb74d7923dac1f75418c5
2016-10-12 14:51:58 -07:00
Ben Walker
bfdc02ab48 nvme: Eliminate nvme_impl.h and use the swappable env lib.
Change-Id: Ibbc557b732d5b0858a2922a7a442c4b17a0d579a
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-10-11 13:34:09 -07:00
Daniel Verkamp
1a37acda67 eofnl: check for extra trailing newlines
Enforce exactly one trailing \n, and fix all of the existing cases.

Change-Id: I6218e4700e90aeb647eaee78089530c79993c8c8
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-10-11 13:30:33 -07:00
Ben Walker
b9fbdd189a env: Move malloc/free wrappers into env
Change-Id: Ief591f5e23c4ae06cb77fab647a7afd082450a73
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-10-05 11:51:52 -07:00
Ben Walker
b0e349a804 nvme: Use log library instead of nvme_printf
Change-Id: Ic9b2db9bff3a914b3e5021695287157f1e076f9f
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-09-28 10:15:55 -07:00
Ben Walker
0606eaad1a No longer wrap assert()
assert is part of the C standard library and is available
on any platform we'd consider porting to. Don't put a
wrapper around it.

Change-Id: I0acfdd6a8a269d6c37df38fb7ddf4f1227630223
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-08-19 10:53:06 -07:00
Tsuyoshi Uchida
0d2330c2df nvme: Add some status codes specified in NVM Express 1.2b (#37) 2016-08-19 08:52:31 -07:00
Tsuyoshi Uchida
81976ebd55 nvme: modify not to retry IOs on reset (#33)
When a controller reset is finished, all outstanding IOs and all queued
IOs which submitted before the reset are returned to the caller.
2016-08-15 10:01:02 -07:00
Ben Walker
c65e726acd nvme: Limit max completions in a single poll
For a single poll of the completion queue, if the user
submits I/O from within their completion callback and their
completion callback is particularly slow to execute, the loop
could potentially continue forever. To support this, we
need to limit the number of completions we'll process
in one batch.

Change-Id: If6bae47e52b36347dbe5622ace68c866ee88a0b2
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-07-07 17:05:17 -07:00
Daniel Verkamp
e2d3cc6502 nvme: replace rte_memcpy with specialized function
Use the knowledge that both the source and destination of
nvme_copy_command() are aligned to emit the aligned variants of the
SSE2/AVX mov instructions.

Change-Id: I0a7e32a3bb10b9a1920cd85691b79fa7172eecb3
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-06-28 14:17:21 -07:00
Ben Walker
6b10df3576 nvme: Update nvme_spec.h to 1.2.1
This moves some definitions from nvmf_spec.h to
nvme_spec.h based on the latest publication.

Change-Id: I51b0abd16f7d034696239894aea5089f8ac70c40
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-06-24 09:18:14 -07:00
Minfei Huang
f0b20026d7 nvme: Return negative errno for failure (#24)
The conventional rule for returning errno is negative, hence there is no
need to modify caller's code to adjust this NVMe library.

Signed-off-by: Minfei Huang <mnghuan@gmail.com>
Signed-off-by: Minfei Huang <minfei.hmf@alibaba-inc.com>
2016-06-14 15:19:10 -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
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
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
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
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
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
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
1dd7473078 nvme: create tracker pool in a single allocation
Replace the previous code that allocated each tracker individually with
one large allocation per queue pair.

struct nvme_tracker is now explicitly padded to reach exactly 4096 bytes
to allow normal array indexing to work correctly while maintaining the
alignment requirement that ensures each tracker's PRP list does not
cross a page boundary.

This also allows removal of the act_tr array, since the tr array can be
indexed directly now, and each tracker can store its own active state.

Change-Id: Ia7c51735b96594d12f7f478cefcc4aedc84207ad
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-03-15 09:20:25 -07:00
Daniel Verkamp
3272320c73 nvme: make I/O queue allocation explicit
The previous method for registering I/O queues did not allow the user
to specify queue priority for weighted round robin arbitration, and it
limited the application to one queue per controller per thread.

Change the API to require explicit allocation of each queue for each
controller using the new function spdk_nvme_ctrlr_alloc_io_qpair().

Each function that submits a command on an I/O queue now takes an
explicit qpair parameter rather than implicitly using the thread-local
queue.

This also allows the application to allocate different numbers of
threads per controller; previously, the number of queues was capped at
the smallest value supported by any attached controller.

Weighted round robin arbitration is not supported yet; additional
changes to the controller startup process are required to enable
alternate arbitration methods.

Change-Id: Ia33be1050a6953bc5a3cca9284aefcd95b01116e
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-03-14 16:00:54 -07:00
Changpeng Liu
2374599671 spdk: fix wrong length parameter for large IO when uses hardware SGL
When I/O spans a stripe boundary, the driver splits the request into
multiple requests, so for 1 segment memory larger than the stripe
size, we also need to split the segment memory.

Change-Id: I22ea5734d7066865a57a3c90fe18d5f76f373f1d
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
2016-03-09 15:22:08 -07:00
Changpeng Liu
eb9ef5cc2b nvme: Add SGL support in NVMe driver
For those NVMe controllers which can support SGL feature in
firmware, we will use SGL for scattered payloads.

Change-Id: If688e6494ed62e8cba1d55fc6372c6e162cc09c3
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
2016-03-04 09:36:40 -07:00
Daniel Verkamp
345d9a4da3 nvme: add spdk_ prefix to nvme_qpair_process_completions()
This will be exposed in the public API.  This rename is in a separate
commit to ease review.

Change-Id: I1b7fef36f85265db27935ac4d22ceef3c7282502
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-03-01 14:42:04 -07:00
Daniel Verkamp
df26ab0583 nvme: add priority field to qpair
Set up the infrastructure for creating I/O submission queues with
variable queue priority (QPRIO in Create I/O SQ command).

Currently, this is unused, since we always use the default arbitration
method (round robin), but it will allow reinitializing submission queues
with the correct priority once weighted round robin is supported.

Change-Id: I425003879e624cfcc9687bdc495b5c1726b5a8af
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-03-01 14:42:03 -07:00
Daniel Verkamp
6eb18e2f3d nvme: rename nvme_qpair to spdk_nvme_qpair
Prepare for qpair to be exposed as part of the public API.

Change-Id: Ia63e863e95554adceeade20c829f12fe346375d5
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-02-29 10:11:35 -07:00
Daniel Verkamp
7c34c2005d nvme: store SGL callback in nvme_payload
Allows simplification of _nvme_qpair_build_sgl_request(), which does not
need to know whether a request is a child or not.

This also removes a read of req->parent for non-split I/Os; the parent
field is in the section of nvme_request that is only intended to be
initialized for split I/Os, which should be detected by looking at
num_children.

Additionally, this fixes a potential problem if requests were nested
more than one level deep (e.g. req->parent was not the original user
request).

Change-Id: I3ea1dc134bbb1e3b8c6b5a479f5d760bd97ea848
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-02-18 15:07:18 -07:00
Daniel Verkamp
6ce73aa6e7 nvme: add spdk_ prefix
Shorten commonly-used names:
controller -> ctrlr
namespace -> ns

Change-Id: I64f0ce7c65385bab0283f8a8341a3447792b3312
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-02-10 11:27:45 -07:00
Daniel Verkamp
ad35d6cd86 nvme_spec: add spdk_ prefixes
Use shorter names for commonly-used objects:
namespace -> ns
controller -> ctrlr
command -> cmd
completion -> cpl

Change-Id: I97d192546b35a6aeb76ad3a709f65631502cde71
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-02-09 11:06:48 -07:00
Daniel Verkamp
53e45aee8c barrier: add spdk_ prefix to wmb() and mb()
Change-Id: Ie5e724e34cbcd8ef9feb9054c867fcb0065f5a1d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-02-08 13:32:19 -07:00
Jim Harris
ff7e2122c7 nvme: reduce number of mmio writes in completion path
Instead of writing the completion doorbell once per completion,
just write it once at the end of the completion while loop.
This reduces the number of mmio writes by coalescing several
writes into one when we get multiple completions at a time.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I3cc3864dcfe43186bec51be1a732e84ef3be05ae
2016-02-08 09:52:15 -07:00
Daniel Verkamp
c02b179490 Remove year from copyright headers.
Also add a space between Copyright and (c).

The copyright year can be determined using git metadata.

Also remove the duplicated "All rights reserved." - every instance of
this line already has a corresponding "All rights reserved" immediately
below it, except for examples/ioat/kperf/kmod/dma_perf.c, where I have
added it manually.

Performed using this command:

git ls-files | xargs sed -i -e 's/Copyright(c) \(.*\) Intel Corporation. All rights reserved./Copyright (c) Intel Corporation./'

Change-Id: I3779f404966800709024eb1eb66a50068af2716c
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-01-28 08:54:18 -07:00
Daniel Verkamp
cbcfe37a56 nvme: move request fail call into request builder
This will allow replacing these _nvme_fail_request_bad_vtophys() calls
with the correct error later. vtophys is not actually used within the
SGL request builder, so this is the wrong error.

Change-Id: Ibc2a3b029a8abad1d563b9df200325d7d64498da
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-01-27 16:52:53 -07:00
Daniel Verkamp
f856fd7138 nvme: split contiguous request building into a function
No code change, just moved into a function for readability.

Change-Id: I883443c06d961c6dbeffed1a6fb153177e6e3fcd
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-01-27 16:52:53 -07:00