From 3875f287dd18e068cf7d9d8d7077752992bebaf5 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Mon, 30 Aug 2021 12:25:20 -0700 Subject: [PATCH] nvme: Add spdk_nvme_ctrlr_get_opts This is needed for reporting additional information in JSON RPCs Change-Id: I45da2ea78cd5415f7536130b6793ca29e929b86e Signed-off-by: Ben Walker Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9338 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Paul Luse Reviewed-by: Changpeng Liu Reviewed-by: Ziye Yang Reviewed-by: Aleksey Marchuk --- CHANGELOG.md | 2 ++ include/spdk/nvme.h | 9 ++++++++- lib/nvme/nvme_ctrlr.c | 6 ++++++ lib/nvme/spdk_nvme.map | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6511253199..d6f0c45902 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,8 @@ Added new functions `spdk_nvme_ctrlr_write_boot_partition`, `spdk_nvme_ctrlr_read_boot_partition_start` and `spdk_nvme_ctrlr_read_boot_partition_poll` to write and read the boot partitions of a controller. +Added `spdk_nvme_ctrlr_get_opts` to retrieve the current controller options. + ### dpdk Updated DPDK submodule to DPDK 21.08. diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index 83f38f6858..0c48640672 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -142,7 +142,7 @@ struct spdk_nvme_ctrlr_opts { /** * The host NQN to use when connecting to NVMe over Fabrics controllers. * - * Unused for local PCIe-attached NVMe devices. + * If empty, a default value will be used. */ char hostnqn[SPDK_NVMF_NQN_MAX_LEN + 1]; @@ -324,6 +324,13 @@ bool spdk_nvme_ctrlr_is_fabrics(struct spdk_nvme_ctrlr *ctrlr); void spdk_nvme_ctrlr_get_default_ctrlr_opts(struct spdk_nvme_ctrlr_opts *opts, size_t opts_size); +/* + * Get the options in use for a given controller. + * + * \param ctrlr Opaque handle to NVMe controller. + */ +const struct spdk_nvme_ctrlr_opts *spdk_nvme_ctrlr_get_opts(struct spdk_nvme_ctrlr *ctrlr); + /** * Reason for qpair disconnect at the transport layer. * diff --git a/lib/nvme/nvme_ctrlr.c b/lib/nvme/nvme_ctrlr.c index 0b067c5649..ff705a45fa 100644 --- a/lib/nvme/nvme_ctrlr.c +++ b/lib/nvme/nvme_ctrlr.c @@ -234,6 +234,12 @@ spdk_nvme_ctrlr_get_default_ctrlr_opts(struct spdk_nvme_ctrlr_opts *opts, size_t #undef SET_FIELD } +const struct spdk_nvme_ctrlr_opts * +spdk_nvme_ctrlr_get_opts(struct spdk_nvme_ctrlr *ctrlr) +{ + return &ctrlr->opts; +} + /** * This function will be called when the process allocates the IO qpair. * Note: the ctrlr_lock must be held when calling this function. diff --git a/lib/nvme/spdk_nvme.map b/lib/nvme/spdk_nvme.map index deff6ebbcd..048879ce72 100644 --- a/lib/nvme/spdk_nvme.map +++ b/lib/nvme/spdk_nvme.map @@ -33,6 +33,7 @@ spdk_nvme_ctrlr_is_discovery; spdk_nvme_ctrlr_is_fabrics; spdk_nvme_ctrlr_get_default_ctrlr_opts; + spdk_nvme_ctrlr_get_opts; spdk_nvme_ctrlr_set_trid; spdk_nvme_ctrlr_reset_subsystem; spdk_nvme_ctrlr_reset;