From b28125b9dea774c2192002091c895169244a289d Mon Sep 17 00:00:00 2001 From: Tsuyoshi Uchida Date: Mon, 12 Dec 2016 15:57:20 -0800 Subject: [PATCH] bdev/nvme: add CSTS in blockdev_nvme_dump_config_json (#85) * bdev/nvme: add CSTS in blockdev_nvme_dump_config_json * bdev/nvme: delete shst - delete shst - change from spdk_json_write_string_fmt to spdk_json_write_uint32 --- include/spdk/nvme.h | 5 +++++ lib/bdev/nvme/blockdev_nvme.c | 34 +++++++++++++++++++++++++++++++--- lib/nvme/nvme_ctrlr.c | 10 ++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index 320cbc0d01..7cf06d7d9b 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -287,6 +287,11 @@ int spdk_nvme_ctrlr_reset(struct spdk_nvme_ctrlr *ctrlr); */ const struct spdk_nvme_ctrlr_data *spdk_nvme_ctrlr_get_data(struct spdk_nvme_ctrlr *ctrlr); +/** + * \brief Get the NVMe controller CSTS (Status) register. + */ +union spdk_nvme_csts_register spdk_nvme_ctrlr_get_regs_csts(struct spdk_nvme_ctrlr *ctrlr); + /** * \brief Get the NVMe controller CAP (Capabilities) register. */ diff --git a/lib/bdev/nvme/blockdev_nvme.c b/lib/bdev/nvme/blockdev_nvme.c index f883fd0f74..3a8b9d7543 100644 --- a/lib/bdev/nvme/blockdev_nvme.c +++ b/lib/bdev/nvme/blockdev_nvme.c @@ -345,10 +345,12 @@ blockdev_nvme_dump_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ct const struct spdk_nvme_ctrlr_data *cdata; struct spdk_nvme_ns *ns; union spdk_nvme_vs_register vs; + union spdk_nvme_csts_register csts; char buf[128]; cdata = spdk_nvme_ctrlr_get_data(nvme_bdev->ctrlr); vs = spdk_nvme_ctrlr_get_regs_vs(nvme_bdev->ctrlr); + csts = spdk_nvme_ctrlr_get_regs_csts(nvme_bdev->ctrlr); ns = nvme_bdev->ns; spdk_json_write_name(w, "nvme"); @@ -359,6 +361,9 @@ blockdev_nvme_dump_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ct nvme_dev->pci_addr.bus, nvme_dev->pci_addr.dev, nvme_dev->pci_addr.func); + spdk_json_write_name(w, "ctrlr_data"); + spdk_json_write_object_begin(w); + spdk_json_write_name(w, "vendor_id"); spdk_json_write_string_fmt(w, "0x%04x", cdata->vid); @@ -377,6 +382,11 @@ blockdev_nvme_dump_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ct spdk_json_write_name(w, "firmware_revision"); spdk_json_write_string(w, buf); + spdk_json_write_object_end(w); + + spdk_json_write_name(w, "vs"); + spdk_json_write_object_begin(w); + spdk_json_write_name(w, "nvme_version"); if (vs.bits.ter) { spdk_json_write_string_fmt(w, "%u.%u.%u", vs.bits.mjr, vs.bits.mnr, vs.bits.ter); @@ -384,17 +394,35 @@ blockdev_nvme_dump_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ct spdk_json_write_string_fmt(w, "%u.%u", vs.bits.mjr, vs.bits.mnr); } - spdk_json_write_name(w, "nsid"); + spdk_json_write_object_end(w); + + spdk_json_write_name(w, "csts"); + spdk_json_write_object_begin(w); + + spdk_json_write_name(w, "rdy"); + spdk_json_write_uint32(w, csts.bits.rdy); + + spdk_json_write_name(w, "cfs"); + spdk_json_write_uint32(w, csts.bits.cfs); + + spdk_json_write_object_end(w); + + spdk_json_write_name(w, "ns_data"); + spdk_json_write_object_begin(w); + + spdk_json_write_name(w, "id"); spdk_json_write_uint32(w, spdk_nvme_ns_get_id(ns)); - spdk_json_write_name(w, "ns_block_size"); + spdk_json_write_name(w, "block_size"); spdk_json_write_uint32(w, spdk_nvme_ns_get_sector_size(ns)); - spdk_json_write_name(w, "ns_total_size"); + spdk_json_write_name(w, "total_size"); spdk_json_write_uint64(w, spdk_nvme_ns_get_size(ns)); spdk_json_write_object_end(w); + spdk_json_write_object_end(w); + return 0; } diff --git a/lib/nvme/nvme_ctrlr.c b/lib/nvme/nvme_ctrlr.c index 453fe283d4..e326de1a98 100644 --- a/lib/nvme/nvme_ctrlr.c +++ b/lib/nvme/nvme_ctrlr.c @@ -1393,6 +1393,16 @@ spdk_nvme_ctrlr_get_data(struct spdk_nvme_ctrlr *ctrlr) return &ctrlr->cdata; } +union spdk_nvme_csts_register spdk_nvme_ctrlr_get_regs_csts(struct spdk_nvme_ctrlr *ctrlr) +{ + union spdk_nvme_csts_register csts; + + if (nvme_ctrlr_get_csts(ctrlr, &csts)) { + csts.raw = 0; + } + return csts; +} + union spdk_nvme_cap_register spdk_nvme_ctrlr_get_regs_cap(struct spdk_nvme_ctrlr *ctrlr) { return ctrlr->cap;