Commit Graph

9020 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
8217814218 nvme: remove dump_command and dump_completion
nvme_dump_command is totally unused aside from the unit test.

nvme_dump_completion was used in qpair, but it can be replaced with the
equivalent nvme_qpair_print_completion.

Also added the missing nvme_completion fields to nvme_qpair_print_completion
that had been printed by nvme_dump_command.

Change-Id: Ia5ee66f3553df06febe8f465d42e49a84c555dd2
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-22 15:48:12 -07:00
Daniel Verkamp
18ce432337 nvme: simplify nvme_ctrlr_construct_admin_qpairs
Remove unnecessary local variables.

Change-Id: Iddcbe24f0a704b6576c9139734258a27a6d272c6
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-22 10:12:33 -07:00
Daniel Verkamp
d7dda8ec63 nvme: delete outdated comments about xfer size
This is calculated elsewhere now, so remove the comments around
nvme_qpair_construct calls.

Change-Id: I2dc4956a9e250b88e62038bc55cdd315940ad391
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-22 09:40:53 -07:00
Daniel Verkamp
4f939758ea nvme: remove dead store
rc is reinitialized before it is ever read.

Change-Id: I9abbc256fb06022f3024b0aa3827be02a273f20a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-22 09:39:00 -07:00
Daniel Verkamp
1010fb3af1 SPDK: Initial check-in
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-09-21 08:52:41 -07:00