Commit Graph

59 Commits

Author SHA1 Message Date
Daniel Verkamp
52ca42aa8a test/nvme/aer: use nvme_ctrlr_cmd_get_log_page()
Change-Id: I1c9be5dcc8ff0e9b21d17524e43de2b34f429d04
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-01-15 13:40:58 -07:00
Daniel Verkamp
af99c46557 nvme: add return code to nvme_ctrlr_cmd_get_log_page
Request allocation may fail, so we need a way to indicate failure to the
caller.

Change-Id: I278c3f42e4d2fa1902bb0ab33ad3bf7c7007fd0d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-01-15 12:49:16 -07:00
Cunyin Chang
9945c00cf2 NVMe: Add public API to get log pages.
1 Add supported log pages data structure.
2 Bulid up supported log pages when NVME start.
3 Provide unified API for getting log pages.
3 Unit test suit optimization base on above modification.

Change-Id: I03cdb93f5c94e6897510d7f19bc7d9f4e70f9222
Signed-off-by: Cunyin Chang <cunyin.chang@intel.com>
2016-01-15 09:10:35 +08:00
Daniel Verkamp
040742359e pci: rename pci_device_has_non_null_driver to non_uio
This more accurately represents what function it performs.

Also remove pci_device_has_uio_driver() from the public API.  Callers
should use pci_device_has_non_uio_driver() instead.

Change-Id: I9623fe1345b43e981d5823804e33d01ac0d3bb1c
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-01-12 08:58:02 -07:00
Daniel Verkamp
2ced60e9bf nvme: return number of completions processed
nvme_ctrlr_process_io_completions() and
nvme_ctrlr_process_admin_completions() now return the number of
completions processed.

This also adds the possibility of returning an error from the
process_*_completions functions (currently unused, but this at least
gets the API ready in case error conditions are added later).

Change-Id: I1b32ee4f2f3c1c474d646fa2d6b8b7bbb769785f
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-01-11 14:44:22 -07:00
Daniel Verkamp
3d6b230ae9 nvme/utest: add asserts to check allocations
Make sure allocation succeed in the unit tests.

Change-Id: I1c9dd64c256d529f2e40be49448d56359969a6f5
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-01-08 09:31:13 -07:00
Daniel Verkamp
5f844a0477 nvme/utest: add SPDK_CU_ASSERT_FATAL wrapper
The normal CU_ASSERT_FATAL macro calls a function that is not marked as
noreturn, so static analyzers (e.g. scan-buid) can't figure out that
fatal asserts are really fatal.

Add a wrapper macro that calls abort(), which the analyzer can determine
does not return.

Change-Id: I0c087bf9c8d3c272bf88120caa70e87dab6d9546
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-01-08 09:31:10 -07:00
Liang Yan
a0ba9ce276 nvme/reset: don't crash if no namespaces are usable
Change-Id: I79b03c97f09125070dbdb1abe49db4a338f6a27f
Signed-off-by: Liang Yan <liangx.yan@intel.com>
2016-01-06 12:21:04 -07:00
Daniel Verkamp
cb18017c42 nvme/aer: check command completion status
If any command fails during the asynchronous event request test, exit
the test with an error rather than waiting for an event that won't
arrive.

Change-Id: I7297afe362bfdac04dd6585cc97ffdceb9f0096e
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-01-06 10:30:12 -07:00
Daniel Verkamp
3b38dd8282 autotest: remove extra process_core invocations
The top-level autotest.sh script will catch any core dumps at the end of
the test run, so sprinkling process_core in the individual test scripts
is unnecessary.

Also make the per-component test scripts run with 'set -e' (exit on
error).

Change-Id: I85f124e164ca93d35eaf672a428a841c119c550b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-01-05 15:31:56 -07:00
Liang Yan
d5cbe304b9 nvme: update nvme_ns_cmd_deallocate unit test
The deallocate command's num_ranges have changed to unit16_t.
Update the nvme_ns_cmd_deallocate unit test for the change.

Change-Id: I43b8637bbb953b0e56c39998e1e6682a54304a8f
Signed-off-by: Liang Yan <liangx.yan@intel.com>
2015-12-30 09:40:22 -07:00
Daniel Verkamp
c8f27b9e6e nvme: mark a few more functions static
nvme_qpair_submit_tracker() and nvme_qpair_manual_complete_request() are
only used from within nvme_qpair.c, so they can be static.

nvme_qpair_submit_tracker() is moved up to avoid needing a declaration
(no other code change).

nvme_ctrlr_hw_reset() is only used from within nvme_ctrlr.c, so it can
be static.

Change-Id: I9a7953d7baaec76e875dd535daf557ea24bef801
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-12-23 08:59:49 -07:00
Daniel Verkamp
d4ab30ba33 ioat: add user-mode Intel I/OAT driver
The ioat driver supports DMA engine copy offload hardware available on
Intel Xeon platforms.

Change-Id: Ida0b17b25816576948ddb1b0443587e0f09574d4
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-12-09 10:14:15 -07:00
Daniel Verkamp
01b48b7c90 build: define a common Makefile clean command
Use $(CLEAN_C) throughout the Makefiles to clean up a consistent set of
generated files.

This also adds coverage files to the list of cleaned files.

Change-Id: Iceb922935a45c9eecbf2f3443bd0ee4f5c966825
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-12-07 15:14:36 -07:00
Liang Yan
ed616a7902 nvme: test admin and io queue in nvme_qpair_destroy
Change-Id: Ic0377960a75d0ec9ed9eb489e7806dc4b27e8be5
Signed-off-by: Liang Yan <liangx.yan@intel.com>
2015-12-04 09:37:57 +08:00
Daniel Verkamp
2a00199d30 nvme: minor nvme reset test cleanups
Change-Id: Ia397d4c8325d059b19a41e079789e157dca5dfb1
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-12-02 16:17:30 -07:00
Liang Yan
1df5899cf5 nvme: Add reset test tool
Realize reset tool to test nvme reset function.

Change-Id: Ia38de1907ddce46738f74b65d3d15ca9f911ac7f
Signed-off-by: Liang Yan <liangx.yan@intel.com>
2015-12-01 13:26:16 +08:00
Jim Harris
366d931183 Reduce NVME_MAX_IO_QUEUES to 1024.
Most devices today support far fewer than 1024, but this is a
more reasonable default upper limit than the spec-defined 64K.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ia8a6d80c3a5aa181f27c8354758c6ca468013d92
2015-11-30 09:33:34 -07:00
Daniel Verkamp
1c3b08c63c build: move $(OBJS) definition to spdk.common.mk
Change-Id: I2dd592269ef644cfe73921151b9b174dc255323d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-11-11 14:59:55 -07:00
Daniel Verkamp
1c28700070 build: remove useless 'objs' targets
The .o files are always kept anyway, so there is no need for an explicit
rule.

Change-Id: Id1687ba89daabfda5802e4328deb127403277928
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-11-11 14:59:54 -07:00
Daniel Verkamp
dba4829471 build: factor out common compile and link commands
Add common $(COMPILE_C), $(LINK_C), and $(LIB_C) variables that contain
the commands to build a .o from a .c, an app from objects and libraries,
and a library from objects, respectively.

Change-Id: Ie2eaa13156b8bf3db7a4ffa66161382d829aef07
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-11-11 14:59:54 -07:00
Daniel Verkamp
22eced89c4 build: simplify vtophys test Makefile
Use the standard pattern of OBJS automatically generated from C_SRCS,
and also link against libspdk_memory instead of including the object
file directly.

Change-Id: I0c8cd8996cde2bcc1f25d9d97811fff3b0bbc88b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-11-11 14:59:54 -07:00
Daniel Verkamp
668847e150 nvme: add max completions limit to I/O polling
nvme_ctrlr_process_io_completions() now takes a second parameter,
max_completions, to let the user limit the number of I/Os completed on
each poll.

If there are many I/Os waiting to be completed, the
nvme_ctrlr_process_io_completions() function could run for a long time
before returning control to the user, so the max_completions parameter
lets the user have more control of latency.

Change-Id: I3173059d94ec1cc5dbb636fc0ffd3dc09f3bfe4b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-11-05 15:07:52 -07:00
Daniel Verkamp
189814de83 autotest: tweak nvme/perf command to test splits
Previously, the I/O splitting code and child I/O completion were not
being tested (aside from in the unit tests).

Tweak the I/O size so that it will get split into two child I/Os on
devices with 128 KB striping.

This causes nvme_cb_complete_child() to be exercised, improving code
coverage.

Change-Id: Ia0299f7f809f8edb93452b5ad45939977a9f67f1
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-11-04 14:35:25 -07:00
Daniel Verkamp
3677f46af8 build: allow make to work from any directory
Set SPDK_ROOT_DIR explicitly in each Makefile so that make from a
subdirectory will work (assuming all dependencies from the upper
directory have already been built).  This allows partial rebuilds of the
source tree, as well as building the unit tests without requiring DPDK.

Change-Id: I3f65b805d490b40ff5ec53cceb61df542ce814f1
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-11-04 10:19:08 -07:00
Daniel Verkamp
2e03f6fe1c build: enable strict prototypes warning
This catches functions with empty parameter lists, which are not the
same as void parameter lists in C, as well as other (less-likely)
K&R-style parameter lists.

Change-Id: I18b09e01a60b3669d1cc5d8d96eec20cd872c497
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-11-02 16:05:06 -07:00
Daniel Verkamp
8307eb5f55 build: enable missing function declaration warning
This helps weed out functions that should be static, functions that are
not declared in public header files, and .c files that don't include
their .h interface headers.

Change-Id: Ie39f83ad4b320847e4a938bd1d4d0b4fa21c2ffa
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-11-02 14:40:23 -07:00
Daniel Verkamp
fd93c1b1ef build: enable missing field initializer warning
Replace {0} initializers with {}, since it is equivalent and simpler
(and avoids the warning).

Change-Id: Id2014a352e2c627598cd3b4f1ca04dba35f2dc3a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-11-02 14:40:22 -07:00
Daniel Verkamp
a945f60c79 build: enable signed-vs-unsigned compare warning
Change-Id: I93f069241cb74b3ec7d272bc390998372c376b16
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-11-02 14:40:22 -07:00
Daniel Verkamp
f79a334e33 build: fix old-style declaration warnings
Fix all of the uses of __thread so they are at the beginning (similar to
e.g. static).

Don't actually enable -Wold-style-declaration, since clang doesn't
understand that.

Change-Id: I0dcbb758143eab90fc978334c8f256c6602cc4cd
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-11-02 14:40:12 -07:00
Daniel Verkamp
4f677a1d4c nvme: only invoke request free macro in one place
Rename the nvme_free_request macro to nvme_dealloc_request to match
nvme_alloc_request and add a wrapper function to nvme.c so that the
macro contents are only expanded once.

The DPDK nvme_impl.h uses rte_mempool_put(), which generates a large
amount of code inline.  Moving this macro expansion to a wrapper
function avoids inlining it in the multiple places nvme_free_request()
gets called, most of which are error handling cases that are not in the
hot I/O path.

Change-Id: I64ea9c39ba47e26672eee8d5058f1489e07eee5b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-10-20 07:43:41 -07:00
Daniel Verkamp
38997df85d nvme/test: fix memory leaks in nvme_ns_cmd_ut
The I/O splitting tests don't pass the I/Os through the normal
completion path, so we need to free the children ourselves.

Fixes all Valgrind warnings for nvme_ns_cmd_ut.

Change-Id: Iaf7d9f7f4cab71428a0123ee30d0f6042001e423
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-10-19 10:57:34 -07:00
Daniel Verkamp
84b8f0cc8b autotest: output timing in flamegraph format
Change-Id: I9f571ce635431613fc6a84e106e5052cce2dbf54
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-10-08 16:07:47 -07:00
Liang Yan
ae482f07c1 nvme: Add get_status_string test for nvme_qpair
Change-Id: Ib3f9d342549de52869ec984d0bc61ccd25b71a14
Signed-off-by: Liang Yan <liangx.yan@intel.com>
2015-10-08 13:44:54 +08:00
Daniel Verkamp
5fc71d7e40 nvme: disable valgrind for nvme_ut
nvme_ut is testing multi-threaded operations, and Valgrind's thread
behavior is different than running the program natively.  Under
Valgrind, the unit test essentially hangs waiting for the global
variable to be updated.

Change-Id: Id3665002c16ac3e695c50325375305a76f72cee4
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-10-06 10:21:23 -07:00
Daniel Verkamp
8780063f2c nvme: run unit tests under Valgrind if available
Change-Id: Iad8403903d420418692793d9940e33e2d3772e6b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-10-05 11:00:29 -07:00
Daniel Verkamp
1c96eff6a2 nvme: fix uninitialized memory in nvme_qpair_ut
nvme_alloc_request() does not zero out the request (this is
intentional, since the real implementation uses a mempool where requests
get reused).  Add nvme_allocate_request() wrapper that initializes the
request correctly.  This fixes all uses of uninitialized memory caught
by Valgrind in nvme_qpair_ut.  This test was also failing in practice on
FreeBSD due to non-zero buffers returned from malloc().

Change-Id: I2d6ea29289bd4887aaa9120fba6bce10088e6917
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-10-05 10:33:22 -07:00
Daniel Verkamp
cac5caec8b nvme: sync up unit test nvme_impl.h mutex wrapper
The default version of nvme_impl.h was cleaned up to release the pthread
mutex attr on failure cases, but the unit test version did not receive
this update.

Change-Id: I899b7dc809393dc8e6fd24ed98e1d0a61ecf1c95
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-30 16:18:18 -07:00
Daniel Verkamp
364331fd94 nvme: add I/O split test with stripe size enabled
Change-Id: I49166c2a07274cf66a8a9519805308c0db5ab13b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-28 14:20:03 -07:00
Daniel Verkamp
ac0c37924c nvme: validate child I/O in splitting test
Check the LBA and block count fields of the I/Os generated by the
splitting function to ensure they were split correctly.

Change-Id: I84abb1ac462fb7423d51a1be384fd1be68dfecae
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-28 14:04:51 -07:00
Daniel Verkamp
d4ee014f21 nvme: use CU_ASSERT_FATAL to abort tests on errors
Instead of repeating the check for conditions that must be fulfilled to
continue the tests, just use CU_ASSERT_FATAL, which will abort the test
and return.

Change-Id: If617b286a587d9efb1ce57b90061634ed5bc7ae8
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-28 14:04:11 -07:00
Daniel Verkamp
21b37d4ee6 nvme: make the unit test assert actually assert
The current implementation of nvme_assert in the unit test nvme_impl.h
just prints the message and continues.

We should not be triggering assert conditions, even in the unit test
code, so make nvme_assert actually call assert().  This lets us catch
mistakes in the unit tests more easily.

Also fix the two unit tests that currently trigger an assert:
- The I/O splitting test in nvme_ns_cmd_ut was passing an invalid
  combination of NULL payload with non-zero lba_count.
- The ctrlr_cmd test was passing an invalid number of entries to
  nvme_ctrlr_cmd_get_error_page().  This case should probably not be an
  assert but rather an error code.  However, the function does not
  return a status code currently, so it is not trivial to make that
  change.  For now, just drop the asserting test case and the code added
  to the test to work around it.

While we're here, fix the macros in the unit test nvme_impl.h so they
are usable in single-line conditionals without braces - that is the
whole point of the do { ... } while (0) pattern, so there should be no
trailing semicolon.

Change-Id: Iad503c5c5d19a426d48c80d9a7d6da12ff2c982a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-28 14:04:07 -07:00
Liang Yan
fdd17ae3ee nvme: Update nvme unit test
Cover more functions and conditions for nvme_ctrlr_cmd.
Remove unnecessary lines in nvme_ctrlr_ut.
Update nvme_qpair_ut.
Remove unnecessary header file.

Change-Id: I8c5a75573b26210ca57711b366acd55ab96614c0
Signed-off-by: Liang Yan <liangx.yan@intel.com>
2015-09-28 10:02:41 -07:00
Jim Harris
1d90157262 Fix header file dependencies.
Move dependency includes into a new spdk.deps.mk file,
then include it at the end of Makefiles that build
source files.

Also add a test to autobuild.sh to confirm that
binaries are regenerated if we make after touching a
header file.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: If6a1905706a840f92cbdf3ace7fbdb27fe2de213
2015-09-28 09:07:04 -07:00
Daniel Verkamp
766afaaacc nvme/test: avoid clang warnings in nvme_ns_cmd_ut
Initialize the full nvme_namespace structure in prepare_for_test() so
that e.g. ns->id is not used uninitialized.

Also check for request allocation failure - if the request is NULL, we
can't run the rest of the tests that dereference request without
crashing.

Change-Id: I3010ca3e81f153a4d0201498a14a963c2b9e960d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-25 14:03:48 -07:00
Jim Harris
4ba47234f3 Add pci_device_has_non_null_driver().
This helps enable FreeBSD, where pciaccess pci_device_has_kernel_driver()
is not functional.  The function will return 0 if there is no driver
attached, or the Linux uio or FreeBSD nic_uio driver is attached.  It will
return 1 otherwise.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I0921e61c9040b1e0411b5dc40b36fc7f2721c8c5
2015-09-25 12:45:04 -07:00
Jim Harris
004e4f6b59 Fix off-by-one errors in log page fetching.
Signed-off-by: Jim Harris <james.r.harri@intel.com>
Change-Id: Iab15a1cef4ebcf4f217cbc70d716141af95367f8
2015-09-25 12:43:25 -07:00
Daniel Verkamp
325b7db392 nvme: use rte_memcpy() to submit commands
GCC generates a series of 64-bit MOV instructions for the memcpy() into
the submission queue.  We can do better with 128-bit SSE2 instructions.

DPDK already has a memcpy implementation that is optimized for small
inline copies, so use it instead of memcpy.

Change-Id: I5f09259b4d5cb089ace4a8ea6d2078c03fee84f3
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-25 09:33:42 -07:00
Daniel Verkamp
36eea2e1c2 nvme/test: simplify struct zero initializations
Use {} consistently rather than {0} when initializing structs as part of
definitions.

Fixes warnings about initializing subobjects when compiling with clang.

Change-Id: I507fdf47e7c41455033d6c3d5edc563ec4667dee
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-24 10:48:46 -07:00
Daniel Verkamp
0a92b40bb8 nvme/test: stub out missing ctrlr_cmd function
nvme_ctrlr_cmd_set_async_event_config() is called from within nvme_ctrlr
but was never stubbed out in its unit test.

Change-Id: I44002540e74ee010f21d0cf2d089d1dc51217a2f
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-24 10:48:46 -07:00