Commit Graph

16114 Commits

Author SHA1 Message Date
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
92da744700 util: add sprintf_alloc() function
Like sprintf() with automatic buffer allocation.

This should help to avoid fixed-size buffers in
non-performance-sensitive code that formats strings.

Change-Id: I35209ae84014ed5daf41baa5b03af8a5f6b02b8e
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-10-06 10:40:51 -07: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
f0b3db3f1e autobuild: FreeBSD portability fixes
Change-Id: Id6db5d80ee7fa602da8763372f92555e7e299445
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-10-06 09:09:00 -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
Liang Yan
2bec440057 nvme: Change some strange alignment in nvme_ctrlr.c
Change-Id: I295d1864eaf8233df0678c3df948ac353613b27d
Signed-off-by: Liang Yan <liangx.yan@intel.com>
2015-09-29 14:01:44 -07:00
Ben Walker
c45dfec4f6 nvme: Add concurrency to nvme perf example.
Change-Id: Ic565b70517bb2958b64fe7f2cf59a31e4b6250ef
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2015-09-29 14:01:33 -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
d2e10e88ec nvme: move nvme_request_add_child to nvme_ns_cmd.c
This is the only place nvme_request_add_child() is used, so move it
nearby and make it static to allow the compiler to inline it.

Change-Id: If4a7e17fde0b0272e1d4432c1dcedbec27c25371
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
Daniel Verkamp
29fb756232 vtophys: avoid NULL dereference if malloc fails
Change-Id: I5fd865d158716966de6baf5d9d45fbeb47c44e71
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-28 12:52:05 -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
f0649be5a0 Add porting guide.
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ic028d9d776b094fc2fa048c23424aec2c8434cc6
2015-09-28 09:07:19 -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
c2fdcfdd9b build: build with DEBUG=n during autopackage
Exercise both the DEBUG=y path (during autobuild) and DEBUG=n (during
autopackage).

Change-Id: Ie2f0fea42ac675cd18f49d0b3274aa2c3413b88a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-25 14:23:01 -07:00
Daniel Verkamp
f19d1faedd build: disable assert() when building for release
Set -DNDEBUG to make assert() a no-op.  Since nvme_assert() is just an
alias for assert(), this controls compilation of nvme_assert as well.

Change-Id: Ie9d0c7fea007eff030179c1b54865adc3dcaf6b6
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-25 14:22:49 -07:00
Daniel Verkamp
736ec4967e nvme: refactor _nvme_ns_cmd_rw()
Pull the almost-identical request splitting code for driver-assisted
striping and maximum I/O size into its own function,
_nvme_ns_cmd_split_request().

Change-Id: I3c15ac2073f8f5aec721c427199c8fb1a5d6a1fc
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-25 14:21:57 -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
4ac57251d5 README.md: add build instructions for FreeBSD
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I4500366475ffbaa9c91ea62a07522c2f82a9a372
2015-09-25 12:45:04 -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
ae2c3152c4 Add unbind_nvme.sh script.
This will rmmod nvme on Linux, and use the DPDK nic_uio driver
to unbind nvme devices from the nvme driver on FreeBSD.

"nic_uio" is actually a misnomer - it is not NIC driver specific,
and can safely be used to bind NVMe devices to an effectively
null driver.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I8b964a070586166d762d79696385b82eeb2e88bd
2015-09-25 12:45:04 -07:00
Jim Harris
ae09ffb720 Update hugepage script for FreeBSD.
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I8adbc9480493c3b6318e0b2a9d170451a0540c71
2015-09-25 12:45:04 -07:00
Jim Harris
5e1c75eedc Break out queue.h code pulled from FreeBSD into a separate file.
Then only include this new file on Linux, to help enable building
SPDK on FreeBSD.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Id818a2d8662c95e603d8b580f1f4b92889cc626e
2015-09-25 12:45:04 -07:00
Jim Harris
f66307d494 Port pci.c to FreeBSD.
The changes are minor:

- remove unneeded error.h
- replace PATH_MAX with a suitable local #define

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I5aecf8b53e0ac7582f394c71b4668888a6c6292f
2015-09-25 12:45:04 -07:00
Jim Harris
6728254a2d Use DPDK-based vtophys implementation.
The Linux pagemap-based implementation obviously does not
work on FreeBSD.  DPDK has data structures describing the huge
pages it has allocated, so use that instead when we need to
populate new 2MB mappings in our tables.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I924e104f42891aaa2f931159aabba2779f239e91
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
04b615bb1c autotest: capture core dumps on early exits
Change-Id: Ic1bb518ecd8d5fba42c7f0b86cbf02524c262f0e
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-25 09:49:09 -07:00
Jim Harris
068b20abab build: add OS to spdk.common.mk
This will add different flags, src files, etc. for FreeBSD.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I4f2d664cf42d01745318f241ce9558dccf148b7d
2015-09-25 09:36:43 -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
8d424e6e71 nvme: simplify logic for whether to call callback
No change in behavior, just a simplification.

We already have a check for retry, so pull the cb_fn check out and put
it under the !retry branch.

This makes it clearer that requests that are going to be retried will
not get their callbacks called.

Change-Id: I70c7067e550c7fca78b0441b5474833f73863315
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-24 14:53:42 -07:00
Daniel Verkamp
e098976c55 doc: remove reference to nonexistent images dir
Change-Id: Idedc1d0ef978739b1dfb8937b824c7326832e3a7
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-24 11:24:16 -07:00
Daniel Verkamp
3302fd86f0 doc: use doxygen in quiet mode
Make doxygen only output warnings and errors.  The other informational
output is not that useful.

Change-Id: Iecdcc45ce3a64905815326734e4783ddc45b654b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-24 11:24:16 -07:00
Liang Yan
655d98f52e nvme: remove _nvme_io_qpair_destroy function
Since it is empty function. It  can be deleted.
Add nvme_assert to fix issue reported by scan-build.

Change-Id: Ia0e8f656e1dac0da7ec72f8404469ea1b0dcb40e
Signed-off-by: Liang Yan <liangx.yan@intel.com>
2015-09-24 11:16:10 -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
9a96ff3b9b nvme/test: build unit tests using common CFLAGS
Inherit the CFLAGS and other common setup from spdk.common.mk instead of
redefining it in nvme.unittest.mk.

In particular, this enables warnings for the unit test code that were
not enabled before.

Change-Id: Id0fbf0ee0b0d63f9de0c362d1d23e2bd036a7145
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
Daniel Verkamp
ed24b97159 nvme/test: remove unused variable
Fixes warning about unused variable req.

Change-Id: Ic192c6f10d59f579755b3d84d5686c6cbf36ffe0
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-24 10:48:46 -07:00
Daniel Verkamp
2d95465379 nvme/test: set phys_addr in stub nvme_malloc()
This prevents warnings about unused phys_addr variable in the unit
tests.

Change-Id: I022483735ba92eb112e541e6de37dc9a8c5d2b8e
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-24 10:48:46 -07:00
Jim Harris
5e95ec6f47 README.md: add more detailed quick start instructions
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I267f27edb8797c794dc732334b557f44dc677015
2015-09-24 09:59:56 -07:00
Daniel Verkamp
3181a61450 nvme: replace stray printf with nvme_printf
This is the only place that was using printf directly in the NVMe
library.  Replace it with the official nvme_printf logging mechanism.

Change-Id: I689a7c0854b5e47eb357150f814e347cd44be79c
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-23 16:25:16 -07:00
Daniel Verkamp
7004492324 build: check formatting with astyle
Change-Id: Ic09b4dd7ccccb557e8236fc0b7e3105fce1644b3
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-23 09:05:51 -07:00
Daniel Verkamp
5abc81fd9a build: make scan-build warnings fatal
Change-Id: I70e86d4b94f24e7e915f6fe011f387919a7c76c7
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-22 16:44:12 -07:00
Daniel Verkamp
5717784633 nvme: assert that tracker's request is valid
In nvme_qpair_complete_tracker, make sure we got a valid request in the
tracker that is being completed.

This should never occur in practice, but safeguard against it in case of
programmer error.  Fixes a scan-build warning about potential NULL
dereference.

Change-Id: Id82af604d2a5ed5de0aeccf3affa1900f6712ebe
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-22 16:44:12 -07:00
Daniel Verkamp
2e1b5532e1 build: handle builds with no scan-build output
Change-Id: Ic96422be95c9e4f84b34d05329ca79b4af989342
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-22 16:44:12 -07:00
Daniel Verkamp
c028633b50 nvme: assert valid nvme_qpair_construct parameters
Document the assumptions made by qpair_construct using asserts.

These values can't actually be 0 in practice due to the way they are
derived, but scan-build can't see that.  It is also useful to have these
asserts in case of future modifications.

Change-Id: I546c057f5cbe7ccc62acd90b595e423cd450d86a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-22 16:31:26 -07:00
Daniel Verkamp
b177c56881 nvme: clean up test_nvme_ctrlr_fail
Replace unnecessary allocation with a stack variable.

Clears up a potential NULL pointer dereference indicated by scan-build.

Change-Id: I81a7591729b0f1630bab9ce378716bd2369d6b85
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-22 16:15:48 -07:00