Commit Graph

51 Commits

Author SHA1 Message Date
Daniel Verkamp
0346dd775e nvme: add ADRFAM (address family) to transport ID
This isn't used yet in the NVMe library, but it will be necessary later
for supporting non-IPv4 addresses.

Change-Id: I167ce63ad25b0e0c9aa192b12d764c8d078e67f9
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-12-14 10:14:10 -07:00
Daniel Verkamp
92ee5fc4be nvme: rename queue_size option to io_queue_size
This better describes what the field controls (it does not affect the
admin queue size).

Change-Id: I851ae46fb4ed0fce819af07ae235824e0fc817e6
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-12-13 15:23:13 -07:00
Ziye Yang
c21e9fa5fb nvme/rdma: move ibv_send_wr/ibv_recv_wr usage from stack to heap
It will be more safe to do in this way.

Change-Id: I2bbe97ac72dc9f8b0e32a183f9aec5a628e0830a
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2016-12-12 17:07:56 -07:00
Daniel Verkamp
4714e34d6e nvme/rdma: reset discovery trid for each entry
Don't leave garbage from previous discover entries in the trid we are
returning to the user.

Change-Id: I60ae5932db4a95cedb8df1ff98a2479220b55ce4
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-12-12 15:31:25 -07:00
Ben Walker
ec0b5d2ba1 nvme: Clean up redundant arguments in transport_ctrlr_construct
The other simplifications to probe_info and trid made the
trtype argument redundant.

Change-Id: Ie7bea4e2204e690dc4909eeacd065e0722b53272
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-12-12 10:49:17 -07:00
Ben Walker
32e838af3c nvme: Remove probe_info, just use transport_id
The probe_info was reduced to just containing a
transport_id, so remove probe_info entirely.

Change-Id: Ica9a22d126cd14e282decd3eea1a0afe0460f099
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-12-12 10:49:17 -07:00
Ben Walker
6c2e170dc7 nvme: Remove pci_id from probe_info
This can be obtained by parsing traddr into a pci_addr,
then getting a handle to the pci_dev and asking for all
of the pci information.

Change-Id: I1948cbd3ec65611293192ef5558ace19dd444d4c
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-12-12 10:49:13 -07:00
Ben Walker
34100924e4 nvme: Rename nvme_probe_one to nvme_ctrlr_probe
Simplify the arguments as well.

Change-Id: I653e1aad4e574cf95d793b41b749cb19e0024c2b
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-12-08 15:22:48 -07:00
Ben Walker
06557b0a4d nvme: Add remove callback to transport scan
Scanning the transport may result in both new
devices and removed devices, so pass the callback
for both operations.

Change-Id: I6f73dbe6fd7cf61575c354b43f8ae3e2a01e2965
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-12-08 15:22:47 -07:00
Ben Walker
d70ff832bf nvme: nvme_transport_ctrlr_scan now takes a transport id
Simplify the arguments to nvme_transport_ctrlr_scan to take
a transport id that identifies the discovery service (or
NULL to scan PCIe).

Further, separate scan into two functions - scan and attach.
Scan is for scanning an entire bus, attach is for a specific
device.

Change-Id: I464f351a02a04bc5a45096dcf5dc8fc5ac489041
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-12-08 15:22:47 -07:00
Ziye Yang
da43f64b17 nvme/rdma: Get right initiatior depth by ibv_device_query
Change-Id: I125e95dd405c21c5aea852e619801f1ef2de94ee
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2016-12-08 14:18:36 -07:00
Ben Walker
5f78155fde nvme: Embed a transport_id in the discovery_info struct
Instead of repeating the fields, just embed a transport_id.

Change-Id: I282704c9d59784abd5f7c93be4e47c673fcf6dde
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-12-08 11:48:21 -07:00
Ben Walker
a2f35bcc16 nvme: Remove nvme_attach
Change-Id: Ia688e49574d8d80f1473f93f127586ca5aaa7d91
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-12-08 11:48:21 -07:00
Ben Walker
4af9f06c73 nvme: Rename discover_info to transport_id
This is a small step toward making discovery more like
scanning a local PCI bus.

Change-Id: Ie7149ad060f2eeb56939b1241187bdf09681f2aa
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-12-08 11:48:21 -07:00
Ziye Yang
f74d64f07f nvme/rdma: fix the nvme_rdma_pre_copy_mem
Before adding readv/writev support in nvme_rdma,
using this patch.

Change-Id: I25ff0df61d0346f22560d011158d7f80e72007ea
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2016-12-08 10:33:05 -07:00
Daniel Verkamp
307d1320d8 nvme/rdma: use common Get Log page function for discovery
Change-Id: Ic635dabd039c56dfebdd0da64c4efe672b240013
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-12-07 13:36:24 -07:00
Ziye Yang
efd7ecd5d4 nvme/rdma: fix the kato value assginment in connection
Change-Id: Idc63a8f20a85bc73d48bd622b5a6e18ca4ed50d6
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2016-12-07 12:34:02 -07:00
Ziye Yang
8eaf533156 nvme/rdma: set IOSQES and IOCQES in cc register
The reason is that kernel nvmf target will check the
value. If not set, it will fail the other commands later.
Even for discovery ctrlr, kernel nvmf target will
check the cc value.

Change-Id: I998327f91ba96281d261952878eb84d648a823da
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2016-12-07 12:34:02 -07:00
Daniel Verkamp
152a3f0528 nvme/rdma: Connect command HSQSIZE is 0-based
Change-Id: I8e089c515bc6dfdf3088cfbb772d58527c6bd8de
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-12-07 12:34:02 -07:00
Ben Walker
5b8c0c5ace nvme: Rename spdk_nvme_transport to spdk_nvme_transport_type
It's not the whole transport - it's just an enum for the
type of transport.

Change-Id: Ia435a21792f221ddf50ddf4f0923c6152622eccb
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-12-07 09:47:00 -07:00
Ziye Yang
b93d5a7ae5 nvme/rdma: set NUMDL/NUMDU fields in Get Log Page
Change it according to the spec thus we can test
kernel nvmf target

Change-Id: Ica98dd40503a40c0f0de8efaefb1f6f67a89cde8
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2016-12-06 12:57:57 -07:00
Ziye Yang
10690dedcd nvme/rdma: change the arg to 0 in nvme_rdma_fabric_prop_get_cmd
The buf is NULL, the size of buffer should be 0.

Change-Id: Iba89732ea6abeb65106ae1e158902e1dd9a1204c
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2016-12-05 13:02:04 +08:00
Daniel Verkamp
be4f8d0562 nvme/rdma: fix double free in qpair creation error path
While we're here, fix up typos and add error logs for all error exits
in nvme_rdma_qpair_connect().

Change-Id: I236fe6571c2012ca047aa8a447638d9227454c2f
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-12-02 15:59:46 -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
Cunyin Chang
d1a37e98e6 nvme: Make the nvme_transport_ctrlr_scan() could scan a specific device.
Change-Id: I74f7582f5175742e96268dc9c0cc83db2e1eaea0
Signed-off-by: Cunyin Chang <cunyin.chang@intel.com>
2016-12-01 10:17:41 +08:00
Daniel Verkamp
6ab28a201b nvme/rdma: register responses as a single ibv_mr
Change-Id: I55ec9275142584768543e3a6de6eb5c675f6a063
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-30 17:10:39 -07:00
Daniel Verkamp
1712d1b7a2 nvme/rdma: convert SGL trace helper into a macro
This makes the function and file/line info actually useful (instead of
pointing to the helper function itself).

Change-Id: I22bac68827115880a49d456706a7eaecdc12e9b5
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-30 17:10:39 -07:00
Daniel Verkamp
a9e436911f nvme: remove transport qpair_destroy() function
Each transport should handle its own qpair cleanup internally.

Change-Id: I7dd737be820ea6bad686f4aad7d74044fad58a47
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-30 17:10:39 -07:00
Daniel Verkamp
ba16e46349 nvme: pass opts and probe_info to nvme_attach()
Let the transport access the controller options during
ctrlr_construct().

Change-Id: I83590c111e75c843685dd9315f0f08416168356d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-30 17:10:39 -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
Daniel Verkamp
11a2f1cf47 nvme/rdma: simplify nvme_rdma_req_get()
nvme_rdma_req_get() is an internal function, and its only caller already
checks for a valid rqpair, so the NULL check is unnecessary.

Also clean up the redundant STAILQ_EMPTY/STAILQ_FIRST logic and use
STAILQ_REMOVE_HEAD.

Change-Id: Ic3828e8b5e881879173cb59350e39c5fac90e6ef
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-30 16:38:48 -07:00
Daniel Verkamp
9c2186ea65 nvme/rdma: make nvme_rdma_pre_copy_mem() return void
nvme_rdma_pre_copy_mem() does not have any failure cases, so remove its
return value and remove the never-taken branch in its only caller,
nvme_rdma_qpair_submit_request().

Change-Id: I91011734ed0c20f8db691d62172fe1a3021dd3a1
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-30 16:38:48 -07:00
Daniel Verkamp
5660dfde83 nvme/rdma: simplify nvme_rdma_req_put()
nvme_rdma_req_put() is an internal nvme_rdma.c function, and all of the
callers already have the rqpair, so pass it directly.  We also already
verify that all of the callers have a valid rqpair and req before
calling nvme_rdma_req_put(), so it doesn't need to check for NULL
pointers.

This also means that spdk_nvme_rdma_req doesn't need to hold a pointer
to its rqpair anymore.

Change-Id: I893a46a9074f0a843e379d10c123f9292eb3b1a4
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-30 16:38:48 -07:00
Daniel Verkamp
de8b8712f8 nvme/rdma: remove unused outstanding_reqs counter
The only place where outstanding_reqs was checked was in
nvme_rdma_req_put(), but the error case there could only happen if some
kind of internal programming error occurred (e.g. calling
nvme_rdma_req_put() on an invalid request).

Change-Id: I71e40ce562a8720dfaf70437ffd4c6493327c091
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-30 16:38:48 -07:00
Daniel Verkamp
e343a735e0 nvme/rdma: inline and simplify send WR init
nvme_rdma_ibv_send_wr_init() was only called in one place, so just move
its contents into nvme_rdma_qpair_submit_request() since it allows
simplification of the code:

- req was always NULL, so remove the code that used req entirely.
- wr and sg_list are never NULL, so remove the checks for those.

Change-Id: I12a4f3502219d3681607686945e343f6808c0d2f
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-30 16:38:48 -07:00
Daniel Verkamp
22d8acbcf1 nvme/rdma: check discovery entry subtype
We currently don't handle discovery service referrals, so skip those, as
well as any other unknown subsystem type.

Change-Id: I64f889e9272fb57b5cf9bb5467b3abca3955baf5
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-30 16:38:48 -07:00
Daniel Verkamp
efca92b85b nvme/rdma: partly remove CC.EN = 1 hack
The generic NVMe library controller initialization process already
handles enabling the controller; the RDMA transport should not need to
set EN itself.

For now, the discovery controller is cheating and not using the normal
initialization process, so move the EN = 1 hack to the discovery
controller bringup until it is overhauled to use the full
nvme_ctrlr_process_init() path.

The previous code where CC.EN was set to 1 before going through the
controller init process would cause an EN = 1 to EN = 0 transition,
which triggers a controller level reset.

This change stops us from causing a reset during the controller
startup sequence, which is defined by the NVMe over Fabrics spec as
terminating the host/controller association (breaking the connection).

Our NVMe over Fabrics target does not yet implement this correctly, but
we should still do the right thing in preparation for a full reset
implementation.

This patch also reverts the NVMe over Fabrics target reset
handling hack that was added as part of the NVMe over Fabrics host
commit to its previous state of just printing an error message.

Change-Id: I0aedd73dfd2dd1168e7b13b79575cc387737d4f0
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-23 16:34:41 -07:00
Daniel Verkamp
ed598ee066 nvme/rdma: fix log level for debug messages
Most of the NOTICE level messages should have been TRACE.

Change-Id: Icbc4d398ab2580cf3a2349be11441b7a09603020
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-23 16:34:13 -07:00
Daniel Verkamp
e2a2165550 nvme/rdma: use getaddrinfo() to parse service ID
Also remove unreachable code handling addr == NULL.

Change-Id: Ia6b5639853bbb6f4193a1b4352d465829b1293d1
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-23 16:34:13 -07:00
Daniel Verkamp
e15a704e2f nvme/rdma: fix nvme_rdma_qpair_destroy() NULL check
Verify that qpair is not NULL before doing pointer math on it.
The NULL check after calling nvme_rdma_qpair(qpair) would not
trigger if qpair was NULL.

Fixes a crash if the Connect command failed, causing
nvme_rdma_ctrlr_create_qpair() to return NULL.

Change-Id: I158a5b1752892a7d5a72a9ac20c0c5b2cd781a81
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-23 16:34:13 -07:00
Daniel Verkamp
648c15d1b9 nvme/rdma: fix connect error message
Change-Id: I21c4cc98fb5b1bd9c7714898599496def265ff83
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-23 16:34:13 -07:00
Ben Walker
aa3d7381cc nvme: Don't add discovery controller to attached_ctrlrs list.
Change-Id: I214b9291cc8f54928bdeb6f078d473661edfebfc
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-11-23 13:37:29 -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
16ae39419d nvme: untangle internal enum_cb complexity
Change-Id: I73ddb996a652b78534ce49e5d4e43b269940ec4d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-22 13:41:38 -07:00
Daniel Verkamp
1910c552f7 nvme/rdma: remove pointless nvme_rdma_ctrlr::cb
It always points to the same internal RDMA request complete function, so
just call that function directly.

Change-Id: Ic1fb6236bf43eaad62413df77d43be9ab855e5c7
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-21 17:02:12 -07:00
Daniel Verkamp
d75b2f6c6f nvme/rdma: use max BB size as max_xfer_size
We can't transfer more than the bounce buffer in a single command, so
report that rather than some bogus value.

Change-Id: I39b147916dcc2ee478470917298763a239a6a35a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-21 17:02:12 -07:00
Daniel Verkamp
be54ddb05c nvme/rdma: retrieve CAP during ctrlr_construct
Fill in the cached copy of CAP in the generic NVMe controller to match
the PCIe transport.

This is not really early enough, since CAP is used during the reset
process to determine the reset timeout, but that will have to be fixed
separately by rearranging some of the transport callbacks.

Change-Id: Ia8e20dbb8f21c2871afb9e00db56d0730e597331
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-21 17:02:11 -07:00
Daniel Verkamp
4544a8b2ee nvme/rdma: fix incorrect NQN strncpy() usage
Make sure the entire NQN field is zero-padded, rather than using
strlen() on the input.

Change-Id: Icee68bd033feed057813beeb30cec102ed90840e
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-21 17:02:11 -07:00