nvme: add a public API to rename spdk_nvme_ctrlr_opts_set_defaults
This change is relating to add a new public API spdk_nvme_connect() under include/spdk/nvme.h. This new spdk_nvme_connect() API will connect the user specified trid and have a user optional ctlr opts. Rename this API and make it as public. A typical usage of this API as following: 1. struct spdk_nvme_ctrlr_opts user_opts = {} 2. Call spdk_nvme_ctrlr_get_default_ctrlr_opts(&user_opts, sizeof(user_opts)) 3. Modify the content of the initialized user_opts with user required value like user_opts.num_io_queues = 8 4. Call spdk_nvme_connect(&trid, &user_opts, sizeof(user_opts)) Change-Id: Ideec8247365ebf7dd15069e29821be8ea27b08be Signed-off-by: GangCao <gang.cao@intel.com> Reviewed-on: https://review.gerrithub.io/380849 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
356a9bc7d3
commit
dc2fb2ed39
@ -146,6 +146,15 @@ struct spdk_nvme_ctrlr_opts {
|
||||
uint8_t extended_host_id[16];
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Get the default options for the creation of a specific NVMe controller.
|
||||
*
|
||||
* \param[out] opts Will be filled with the default option.
|
||||
* \param opts_size Must be set to sizeof(struct spdk_nvme_ctrlr_opts).
|
||||
*/
|
||||
void spdk_nvme_ctrlr_get_default_ctrlr_opts(struct spdk_nvme_ctrlr_opts *opts,
|
||||
size_t opts_size);
|
||||
|
||||
/**
|
||||
* NVMe library transports
|
||||
*
|
||||
|
@ -320,7 +320,7 @@ nvme_ctrlr_probe(const struct spdk_nvme_transport_id *trid, void *devhandle,
|
||||
struct spdk_nvme_ctrlr *ctrlr;
|
||||
struct spdk_nvme_ctrlr_opts opts;
|
||||
|
||||
spdk_nvme_ctrlr_opts_set_defaults(&opts, sizeof(opts));
|
||||
spdk_nvme_ctrlr_get_default_ctrlr_opts(&opts, sizeof(opts));
|
||||
|
||||
if (probe_cb(cb_ctx, trid, &opts)) {
|
||||
ctrlr = nvme_transport_ctrlr_construct(trid, &opts, devhandle);
|
||||
|
@ -78,7 +78,7 @@ nvme_ctrlr_set_cc(struct spdk_nvme_ctrlr *ctrlr, const union spdk_nvme_cc_regist
|
||||
}
|
||||
|
||||
void
|
||||
spdk_nvme_ctrlr_opts_set_defaults(struct spdk_nvme_ctrlr_opts *opts, size_t opts_size)
|
||||
spdk_nvme_ctrlr_get_default_ctrlr_opts(struct spdk_nvme_ctrlr_opts *opts, size_t opts_size)
|
||||
{
|
||||
char host_id_str[37];
|
||||
|
||||
|
@ -587,8 +587,6 @@ void nvme_free_request(struct nvme_request *req);
|
||||
void nvme_request_remove_child(struct nvme_request *parent, struct nvme_request *child);
|
||||
uint64_t nvme_get_quirks(const struct spdk_pci_id *id);
|
||||
|
||||
void spdk_nvme_ctrlr_opts_set_defaults(struct spdk_nvme_ctrlr_opts *opts, size_t opts_size);
|
||||
|
||||
int nvme_robust_mutex_init_shared(pthread_mutex_t *mtx);
|
||||
int nvme_robust_mutex_init_recursive_shared(pthread_mutex_t *mtx);
|
||||
|
||||
|
@ -1192,7 +1192,7 @@ nvme_rdma_ctrlr_scan(const struct spdk_nvme_transport_id *discovery_trid,
|
||||
return rc;
|
||||
}
|
||||
|
||||
spdk_nvme_ctrlr_opts_set_defaults(&discovery_opts, sizeof(discovery_opts));
|
||||
spdk_nvme_ctrlr_get_default_ctrlr_opts(&discovery_opts, sizeof(discovery_opts));
|
||||
/* For discovery_ctrlr set the timeout to 0 */
|
||||
discovery_opts.keep_alive_timeout_ms = 0;
|
||||
|
||||
|
@ -95,7 +95,7 @@ nvme_ctrlr_destruct(struct spdk_nvme_ctrlr *ctrlr)
|
||||
}
|
||||
|
||||
void
|
||||
spdk_nvme_ctrlr_opts_set_defaults(struct spdk_nvme_ctrlr_opts *opts, size_t opts_size)
|
||||
spdk_nvme_ctrlr_get_default_ctrlr_opts(struct spdk_nvme_ctrlr_opts *opts, size_t opts_size)
|
||||
{
|
||||
memset(opts, 0, sizeof(*opts));
|
||||
}
|
||||
|
@ -1402,7 +1402,7 @@ test_nvme_ctrlr_set_supported_features(void)
|
||||
}
|
||||
|
||||
static void
|
||||
test_ctrlr_opts_set_defaults(void)
|
||||
test_ctrlr_get_default_ctrlr_opts(void)
|
||||
{
|
||||
struct spdk_nvme_ctrlr_opts opts = {};
|
||||
uuid_t uuid;
|
||||
@ -1415,7 +1415,7 @@ test_ctrlr_opts_set_defaults(void)
|
||||
|
||||
/* set a smaller opts_size */
|
||||
CU_ASSERT(sizeof(opts) > 8);
|
||||
spdk_nvme_ctrlr_opts_set_defaults(&opts, 8);
|
||||
spdk_nvme_ctrlr_get_default_ctrlr_opts(&opts, 8);
|
||||
CU_ASSERT_EQUAL(opts.num_io_queues, DEFAULT_MAX_IO_QUEUES);
|
||||
CU_ASSERT_TRUE(opts.use_cmb_sqs);
|
||||
/* check below fields are not initialized by default value */
|
||||
@ -1434,7 +1434,7 @@ test_ctrlr_opts_set_defaults(void)
|
||||
CU_ASSERT(strlen(opts.src_svcid) == 0);
|
||||
|
||||
/* set a consistent opts_size */
|
||||
spdk_nvme_ctrlr_opts_set_defaults(&opts, sizeof(opts));
|
||||
spdk_nvme_ctrlr_get_default_ctrlr_opts(&opts, sizeof(opts));
|
||||
CU_ASSERT_EQUAL(opts.num_io_queues, DEFAULT_MAX_IO_QUEUES);
|
||||
CU_ASSERT_TRUE(opts.use_cmb_sqs);
|
||||
CU_ASSERT_EQUAL(opts.arb_mechanism, SPDK_NVME_CC_AMS_RR);
|
||||
@ -1605,7 +1605,7 @@ int main(int argc, char **argv)
|
||||
|| CU_add_test(suite, "test nvme_ctrlr init CC.EN = 0 CSTS.RDY = 0 AMS = VS",
|
||||
test_nvme_ctrlr_init_en_0_rdy_0_ams_vs) == NULL
|
||||
|| CU_add_test(suite, "alloc_io_qpair_rr 1", test_alloc_io_qpair_rr_1) == NULL
|
||||
|| CU_add_test(suite, "set_defaults", test_ctrlr_opts_set_defaults) == NULL
|
||||
|| CU_add_test(suite, "get_default_ctrlr_opts", test_ctrlr_get_default_ctrlr_opts) == NULL
|
||||
|| CU_add_test(suite, "get_default_io_qpair_opts", test_ctrlr_get_default_io_qpair_opts) == NULL
|
||||
|| CU_add_test(suite, "alloc_io_qpair_wrr 1", test_alloc_io_qpair_wrr_1) == NULL
|
||||
|| CU_add_test(suite, "alloc_io_qpair_wrr 2", test_alloc_io_qpair_wrr_2) == NULL
|
||||
|
@ -135,7 +135,7 @@ spdk_pci_addr_compare(const struct spdk_pci_addr *a1, const struct spdk_pci_addr
|
||||
}
|
||||
|
||||
void
|
||||
spdk_nvme_ctrlr_opts_set_defaults(struct spdk_nvme_ctrlr_opts *opts, size_t opts_size)
|
||||
spdk_nvme_ctrlr_get_default_ctrlr_opts(struct spdk_nvme_ctrlr_opts *opts, size_t opts_size)
|
||||
{
|
||||
memset(opts, 0, sizeof(*opts));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user