Commit Graph

254 Commits

Author SHA1 Message Date
Daniel Verkamp
13827a74a8 nvme: do not detach automatically on hot remove
The user's remove_cb should detach the NVMe controller when it can
ensure that it is no longer in use.  In the interim (between remove_cb
and spdk_nvme_detach()), the controller will remain in a failed state,
so any new I/O submissions will return an error code but not crash.

examples/nvme/hotplug is not yet updated for this change, but that will
be done in a separate patch.

Change-Id: I8827ba36f9688ccb734e7871f20f11ec11e88f96
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-12-05 11:13:16 -07:00
Daniel Verkamp
9d025383eb nvme: rename nqn fields in public API to subnqn
The discover and probe 'nqn' fields are subsystem NQNs, so name them
subnqn to be consistent with the spec and the rest of the code and to
distinguish them from host NQNs.

Change-Id: I4a80fbc1f4b037c8a4f91c8f28d2a96e47c66c47
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-12-01 08:08:19 -07:00
Daniel Verkamp
89136259ec nvme/rdma: add hostnqn to spdk_nvme_ctrlr_opts
Allow the host NQN to be overriden when connecting to NVMe over Fabrics
controllers.

Change-Id: I8fcf2e89ae7d9722677e834f76a8fe805c52f91b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-12-01 08:08:19 -07:00
Ziye Yang
2e6ec373bf nvme/rdma: fix the I/O qpair creation issue
Change-Id: I357f4a83736977d319175445b4d65443f57b2c6f
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2016-11-30 16:57:18 -07:00
Cunyin Chang
56765aa39f env_dpdk: Add spdk_pci_device_[attach|detach]
These functions will attach or detach from a PCI device. Attaching
typically means mapping the BAR.

Change-Id: Iaaf59010b8a0366d32ec80bb90c1c277ada7cfe7
Signed-off-by: Cunyin Chang <cunyin.chang@intel.com>
2016-11-30 14:10:52 -07:00
GangCao
73e926f087 nvme: add thread safety comment for spdk_nvme_probe()
Change-Id: I8460a6fddcf383781c520f36a08df1b0a802a709
Signed-off-by: GangCao <gang.cao@intel.com>
2016-11-29 12:52:50 -07:00
Daniel Verkamp
c454900960 log: print trace flag names in SPDK_TRACELOG()
Change-Id: I962ee098818f48563e67f9b4214bc3519eee48b4
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-28 13:15:08 -07:00
Daniel Verkamp
6ca517d460 nvmf: split subsystem lookup from host check
This allows us to print better error messages when connecting to a
subsystem that exists but does not allow a specific host.

Additionally, we can now return the correct error code for a host that
is not allowed.

Change-Id: I16cd4ac2745cf50bb54601b464b0d23954f86fda
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-23 16:34:13 -07:00
Changpeng Liu
a3ed1795cd nvmf: add subsystem check on creation and cleanup for nvmf rpc
Change-Id: I85826c99c450426c26870ae261a7b7c8daeba031
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
2016-11-23 10:27:54 -07:00
Daniel Verkamp
1cb7e396a7 json: add printf-style spdk_json_write_string_fmt()
Change-Id: I9ea18072d4e54344f145a0b2d16aa6ab7f4d5e03
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-22 16:32:35 -07:00
Daniel Verkamp
7d5bcb4893 nvme: remove spdk_nvme_transport_type from API
Use the NVMe over Fabrics spec definitions for TRTYPE rather than the
internal library transport type.

Change-Id: Idead559a8f8d95274fc580d10e82033822e6eda8
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-22 13:42:00 -07:00
Daniel Verkamp
9a40113a19 nvme: convert probe strings into char arrays
These need to be available for the lifetime of the probe_info structure,
so they can't be pointing at e.g. temporary buffers on the stack.

Change-Id: I5aaa898acf9314aab51600dd756f966965d37fd0
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-22 13:42:00 -07:00
Daniel Verkamp
b4bd76bc63 util: add vsprintf version of spdk_sprintf_alloc
-Wformat-nonliteral needs to be disabled since clang triggers it on the
call to vsnprintf() now that it is nested two calls deep.

Change-Id: I228b9d099cfc2b65181941cbb4798b7f8eae3baa
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-22 11:52:00 -07:00
Daniel Verkamp
ae6fbf1d2d util: add spdk_strlen_pad() function
This is a counterpart to spdk_strcpy_pad() which determines the length
of a string in a fixed-size buffer that may be right-padded with a
specific character.

Change-Id: I2dab8d218ee9d55f7c264daa3956c2752d9fc7f7
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-22 11:36:34 -07:00
Daniel Verkamp
635602718b nvme: clean up Doxygen comments in API header
Change-Id: I16548628fa4eebc7ebd1d24f2775d38135d26822
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-21 17:02:12 -07:00
Daniel Verkamp
cf3fb7bb7d bdev/rpc: add driver-specific data to get_bdevs
Change-Id: Ieb37c9fdb55b36b62adcb421ab1d0426052d23a4
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-21 12:35:57 -07:00
Pawel Wodkowski
a1948352a3 lib/scsi: handle scattered input/output buffers for non IO commands
Fix buffer overflow/underflow for commands with alloc length scattered
into multiple preallocated buffers (eg. INQUIRY)

Change-Id: If6f7cabc7a6a7fb384bb015e14dc38548f484d0f
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2016-11-21 10:52:35 -07:00
Ziye Yang
246c39a7ee nvme: Add nvme over fabrics support
Change-Id: I6f6259e77baa5dc5861f31ec4a9034e15297d333
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2016-11-18 13:58:44 -07:00
Daniel Verkamp
cbc83c85db assert.h: remove unused SPDK_CONCAT macro
Change-Id: Ib0cff3720ae3f0dc20df655923acfa2dd70ced13
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-17 12:46:45 -07:00
Daniel Verkamp
5b63b8a448 copy_engine: rename spdk_copy_module_get_max_ctx_size() to spdk_copy_task_size()
Make the public API clearer - if the user wants to allocate a
spdk_copy_task directly, they need to allocate spdk_copy_task_size()
bytes.

Also change the return type to size_t for consistency.

Change-Id: I0f3757056757c510421d680c5b4532edd9bc2561
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-16 15:04:40 -07:00
Daniel Verkamp
945217d2b2 copy_engine: split internals into spdk_internal
Change-Id: I3102e9761888c5afdc20d1a1abc9abf50484233d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-16 14:44:35 -07:00
Daniel Verkamp
ee64969a7b copy_engine: add spdk_ prefix to types
Change-Id: I060718887950ee7f890e76d7e041e70db39974a2
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-16 14:14:50 -07:00
Daniel Verkamp
d27b24c94b log: split internal TRACELOG macro into new header
The SPDK_TRACELOG macro depends on a CONFIG setting (DEBUG), so it
should not be part of the public API.

Create a new include/spdk_internal directory for headers that should
only be used within SPDK, not exported for public use.

Change-Id: I39b90ce57da3270e735ba32210c4b3a3468c460b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-16 13:33:51 -07:00
Daniel Verkamp
396c32c48f conf: move structures out of public API header
Change-Id: Id2a7f083d959c9bbe493c383e6c9578de34c5eae
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-16 10:33:16 -07:00
Daniel Verkamp
04c48172b9 conf: add accessors for section name and num
Remove usage of the conf structs so they can be moved out of the public
API header.

Change-Id: I1c7375ec7708b323f50af09aeb7b2b2c9c770df4
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-16 10:33:12 -07:00
Daniel Verkamp
9df6675ebf endian: constify from_* functions
Change-Id: I8ee39258ce0ba759347ff0a9cec7c70a1495f8af
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-16 10:30:04 -07:00
Daniel Verkamp
5a5f25d6cd endian: add little-endian helpers
Change-Id: I38b910e90f567460443d44bbe3adef740c63d88c
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-16 10:30:04 -07:00
Jim Harris
3d1b60557c env: add spdk_vtophys_register/unregister
These APIs can be used to register/unregister regions
of pinned, huge page memory that are separate from
huge page memory allocated by the default DPDK
allocations.  These APIs will be used by an upcoming
SPDK vhost-scsi target to enable SPDK to target
NVMe DMA operations directly to VM memory that has
been allocated by QEMU using pinned huge pages.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I649a4adeeb758b29bd29cd42c8872eed3d5d6ce9
2016-11-16 09:21:57 -07:00
Daniel Verkamp
e2abf192c7 env.h: fix coding style
Only function definitions should have a line break between the return
type and function name, not prototypes.

Change-Id: Ic547a6c6541e31bbf95e3d95a28077c9e6510ba6
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-16 08:44:21 -07:00
Daniel Verkamp
fc9983b638 env: drop spdk_pci_device_get_class()
Now that the env PCI framework already requires enumerating devices
based on an enum of specific device types, it is not useful to query the
class code of a PCI device handle.

It is currently unused and does not work in its current form on FreeBSD
(it reads a file from /sys).  This lets us drop a big chunk of file
reading and parsing code.

Change-Id: I1d720398416ba3d6f91e077b807ec11a6de562cf
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-16 08:44:21 -07:00
Ben Walker
b43db69a44 nvmf: Remove spdk_nvmf_transport from public API
The details of the structure were removed earlier, but
now remove all references even to a pointer to the
structure. The user can refer to transports by their
string name.

Change-Id: I273356f46329ea5372dcd951eda6f14767477d69
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-11-16 08:11:46 -07:00
Ben Walker
bb5d8e506c nvmf: Combine nvmf_tgt_init and nvmf_transport_init
Change-Id: I6d0f92842f3b8626bc2c25b38bfa7f7ddea5e7cc
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-11-16 08:11:46 -07:00
Ben Walker
3cbed2ed86 nvmf: Add some accessors for subsystem data
This is a step toward abstracting away the definition
of the subsystem.

Change-Id: I88b2aa107b27152620f51a1ca2a153792b4c85e9
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-11-16 08:11:46 -07:00
Ben Walker
f1017d7769 nvmf: Remove num from subsystem
It wasn't used for anything.

Change-Id: Ifc8c97481490f6389a739a37df03dea6c88ec692
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-11-16 08:11:46 -07:00
GangCao
47214fa6c2 API: add new comment to spdk_memzone_reserve API
Change-Id: Ia6ba71776de638636efa703d132a863424900d3c
Signed-off-by: GangCao <gang.cao@intel.com>
2016-11-14 10:38:12 -07:00
GangCao
621f96f7aa util/bit_array: use spdk_realloc for process sharing
Change-Id: I8fe49388e7bec9306474f27de7c17e767dfa19e8
Signed-off-by: GangCao <gang.cao@intel.com>
2016-11-09 15:04:20 -07:00
Pawel Wodkowski
f30f0c76f1 scsi: refactor usage of iov from spdk_scsi_task
This patch is preparation for fixing alloc_len overrun in SENSE 6/10 and
READCAP 6/10. To simplify code forbid usage of iov outside of
scsi/task.c.

This also drop SPDK_SCSI_TASK_ALLOC_BUFFER flag that obfuscate code. As
a replacement assume that if field alloc_len is non zero it mean that
iov.buffer is internally allocated. Functions
spdk_scsi_task_free_data(), spdk_scsi_task_set_data() and
spdk_scsi_task_alloc_data() manage this field.

Change-Id: Ife357a5bc36121f93a4c5d259b9a5a01559e7708
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2016-11-09 10:19:53 -07:00
Daniel Verkamp
1f3d48b22d bdev: move spdk_bdev_fn_table into bdev_module.h
The bdev function table should not be part of the public API.

Change-Id: I5d6f40d1b37c4471041c1c9d6253a3f92e9e9701
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-09 09:59:39 -07:00
Daniel Verkamp
0aec36be1f nvme: return virtual address in SGL callback
Instead of the next_sge callback returning the physical address
directly, make it return the virtual address and convert to physical
address inside the NVMe library.

This is necessary for NVMe over Fabrics host support, since the RDMA
userspace API requires virtual addresses rather than physical addresses.
It is also more consistent with the normal non-SGL NVMe functions that
already take virtual addresses.

Change-Id: I79a7af64ead987535f6bf3057b2b22aef3171c5b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-09 08:57:40 -07:00
Daniel Verkamp
3aaa9a5eb7 nvme: use canonical "spdk/" path in include
Change-Id: I05ab1781b04a23ecec8f31bf0f1492eb4627ac9d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-08 08:58:02 -07:00
Tsuyoshi Uchida
6583441f54 bdev: add members for SCSI sense information in spdk_bdev_io (#59)
Custom bdev modules can return any SCSI status and SCSI sense
information to a host by this patch. This is usefull when a custome bdev
module detect an error in the module and need to return meaningful
information to a host.
2016-11-07 13:14:47 -07:00
Daniel Verkamp
1ffec5d53a nvme: convert transport type to an enum
Function pointers will not work for the DPDK multi-process model (they
can have different addresses in different processes), so define a
transport enum and dispatch functions that switch on the transport type
instead.

Change-Id: Ic16866786eba5e523ce533e56e7a5c92672eb2a5
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-07 10:42:18 -07:00
Pan Liu
fa5206c416 env: add wrapper to call function without thread affinity (#60)
Make a wrapper that spdk can call a function without thread affinity, and
call this wrapper to open rbd image.

Change-Id: Iadc87a948f43632abf497f88165483a0e269ba54
2016-11-07 10:32:16 -07:00
Jim Harris
3266d7dbcc app: add spdk_app_start_shutdown()
This enables using SPDK within a larger process that
is SPDK-centric.  In this case the process may start
SPDK and then wish to stop it explicitly (without a
signal).

While here, remove an incorrect comment - DPDK mempools
can be used from non-DPDK threads.  Also set the
g_shutdown_event to NULL after it is called.  After the
event executes, the event is freed and is no longer valid.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ie4f07bee7d05fae683c72f6680cb3bcce2d4a119
2016-11-07 09:59:59 -07:00
Daniel Verkamp
52bbb267d8 event: process events in batches
Since we are usually going to be removing multiple events from the queue
at once, use the DPDK burst dequeue interface to improve efficiency.

Also rework the event queue runner to always process a fixed maximum
number of events per timeslice for simplicity.  This removes the
rte_ring_count() call from the hot path and improves fairness between
events and pollers.

Now that events are dequeued in bulk, we can also put the event objects
back into the mempool in bulk.  Add an env wrapper around
rte_mempool_put_bulk() and use it to free all of the events at once.

Basic performance benchmark using test/lib/event/event/event -t 10
is improved: previously ~40 million events per second, now ~46 million
events per second.

Change-Id: I432e8a48774a087eec2be3a64c38c339608af42a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-07 09:32:25 -07:00
Daniel Verkamp
dca887b7d8 env: remove spdk_pci_device_get_device_name()
It always returns NULL in the current DPDK env implementation and was
not used outside of a few ioat examples where it is not particularly
informational.

Change-Id: I14b237c33bc25ddebc6b36bfbd6a4edf6762e3ca
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-02 15:58:03 -07:00
Jim Harris
1732eeb4bb env: add spdk_malloc
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ieaca9fdded2231c6d01101b345ac6c9a01608eef
2016-11-02 14:15:15 -07:00
Daniel Verkamp
fcb00f3780 nvme: expand probe information to a struct
spdk_nvme_probe() will now provide a struct spdk_nvme_probe_info to the
probe and attach callbacks in place of the PCI device pointer.

This struct contains the useful information that could be retrieved from
the PCI device during probe.

The goal of this change is to allow expansion of the probe information
in the future when other transports (specifically, NVMe over Fabrics)
are added that do not necessarily use PCI addressing or device IDs.

Change-Id: I59a2a9e874e248ce5fa1d7f4b57c8056962ff3cd
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-02 14:15:02 -07:00
Daniel Verkamp
bbd7e1c4da env: add spdk_pci_addr_parse()
Add a helper function that converts a PCI address from a string into a
struct spdk_pci_addr and use it in place of the various sscanf()
invocations throughout SPDK.

Change-Id: Id2749723f76db741567e01b4bcb0fffb0e425fcd
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-02 14:15:02 -07:00
Daniel Verkamp
d921d9ed9f json: add spdk_json_write_[u]int64()
Change-Id: I29c2c8f8546774842adf7e77e7bb550735c6fccc
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-02 09:10:54 -07:00