examples/nvme/identify: pass nsid to Error Recovery feature

The P5800X drive will report the following error when getting Error Recovery
feature, according to the specification we should pass valid nsid.

nvme_qpair.c: 238:nvme_admin_qpair_print_command: *NOTICE*: GET FEATURES ERROR_RECOVERY cid:23 cdw10:00000005 PRP1 0x0 PRP2 0x0
nvme_qpair.c: 452:spdk_nvme_print_completion: *NOTICE*: INVALID NAMESPACE OR FORMAT (00/0b) qid:0 cid:23 cdw0:0 sqhd:000f p:1 m:0 dnr:1
get_feature(0x05) failed

Fix issue #1955

Change-Id: I30ce60cddcddbf78e57a8c172a2056a82ac72802
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8009
Reviewed-by: Chengqiang Meng <chengqiangx.meng@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: <dongx.yi@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Changpeng Liu 2021-05-24 20:30:02 +08:00 committed by Tomasz Zawadzki
parent 7ee25c2e4c
commit 51b6cbb9a7

View File

@ -251,7 +251,6 @@ get_ctrlr_features(struct spdk_nvme_ctrlr *ctrlr)
SPDK_NVME_FEAT_ARBITRATION,
SPDK_NVME_FEAT_POWER_MANAGEMENT,
SPDK_NVME_FEAT_TEMPERATURE_THRESHOLD,
SPDK_NVME_FEAT_ERROR_RECOVERY,
SPDK_NVME_FEAT_NUMBER_OF_QUEUES,
SPDK_OCSSD_FEAT_MEDIA_FEEDBACK,
};
@ -259,6 +258,16 @@ get_ctrlr_features(struct spdk_nvme_ctrlr *ctrlr)
get_features(ctrlr, features_to_get, SPDK_COUNTOF(features_to_get), 0);
}
static void
get_ns_features(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid)
{
uint8_t features_to_get[] = {
SPDK_NVME_FEAT_ERROR_RECOVERY,
};
get_features(ctrlr, features_to_get, SPDK_COUNTOF(features_to_get), nsid);
}
static int
get_error_log_page(struct spdk_nvme_ctrlr *ctrlr)
{
@ -950,6 +959,16 @@ print_namespace(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ns *ns)
/* This function is only called for active namespaces. */
assert(spdk_nvme_ns_is_active(ns));
if (features[SPDK_NVME_FEAT_ERROR_RECOVERY].valid) {
unsigned tler = features[SPDK_NVME_FEAT_ERROR_RECOVERY].result & 0xFFFF;
printf("Error Recovery Timeout: ");
if (tler == 0) {
printf("Unlimited\n");
} else {
printf("%u milliseconds\n", tler * 100);
}
}
printf("Command Set Identifier: %s (%02Xh)\n",
csi_name(spdk_nvme_ns_get_csi(ns)), spdk_nvme_ns_get_csi(ns));
printf("Deallocate: %s\n",
@ -1273,15 +1292,6 @@ print_controller(struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_transport
printf("%" PRIu64 "\n", (uint64_t)1 << (12 + cap.bits.mpsmin + cdata->mdts));
}
printf("Max Number of Namespaces: %d\n", cdata->nn);
if (features[SPDK_NVME_FEAT_ERROR_RECOVERY].valid) {
unsigned tler = features[SPDK_NVME_FEAT_ERROR_RECOVERY].result & 0xFFFF;
printf("Error Recovery Timeout: ");
if (tler == 0) {
printf("Unlimited\n");
} else {
printf("%u milliseconds\n", tler * 100);
}
}
printf("NVMe Specification Version (VS): %u.%u", vs.bits.mjr, vs.bits.mnr);
if (vs.bits.ter) {
printf(".%u", vs.bits.ter);
@ -1963,6 +1973,7 @@ print_controller(struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_transport
printf("=================\n");
for (nsid = spdk_nvme_ctrlr_get_first_active_ns(ctrlr);
nsid != 0; nsid = spdk_nvme_ctrlr_get_next_active_ns(ctrlr, nsid)) {
get_ns_features(ctrlr, nsid);
print_namespace(ctrlr, spdk_nvme_ctrlr_get_ns(ctrlr, nsid));
}