diff --git a/lib/nvmf/ctrlr.c b/lib/nvmf/ctrlr.c index 717243dec..f5c90178a 100644 --- a/lib/nvmf/ctrlr.c +++ b/lib/nvmf/ctrlr.c @@ -33,10 +33,7 @@ #include "spdk/stdinc.h" -#include "ctrlr.h" #include "nvmf_internal.h" -#include "request.h" -#include "subsystem.h" #include "transport.h" #include "spdk/io_channel.h" diff --git a/lib/nvmf/ctrlr.h b/lib/nvmf/ctrlr.h deleted file mode 100644 index d226fe806..000000000 --- a/lib/nvmf/ctrlr.h +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * BSD LICENSE - * - * Copyright (c) Intel Corporation. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SPDK_NVMF_CTRLR_H -#define SPDK_NVMF_CTRLR_H - -#include "spdk/stdinc.h" - -#include "spdk/nvmf_spec.h" -#include "spdk/queue.h" - -struct spdk_bdev; - -/* define a virtual controller limit to the number of QPs supported */ -#define MAX_QPAIRS_PER_CTRLR 64 - -struct spdk_nvmf_transport; -struct spdk_nvmf_request; - -enum spdk_nvmf_qpair_type { - QPAIR_TYPE_AQ = 0, - QPAIR_TYPE_IOQ = 1, -}; - -struct spdk_nvmf_qpair { - struct spdk_nvmf_transport *transport; - struct spdk_nvmf_ctrlr *ctrlr; - enum spdk_nvmf_qpair_type type; - - struct spdk_thread *thread; - - uint16_t qid; - uint16_t sq_head; - uint16_t sq_head_max; - - TAILQ_ENTRY(spdk_nvmf_qpair) link; -}; - -/* - * This structure represents an NVMe-oF controller, - * which is like a "session" in networking terms. - */ -struct spdk_nvmf_ctrlr { - uint16_t cntlid; - struct spdk_nvmf_subsystem *subsys; - - struct { - union spdk_nvme_cap_register cap; - union spdk_nvme_vs_register vs; - union spdk_nvme_cc_register cc; - union spdk_nvme_csts_register csts; - } vcprop; /* virtual controller properties */ - - TAILQ_HEAD(, spdk_nvmf_qpair) qpairs; - int num_qpairs; - int max_qpairs_allowed; - uint32_t kato; - union { - uint32_t raw; - struct { - union spdk_nvme_critical_warning_state crit_warn; - uint8_t ns_attr_notice : 1; - uint8_t fw_activation_notice : 1; - } bits; - } async_event_config; - struct spdk_nvmf_request *aer_req; - uint8_t hostid[16]; - struct spdk_nvmf_poll_group *group; - - TAILQ_ENTRY(spdk_nvmf_ctrlr) link; -}; - -void spdk_nvmf_ctrlr_connect(struct spdk_nvmf_qpair *qpair, - struct spdk_nvmf_fabric_connect_cmd *cmd, - struct spdk_nvmf_fabric_connect_data *data, - struct spdk_nvmf_fabric_connect_rsp *rsp); - -struct spdk_nvmf_qpair *spdk_nvmf_ctrlr_get_qpair(struct spdk_nvmf_ctrlr *ctrlr, uint16_t qid); - -void -spdk_nvmf_property_get(struct spdk_nvmf_ctrlr *ctrlr, - struct spdk_nvmf_fabric_prop_get_cmd *cmd, - struct spdk_nvmf_fabric_prop_get_rsp *response); - -void -spdk_nvmf_property_set(struct spdk_nvmf_ctrlr *ctrlr, - struct spdk_nvmf_fabric_prop_set_cmd *cmd, - struct spdk_nvme_cpl *rsp); - -int spdk_nvmf_ctrlr_poll(struct spdk_nvmf_ctrlr *ctrlr); - -void spdk_nvmf_ctrlr_destruct(struct spdk_nvmf_ctrlr *ctrlr); - -int spdk_nvmf_ctrlr_process_admin_cmd(struct spdk_nvmf_request *req); - -int spdk_nvmf_ctrlr_process_io_cmd(struct spdk_nvmf_request *req); - -bool spdk_nvmf_ctrlr_dsm_supported(struct spdk_nvmf_ctrlr *ctrlr); - -int spdk_nvmf_bdev_ctrlr_identify_ns(struct spdk_bdev *bdev, struct spdk_nvme_ns_data *nsdata); - -#endif diff --git a/lib/nvmf/ctrlr_bdev.c b/lib/nvmf/ctrlr_bdev.c index 62a421f09..bda57eac7 100644 --- a/lib/nvmf/ctrlr_bdev.c +++ b/lib/nvmf/ctrlr_bdev.c @@ -33,9 +33,7 @@ #include "spdk/stdinc.h" -#include "subsystem.h" -#include "ctrlr.h" -#include "request.h" +#include "nvmf_internal.h" #include "spdk/bdev.h" #include "spdk/endian.h" diff --git a/lib/nvmf/ctrlr_discovery.c b/lib/nvmf/ctrlr_discovery.c index 34993242c..80d2ef387 100644 --- a/lib/nvmf/ctrlr_discovery.c +++ b/lib/nvmf/ctrlr_discovery.c @@ -38,9 +38,6 @@ #include "spdk/stdinc.h" #include "nvmf_internal.h" -#include "ctrlr.h" -#include "subsystem.h" -#include "request.h" #include "transport.h" #include "spdk/string.h" diff --git a/lib/nvmf/nvmf.c b/lib/nvmf/nvmf.c index af7a2c601..d32fe4be0 100644 --- a/lib/nvmf/nvmf.c +++ b/lib/nvmf/nvmf.c @@ -40,8 +40,7 @@ #include "spdk_internal/log.h" -#include "ctrlr.h" -#include "subsystem.h" +#include "nvmf_internal.h" #include "transport.h" SPDK_LOG_REGISTER_TRACE_FLAG("nvmf", SPDK_TRACE_NVMF) diff --git a/lib/nvmf/nvmf_internal.h b/lib/nvmf/nvmf_internal.h index 9e1113b41..891177d22 100644 --- a/lib/nvmf/nvmf_internal.h +++ b/lib/nvmf/nvmf_internal.h @@ -80,6 +80,36 @@ struct spdk_nvmf_poll_group { TAILQ_ENTRY(spdk_nvmf_poll_group) link; }; +typedef enum _spdk_nvmf_request_exec_status { + SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE, + SPDK_NVMF_REQUEST_EXEC_STATUS_ASYNCHRONOUS, +} spdk_nvmf_request_exec_status; + +union nvmf_h2c_msg { + struct spdk_nvmf_capsule_cmd nvmf_cmd; + struct spdk_nvme_cmd nvme_cmd; + struct spdk_nvmf_fabric_prop_set_cmd prop_set_cmd; + struct spdk_nvmf_fabric_prop_get_cmd prop_get_cmd; + struct spdk_nvmf_fabric_connect_cmd connect_cmd; +}; +SPDK_STATIC_ASSERT(sizeof(union nvmf_h2c_msg) == 64, "Incorrect size"); + +union nvmf_c2h_msg { + struct spdk_nvme_cpl nvme_cpl; + struct spdk_nvmf_fabric_prop_get_rsp prop_get_rsp; + struct spdk_nvmf_fabric_connect_rsp connect_rsp; +}; +SPDK_STATIC_ASSERT(sizeof(union nvmf_c2h_msg) == 16, "Incorrect size"); + +struct spdk_nvmf_request { + struct spdk_nvmf_qpair *qpair; + uint32_t length; + enum spdk_nvme_data_transfer xfer; + void *data; + union nvmf_h2c_msg *cmd; + union nvmf_c2h_msg *rsp; +}; + struct spdk_nvmf_ns { struct spdk_bdev *bdev; struct spdk_bdev_desc *desc; @@ -88,6 +118,59 @@ struct spdk_nvmf_ns { bool allocated; }; +enum spdk_nvmf_qpair_type { + QPAIR_TYPE_AQ = 0, + QPAIR_TYPE_IOQ = 1, +}; + +struct spdk_nvmf_qpair { + struct spdk_nvmf_transport *transport; + struct spdk_nvmf_ctrlr *ctrlr; + enum spdk_nvmf_qpair_type type; + + struct spdk_thread *thread; + + uint16_t qid; + uint16_t sq_head; + uint16_t sq_head_max; + + TAILQ_ENTRY(spdk_nvmf_qpair) link; +}; + +/* + * This structure represents an NVMe-oF controller, + * which is like a "session" in networking terms. + */ +struct spdk_nvmf_ctrlr { + uint16_t cntlid; + struct spdk_nvmf_subsystem *subsys; + + struct { + union spdk_nvme_cap_register cap; + union spdk_nvme_vs_register vs; + union spdk_nvme_cc_register cc; + union spdk_nvme_csts_register csts; + } vcprop; /* virtual controller properties */ + + TAILQ_HEAD(, spdk_nvmf_qpair) qpairs; + int num_qpairs; + int max_qpairs_allowed; + uint32_t kato; + union { + uint32_t raw; + struct { + union spdk_nvme_critical_warning_state crit_warn; + uint8_t ns_attr_notice : 1; + uint8_t fw_activation_notice : 1; + } bits; + } async_event_config; + struct spdk_nvmf_request *aer_req; + uint8_t hostid[16]; + struct spdk_nvmf_poll_group *group; + + TAILQ_ENTRY(spdk_nvmf_ctrlr) link; +}; + struct spdk_nvmf_subsystem { uint32_t id; char subnqn[SPDK_NVMF_NQN_MAX_LEN + 1]; @@ -113,23 +196,50 @@ struct spdk_nvmf_subsystem { }; uint16_t spdk_nvmf_tgt_gen_cntlid(struct spdk_nvmf_tgt *tgt); - struct spdk_nvmf_transport *spdk_nvmf_tgt_get_transport(struct spdk_nvmf_tgt *tgt, enum spdk_nvme_transport_type); struct spdk_nvmf_poll_group *spdk_nvmf_poll_group_create( struct spdk_nvmf_tgt *tgt); - void spdk_nvmf_poll_group_destroy(struct spdk_nvmf_poll_group *group); - int spdk_nvmf_poll_group_add(struct spdk_nvmf_poll_group *group, struct spdk_nvmf_qpair *qpair); - int spdk_nvmf_poll_group_remove(struct spdk_nvmf_poll_group *group, struct spdk_nvmf_qpair *qpair); - int spdk_nvmf_poll_group_poll(struct spdk_nvmf_poll_group *group); +int spdk_nvmf_request_exec(struct spdk_nvmf_request *req); +int spdk_nvmf_request_complete(struct spdk_nvmf_request *req); +int spdk_nvmf_request_abort(struct spdk_nvmf_request *req); + +void spdk_nvmf_get_discovery_log_page(struct spdk_nvmf_tgt *tgt, + void *buffer, uint64_t offset, + uint32_t length); + +void spdk_nvmf_property_get(struct spdk_nvmf_ctrlr *ctrlr, + struct spdk_nvmf_fabric_prop_get_cmd *cmd, + struct spdk_nvmf_fabric_prop_get_rsp *response); + +void spdk_nvmf_property_set(struct spdk_nvmf_ctrlr *ctrlr, + struct spdk_nvmf_fabric_prop_set_cmd *cmd, + struct spdk_nvme_cpl *rsp); + +void spdk_nvmf_ctrlr_connect(struct spdk_nvmf_qpair *qpair, + struct spdk_nvmf_fabric_connect_cmd *cmd, + struct spdk_nvmf_fabric_connect_data *data, + struct spdk_nvmf_fabric_connect_rsp *rsp); +struct spdk_nvmf_qpair *spdk_nvmf_ctrlr_get_qpair(struct spdk_nvmf_ctrlr *ctrlr, uint16_t qid); +int spdk_nvmf_ctrlr_poll(struct spdk_nvmf_ctrlr *ctrlr); +void spdk_nvmf_ctrlr_destruct(struct spdk_nvmf_ctrlr *ctrlr); +int spdk_nvmf_ctrlr_process_admin_cmd(struct spdk_nvmf_request *req); +int spdk_nvmf_ctrlr_process_io_cmd(struct spdk_nvmf_request *req); +bool spdk_nvmf_ctrlr_dsm_supported(struct spdk_nvmf_ctrlr *ctrlr); + +int spdk_nvmf_bdev_ctrlr_identify_ns(struct spdk_bdev *bdev, struct spdk_nvme_ns_data *nsdata); + +int spdk_nvmf_subsystem_bdev_attach(struct spdk_nvmf_subsystem *subsystem); +void spdk_nvmf_subsystem_bdev_detach(struct spdk_nvmf_subsystem *subsystem); + static inline struct spdk_nvmf_ns * _spdk_nvmf_subsystem_get_ns(struct spdk_nvmf_subsystem *subsystem, uint32_t nsid) { diff --git a/lib/nvmf/rdma.c b/lib/nvmf/rdma.c index 7ce3c1747..f08cfe8aa 100644 --- a/lib/nvmf/rdma.c +++ b/lib/nvmf/rdma.c @@ -38,9 +38,6 @@ #include #include "nvmf_internal.h" -#include "request.h" -#include "ctrlr.h" -#include "subsystem.h" #include "transport.h" #include "spdk/assert.h" diff --git a/lib/nvmf/request.c b/lib/nvmf/request.c index e8a0a7904..9f11fbe5d 100644 --- a/lib/nvmf/request.c +++ b/lib/nvmf/request.c @@ -34,9 +34,6 @@ #include "spdk/stdinc.h" #include "nvmf_internal.h" -#include "request.h" -#include "ctrlr.h" -#include "subsystem.h" #include "transport.h" #include "spdk/io_channel.h" diff --git a/lib/nvmf/request.h b/lib/nvmf/request.h deleted file mode 100644 index b20841336..000000000 --- a/lib/nvmf/request.h +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * BSD LICENSE - * - * Copyright (c) Intel Corporation. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef NVMF_REQUEST_H -#define NVMF_REQUEST_H - -#include "spdk/nvmf_spec.h" -#include "spdk/queue.h" - -typedef enum _spdk_nvmf_request_exec_status { - SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE, - SPDK_NVMF_REQUEST_EXEC_STATUS_ASYNCHRONOUS, -} spdk_nvmf_request_exec_status; - -union nvmf_h2c_msg { - struct spdk_nvmf_capsule_cmd nvmf_cmd; - struct spdk_nvme_cmd nvme_cmd; - struct spdk_nvmf_fabric_prop_set_cmd prop_set_cmd; - struct spdk_nvmf_fabric_prop_get_cmd prop_get_cmd; - struct spdk_nvmf_fabric_connect_cmd connect_cmd; -}; -SPDK_STATIC_ASSERT(sizeof(union nvmf_h2c_msg) == 64, "Incorrect size"); - -union nvmf_c2h_msg { - struct spdk_nvme_cpl nvme_cpl; - struct spdk_nvmf_fabric_prop_get_rsp prop_get_rsp; - struct spdk_nvmf_fabric_connect_rsp connect_rsp; -}; -SPDK_STATIC_ASSERT(sizeof(union nvmf_c2h_msg) == 16, "Incorrect size"); - -struct spdk_nvmf_request { - struct spdk_nvmf_qpair *qpair; - uint32_t length; - enum spdk_nvme_data_transfer xfer; - void *data; - union nvmf_h2c_msg *cmd; - union nvmf_c2h_msg *rsp; -}; - -int -spdk_nvmf_request_exec(struct spdk_nvmf_request *req); - -int spdk_nvmf_request_complete(struct spdk_nvmf_request *req); - -int spdk_nvmf_request_abort(struct spdk_nvmf_request *req); - -#endif diff --git a/lib/nvmf/subsystem.c b/lib/nvmf/subsystem.c index 851bf0450..46776053f 100644 --- a/lib/nvmf/subsystem.c +++ b/lib/nvmf/subsystem.c @@ -34,8 +34,6 @@ #include "spdk/stdinc.h" #include "nvmf_internal.h" -#include "ctrlr.h" -#include "subsystem.h" #include "transport.h" #include "spdk/likely.h" diff --git a/lib/nvmf/subsystem.h b/lib/nvmf/subsystem.h deleted file mode 100644 index 248b45f20..000000000 --- a/lib/nvmf/subsystem.h +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * BSD LICENSE - * - * Copyright (c) Intel Corporation. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SPDK_NVMF_SUBSYSTEM_H -#define SPDK_NVMF_SUBSYSTEM_H - -#include "nvmf_internal.h" - -#include "spdk/nvme.h" -#include "spdk/nvmf.h" - -void spdk_nvmf_get_discovery_log_page(struct spdk_nvmf_tgt *tgt, - void *buffer, uint64_t offset, - uint32_t length); - -int spdk_nvmf_subsystem_bdev_attach(struct spdk_nvmf_subsystem *subsystem); -void spdk_nvmf_subsystem_bdev_detach(struct spdk_nvmf_subsystem *subsystem); - -#endif /* SPDK_NVMF_SUBSYSTEM_H */ diff --git a/lib/nvmf/transport.c b/lib/nvmf/transport.c index 9eea680c8..150caf1a6 100644 --- a/lib/nvmf/transport.c +++ b/lib/nvmf/transport.c @@ -33,6 +33,7 @@ #include "spdk/stdinc.h" +#include "nvmf_internal.h" #include "transport.h" #include "spdk/log.h" @@ -40,10 +41,6 @@ #include "spdk/queue.h" #include "spdk/util.h" -#include "ctrlr.h" -#include "nvmf_internal.h" -#include "request.h" - static const struct spdk_nvmf_transport_ops *const g_transport_ops[] = { #ifdef SPDK_CONFIG_RDMA &spdk_nvmf_transport_rdma, diff --git a/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c b/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c index 982bd200f..abda3e2ec 100644 --- a/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c +++ b/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c @@ -34,7 +34,6 @@ #include "spdk/stdinc.h" #include "spdk_cunit.h" -#include "subsystem.h" #include "subsystem.c"