nvmf: Change spdk_nvmf_tgt_init to take an options struct
The list of options is going to continue to grow, so avoid constant API churn by adding an options struct. Change-Id: Ie9e7248281726d4aee42b3519fcf7535ba01ee34 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/374872 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
977d78778b
commit
d868cd0895
@ -59,22 +59,6 @@ struct spdk_nvmf_probe_ctx {
|
||||
|
||||
#define MAX_STRING_LEN 255
|
||||
|
||||
#define SPDK_NVMF_CONFIG_QUEUES_PER_SESSION_DEFAULT 4
|
||||
#define SPDK_NVMF_CONFIG_QUEUES_PER_SESSION_MIN 2
|
||||
#define SPDK_NVMF_CONFIG_QUEUES_PER_SESSION_MAX 1024
|
||||
|
||||
#define SPDK_NVMF_CONFIG_QUEUE_DEPTH_DEFAULT 128
|
||||
#define SPDK_NVMF_CONFIG_QUEUE_DEPTH_MIN 16
|
||||
#define SPDK_NVMF_CONFIG_QUEUE_DEPTH_MAX 1024
|
||||
|
||||
#define SPDK_NVMF_CONFIG_IN_CAPSULE_DATA_SIZE_DEFAULT 4096
|
||||
#define SPDK_NVMF_CONFIG_IN_CAPSULE_DATA_SIZE_MIN 4096
|
||||
#define SPDK_NVMF_CONFIG_IN_CAPSULE_DATA_SIZE_MAX 131072
|
||||
|
||||
#define SPDK_NVMF_CONFIG_MAX_IO_SIZE_DEFAULT 131072
|
||||
#define SPDK_NVMF_CONFIG_MAX_IO_SIZE_MIN 4096
|
||||
#define SPDK_NVMF_CONFIG_MAX_IO_SIZE_MAX 131072
|
||||
|
||||
struct spdk_nvmf_tgt_conf g_spdk_nvmf_tgt_conf;
|
||||
static int32_t g_last_core = -1;
|
||||
|
||||
@ -148,6 +132,7 @@ static int
|
||||
spdk_nvmf_parse_nvmf_tgt(void)
|
||||
{
|
||||
struct spdk_conf_section *sp;
|
||||
struct spdk_nvmf_tgt_opts opts;
|
||||
int max_queue_depth;
|
||||
int max_queues_per_sess;
|
||||
int in_capsule_data_size;
|
||||
@ -162,39 +147,27 @@ spdk_nvmf_parse_nvmf_tgt(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
spdk_nvmf_tgt_opts_init(&opts);
|
||||
|
||||
max_queue_depth = spdk_conf_section_get_intval(sp, "MaxQueueDepth");
|
||||
if (max_queue_depth < 0) {
|
||||
max_queue_depth = SPDK_NVMF_CONFIG_QUEUE_DEPTH_DEFAULT;
|
||||
if (max_queue_depth >= 0) {
|
||||
opts.max_queue_depth = max_queue_depth;
|
||||
}
|
||||
max_queue_depth = spdk_max(max_queue_depth, SPDK_NVMF_CONFIG_QUEUE_DEPTH_MIN);
|
||||
max_queue_depth = spdk_min(max_queue_depth, SPDK_NVMF_CONFIG_QUEUE_DEPTH_MAX);
|
||||
|
||||
max_queues_per_sess = spdk_conf_section_get_intval(sp, "MaxQueuesPerSession");
|
||||
if (max_queues_per_sess < 0) {
|
||||
max_queues_per_sess = SPDK_NVMF_CONFIG_QUEUES_PER_SESSION_DEFAULT;
|
||||
if (max_queues_per_sess >= 0) {
|
||||
opts.max_qpairs_per_ctrlr = max_queues_per_sess;
|
||||
}
|
||||
max_queues_per_sess = spdk_max(max_queues_per_sess, SPDK_NVMF_CONFIG_QUEUES_PER_SESSION_MIN);
|
||||
max_queues_per_sess = spdk_min(max_queues_per_sess, SPDK_NVMF_CONFIG_QUEUES_PER_SESSION_MAX);
|
||||
|
||||
in_capsule_data_size = spdk_conf_section_get_intval(sp, "InCapsuleDataSize");
|
||||
if (in_capsule_data_size < 0) {
|
||||
in_capsule_data_size = SPDK_NVMF_CONFIG_IN_CAPSULE_DATA_SIZE_DEFAULT;
|
||||
} else if ((in_capsule_data_size % 16) != 0) {
|
||||
SPDK_ERRLOG("InCapsuleDataSize must be a multiple of 16\n");
|
||||
return -1;
|
||||
if (in_capsule_data_size >= 0) {
|
||||
opts.in_capsule_data_size = in_capsule_data_size;
|
||||
}
|
||||
in_capsule_data_size = spdk_max(in_capsule_data_size, SPDK_NVMF_CONFIG_IN_CAPSULE_DATA_SIZE_MIN);
|
||||
in_capsule_data_size = spdk_min(in_capsule_data_size, SPDK_NVMF_CONFIG_IN_CAPSULE_DATA_SIZE_MAX);
|
||||
|
||||
max_io_size = spdk_conf_section_get_intval(sp, "MaxIOSize");
|
||||
if (max_io_size < 0) {
|
||||
max_io_size = SPDK_NVMF_CONFIG_MAX_IO_SIZE_DEFAULT;
|
||||
} else if ((max_io_size % 4096) != 0) {
|
||||
SPDK_ERRLOG("MaxIOSize must be a multiple of 4096\n");
|
||||
return -1;
|
||||
if (max_io_size >= 0) {
|
||||
opts.max_io_size = max_io_size;
|
||||
}
|
||||
max_io_size = spdk_max(max_io_size, SPDK_NVMF_CONFIG_MAX_IO_SIZE_MIN);
|
||||
max_io_size = spdk_min(max_io_size, SPDK_NVMF_CONFIG_MAX_IO_SIZE_MAX);
|
||||
|
||||
acceptor_lcore = spdk_conf_section_get_intval(sp, "AcceptorCore");
|
||||
if (acceptor_lcore < 0) {
|
||||
@ -208,7 +181,7 @@ spdk_nvmf_parse_nvmf_tgt(void)
|
||||
}
|
||||
g_spdk_nvmf_tgt_conf.acceptor_poll_rate = acceptor_poll_rate;
|
||||
|
||||
rc = spdk_nvmf_tgt_init(max_queue_depth, max_queues_per_sess, in_capsule_data_size, max_io_size);
|
||||
rc = spdk_nvmf_tgt_init(&opts);
|
||||
if (rc != 0) {
|
||||
SPDK_ERRLOG("spdk_nvmf_tgt_init() failed\n");
|
||||
return rc;
|
||||
|
@ -48,8 +48,16 @@
|
||||
#define MAX_VIRTUAL_NAMESPACE 16
|
||||
#define MAX_SN_LEN 20
|
||||
|
||||
int spdk_nvmf_tgt_init(uint16_t max_queue_depth, uint16_t max_qpair_per_ctrlr,
|
||||
uint32_t in_capsule_data_size, uint32_t max_io_size);
|
||||
struct spdk_nvmf_tgt_opts {
|
||||
uint16_t max_queue_depth;
|
||||
uint16_t max_qpairs_per_ctrlr;
|
||||
uint32_t in_capsule_data_size;
|
||||
uint32_t max_io_size;
|
||||
};
|
||||
|
||||
void spdk_nvmf_tgt_opts_init(struct spdk_nvmf_tgt_opts *opts);
|
||||
|
||||
int spdk_nvmf_tgt_init(struct spdk_nvmf_tgt_opts *opts);
|
||||
|
||||
int spdk_nvmf_tgt_fini(void);
|
||||
|
||||
|
@ -88,7 +88,7 @@ spdk_nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem,
|
||||
ctrlr->async_event_config.raw = 0;
|
||||
ctrlr->num_qpairs = 0;
|
||||
ctrlr->subsys = subsystem;
|
||||
ctrlr->max_qpairs_allowed = g_nvmf_tgt.max_qpairs_per_ctrlr;
|
||||
ctrlr->max_qpairs_allowed = g_nvmf_tgt.opts.max_qpairs_per_ctrlr;
|
||||
|
||||
memcpy(ctrlr->hostid, connect_data->hostid, sizeof(ctrlr->hostid));
|
||||
|
||||
@ -100,7 +100,7 @@ spdk_nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem,
|
||||
|
||||
ctrlr->vcprop.cap.raw = 0;
|
||||
ctrlr->vcprop.cap.bits.cqr = 1; /* NVMe-oF specification required */
|
||||
ctrlr->vcprop.cap.bits.mqes = g_nvmf_tgt.max_queue_depth - 1; /* max queue depth */
|
||||
ctrlr->vcprop.cap.bits.mqes = g_nvmf_tgt.opts.max_queue_depth - 1; /* max queue depth */
|
||||
ctrlr->vcprop.cap.bits.ams = 0; /* optional arb mechanisms */
|
||||
ctrlr->vcprop.cap.bits.to = 1; /* ready timeout - 500 msec units */
|
||||
ctrlr->vcprop.cap.bits.dstrd = 0; /* fixed to 0 for NVMe-oF */
|
||||
@ -235,9 +235,9 @@ spdk_nvmf_ctrlr_connect(struct spdk_nvmf_qpair *qpair,
|
||||
* SQSIZE is a 0-based value, so it must be at least 1 (minimum queue depth is 2) and
|
||||
* strictly less than max_queue_depth.
|
||||
*/
|
||||
if (cmd->sqsize == 0 || cmd->sqsize >= g_nvmf_tgt.max_queue_depth) {
|
||||
if (cmd->sqsize == 0 || cmd->sqsize >= g_nvmf_tgt.opts.max_queue_depth) {
|
||||
SPDK_ERRLOG("Invalid SQSIZE %u (min 1, max %u)\n",
|
||||
cmd->sqsize, g_nvmf_tgt.max_queue_depth - 1);
|
||||
cmd->sqsize, g_nvmf_tgt.opts.max_queue_depth - 1);
|
||||
INVALID_CONNECT_CMD(sqsize);
|
||||
return;
|
||||
}
|
||||
@ -866,13 +866,13 @@ spdk_nvmf_ctrlr_identify_ctrlr(struct spdk_nvmf_ctrlr *ctrlr, struct spdk_nvme_c
|
||||
* Common fields for discovery and NVM subsystems
|
||||
*/
|
||||
spdk_strcpy_pad(cdata->fr, FW_VERSION, sizeof(cdata->fr), ' ');
|
||||
assert((g_nvmf_tgt.max_io_size % 4096) == 0);
|
||||
cdata->mdts = spdk_u32log2(g_nvmf_tgt.max_io_size / 4096);
|
||||
assert((g_nvmf_tgt.opts.max_io_size % 4096) == 0);
|
||||
cdata->mdts = spdk_u32log2(g_nvmf_tgt.opts.max_io_size / 4096);
|
||||
cdata->cntlid = ctrlr->cntlid;
|
||||
cdata->ver = ctrlr->vcprop.vs;
|
||||
cdata->lpa.edlp = 1;
|
||||
cdata->elpe = 127;
|
||||
cdata->maxcmd = g_nvmf_tgt.max_queue_depth;
|
||||
cdata->maxcmd = g_nvmf_tgt.opts.max_queue_depth;
|
||||
cdata->sgls.supported = 1;
|
||||
cdata->sgls.keyed_sgl = 1;
|
||||
cdata->sgls.sgl_offset = 1;
|
||||
@ -910,7 +910,7 @@ spdk_nvmf_ctrlr_identify_ctrlr(struct spdk_nvmf_ctrlr *ctrlr, struct spdk_nvme_c
|
||||
cdata->nvmf_specific.msdbd = 1; /* target supports single SGL in capsule */
|
||||
|
||||
/* TODO: this should be set by the transport */
|
||||
cdata->nvmf_specific.ioccsz += g_nvmf_tgt.in_capsule_data_size / 16;
|
||||
cdata->nvmf_specific.ioccsz += g_nvmf_tgt.opts.in_capsule_data_size / 16;
|
||||
|
||||
cdata->oncs.dsm = spdk_nvmf_ctrlr_dsm_supported(ctrlr);
|
||||
|
||||
|
@ -96,7 +96,7 @@ nvmf_update_discovery_log(void)
|
||||
memset(entry, 0, sizeof(*entry));
|
||||
entry->portid = numrec;
|
||||
entry->cntlid = 0xffff;
|
||||
entry->asqsz = g_nvmf_tgt.max_queue_depth;
|
||||
entry->asqsz = g_nvmf_tgt.opts.max_queue_depth;
|
||||
entry->subtype = subsystem->subtype;
|
||||
snprintf(entry->subnqn, sizeof(entry->subnqn), "%s", subsystem->subnqn);
|
||||
|
||||
|
@ -46,16 +46,31 @@ SPDK_LOG_REGISTER_TRACE_FLAG("nvmf", SPDK_TRACE_NVMF)
|
||||
|
||||
#define MAX_SUBSYSTEMS 4
|
||||
|
||||
#define SPDK_NVMF_DEFAULT_MAX_QUEUE_DEPTH 128
|
||||
#define SPDK_NVMF_DEFAULT_MAX_QPAIRS_PER_CTRLR 64
|
||||
#define SPDK_NVMF_DEFAULT_IN_CAPSULE_DATA_SIZE 4096
|
||||
#define SPDK_NVMF_DEFAULT_MAX_IO_SIZE 131072
|
||||
|
||||
struct spdk_nvmf_tgt g_nvmf_tgt;
|
||||
|
||||
int
|
||||
spdk_nvmf_tgt_init(uint16_t max_queue_depth, uint16_t max_qpairs_per_ctrlr,
|
||||
uint32_t in_capsule_data_size, uint32_t max_io_size)
|
||||
void
|
||||
spdk_nvmf_tgt_opts_init(struct spdk_nvmf_tgt_opts *opts)
|
||||
{
|
||||
g_nvmf_tgt.max_qpairs_per_ctrlr = max_qpairs_per_ctrlr;
|
||||
g_nvmf_tgt.max_queue_depth = max_queue_depth;
|
||||
g_nvmf_tgt.in_capsule_data_size = in_capsule_data_size;
|
||||
g_nvmf_tgt.max_io_size = max_io_size;
|
||||
opts->max_queue_depth = SPDK_NVMF_DEFAULT_MAX_QUEUE_DEPTH;
|
||||
opts->max_qpairs_per_ctrlr = SPDK_NVMF_DEFAULT_MAX_QPAIRS_PER_CTRLR;
|
||||
opts->in_capsule_data_size = SPDK_NVMF_DEFAULT_IN_CAPSULE_DATA_SIZE;
|
||||
opts->max_io_size = SPDK_NVMF_DEFAULT_MAX_IO_SIZE;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvmf_tgt_init(struct spdk_nvmf_tgt_opts *opts)
|
||||
{
|
||||
if (!opts) {
|
||||
spdk_nvmf_tgt_opts_init(&g_nvmf_tgt.opts);
|
||||
} else {
|
||||
g_nvmf_tgt.opts = *opts;
|
||||
}
|
||||
|
||||
g_nvmf_tgt.discovery_genctr = 0;
|
||||
g_nvmf_tgt.discovery_log_page = NULL;
|
||||
g_nvmf_tgt.discovery_log_page_size = 0;
|
||||
@ -64,10 +79,12 @@ spdk_nvmf_tgt_init(uint16_t max_queue_depth, uint16_t max_qpairs_per_ctrlr,
|
||||
TAILQ_INIT(&g_nvmf_tgt.listen_addrs);
|
||||
TAILQ_INIT(&g_nvmf_tgt.transports);
|
||||
|
||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Max Queue Pairs Per Controller: %d\n", max_qpairs_per_ctrlr);
|
||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Max Queue Depth: %d\n", max_queue_depth);
|
||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Max In Capsule Data: %d bytes\n", in_capsule_data_size);
|
||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Max I/O Size: %d bytes\n", max_io_size);
|
||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Max Queue Pairs Per Controller: %d\n",
|
||||
g_nvmf_tgt.opts.max_qpairs_per_ctrlr);
|
||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Max Queue Depth: %d\n", g_nvmf_tgt.opts.max_queue_depth);
|
||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Max In Capsule Data: %d bytes\n",
|
||||
g_nvmf_tgt.opts.in_capsule_data_size);
|
||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Max I/O Size: %d bytes\n", g_nvmf_tgt.opts.max_io_size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -46,10 +46,8 @@
|
||||
#define SPDK_NVMF_DEFAULT_NUM_CTRLRS_PER_LCORE 1
|
||||
|
||||
struct spdk_nvmf_tgt {
|
||||
uint16_t max_queue_depth;
|
||||
uint16_t max_qpairs_per_ctrlr;
|
||||
uint32_t in_capsule_data_size;
|
||||
uint32_t max_io_size;
|
||||
struct spdk_nvmf_tgt_opts opts;
|
||||
|
||||
uint64_t discovery_genctr;
|
||||
TAILQ_HEAD(, spdk_nvmf_subsystem) subsystems;
|
||||
struct spdk_nvmf_discovery_log_page *discovery_log_page;
|
||||
|
@ -1099,9 +1099,9 @@ spdk_nvmf_rdma_create(struct spdk_nvmf_tgt *tgt)
|
||||
|
||||
SPDK_NOTICELOG("*** RDMA Transport Init ***\n");
|
||||
|
||||
rtransport->max_queue_depth = tgt->max_queue_depth;
|
||||
rtransport->max_io_size = tgt->max_io_size;
|
||||
rtransport->in_capsule_data_size = tgt->in_capsule_data_size;
|
||||
rtransport->max_queue_depth = tgt->opts.max_queue_depth;
|
||||
rtransport->max_io_size = tgt->opts.max_io_size;
|
||||
rtransport->in_capsule_data_size = tgt->opts.in_capsule_data_size;
|
||||
|
||||
rtransport->event_channel = rdma_create_event_channel();
|
||||
if (rtransport->event_channel == NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user