nvmf: deduplicate transport listen dump opts

Signed-off-by: Jacek Kalwas <jacek.kalwas@intel.com>
Change-Id: I1a4818a33cd82fce7dfb57030f2530522a01c45f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9354
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Jacek Kalwas 2021-09-01 04:28:10 -04:00 committed by Tomasz Zawadzki
parent 220bcf7d74
commit 1f094a9405
7 changed files with 24 additions and 27 deletions

View File

@ -443,7 +443,6 @@ nvmf_write_subsystem_config_json(struct spdk_json_write_ctx *w,
struct spdk_nvmf_ns_opts ns_opts;
uint32_t max_namespaces;
char uuid_str[SPDK_UUID_STRING_LEN];
const char *adrfam;
if (spdk_nvmf_subsystem_get_type(subsystem) != SPDK_NVMF_SUBTYPE_NVME) {
return;
@ -479,8 +478,6 @@ nvmf_write_subsystem_config_json(struct spdk_json_write_ctx *w,
listener = spdk_nvmf_subsystem_get_next_listener(subsystem, listener)) {
trid = spdk_nvmf_subsystem_listener_get_trid(listener);
adrfam = spdk_nvme_transport_id_adrfam_str(trid->adrfam);
spdk_json_write_object_begin(w);
spdk_json_write_named_string(w, "method", "nvmf_subsystem_add_listener");
@ -488,19 +485,7 @@ nvmf_write_subsystem_config_json(struct spdk_json_write_ctx *w,
spdk_json_write_named_object_begin(w, "params");
spdk_json_write_named_string(w, "nqn", spdk_nvmf_subsystem_get_nqn(subsystem));
/* "listen_address" : { */
spdk_json_write_named_object_begin(w, "listen_address");
spdk_json_write_named_string(w, "trtype", trid->trstring);
if (adrfam) {
spdk_json_write_named_string(w, "adrfam", adrfam);
}
spdk_json_write_named_string(w, "traddr", trid->traddr);
spdk_json_write_named_string(w, "trsvcid", trid->trsvcid);
/* } "listen_address" */
spdk_json_write_object_end(w);
nvmf_transport_listen_dump_opts(listener->transport, trid, w);
/* } "params" */
spdk_json_write_object_end(w);

View File

@ -391,6 +391,8 @@ struct spdk_nvmf_listener *nvmf_transport_find_listener(
const struct spdk_nvme_transport_id *trid);
void nvmf_transport_dump_opts(struct spdk_nvmf_transport *transport, struct spdk_json_write_ctx *w,
bool named);
void nvmf_transport_listen_dump_opts(struct spdk_nvmf_transport *transport,
const struct spdk_nvme_transport_id *trid, struct spdk_json_write_ctx *w);
void nvmf_subsystem_set_ana_state(struct spdk_nvmf_subsystem *subsystem,
const struct spdk_nvme_transport_id *trid,
enum spdk_nvme_ana_state ana_state, uint32_t anagrpid,

View File

@ -2141,7 +2141,6 @@ static void
dump_nvmf_qpair(struct spdk_json_write_ctx *w, struct spdk_nvmf_qpair *qpair)
{
struct spdk_nvme_transport_id listen_trid = {};
const char *adrfam;
spdk_json_write_object_begin(w);
@ -2150,16 +2149,7 @@ dump_nvmf_qpair(struct spdk_json_write_ctx *w, struct spdk_nvmf_qpair *qpair)
spdk_json_write_named_string(w, "state", nvmf_qpair_state_str(qpair->state));
if (spdk_nvmf_qpair_get_listen_trid(qpair, &listen_trid) == 0) {
spdk_json_write_named_object_begin(w, "listen_address");
adrfam = spdk_nvme_transport_id_adrfam_str(listen_trid.adrfam);
if (adrfam == NULL) {
adrfam = "unknown";
}
spdk_json_write_named_string(w, "trtype", listen_trid.trstring);
spdk_json_write_named_string(w, "adrfam", adrfam);
spdk_json_write_named_string(w, "traddr", listen_trid.traddr);
spdk_json_write_named_string(w, "trsvcid", listen_trid.trsvcid);
spdk_json_write_object_end(w);
nvmf_transport_listen_dump_opts(qpair->transport, &listen_trid, w);
}
spdk_json_write_object_end(w);

View File

@ -123,6 +123,22 @@ nvmf_transport_dump_opts(struct spdk_nvmf_transport *transport, struct spdk_json
spdk_json_write_object_end(w);
}
void
nvmf_transport_listen_dump_opts(struct spdk_nvmf_transport *transport,
const struct spdk_nvme_transport_id *trid, struct spdk_json_write_ctx *w)
{
const char *adrfam = spdk_nvme_transport_id_adrfam_str(trid->adrfam);
spdk_json_write_named_object_begin(w, "listen_address");
spdk_json_write_named_string(w, "trtype", trid->trstring);
spdk_json_write_named_string(w, "adrfam", adrfam ? adrfam : "unknown");
spdk_json_write_named_string(w, "traddr", trid->traddr);
spdk_json_write_named_string(w, "trsvcid", trid->trsvcid);
spdk_json_write_object_end(w);
}
spdk_nvme_transport_type_t
spdk_nvmf_get_transport_type(struct spdk_nvmf_transport *transport)
{

View File

@ -130,6 +130,8 @@ DEFINE_STUB(spdk_nvmf_subsystem_get_first, struct spdk_nvmf_subsystem *,
(struct spdk_nvmf_tgt *tgt), NULL);
DEFINE_STUB_V(nvmf_transport_dump_opts, (struct spdk_nvmf_transport *transport,
struct spdk_json_write_ctx *w, bool named));
DEFINE_STUB_V(nvmf_transport_listen_dump_opts, (struct spdk_nvmf_transport *transport,
const struct spdk_nvme_transport_id *trid, struct spdk_json_write_ctx *w));
struct spdk_io_channel {
struct spdk_thread *thread;

View File

@ -76,6 +76,7 @@ DEFINE_STUB_V(spdk_nvme_trid_populate_transport, (struct spdk_nvme_transport_id
enum spdk_nvme_transport_type trtype));
DEFINE_STUB_V(spdk_nvmf_tgt_new_qpair, (struct spdk_nvmf_tgt *tgt, struct spdk_nvmf_qpair *qpair));
DEFINE_STUB(nvmf_ctrlr_abort_request, int, (struct spdk_nvmf_request *req), 0);
DEFINE_STUB(spdk_nvme_transport_id_adrfam_str, const char *, (enum spdk_nvmf_adrfam adrfam), NULL);
int ibv_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
int attr_mask, struct ibv_qp_init_attr *init_attr)

View File

@ -110,6 +110,7 @@ DEFINE_STUB(spdk_nvmf_qpair_get_listen_trid, int, (struct spdk_nvmf_qpair *qpair
struct spdk_nvme_transport_id *trid), 0);
DEFINE_STUB(ibv_reg_mr_iova2, struct ibv_mr *, (struct ibv_pd *pd, void *addr, size_t length,
uint64_t iova, unsigned int access), NULL);
DEFINE_STUB(spdk_nvme_transport_id_adrfam_str, const char *, (enum spdk_nvmf_adrfam adrfam), NULL);
/* ibv_reg_mr can be a macro, need to undefine it */
#ifdef ibv_reg_mr