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
This commit is contained in:
Tsuyoshi Uchida 2016-12-12 15:57:20 -08:00 committed by Daniel Verkamp
parent 4714e34d6e
commit b28125b9de
3 changed files with 46 additions and 3 deletions

View File

@ -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.
*/

View File

@ -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;
}

View File

@ -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;