From: Keith Busch Date: Tue, 12 Jan 2021 22:22:09 +0000 (-0800) Subject: Merge branch 'master' of https://github.com/hanumanthuh/nvme-cli into hanumanthuh... X-Git-Tag: v1.14~125^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=fbec87a35b3b793c2ab20c29d1b644d4df25a9ab;p=users%2Fsagi%2Fnvme-cli.git Merge branch 'master' of https://github.com/hanumanthuh/nvme-cli into hanumanthuh-master --- fbec87a35b3b793c2ab20c29d1b644d4df25a9ab diff --cc plugins/micron/micron-nvme.c index 29d8bdb6,1c324c0e..97bcff05 --- a/plugins/micron/micron-nvme.c +++ b/plugins/micron/micron-nvme.c @@@ -1097,43 -1200,26 +1202,27 @@@ static int micron_nand_stats(int argc, close(fd); goto out; } + - err = nvme_get_log(fd, NVME_NSID_ALL, 0xD0, false, D0_log_size, extSmartLog); ++ err = nvme_get_log(fd, NVME_NSID_ALL, 0xD0, false, NVME_NO_LOG_LSP, D0_log_size, extSmartLog); + has_d0_log = (0 == err); + /* should check for firmware version if this log is supported or not */ - if (eModel == M5407) { - log_page = 0xFB; - log_size = FB_log_size; - } - err = nvme_get_log(fd, NVME_NSID_ALL, log_page, false, NVME_NO_LOG_LSP, - log_size, extSmartLog); - if (err) { - printf("Unable to retrieve extended smart log for the drive\n"); - goto out; - } - - if (eModel == M5407) { - printf("Print log in json(%d) format\n", is_json); - print_m5407_nand_stats((__u8 *)extSmartLog, is_json); - goto out; + if (eModel == M5407 || eModel == M5410) { - err = nvme_get_log(fd, NVME_NSID_ALL, 0xFB, false, FB_log_size, logFB); ++ err = nvme_get_log(fd, NVME_NSID_ALL, 0xFB, false, NVME_NO_LOG_LSP, ++ FB_log_size, logFB); + has_fb_log = (0 == err); } - unsigned long long count = ((unsigned long long)extSmartLog[45] << 32) | extSmartLog[44]; - printf("%-40s : 0x%llx\n", "NAND Writes (Bytes Written)", count); - printf("%-40s : ", "Program Failure Count"); + nsze = (ctrl.vs[987] == 0x12); + if (nsze == 0 && nsze_from_oacs) + nsze = (ctrl.oacs >> 3 & 0x1); - unsigned long long count_hi = ((unsigned long long)extSmartLog[39] << 32) | extSmartLog[38]; - unsigned long long count_lo = ((unsigned long long)extSmartLog[37] << 32) | extSmartLog[36]; - if (count_hi != 0) - printf("0x%llx%016llx", count_hi, count_lo); + if (has_fb_log) + print_nand_stats_fb((__u8 *)logFB, (__u8 *)extSmartLog, nsze, is_json); + else if (has_d0_log) + print_nand_stats_d0((__u8 *)extSmartLog, nsze, is_json); else - printf("0x%llx\n", count_lo); - - count = ((unsigned long long)extSmartLog[25] << 32) | extSmartLog[24]; - printf("%-40s : 0x%llx\n", "Erase Failures", count); - printf("%-40s : 0x%x\n", "Bad Block Count", extSmartLog[3]); - - count = (unsigned long long)extSmartLog[3] - (count_lo + count); - printf("%-40s : 0x%llx\n", "NAND XOR/RAID Recovery Trigger Events", count); - printf("%-40s : 0x%x\n", "NSZE Change Supported", (ctrl.oacs >> 3) & 0x1); - printf("%-40s : 0x%x\n", "Number of NSZE Modifications", extSmartLog[1]); + printf("Unable to retrieve extended smart log for the drive\n"); out: close(fd); return err; @@@ -1780,8 -1883,10 +1886,11 @@@ static int micron_internal_logs(int arg } if (bSize != 0 && (dataBuffer = (unsigned char *)malloc(bSize)) != NULL) { memset(dataBuffer, 0, bSize); - err = nvme_get_log(fd, NVME_NSID_ALL, aVendorLogs[i].ucLogPage, false, NVME_NO_LOG_LSP, - bSize, dataBuffer); + if (eModel == M5410 || eModel == M5407) + err = NVMEGetLogPage(fd, aVendorLogs[i].ucLogPage, dataBuffer, bSize); + else - err = nvme_get_log(fd, NVME_NSID_ALL, aVendorLogs[i].ucLogPage, false, bSize, dataBuffer); ++ err = nvme_get_log(fd, NVME_NSID_ALL, aVendorLogs[i].ucLogPage, false, NVME_NO_LOG_LSP, ++ bSize, dataBuffer); } break;