From 4ed089396bc7f14bcb94e80f0f9f4757fd8c48b7 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 5 Nov 2022 19:23:30 +0100 Subject: Merging upstream version 2.2.1. Signed-off-by: Daniel Baumann --- .github/cross/ubuntu-armhf.txt | 17 + .github/cross/ubuntu-ppc64le.txt | 17 + .github/workflows/meson.yml | 60 + .github/workflows/release.yml | 2 +- Documentation/cmds-main.txt | 3 + Documentation/meson.build | 15 + Documentation/nvme-admin-passthru.1 | 4 +- Documentation/nvme-admin-passthru.html | 2 +- Documentation/nvme-ana-log.1 | 4 +- Documentation/nvme-ana-log.html | 2 +- Documentation/nvme-attach-ns.1 | 4 +- Documentation/nvme-attach-ns.html | 2 +- Documentation/nvme-boot-part-log.1 | 4 +- Documentation/nvme-boot-part-log.html | 2 +- Documentation/nvme-capacity-mgmt.1 | 4 +- Documentation/nvme-capacity-mgmt.html | 2 +- Documentation/nvme-changed-ns-list-log.1 | 4 +- Documentation/nvme-changed-ns-list-log.html | 2 +- Documentation/nvme-cmdset-ind-id-ns.1 | 4 +- Documentation/nvme-cmdset-ind-id-ns.html | 2 +- Documentation/nvme-compare.1 | 4 +- Documentation/nvme-compare.html | 2 +- Documentation/nvme-connect-all.1 | 4 +- Documentation/nvme-connect-all.html | 2 +- Documentation/nvme-connect.1 | 4 +- Documentation/nvme-connect.html | 2 +- Documentation/nvme-copy.1 | 4 +- Documentation/nvme-copy.html | 2 +- Documentation/nvme-create-ns.1 | 4 +- Documentation/nvme-create-ns.html | 2 +- Documentation/nvme-delete-ns.1 | 4 +- Documentation/nvme-delete-ns.html | 2 +- Documentation/nvme-dera-stat.1 | 4 +- Documentation/nvme-dera-stat.html | 2 +- Documentation/nvme-detach-ns.1 | 4 +- Documentation/nvme-detach-ns.html | 2 +- Documentation/nvme-device-self-test.1 | 4 +- Documentation/nvme-device-self-test.html | 2 +- Documentation/nvme-dim.1 | 4 +- Documentation/nvme-dim.html | 2 +- Documentation/nvme-dir-receive.1 | 4 +- Documentation/nvme-dir-receive.html | 2 +- Documentation/nvme-dir-send.1 | 4 +- Documentation/nvme-dir-send.html | 2 +- Documentation/nvme-disconnect-all.1 | 4 +- Documentation/nvme-disconnect-all.html | 2 +- Documentation/nvme-disconnect.1 | 4 +- Documentation/nvme-disconnect.html | 2 +- Documentation/nvme-discover.1 | 4 +- Documentation/nvme-discover.html | 2 +- Documentation/nvme-dsm.1 | 4 +- Documentation/nvme-dsm.html | 2 +- Documentation/nvme-effects-log.1 | 4 +- Documentation/nvme-effects-log.html | 2 +- Documentation/nvme-endurance-event-agg-log.1 | 4 +- Documentation/nvme-endurance-event-agg-log.html | 2 +- Documentation/nvme-endurance-log.1 | 4 +- Documentation/nvme-endurance-log.html | 2 +- Documentation/nvme-error-log.1 | 4 +- Documentation/nvme-error-log.html | 2 +- Documentation/nvme-fid-support-effects-log.1 | 4 +- Documentation/nvme-fid-support-effects-log.html | 2 +- Documentation/nvme-flush.1 | 4 +- Documentation/nvme-flush.html | 2 +- Documentation/nvme-format.1 | 4 +- Documentation/nvme-format.html | 2 +- Documentation/nvme-fw-commit.1 | 4 +- Documentation/nvme-fw-commit.html | 2 +- Documentation/nvme-fw-download.1 | 4 +- Documentation/nvme-fw-download.html | 2 +- Documentation/nvme-fw-log.1 | 4 +- Documentation/nvme-fw-log.html | 2 +- Documentation/nvme-gen-hostnqn.1 | 4 +- Documentation/nvme-gen-hostnqn.html | 2 +- Documentation/nvme-get-feature.1 | 4 +- Documentation/nvme-get-feature.html | 2 +- Documentation/nvme-get-lba-status.1 | 4 +- Documentation/nvme-get-lba-status.html | 2 +- Documentation/nvme-get-log.1 | 4 +- Documentation/nvme-get-log.html | 2 +- Documentation/nvme-get-ns-id.1 | 4 +- Documentation/nvme-get-ns-id.html | 2 +- Documentation/nvme-get-property.1 | 4 +- Documentation/nvme-get-property.html | 2 +- Documentation/nvme-help.1 | 4 +- Documentation/nvme-help.html | 2 +- Documentation/nvme-huawei-id-ctrl.1 | 4 +- Documentation/nvme-huawei-id-ctrl.html | 2 +- Documentation/nvme-huawei-list.1 | 4 +- Documentation/nvme-huawei-list.html | 2 +- Documentation/nvme-id-ctrl.1 | 4 +- Documentation/nvme-id-ctrl.html | 2 +- Documentation/nvme-id-domain.1 | 4 +- Documentation/nvme-id-domain.html | 2 +- Documentation/nvme-id-iocs.1 | 4 +- Documentation/nvme-id-iocs.html | 2 +- Documentation/nvme-id-ns.1 | 4 +- Documentation/nvme-id-ns.html | 2 +- Documentation/nvme-id-nvmset.1 | 4 +- Documentation/nvme-id-nvmset.html | 2 +- Documentation/nvme-intel-id-ctrl.1 | 4 +- Documentation/nvme-intel-id-ctrl.html | 2 +- Documentation/nvme-intel-internal-log.1 | 4 +- Documentation/nvme-intel-internal-log.html | 2 +- Documentation/nvme-intel-lat-stats.1 | 4 +- Documentation/nvme-intel-lat-stats.html | 2 +- Documentation/nvme-intel-market-name.1 | 4 +- Documentation/nvme-intel-market-name.html | 2 +- Documentation/nvme-intel-smart-log-add.1 | 4 +- Documentation/nvme-intel-smart-log-add.html | 2 +- Documentation/nvme-intel-temp-stats.1 | 4 +- Documentation/nvme-intel-temp-stats.html | 2 +- Documentation/nvme-io-passthru.1 | 4 +- Documentation/nvme-io-passthru.html | 2 +- Documentation/nvme-lba-status-log.1 | 4 +- Documentation/nvme-lba-status-log.html | 2 +- Documentation/nvme-list-ctrl.1 | 4 +- Documentation/nvme-list-ctrl.html | 2 +- Documentation/nvme-list-endgrp.1 | 4 +- Documentation/nvme-list-endgrp.html | 2 +- Documentation/nvme-list-ns.1 | 4 +- Documentation/nvme-list-ns.html | 2 +- Documentation/nvme-list-subsys.1 | 20 +- Documentation/nvme-list-subsys.html | 18 +- Documentation/nvme-list-subsys.txt | 16 +- Documentation/nvme-list.1 | 4 +- Documentation/nvme-list.html | 2 +- Documentation/nvme-lockdown.1 | 4 +- Documentation/nvme-lockdown.html | 2 +- Documentation/nvme-mi-cmd-support-effects-log.1 | 4 +- Documentation/nvme-mi-cmd-support-effects-log.html | 2 +- Documentation/nvme-micron-clear-pcie-errors.1 | 4 +- Documentation/nvme-micron-clear-pcie-errors.html | 2 +- Documentation/nvme-micron-internal-log.1 | 4 +- Documentation/nvme-micron-internal-log.html | 2 +- Documentation/nvme-micron-nand-stats.1 | 4 +- Documentation/nvme-micron-nand-stats.html | 2 +- Documentation/nvme-micron-pcie-stats.1 | 4 +- Documentation/nvme-micron-pcie-stats.html | 2 +- Documentation/nvme-micron-selective-download.1 | 4 +- Documentation/nvme-micron-selective-download.html | 2 +- Documentation/nvme-micron-smart-add-log.1 | 4 +- Documentation/nvme-micron-smart-add-log.html | 2 +- Documentation/nvme-micron-temperature-stats.1 | 4 +- Documentation/nvme-micron-temperature-stats.html | 2 +- Documentation/nvme-netapp-ontapdevices.1 | 4 +- Documentation/nvme-netapp-ontapdevices.html | 2 +- Documentation/nvme-netapp-smdevices.1 | 4 +- Documentation/nvme-netapp-smdevices.html | 2 +- Documentation/nvme-ns-descs.1 | 4 +- Documentation/nvme-ns-descs.html | 2 +- Documentation/nvme-ns-rescan.1 | 4 +- Documentation/nvme-ns-rescan.html | 2 +- Documentation/nvme-nvm-id-ctrl.1 | 4 +- Documentation/nvme-nvm-id-ctrl.html | 2 +- Documentation/nvme-ocp-latency-monitor-log.1 | 4 +- Documentation/nvme-ocp-latency-monitor-log.html | 2 +- Documentation/nvme-ocp-smart-add-log.1 | 4 +- Documentation/nvme-ocp-smart-add-log.html | 2 +- Documentation/nvme-persistent-event-log.1 | 4 +- Documentation/nvme-persistent-event-log.html | 2 +- Documentation/nvme-pred-lat-event-agg-log.1 | 4 +- Documentation/nvme-pred-lat-event-agg-log.html | 2 +- Documentation/nvme-predictable-lat-log.1 | 4 +- Documentation/nvme-predictable-lat-log.html | 2 +- Documentation/nvme-primary-ctrl-caps.1 | 4 +- Documentation/nvme-primary-ctrl-caps.html | 2 +- Documentation/nvme-read.1 | 4 +- Documentation/nvme-read.html | 2 +- Documentation/nvme-reset.1 | 4 +- Documentation/nvme-reset.html | 2 +- Documentation/nvme-resv-acquire.1 | 4 +- Documentation/nvme-resv-acquire.html | 2 +- Documentation/nvme-resv-notif-log.1 | 4 +- Documentation/nvme-resv-notif-log.html | 2 +- Documentation/nvme-resv-register.1 | 4 +- Documentation/nvme-resv-register.html | 2 +- Documentation/nvme-resv-release.1 | 4 +- Documentation/nvme-resv-release.html | 2 +- Documentation/nvme-resv-report.1 | 4 +- Documentation/nvme-resv-report.html | 2 +- Documentation/nvme-rpmb.1 | 4 +- Documentation/nvme-rpmb.html | 2 +- Documentation/nvme-sanitize-log.1 | 4 +- Documentation/nvme-sanitize-log.html | 2 +- Documentation/nvme-sanitize.1 | 46 +- Documentation/nvme-sanitize.html | 42 +- Documentation/nvme-sanitize.txt | 15 +- .../nvme-seagate-clear-fw-activate-history.1 | 60 + .../nvme-seagate-clear-fw-activate-history.html | 799 ++++++++ .../nvme-seagate-clear-fw-activate-history.txt | 37 + .../nvme-seagate-clear-pcie-correctable-errors.1 | 63 + ...nvme-seagate-clear-pcie-correctable-errors.html | 809 ++++++++ .../nvme-seagate-clear-pcie-correctable-errors.txt | 38 + .../nvme-seagate-cloud-SSD-plugin-version.1 | 58 + .../nvme-seagate-cloud-SSD-plugin-version.html | 794 ++++++++ .../nvme-seagate-cloud-SSD-plugin-version.txt | 31 + Documentation/nvme-seagate-get-ctrl-tele.1 | 68 + Documentation/nvme-seagate-get-ctrl-tele.html | 820 ++++++++ Documentation/nvme-seagate-get-ctrl-tele.txt | 42 + Documentation/nvme-seagate-get-host-tele.1 | 73 + Documentation/nvme-seagate-get-host-tele.html | 832 +++++++++ Documentation/nvme-seagate-get-host-tele.txt | 47 + Documentation/nvme-seagate-help.1 | 85 + Documentation/nvme-seagate-help.html | 819 ++++++++ Documentation/nvme-seagate-help.txt | 49 + Documentation/nvme-seagate-plugin-version.1 | 58 + Documentation/nvme-seagate-plugin-version.html | 794 ++++++++ Documentation/nvme-seagate-plugin-version.txt | 31 + Documentation/nvme-seagate-version.1 | 58 + Documentation/nvme-seagate-version.html | 794 ++++++++ Documentation/nvme-seagate-version.txt | 31 + .../nvme-seagate-vs-fw-activate-history.1 | 68 + .../nvme-seagate-vs-fw-activate-history.html | 820 ++++++++ .../nvme-seagate-vs-fw-activate-history.txt | 42 + Documentation/nvme-seagate-vs-internal-log.1 | 68 + Documentation/nvme-seagate-vs-internal-log.html | 820 ++++++++ Documentation/nvme-seagate-vs-internal-log.txt | 42 + Documentation/nvme-seagate-vs-log-page-sup.1 | 75 + Documentation/nvme-seagate-vs-log-page-sup.html | 821 ++++++++ Documentation/nvme-seagate-vs-log-page-sup.txt | 50 + Documentation/nvme-seagate-vs-pcie-stats.1 | 63 + Documentation/nvme-seagate-vs-pcie-stats.html | 809 ++++++++ Documentation/nvme-seagate-vs-pcie-stats.txt | 38 + Documentation/nvme-seagate-vs-smart-add-log.1 | 79 + Documentation/nvme-seagate-vs-smart-add-log.html | 837 +++++++++ Documentation/nvme-seagate-vs-smart-add-log.txt | 55 + Documentation/nvme-seagate-vs-temperature-stats.1 | 63 + .../nvme-seagate-vs-temperature-stats.html | 809 ++++++++ .../nvme-seagate-vs-temperature-stats.txt | 38 + Documentation/nvme-security-recv.1 | 4 +- Documentation/nvme-security-recv.html | 2 +- Documentation/nvme-security-send.1 | 4 +- Documentation/nvme-security-send.html | 2 +- Documentation/nvme-self-test-log.1 | 4 +- Documentation/nvme-self-test-log.html | 2 +- Documentation/nvme-set-feature.1 | 4 +- Documentation/nvme-set-feature.html | 2 +- Documentation/nvme-set-property.1 | 4 +- Documentation/nvme-set-property.html | 2 +- Documentation/nvme-show-hostnqn.1 | 4 +- Documentation/nvme-show-hostnqn.html | 2 +- Documentation/nvme-show-regs.1 | 4 +- Documentation/nvme-show-regs.html | 2 +- Documentation/nvme-show-topology.1 | 70 + Documentation/nvme-show-topology.html | 829 +++++++++ Documentation/nvme-show-topology.txt | 42 + Documentation/nvme-smart-log.1 | 4 +- Documentation/nvme-smart-log.html | 2 +- Documentation/nvme-subsystem-reset.1 | 4 +- Documentation/nvme-subsystem-reset.html | 2 +- Documentation/nvme-supported-log-pages.1 | 4 +- Documentation/nvme-supported-log-pages.html | 2 +- Documentation/nvme-telemetry-log.1 | 4 +- Documentation/nvme-telemetry-log.html | 2 +- .../nvme-toshiba-clear-pcie-correctable-errors.1 | 4 +- ...nvme-toshiba-clear-pcie-correctable-errors.html | 2 +- Documentation/nvme-toshiba-vs-internal-log.1 | 4 +- Documentation/nvme-toshiba-vs-internal-log.html | 2 +- Documentation/nvme-toshiba-vs-smart-add-log.1 | 4 +- Documentation/nvme-toshiba-vs-smart-add-log.html | 2 +- Documentation/nvme-transcend-badblock.1 | 4 +- Documentation/nvme-transcend-badblock.html | 2 +- Documentation/nvme-transcend-healthvalue.1 | 4 +- Documentation/nvme-transcend-healthvalue.html | 2 +- Documentation/nvme-verify.1 | 4 +- Documentation/nvme-verify.html | 2 +- .../nvme-virtium-save-smart-to-vtview-log.1 | 4 +- .../nvme-virtium-save-smart-to-vtview-log.html | 2 +- Documentation/nvme-virtium-show-identify.1 | 4 +- Documentation/nvme-virtium-show-identify.html | 2 +- Documentation/nvme-wdc-cap-diag.1 | 4 +- Documentation/nvme-wdc-cap-diag.html | 2 +- Documentation/nvme-wdc-capabilities.1 | 4 +- Documentation/nvme-wdc-capabilities.html | 2 +- Documentation/nvme-wdc-clear-assert-dump.1 | 4 +- Documentation/nvme-wdc-clear-assert-dump.html | 2 +- Documentation/nvme-wdc-clear-fw-activate-history.1 | 4 +- .../nvme-wdc-clear-fw-activate-history.html | 2 +- .../nvme-wdc-clear-pcie-correctable-errors.1 | 4 +- .../nvme-wdc-clear-pcie-correctable-errors.html | 2 +- Documentation/nvme-wdc-cloud-SSD-plugin-version.1 | 4 +- .../nvme-wdc-cloud-SSD-plugin-version.html | 2 +- Documentation/nvme-wdc-cloud-boot-SSD-version.1 | 4 +- Documentation/nvme-wdc-cloud-boot-SSD-version.html | 2 +- Documentation/nvme-wdc-drive-essentials.1 | 4 +- Documentation/nvme-wdc-drive-essentials.html | 2 +- Documentation/nvme-wdc-drive-log.1 | 4 +- Documentation/nvme-wdc-drive-log.html | 2 +- Documentation/nvme-wdc-drive-resize.1 | 4 +- Documentation/nvme-wdc-drive-resize.html | 2 +- Documentation/nvme-wdc-enc-get-log.1 | 4 +- Documentation/nvme-wdc-enc-get-log.html | 2 +- Documentation/nvme-wdc-get-crash-dump.1 | 4 +- Documentation/nvme-wdc-get-crash-dump.html | 2 +- Documentation/nvme-wdc-get-dev-capabilities-log.1 | 4 +- .../nvme-wdc-get-dev-capabilities-log.html | 2 +- Documentation/nvme-wdc-get-drive-status.1 | 4 +- Documentation/nvme-wdc-get-drive-status.html | 2 +- Documentation/nvme-wdc-get-error-recovery-log.1 | 4 +- Documentation/nvme-wdc-get-error-recovery-log.html | 2 +- Documentation/nvme-wdc-get-latency-monitor-log.1 | 4 +- .../nvme-wdc-get-latency-monitor-log.html | 2 +- Documentation/nvme-wdc-get-pfail-dump.1 | 4 +- Documentation/nvme-wdc-get-pfail-dump.html | 2 +- Documentation/nvme-wdc-get-unsupported-reqs-log.1 | 4 +- .../nvme-wdc-get-unsupported-reqs-log.html | 2 +- Documentation/nvme-wdc-id-ctrl.1 | 4 +- Documentation/nvme-wdc-id-ctrl.html | 2 +- Documentation/nvme-wdc-log-page-directory.1 | 4 +- Documentation/nvme-wdc-log-page-directory.html | 2 +- Documentation/nvme-wdc-namespace-resize.1 | 4 +- Documentation/nvme-wdc-namespace-resize.html | 2 +- Documentation/nvme-wdc-purge-monitor.1 | 4 +- Documentation/nvme-wdc-purge-monitor.html | 2 +- Documentation/nvme-wdc-purge.1 | 4 +- Documentation/nvme-wdc-purge.html | 2 +- Documentation/nvme-wdc-vs-cloud-log.1 | 4 +- Documentation/nvme-wdc-vs-cloud-log.html | 2 +- Documentation/nvme-wdc-vs-device-waf.1 | 4 +- Documentation/nvme-wdc-vs-device-waf.html | 2 +- Documentation/nvme-wdc-vs-drive-info.1 | 4 +- Documentation/nvme-wdc-vs-drive-info.html | 2 +- .../nvme-wdc-vs-error-reason-identifier.1 | 4 +- .../nvme-wdc-vs-error-reason-identifier.html | 2 +- Documentation/nvme-wdc-vs-fw-activate-history.1 | 4 +- Documentation/nvme-wdc-vs-fw-activate-history.html | 2 +- Documentation/nvme-wdc-vs-hw-rev-log.1 | 4 +- Documentation/nvme-wdc-vs-hw-rev-log.html | 2 +- Documentation/nvme-wdc-vs-internal-log.1 | 4 +- Documentation/nvme-wdc-vs-internal-log.html | 2 +- Documentation/nvme-wdc-vs-nand-stats.1 | 4 +- Documentation/nvme-wdc-vs-nand-stats.html | 2 +- Documentation/nvme-wdc-vs-smart-add-log.1 | 4 +- Documentation/nvme-wdc-vs-smart-add-log.html | 2 +- .../nvme-wdc-vs-telemetry-controller-option.1 | 4 +- .../nvme-wdc-vs-telemetry-controller-option.html | 2 +- Documentation/nvme-wdc-vs-temperature-stats.1 | 4 +- Documentation/nvme-wdc-vs-temperature-stats.html | 2 +- Documentation/nvme-write-uncor.1 | 4 +- Documentation/nvme-write-uncor.html | 2 +- Documentation/nvme-write-zeroes.1 | 4 +- Documentation/nvme-write-zeroes.html | 2 +- Documentation/nvme-write.1 | 4 +- Documentation/nvme-write.html | 2 +- Documentation/nvme-zns-changed-zone-list.1 | 4 +- Documentation/nvme-zns-changed-zone-list.html | 2 +- Documentation/nvme-zns-close-zone.1 | 4 +- Documentation/nvme-zns-close-zone.html | 2 +- Documentation/nvme-zns-finish-zone.1 | 4 +- Documentation/nvme-zns-finish-zone.html | 2 +- Documentation/nvme-zns-id-ctrl.1 | 4 +- Documentation/nvme-zns-id-ctrl.html | 2 +- Documentation/nvme-zns-id-ns.1 | 4 +- Documentation/nvme-zns-id-ns.html | 2 +- Documentation/nvme-zns-offline-zone.1 | 4 +- Documentation/nvme-zns-offline-zone.html | 2 +- Documentation/nvme-zns-open-zone.1 | 4 +- Documentation/nvme-zns-open-zone.html | 2 +- Documentation/nvme-zns-report-zones.1 | 4 +- Documentation/nvme-zns-report-zones.html | 2 +- Documentation/nvme-zns-reset-zone.1 | 4 +- Documentation/nvme-zns-reset-zone.html | 2 +- Documentation/nvme-zns-set-zone-desc.1 | 4 +- Documentation/nvme-zns-set-zone-desc.html | 2 +- Documentation/nvme-zns-zone-append.1 | 4 +- Documentation/nvme-zns-zone-append.html | 2 +- Documentation/nvme-zns-zone-mgmt-recv.1 | 4 +- Documentation/nvme-zns-zone-mgmt-recv.html | 2 +- Documentation/nvme-zns-zone-mgmt-send.1 | 4 +- Documentation/nvme-zns-zone-mgmt-send.html | 2 +- Documentation/nvme.1 | 9 +- Documentation/nvme.html | 10 +- Makefile | 9 + README.md | 48 +- completions/_nvme | 16 +- completions/bash-nvme-completion.sh | 5 +- fabrics.c | 107 +- libnvme-wrap.c | 56 + meson.build | 22 +- nvme-builtin.h | 3 +- nvme-print.c | 714 ++++--- nvme-print.h | 5 +- nvme-rpmb.c | 33 +- nvme-wrap.c | 362 ++++ nvme-wrap.h | 125 ++ nvme.c | 1959 +++++++++++--------- nvme.h | 63 +- .../systemd/nvmf-autoconnect.service.in | 3 +- .../udev-rules/70-nvmf-autoconnect.rules.in | 17 +- plugins/dera/dera-nvme.c | 15 +- plugins/innogrit/innogrit-nvme.c | 92 +- plugins/innogrit/typedef.h | 8 +- plugins/intel/intel-nvme.c | 144 +- plugins/memblaze/memblaze-nvme.c | 138 +- plugins/micron/micron-nvme.c | 308 +-- plugins/netapp/netapp-nvme.c | 5 +- plugins/ocp/ocp-nvme.c | 67 +- plugins/scaleflux/sfx-nvme.c | 149 +- plugins/seagate/seagate-diag.h | 258 ++- plugins/seagate/seagate-nvme.c | 1053 ++++++++--- plugins/seagate/seagate-nvme.h | 23 +- plugins/shannon/shannon-nvme.c | 56 +- plugins/solidigm/meson.build | 2 + plugins/solidigm/solidigm-garbage-collection.c | 28 +- plugins/solidigm/solidigm-latency-tracking.c | 27 +- plugins/solidigm/solidigm-nvme.c | 6 + plugins/solidigm/solidigm-nvme.h | 3 +- plugins/solidigm/solidigm-smart.c | 27 +- plugins/solidigm/solidigm-telemetry.c | 183 ++ plugins/solidigm/solidigm-telemetry.h | 8 + plugins/solidigm/solidigm-telemetry/cod.c | 194 ++ plugins/solidigm/solidigm-telemetry/cod.h | 9 + plugins/solidigm/solidigm-telemetry/config.c | 44 + plugins/solidigm/solidigm-telemetry/config.h | 10 + plugins/solidigm/solidigm-telemetry/data-area.c | 424 +++++ plugins/solidigm/solidigm-telemetry/data-area.h | 11 + plugins/solidigm/solidigm-telemetry/header.c | 199 ++ plugins/solidigm/solidigm-telemetry/header.h | 9 + plugins/solidigm/solidigm-telemetry/meson.build | 6 + .../solidigm/solidigm-telemetry/telemetry-log.h | 31 + plugins/toshiba/toshiba-nvme.c | 53 +- plugins/transcend/transcend-nvme.c | 25 +- plugins/virtium/virtium-nvme.c | 71 +- plugins/wdc/wdc-nvme.c | 1553 +++++++++------- plugins/wdc/wdc-nvme.h | 2 +- plugins/ymtc/ymtc-nvme.c | 24 +- plugins/zns/zns.c | 244 +-- subprojects/json-c.wrap | 9 +- subprojects/libnvme.wrap | 3 +- subprojects/uuid.wrap | 6 - subprojects/zlib.wrap | 16 +- tests/meson.build | 19 +- tests/nvme_copy_test.py | 2 +- tests/nvme_dsm_test.py | 2 +- tests/nvme_get_lba_status_test.py | 2 +- tests/nvme_lba_status_log_test.py | 2 +- tests/nvme_verify_test.py | 2 +- tests/test-uint128.c | 62 + util/argconfig.c | 45 + util/argconfig.h | 2 + util/json.c | 41 + util/json.h | 20 +- util/meson.build | 1 + util/types.c | 99 + util/types.h | 35 + wrapper.c | 42 - 447 files changed, 21112 insertions(+), 3414 deletions(-) create mode 100644 .github/cross/ubuntu-armhf.txt create mode 100644 .github/cross/ubuntu-ppc64le.txt create mode 100644 Documentation/nvme-seagate-clear-fw-activate-history.1 create mode 100644 Documentation/nvme-seagate-clear-fw-activate-history.html create mode 100644 Documentation/nvme-seagate-clear-fw-activate-history.txt create mode 100644 Documentation/nvme-seagate-clear-pcie-correctable-errors.1 create mode 100644 Documentation/nvme-seagate-clear-pcie-correctable-errors.html create mode 100644 Documentation/nvme-seagate-clear-pcie-correctable-errors.txt create mode 100644 Documentation/nvme-seagate-cloud-SSD-plugin-version.1 create mode 100644 Documentation/nvme-seagate-cloud-SSD-plugin-version.html create mode 100644 Documentation/nvme-seagate-cloud-SSD-plugin-version.txt create mode 100644 Documentation/nvme-seagate-get-ctrl-tele.1 create mode 100644 Documentation/nvme-seagate-get-ctrl-tele.html create mode 100644 Documentation/nvme-seagate-get-ctrl-tele.txt create mode 100644 Documentation/nvme-seagate-get-host-tele.1 create mode 100644 Documentation/nvme-seagate-get-host-tele.html create mode 100644 Documentation/nvme-seagate-get-host-tele.txt create mode 100644 Documentation/nvme-seagate-help.1 create mode 100644 Documentation/nvme-seagate-help.html create mode 100644 Documentation/nvme-seagate-help.txt create mode 100644 Documentation/nvme-seagate-plugin-version.1 create mode 100644 Documentation/nvme-seagate-plugin-version.html create mode 100644 Documentation/nvme-seagate-plugin-version.txt create mode 100644 Documentation/nvme-seagate-version.1 create mode 100644 Documentation/nvme-seagate-version.html create mode 100644 Documentation/nvme-seagate-version.txt create mode 100644 Documentation/nvme-seagate-vs-fw-activate-history.1 create mode 100644 Documentation/nvme-seagate-vs-fw-activate-history.html create mode 100644 Documentation/nvme-seagate-vs-fw-activate-history.txt create mode 100644 Documentation/nvme-seagate-vs-internal-log.1 create mode 100644 Documentation/nvme-seagate-vs-internal-log.html create mode 100644 Documentation/nvme-seagate-vs-internal-log.txt create mode 100644 Documentation/nvme-seagate-vs-log-page-sup.1 create mode 100644 Documentation/nvme-seagate-vs-log-page-sup.html create mode 100644 Documentation/nvme-seagate-vs-log-page-sup.txt create mode 100644 Documentation/nvme-seagate-vs-pcie-stats.1 create mode 100644 Documentation/nvme-seagate-vs-pcie-stats.html create mode 100644 Documentation/nvme-seagate-vs-pcie-stats.txt create mode 100644 Documentation/nvme-seagate-vs-smart-add-log.1 create mode 100644 Documentation/nvme-seagate-vs-smart-add-log.html create mode 100644 Documentation/nvme-seagate-vs-smart-add-log.txt create mode 100644 Documentation/nvme-seagate-vs-temperature-stats.1 create mode 100644 Documentation/nvme-seagate-vs-temperature-stats.html create mode 100644 Documentation/nvme-seagate-vs-temperature-stats.txt create mode 100644 Documentation/nvme-show-topology.1 create mode 100644 Documentation/nvme-show-topology.html create mode 100644 Documentation/nvme-show-topology.txt create mode 100644 libnvme-wrap.c create mode 100644 nvme-wrap.c create mode 100644 nvme-wrap.h create mode 100644 plugins/solidigm/solidigm-telemetry.c create mode 100644 plugins/solidigm/solidigm-telemetry.h create mode 100644 plugins/solidigm/solidigm-telemetry/cod.c create mode 100644 plugins/solidigm/solidigm-telemetry/cod.h create mode 100644 plugins/solidigm/solidigm-telemetry/config.c create mode 100644 plugins/solidigm/solidigm-telemetry/config.h create mode 100644 plugins/solidigm/solidigm-telemetry/data-area.c create mode 100644 plugins/solidigm/solidigm-telemetry/data-area.h create mode 100644 plugins/solidigm/solidigm-telemetry/header.c create mode 100644 plugins/solidigm/solidigm-telemetry/header.h create mode 100644 plugins/solidigm/solidigm-telemetry/meson.build create mode 100644 plugins/solidigm/solidigm-telemetry/telemetry-log.h delete mode 100644 subprojects/uuid.wrap create mode 100644 tests/test-uint128.c create mode 100644 util/types.c create mode 100644 util/types.h delete mode 100644 wrapper.c diff --git a/.github/cross/ubuntu-armhf.txt b/.github/cross/ubuntu-armhf.txt new file mode 100644 index 0000000..2eee70b --- /dev/null +++ b/.github/cross/ubuntu-armhf.txt @@ -0,0 +1,17 @@ +[binaries] +c = '/usr/bin/arm-linux-gnueabihf-gcc' +ar = '/usr/arm-linux-gnueabihf/bin/ar' +strip = '/usr/arm-linux-gnueabihf/bin/strip' +pkgconfig = '/usr/bin/arm-linux-gnueabihf-pkg-config' +ld = '/usr/bin/arm-linux/gnueabihf-ld' + +[properties] +root = '/usr/arm-linux-gnueabihf' +has_function_printf = true +skip_sanity_check = true + +[host_machine] +system = 'linux' +cpu_family = 'arm' +cpu = 'armv7' +endian = 'little' diff --git a/.github/cross/ubuntu-ppc64le.txt b/.github/cross/ubuntu-ppc64le.txt new file mode 100644 index 0000000..4cf6a92 --- /dev/null +++ b/.github/cross/ubuntu-ppc64le.txt @@ -0,0 +1,17 @@ +[binaries] +c = '/usr/bin/powerpc64le-linux-gnu-gcc' +ar = '/usr/powerpc64le-linux-gnu/bin/ar' +strip = '/usr/powerpc64le-linux-gnu/bin/strip' +pkgconfig = '/usr/bin/powerpc64le-linux-gnu-pkg-config' +ld = '/usr/bin/powerpc64le-linux-gnu-ld' + +[properties] +root = '/usr/powerpc64le-linux-gnu' +has_function_printf = true +skip_sanity_check = true + +[host_machine] +system = 'linux' +cpu_family = 'ppc64' +cpu = '' +endian = 'little' diff --git a/.github/workflows/meson.yml b/.github/workflows/meson.yml index c49470b..ee80af3 100644 --- a/.github/workflows/meson.yml +++ b/.github/workflows/meson.yml @@ -28,6 +28,66 @@ jobs: setup-options: --werror action: build + build-cross-armhf: + runs-on: ubuntu-latest + steps: + - name: set up arm architecture + run: | + export release=$(lsb_release -c -s) + sudo dpkg --add-architecture armhf + sudo sed -i -e 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list + sudo dd of=/etc/apt/sources.list.d/armhf.list < -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ADMIN\-PASSTHR" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ADMIN\-PASSTHR" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-admin-passthru.html b/Documentation/nvme-admin-passthru.html index 27683ef..41da63e 100644 --- a/Documentation/nvme-admin-passthru.html +++ b/Documentation/nvme-admin-passthru.html @@ -998,7 +998,7 @@ Or if you want to save that structure to a file: diff --git a/Documentation/nvme-ana-log.1 b/Documentation/nvme-ana-log.1 index 34f4327..2c0e905 100644 --- a/Documentation/nvme-ana-log.1 +++ b/Documentation/nvme-ana-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-ana-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ANA\-LOG" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ANA\-LOG" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-ana-log.html b/Documentation/nvme-ana-log.html index a6bc46c..e93ae20 100644 --- a/Documentation/nvme-ana-log.html +++ b/Documentation/nvme-ana-log.html @@ -823,7 +823,7 @@ Print the ANA log page in a human readable format: diff --git a/Documentation/nvme-attach-ns.1 b/Documentation/nvme-attach-ns.1 index cfa5f85..53746ea 100644 --- a/Documentation/nvme-attach-ns.1 +++ b/Documentation/nvme-attach-ns.1 @@ -2,12 +2,12 @@ .\" Title: nvme-attach-ns .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ATTACH\-NS" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ATTACH\-NS" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-attach-ns.html b/Documentation/nvme-attach-ns.html index 55eb72e..b213377 100644 --- a/Documentation/nvme-attach-ns.html +++ b/Documentation/nvme-attach-ns.html @@ -817,7 +817,7 @@ controller identifiers.

diff --git a/Documentation/nvme-boot-part-log.1 b/Documentation/nvme-boot-part-log.1 index 8c08712..c1e2438 100644 --- a/Documentation/nvme-boot-part-log.1 +++ b/Documentation/nvme-boot-part-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-boot-part-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-BOOT\-PART\-LO" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-BOOT\-PART\-LO" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-boot-part-log.html b/Documentation/nvme-boot-part-log.html index ae7bafb..4dce5ef 100644 --- a/Documentation/nvme-boot-part-log.html +++ b/Documentation/nvme-boot-part-log.html @@ -835,7 +835,7 @@ Retrieve Boot Partition data to boot_part_log.bin diff --git a/Documentation/nvme-capacity-mgmt.1 b/Documentation/nvme-capacity-mgmt.1 index 425327f..ea0418c 100644 --- a/Documentation/nvme-capacity-mgmt.1 +++ b/Documentation/nvme-capacity-mgmt.1 @@ -2,12 +2,12 @@ .\" Title: nvme-capacity-mgmt .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-CAPACITY\-MGMT" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-CAPACITY\-MGMT" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-capacity-mgmt.html b/Documentation/nvme-capacity-mgmt.html index 519a288..1ca3d42 100644 --- a/Documentation/nvme-capacity-mgmt.html +++ b/Documentation/nvme-capacity-mgmt.html @@ -839,7 +839,7 @@ device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).

diff --git a/Documentation/nvme-changed-ns-list-log.1 b/Documentation/nvme-changed-ns-list-log.1 index 7d1cbb3..0f8f52d 100644 --- a/Documentation/nvme-changed-ns-list-log.1 +++ b/Documentation/nvme-changed-ns-list-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-changed-ns-list-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-CHANGED\-NS\-L" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-CHANGED\-NS\-L" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-changed-ns-list-log.html b/Documentation/nvme-changed-ns-list-log.html index 08bb4d5..2358d44 100644 --- a/Documentation/nvme-changed-ns-list-log.html +++ b/Documentation/nvme-changed-ns-list-log.html @@ -835,7 +835,7 @@ Print the raw Changed Namespace List log to a file: diff --git a/Documentation/nvme-cmdset-ind-id-ns.1 b/Documentation/nvme-cmdset-ind-id-ns.1 index 263f760..f034482 100644 --- a/Documentation/nvme-cmdset-ind-id-ns.1 +++ b/Documentation/nvme-cmdset-ind-id-ns.1 @@ -2,12 +2,12 @@ .\" Title: nvme-cmdset-ind-id-ns .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-CMDSET\-IND\-I" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-CMDSET\-IND\-I" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-cmdset-ind-id-ns.html b/Documentation/nvme-cmdset-ind-id-ns.html index 7ef0bb3..73b5a3c 100644 --- a/Documentation/nvme-cmdset-ind-id-ns.html +++ b/Documentation/nvme-cmdset-ind-id-ns.html @@ -879,7 +879,7 @@ Have the program return the raw structure in binary: diff --git a/Documentation/nvme-compare.1 b/Documentation/nvme-compare.1 index e58cacd..8d53902 100644 --- a/Documentation/nvme-compare.1 +++ b/Documentation/nvme-compare.1 @@ -2,12 +2,12 @@ .\" Title: nvme-compare .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-COMPARE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-COMPARE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-compare.html b/Documentation/nvme-compare.html index 93204a6..e058fb0 100644 --- a/Documentation/nvme-compare.html +++ b/Documentation/nvme-compare.html @@ -1083,7 +1083,7 @@ metadata is passes.

diff --git a/Documentation/nvme-connect-all.1 b/Documentation/nvme-connect-all.1 index 57762ed..8f4b81b 100644 --- a/Documentation/nvme-connect-all.1 +++ b/Documentation/nvme-connect-all.1 @@ -2,12 +2,12 @@ .\" Title: nvme-connect-all .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-CONNECT\-ALL" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-CONNECT\-ALL" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-connect-all.html b/Documentation/nvme-connect-all.html index f0fa62e..46d806b 100644 --- a/Documentation/nvme-connect-all.html +++ b/Documentation/nvme-connect-all.html @@ -1156,7 +1156,7 @@ nvme-connect(1)

diff --git a/Documentation/nvme-connect.1 b/Documentation/nvme-connect.1 index 6e4a8e3..7de1e87 100644 --- a/Documentation/nvme-connect.1 +++ b/Documentation/nvme-connect.1 @@ -2,12 +2,12 @@ .\" Title: nvme-connect .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-CONNECT" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-CONNECT" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-connect.html b/Documentation/nvme-connect.html index c816b2a..4119b57 100644 --- a/Documentation/nvme-connect.html +++ b/Documentation/nvme-connect.html @@ -1162,7 +1162,7 @@ and Christoph Hellwig

diff --git a/Documentation/nvme-copy.1 b/Documentation/nvme-copy.1 index 9ac2412..34e8161 100644 --- a/Documentation/nvme-copy.1 +++ b/Documentation/nvme-copy.1 @@ -2,12 +2,12 @@ .\" Title: nvme-copy .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-COPY" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-COPY" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-copy.html b/Documentation/nvme-copy.html index 468feee..a896ba8 100644 --- a/Documentation/nvme-copy.html +++ b/Documentation/nvme-copy.html @@ -982,7 +982,7 @@ logical block ranges to a single consecutive destination logical block range.

diff --git a/Documentation/nvme-create-ns.1 b/Documentation/nvme-create-ns.1 index e0f5460..96cb562 100644 --- a/Documentation/nvme-create-ns.1 +++ b/Documentation/nvme-create-ns.1 @@ -2,12 +2,12 @@ .\" Title: nvme-create-ns .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-CREATE\-NS" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-CREATE\-NS" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-create-ns.html b/Documentation/nvme-create-ns.html index 900a402..1ce2ef9 100644 --- a/Documentation/nvme-create-ns.html +++ b/Documentation/nvme-create-ns.html @@ -910,7 +910,7 @@ OPTIONS diff --git a/Documentation/nvme-delete-ns.1 b/Documentation/nvme-delete-ns.1 index 75c383d..b6897ea 100644 --- a/Documentation/nvme-delete-ns.1 +++ b/Documentation/nvme-delete-ns.1 @@ -2,12 +2,12 @@ .\" Title: nvme-id-ns .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ID\-NS" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ID\-NS" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-delete-ns.html b/Documentation/nvme-delete-ns.html index 287f2a0..57246f6 100644 --- a/Documentation/nvme-delete-ns.html +++ b/Documentation/nvme-delete-ns.html @@ -799,7 +799,7 @@ The '--namespace-id' option is mandatory.

diff --git a/Documentation/nvme-dera-stat.1 b/Documentation/nvme-dera-stat.1 index 0f8e647..d429bac 100644 --- a/Documentation/nvme-dera-stat.1 +++ b/Documentation/nvme-dera-stat.1 @@ -2,12 +2,12 @@ .\" Title: nvme-dera-stat .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-DERA\-STAT" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-DERA\-STAT" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-dera-stat.html b/Documentation/nvme-dera-stat.html index f01206c..5737d77 100644 --- a/Documentation/nvme-dera-stat.html +++ b/Documentation/nvme-dera-stat.html @@ -797,7 +797,7 @@ Print the Dera Device status and Additional SMART log page in a human readable f diff --git a/Documentation/nvme-detach-ns.1 b/Documentation/nvme-detach-ns.1 index fe3fca5..8efed67 100644 --- a/Documentation/nvme-detach-ns.1 +++ b/Documentation/nvme-detach-ns.1 @@ -2,12 +2,12 @@ .\" Title: nvme-detach-ns .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-DETACH\-NS" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-DETACH\-NS" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-detach-ns.html b/Documentation/nvme-detach-ns.html index bf51536..1140a2f 100644 --- a/Documentation/nvme-detach-ns.html +++ b/Documentation/nvme-detach-ns.html @@ -810,7 +810,7 @@ controller identifiers.

diff --git a/Documentation/nvme-device-self-test.1 b/Documentation/nvme-device-self-test.1 index b9c4027..a9461ff 100644 --- a/Documentation/nvme-device-self-test.1 +++ b/Documentation/nvme-device-self-test.1 @@ -2,12 +2,12 @@ .\" Title: nvme-device-self-test .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-DEVICE\-SELF\-" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-DEVICE\-SELF\-" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-device-self-test.html b/Documentation/nvme-device-self-test.html index e9eb6d7..45ce554 100644 --- a/Documentation/nvme-device-self-test.html +++ b/Documentation/nvme-device-self-test.html @@ -833,7 +833,7 @@ Abort the device self-test operation in the namespace-id 1: diff --git a/Documentation/nvme-dim.1 b/Documentation/nvme-dim.1 index 22fbef3..866eb7d 100644 --- a/Documentation/nvme-dim.1 +++ b/Documentation/nvme-dim.1 @@ -2,12 +2,12 @@ .\" Title: nvme-dim .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-DIM" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-DIM" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-dim.html b/Documentation/nvme-dim.html index d06d0a2..cee3630 100644 --- a/Documentation/nvme-dim.html +++ b/Documentation/nvme-dim.html @@ -863,7 +863,7 @@ Deregister from Central Discovery Controller (CDC) associated with nvme4 diff --git a/Documentation/nvme-dir-receive.1 b/Documentation/nvme-dir-receive.1 index 52ea328..c4b46ea 100644 --- a/Documentation/nvme-dir-receive.1 +++ b/Documentation/nvme-dir-receive.1 @@ -2,12 +2,12 @@ .\" Title: nvme-dir-receive .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-DIR\-RECEIVE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-DIR\-RECEIVE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-dir-receive.html b/Documentation/nvme-dir-receive.html index bf0e505..b13de02 100644 --- a/Documentation/nvme-dir-receive.html +++ b/Documentation/nvme-dir-receive.html @@ -969,7 +969,7 @@ Get streams directive status : diff --git a/Documentation/nvme-dir-send.1 b/Documentation/nvme-dir-send.1 index 97b063d..2733697 100644 --- a/Documentation/nvme-dir-send.1 +++ b/Documentation/nvme-dir-send.1 @@ -2,12 +2,12 @@ .\" Title: nvme-dir-send .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-DIR\-SEND" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-DIR\-SEND" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-dir-send.html b/Documentation/nvme-dir-send.html index bbcd938..9710f8b 100644 --- a/Documentation/nvme-dir-send.html +++ b/Documentation/nvme-dir-send.html @@ -982,7 +982,7 @@ Release stream ID 3 : diff --git a/Documentation/nvme-disconnect-all.1 b/Documentation/nvme-disconnect-all.1 index 7bd523e..f40e9b8 100644 --- a/Documentation/nvme-disconnect-all.1 +++ b/Documentation/nvme-disconnect-all.1 @@ -2,12 +2,12 @@ .\" Title: nvme-disconnect-all .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-DISCONNECT\-AL" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-DISCONNECT\-AL" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-disconnect-all.html b/Documentation/nvme-disconnect-all.html index 4280c37..0e5c5b4 100644 --- a/Documentation/nvme-disconnect-all.html +++ b/Documentation/nvme-disconnect-all.html @@ -795,7 +795,7 @@ Disconnect all existing nvme controllers: diff --git a/Documentation/nvme-disconnect.1 b/Documentation/nvme-disconnect.1 index 8478104..703cc23 100644 --- a/Documentation/nvme-disconnect.1 +++ b/Documentation/nvme-disconnect.1 @@ -2,12 +2,12 @@ .\" Title: nvme-disconnect .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-DISCONNECT" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-DISCONNECT" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-disconnect.html b/Documentation/nvme-disconnect.html index 851bed2..4f77f80 100644 --- a/Documentation/nvme-disconnect.html +++ b/Documentation/nvme-disconnect.html @@ -839,7 +839,7 @@ Disconnect the controller nvme4 diff --git a/Documentation/nvme-discover.1 b/Documentation/nvme-discover.1 index a24bf1f..547900c 100644 --- a/Documentation/nvme-discover.1 +++ b/Documentation/nvme-discover.1 @@ -2,12 +2,12 @@ .\" Title: nvme-discover .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-DISCOVER" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-DISCOVER" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-discover.html b/Documentation/nvme-discover.html index f0953b8..81063a4 100644 --- a/Documentation/nvme-discover.html +++ b/Documentation/nvme-discover.html @@ -1218,7 +1218,7 @@ nvme-connect-all(1)

diff --git a/Documentation/nvme-dsm.1 b/Documentation/nvme-dsm.1 index 0955a08..e6f4fe2 100644 --- a/Documentation/nvme-dsm.1 +++ b/Documentation/nvme-dsm.1 @@ -2,12 +2,12 @@ .\" Title: nvme-dsm .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-DSM" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-DSM" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-dsm.html b/Documentation/nvme-dsm.html index 502a307..942198f 100644 --- a/Documentation/nvme-dsm.html +++ b/Documentation/nvme-dsm.html @@ -893,7 +893,7 @@ any settings from the flags may have provided.

diff --git a/Documentation/nvme-effects-log.1 b/Documentation/nvme-effects-log.1 index 69b8d56..4e1856f 100644 --- a/Documentation/nvme-effects-log.1 +++ b/Documentation/nvme-effects-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-effects-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-EFFECTS\-LOG" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-EFFECTS\-LOG" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-effects-log.html b/Documentation/nvme-effects-log.html index ddff9e5..ec6a645 100644 --- a/Documentation/nvme-effects-log.html +++ b/Documentation/nvme-effects-log.html @@ -847,7 +847,7 @@ Have the program return the raw structure in binary: diff --git a/Documentation/nvme-endurance-event-agg-log.1 b/Documentation/nvme-endurance-event-agg-log.1 index 6bb8981..6d45580 100644 --- a/Documentation/nvme-endurance-event-agg-log.1 +++ b/Documentation/nvme-endurance-event-agg-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-endurance-event-agg-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ENDURANCE\-EVE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ENDURANCE\-EVE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-endurance-event-agg-log.html b/Documentation/nvme-endurance-event-agg-log.html index 428d0c3..5950eae 100644 --- a/Documentation/nvme-endurance-event-agg-log.html +++ b/Documentation/nvme-endurance-event-agg-log.html @@ -851,7 +851,7 @@ Print the raw Endurance log to a file: diff --git a/Documentation/nvme-endurance-log.1 b/Documentation/nvme-endurance-log.1 index 8e4b545..bfea30b 100644 --- a/Documentation/nvme-endurance-log.1 +++ b/Documentation/nvme-endurance-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-endurance-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ENDURANCE\-LOG" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ENDURANCE\-LOG" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-endurance-log.html b/Documentation/nvme-endurance-log.html index 03206fb..fc79319 100644 --- a/Documentation/nvme-endurance-log.html +++ b/Documentation/nvme-endurance-log.html @@ -834,7 +834,7 @@ Print the raw Endurance log to a file: diff --git a/Documentation/nvme-error-log.1 b/Documentation/nvme-error-log.1 index 5021d37..527e173 100644 --- a/Documentation/nvme-error-log.1 +++ b/Documentation/nvme-error-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-error-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ERROR\-LOG" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ERROR\-LOG" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-error-log.html b/Documentation/nvme-error-log.html index c9b1ebb..480e3a7 100644 --- a/Documentation/nvme-error-log.html +++ b/Documentation/nvme-error-log.html @@ -849,7 +849,7 @@ Print the raw output to a file: diff --git a/Documentation/nvme-fid-support-effects-log.1 b/Documentation/nvme-fid-support-effects-log.1 index b61a745..8c748fa 100644 --- a/Documentation/nvme-fid-support-effects-log.1 +++ b/Documentation/nvme-fid-support-effects-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-fid-support-effects-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-FID\-SUPPORT\-" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-FID\-SUPPORT\-" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-fid-support-effects-log.html b/Documentation/nvme-fid-support-effects-log.html index 75abd3d..12b904e 100644 --- a/Documentation/nvme-fid-support-effects-log.html +++ b/Documentation/nvme-fid-support-effects-log.html @@ -814,7 +814,7 @@ raw buffer may be printed to stdout.

diff --git a/Documentation/nvme-flush.1 b/Documentation/nvme-flush.1 index c5654ba..303ba81 100644 --- a/Documentation/nvme-flush.1 +++ b/Documentation/nvme-flush.1 @@ -2,12 +2,12 @@ .\" Title: nvme-flush .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-FLUSH" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-FLUSH" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-flush.html b/Documentation/nvme-flush.html index 3b8f45b..c9dbe68 100644 --- a/Documentation/nvme-flush.html +++ b/Documentation/nvme-flush.html @@ -800,7 +800,7 @@ any namespace.

diff --git a/Documentation/nvme-format.1 b/Documentation/nvme-format.1 index 422cf34..0012045 100644 --- a/Documentation/nvme-format.1 +++ b/Documentation/nvme-format.1 @@ -2,12 +2,12 @@ .\" Title: nvme-format .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-FORMAT" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-FORMAT" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-format.html b/Documentation/nvme-format.html index 28eef20..b581df5 100644 --- a/Documentation/nvme-format.html +++ b/Documentation/nvme-format.html @@ -1035,7 +1035,7 @@ information: diff --git a/Documentation/nvme-fw-commit.1 b/Documentation/nvme-fw-commit.1 index 6701bcf..2b85de1 100644 --- a/Documentation/nvme-fw-commit.1 +++ b/Documentation/nvme-fw-commit.1 @@ -2,12 +2,12 @@ .\" Title: nvme-fw-commit .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-FW\-COMMIT" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-FW\-COMMIT" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-fw-commit.html b/Documentation/nvme-fw-commit.html index 13c810e..7384673 100644 --- a/Documentation/nvme-fw-commit.html +++ b/Documentation/nvme-fw-commit.html @@ -905,7 +905,7 @@ commit the last downloaded fw to slot 1. diff --git a/Documentation/nvme-fw-download.1 b/Documentation/nvme-fw-download.1 index ac58b8b..0d572bc 100644 --- a/Documentation/nvme-fw-download.1 +++ b/Documentation/nvme-fw-download.1 @@ -2,12 +2,12 @@ .\" Title: nvme-fw-download .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-FW\-DOWNLOAD" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-FW\-DOWNLOAD" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-fw-download.html b/Documentation/nvme-fw-download.html index 7a708c6..eb916a2 100644 --- a/Documentation/nvme-fw-download.html +++ b/Documentation/nvme-fw-download.html @@ -852,7 +852,7 @@ Transfer a firmware size 128KiB at a time: diff --git a/Documentation/nvme-fw-log.1 b/Documentation/nvme-fw-log.1 index 81abc41..e3d27c1 100644 --- a/Documentation/nvme-fw-log.1 +++ b/Documentation/nvme-fw-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-fw-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-FW\-LOG" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-FW\-LOG" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-fw-log.html b/Documentation/nvme-fw-log.html index 40e1ebc..9f2db92 100644 --- a/Documentation/nvme-fw-log.html +++ b/Documentation/nvme-fw-log.html @@ -835,7 +835,7 @@ Print the log firmware to a file: diff --git a/Documentation/nvme-gen-hostnqn.1 b/Documentation/nvme-gen-hostnqn.1 index 40d0d7f..bdd49e9 100644 --- a/Documentation/nvme-gen-hostnqn.1 +++ b/Documentation/nvme-gen-hostnqn.1 @@ -2,12 +2,12 @@ .\" Title: nvme-gen-hostnqn .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-GEN\-HOSTNQN" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-GEN\-HOSTNQN" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-gen-hostnqn.html b/Documentation/nvme-gen-hostnqn.html index 29d2b74..789ea41 100644 --- a/Documentation/nvme-gen-hostnqn.html +++ b/Documentation/nvme-gen-hostnqn.html @@ -785,7 +785,7 @@ and prints it to stdout.

diff --git a/Documentation/nvme-get-feature.1 b/Documentation/nvme-get-feature.1 index 13eb5b3..bfe6012 100644 --- a/Documentation/nvme-get-feature.1 +++ b/Documentation/nvme-get-feature.1 @@ -2,12 +2,12 @@ .\" Title: nvme-get-feature .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-GET\-FEATURE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-GET\-FEATURE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-get-feature.html b/Documentation/nvme-get-feature.html index 3296f48..43aed8e 100644 --- a/Documentation/nvme-get-feature.html +++ b/Documentation/nvme-get-feature.html @@ -977,7 +977,7 @@ format: diff --git a/Documentation/nvme-get-lba-status.1 b/Documentation/nvme-get-lba-status.1 index 9fc81b1..8206067 100644 --- a/Documentation/nvme-get-lba-status.1 +++ b/Documentation/nvme-get-lba-status.1 @@ -2,12 +2,12 @@ .\" Title: nvme-get-lba-status .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-GET\-LBA\-STAT" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-GET\-LBA\-STAT" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-get-lba-status.html b/Documentation/nvme-get-lba-status.html index c648699..e0ff7a4 100644 --- a/Documentation/nvme-get-lba-status.html +++ b/Documentation/nvme-get-lba-status.html @@ -896,7 +896,7 @@ Get LBA Status of the namespace 1 from SLBA 10 for the max Dwords of 0x1000 diff --git a/Documentation/nvme-get-log.1 b/Documentation/nvme-get-log.1 index e6f0f87..080c84f 100644 --- a/Documentation/nvme-get-log.1 +++ b/Documentation/nvme-get-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-get-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-GET\-LOG" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-GET\-LOG" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-get-log.html b/Documentation/nvme-get-log.html index 5897f6f..4e06797 100644 --- a/Documentation/nvme-get-log.html +++ b/Documentation/nvme-get-log.html @@ -962,7 +962,7 @@ Have the program return the raw log page in binary: diff --git a/Documentation/nvme-get-ns-id.1 b/Documentation/nvme-get-ns-id.1 index cbfe8b6..2358c36 100644 --- a/Documentation/nvme-get-ns-id.1 +++ b/Documentation/nvme-get-ns-id.1 @@ -2,12 +2,12 @@ .\" Title: nvme-get-ns-id .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-GET\-NS\-ID" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-GET\-NS\-ID" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-get-ns-id.html b/Documentation/nvme-get-ns-id.html index d41d27c..38a2325 100644 --- a/Documentation/nvme-get-ns-id.html +++ b/Documentation/nvme-get-ns-id.html @@ -794,7 +794,7 @@ Shows the namespace id for the given block device: diff --git a/Documentation/nvme-get-property.1 b/Documentation/nvme-get-property.1 index c093536..407d9ac 100644 --- a/Documentation/nvme-get-property.1 +++ b/Documentation/nvme-get-property.1 @@ -2,12 +2,12 @@ .\" Title: nvme-get-property .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-GET\-PROPERTY" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-GET\-PROPERTY" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-get-property.html b/Documentation/nvme-get-property.html index 0fa9bb4..13b97f0 100644 --- a/Documentation/nvme-get-property.html +++ b/Documentation/nvme-get-property.html @@ -843,7 +843,7 @@ Then look for NVMe Fabrics command (0x7f) at trace diff --git a/Documentation/nvme-help.1 b/Documentation/nvme-help.1 index a5efbe1..6ad288d 100644 --- a/Documentation/nvme-help.1 +++ b/Documentation/nvme-help.1 @@ -2,12 +2,12 @@ .\" Title: nvme-help .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-HELP" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-HELP" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-help.html b/Documentation/nvme-help.html index 95d61fd..4d9057d 100644 --- a/Documentation/nvme-help.html +++ b/Documentation/nvme-help.html @@ -794,7 +794,7 @@ Show help for nvme smart log: diff --git a/Documentation/nvme-huawei-id-ctrl.1 b/Documentation/nvme-huawei-id-ctrl.1 index e351145..5b3a9d0 100644 --- a/Documentation/nvme-huawei-id-ctrl.1 +++ b/Documentation/nvme-huawei-id-ctrl.1 @@ -2,12 +2,12 @@ .\" Title: nvme-huawei-id-ctrl .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-HUAWEI\-ID\-CT" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-HUAWEI\-ID\-CT" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-huawei-id-ctrl.html b/Documentation/nvme-huawei-id-ctrl.html index 2644b5c..f6a617d 100644 --- a/Documentation/nvme-huawei-id-ctrl.html +++ b/Documentation/nvme-huawei-id-ctrl.html @@ -855,7 +855,7 @@ fields in a human readable format: diff --git a/Documentation/nvme-huawei-list.1 b/Documentation/nvme-huawei-list.1 index 7c74936..04d701e 100644 --- a/Documentation/nvme-huawei-list.1 +++ b/Documentation/nvme-huawei-list.1 @@ -2,12 +2,12 @@ .\" Title: nvme-list .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-LIST" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-LIST" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-huawei-list.html b/Documentation/nvme-huawei-list.html index 98068b8..4c6a3e7 100644 --- a/Documentation/nvme-huawei-list.html +++ b/Documentation/nvme-huawei-list.html @@ -797,7 +797,7 @@ for those Huawei devices as well as some pertinent information about them.

diff --git a/Documentation/nvme-id-ctrl.1 b/Documentation/nvme-id-ctrl.1 index c795bbc..04dc94b 100644 --- a/Documentation/nvme-id-ctrl.1 +++ b/Documentation/nvme-id-ctrl.1 @@ -2,12 +2,12 @@ .\" Title: nvme-id-ctrl .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ID\-CTRL" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ID\-CTRL" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-id-ctrl.html b/Documentation/nvme-id-ctrl.html index f1a2395..09a26f6 100644 --- a/Documentation/nvme-id-ctrl.html +++ b/Documentation/nvme-id-ctrl.html @@ -910,7 +910,7 @@ int main(int argc, char **argv) diff --git a/Documentation/nvme-id-domain.1 b/Documentation/nvme-id-domain.1 index 3313319..cb93376 100644 --- a/Documentation/nvme-id-domain.1 +++ b/Documentation/nvme-id-domain.1 @@ -2,12 +2,12 @@ .\" Title: nvme-id-domain .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ID\-DOMAIN" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ID\-DOMAIN" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-id-domain.html b/Documentation/nvme-id-domain.html index d05b1b3..a029b28 100644 --- a/Documentation/nvme-id-domain.html +++ b/Documentation/nvme-id-domain.html @@ -812,7 +812,7 @@ device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).

diff --git a/Documentation/nvme-id-iocs.1 b/Documentation/nvme-id-iocs.1 index 8dd7702..8348ee3 100644 --- a/Documentation/nvme-id-iocs.1 +++ b/Documentation/nvme-id-iocs.1 @@ -2,12 +2,12 @@ .\" Title: nvme-id-iocs .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ID\-IOCS" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ID\-IOCS" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-id-iocs.html b/Documentation/nvme-id-iocs.html index f045c59..479201c 100644 --- a/Documentation/nvme-id-iocs.html +++ b/Documentation/nvme-id-iocs.html @@ -844,7 +844,7 @@ show the fields in human readable format diff --git a/Documentation/nvme-id-ns.1 b/Documentation/nvme-id-ns.1 index 242b0d8..6225e12 100644 --- a/Documentation/nvme-id-ns.1 +++ b/Documentation/nvme-id-ns.1 @@ -2,12 +2,12 @@ .\" Title: nvme-id-ns .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ID\-NS" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ID\-NS" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-id-ns.html b/Documentation/nvme-id-ns.html index 63a32ab..437795f 100644 --- a/Documentation/nvme-id-ns.html +++ b/Documentation/nvme-id-ns.html @@ -955,7 +955,7 @@ int main(int argc, char **argv) diff --git a/Documentation/nvme-id-nvmset.1 b/Documentation/nvme-id-nvmset.1 index cfecb07..e2ff2e2 100644 --- a/Documentation/nvme-id-nvmset.1 +++ b/Documentation/nvme-id-nvmset.1 @@ -2,12 +2,12 @@ .\" Title: nvme-id-nvmset .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ID\-NVMSET" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ID\-NVMSET" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-id-nvmset.html b/Documentation/nvme-id-nvmset.html index e6e5c88..9428be6 100644 --- a/Documentation/nvme-id-nvmset.html +++ b/Documentation/nvme-id-nvmset.html @@ -851,7 +851,7 @@ as shown in the above example, or you can 'cat' a saved output buff diff --git a/Documentation/nvme-intel-id-ctrl.1 b/Documentation/nvme-intel-id-ctrl.1 index 61e10b7..6f14121 100644 --- a/Documentation/nvme-intel-id-ctrl.1 +++ b/Documentation/nvme-intel-id-ctrl.1 @@ -2,12 +2,12 @@ .\" Title: nvme-intel-id-ctrl .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-INTEL\-ID\-CTR" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-INTEL\-ID\-CTR" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-intel-id-ctrl.html b/Documentation/nvme-intel-id-ctrl.html index 9c83d00..37e6228 100644 --- a/Documentation/nvme-intel-id-ctrl.html +++ b/Documentation/nvme-intel-id-ctrl.html @@ -853,7 +853,7 @@ fields in a human readable format: diff --git a/Documentation/nvme-intel-internal-log.1 b/Documentation/nvme-intel-internal-log.1 index 122d313..25f9984 100644 --- a/Documentation/nvme-intel-internal-log.1 +++ b/Documentation/nvme-intel-internal-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-intel-internal-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-INTEL\-INTERNA" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-INTEL\-INTERNA" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-intel-internal-log.html b/Documentation/nvme-intel-internal-log.html index 19b66f7..16f40d1 100644 --- a/Documentation/nvme-intel-internal-log.html +++ b/Documentation/nvme-intel-internal-log.html @@ -873,7 +873,7 @@ Gets the event log from the device and saves to defined file: diff --git a/Documentation/nvme-intel-lat-stats.1 b/Documentation/nvme-intel-lat-stats.1 index 4e7c93a..85af949 100644 --- a/Documentation/nvme-intel-lat-stats.1 +++ b/Documentation/nvme-intel-lat-stats.1 @@ -2,12 +2,12 @@ .\" Title: nvme-intel-lat-stats .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-INTEL\-LAT\-ST" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-INTEL\-LAT\-ST" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-intel-lat-stats.html b/Documentation/nvme-intel-lat-stats.html index 832ea13..fe75c8f 100644 --- a/Documentation/nvme-intel-lat-stats.html +++ b/Documentation/nvme-intel-lat-stats.html @@ -832,7 +832,7 @@ Get the write statistics diff --git a/Documentation/nvme-intel-market-name.1 b/Documentation/nvme-intel-market-name.1 index 9bc461f..0338c4d 100644 --- a/Documentation/nvme-intel-market-name.1 +++ b/Documentation/nvme-intel-market-name.1 @@ -2,12 +2,12 @@ .\" Title: nvme-intel-market-name .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-INTEL\-MARKET\" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-INTEL\-MARKET\" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-intel-market-name.html b/Documentation/nvme-intel-market-name.html index d0832f9..2fda9a0 100644 --- a/Documentation/nvme-intel-market-name.html +++ b/Documentation/nvme-intel-market-name.html @@ -813,7 +813,7 @@ Get the marketing name diff --git a/Documentation/nvme-intel-smart-log-add.1 b/Documentation/nvme-intel-smart-log-add.1 index a90ac51..b11957f 100644 --- a/Documentation/nvme-intel-smart-log-add.1 +++ b/Documentation/nvme-intel-smart-log-add.1 @@ -2,12 +2,12 @@ .\" Title: nvme-intel-smart-log-add .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-INTEL\-SMART\-" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-INTEL\-SMART\-" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-intel-smart-log-add.html b/Documentation/nvme-intel-smart-log-add.html index c842af1..55a81a4 100644 --- a/Documentation/nvme-intel-smart-log-add.html +++ b/Documentation/nvme-intel-smart-log-add.html @@ -850,7 +850,7 @@ Print the raw Intel Additional SMART log to a file: diff --git a/Documentation/nvme-intel-temp-stats.1 b/Documentation/nvme-intel-temp-stats.1 index de26521..e446276 100644 --- a/Documentation/nvme-intel-temp-stats.1 +++ b/Documentation/nvme-intel-temp-stats.1 @@ -2,12 +2,12 @@ .\" Title: nvme-intel-temp-stats .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-INTEL\-TEMP\-S" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-INTEL\-TEMP\-S" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-intel-temp-stats.html b/Documentation/nvme-intel-temp-stats.html index 4485f29..0c7fa3c 100644 --- a/Documentation/nvme-intel-temp-stats.html +++ b/Documentation/nvme-intel-temp-stats.html @@ -822,7 +822,7 @@ Print the raw SMART log to a file: diff --git a/Documentation/nvme-io-passthru.1 b/Documentation/nvme-io-passthru.1 index 9730ec0..fceda0e 100644 --- a/Documentation/nvme-io-passthru.1 +++ b/Documentation/nvme-io-passthru.1 @@ -2,12 +2,12 @@ .\" Title: nvme-io-passthru .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-IO\-PASSTHRU" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-IO\-PASSTHRU" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-io-passthru.html b/Documentation/nvme-io-passthru.html index b09f8eb..94f5447 100644 --- a/Documentation/nvme-io-passthru.html +++ b/Documentation/nvme-io-passthru.html @@ -993,7 +993,7 @@ printed to stdout for another program to parse.

diff --git a/Documentation/nvme-lba-status-log.1 b/Documentation/nvme-lba-status-log.1 index d385af3..0423eac 100644 --- a/Documentation/nvme-lba-status-log.1 +++ b/Documentation/nvme-lba-status-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-lba-status-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-LBA\-STATUS\-L" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-LBA\-STATUS\-L" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-lba-status-log.html b/Documentation/nvme-lba-status-log.html index 0cb30f9..00bd601 100644 --- a/Documentation/nvme-lba-status-log.html +++ b/Documentation/nvme-lba-status-log.html @@ -831,7 +831,7 @@ NVME diff --git a/Documentation/nvme-list-ctrl.1 b/Documentation/nvme-list-ctrl.1 index b703e80..a00636a 100644 --- a/Documentation/nvme-list-ctrl.1 +++ b/Documentation/nvme-list-ctrl.1 @@ -2,12 +2,12 @@ .\" Title: nvme-list-ctrl .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-LIST\-CTRL" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-LIST\-CTRL" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-list-ctrl.html b/Documentation/nvme-list-ctrl.html index 16ce038..5d852f3 100644 --- a/Documentation/nvme-list-ctrl.html +++ b/Documentation/nvme-list-ctrl.html @@ -828,7 +828,7 @@ OPTIONS diff --git a/Documentation/nvme-list-endgrp.1 b/Documentation/nvme-list-endgrp.1 index 331d993..39b14a1 100644 --- a/Documentation/nvme-list-endgrp.1 +++ b/Documentation/nvme-list-endgrp.1 @@ -2,12 +2,12 @@ .\" Title: nvme-list-endgrp .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-LIST\-ENDGRP" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-LIST\-ENDGRP" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-list-endgrp.html b/Documentation/nvme-list-endgrp.html index d82561d..ab125c8 100644 --- a/Documentation/nvme-list-endgrp.html +++ b/Documentation/nvme-list-endgrp.html @@ -815,7 +815,7 @@ than or equal to the value specified in the CDW11.ENDGID field.

diff --git a/Documentation/nvme-list-ns.1 b/Documentation/nvme-list-ns.1 index d69bc50..dafc921 100644 --- a/Documentation/nvme-list-ns.1 +++ b/Documentation/nvme-list-ns.1 @@ -2,12 +2,12 @@ .\" Title: nvme-id-ns .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ID\-NS" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ID\-NS" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-list-ns.html b/Documentation/nvme-list-ns.html index 0940bb4..5912e7f 100644 --- a/Documentation/nvme-list-ns.html +++ b/Documentation/nvme-list-ns.html @@ -859,7 +859,7 @@ Print the namespaces present for NVM Command Set in normal format diff --git a/Documentation/nvme-list-subsys.1 b/Documentation/nvme-list-subsys.1 index f806a63..91240f8 100644 --- a/Documentation/nvme-list-subsys.1 +++ b/Documentation/nvme-list-subsys.1 @@ -2,12 +2,12 @@ .\" Title: nvme-list-subsys .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-LIST\-SUBSYS" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-LIST\-SUBSYS" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -55,12 +55,12 @@ or \m[blue]\fBroot@host\fR\m[]\&\s-2\u[1]\d\s+2# nvme list\-subsys nvme\-subsys0 \- NQN=nvmf\-test \e - +\- nvme0 rdma traddr=1\&.1\&.1\&.3 trsvcid=4420 host_traddr=1\&.1\&.1\&.1 - +\- nvme1 rdma traddr=1\&.1\&.1\&.3 trsvcid=4420 host_traddr=1\&.1\&.1\&.2 + +\- nvme0 rdma traddr=1\&.1\&.1\&.3,trsvcid=4420,host_traddr=1\&.1\&.1\&.1 + +\- nvme1 rdma traddr=1\&.1\&.1\&.3,trsvcid=4420,host_traddr=1\&.1\&.1\&.2 nvme\-subsys1 \- NQN=nvmf\-test2 \e - +\- nvme2 rdma traddr=1\&.1\&.1\&.3 trsvcid=4420 host_traddr=1\&.1\&.1\&.2 - +\- nvme3 rdma traddr=1\&.1\&.1\&.3 trsvcid=4420 host_traddr=1\&.1\&.1\&.1 + +\- nvme2 rdma traddr=1\&.1\&.1\&.3,trsvcid=4420,host_traddr=1\&.1\&.1\&.2 + +\- nvme3 rdma traddr=1\&.1\&.1\&.3,trsvcid=4420,host_traddr=1\&.1\&.1\&.1 .fi .if n \{\ .RE @@ -82,12 +82,12 @@ nvme\-subsys1 \- NQN=nvmf\-test2 { "Name" : "nvme0", "Transport" : "rdma", - "Address" : "traddr=1\&.1\&.1\&.3 trsvcid=4420 host_traddr=1\&.1\&.1\&.1" + "Address" : "traddr=1\&.1\&.1\&.3,trsvcid=4420,host_traddr=1\&.1\&.1\&.1" }, { "Name" : "nvme1", "Transport" : "rdma", - "Address" : "traddr=1\&.1\&.1\&.3 trsvcid=4420 host_traddr=1\&.1\&.1\&.2" + "Address" : "traddr=1\&.1\&.1\&.3,trsvcid=4420,host_traddr=1\&.1\&.1\&.2" } ] }, @@ -100,12 +100,12 @@ nvme\-subsys1 \- NQN=nvmf\-test2 { "Name" : "nvme2", "Transport" : "rdma", - "Address" : "traddr=1\&.1\&.1\&.3 trsvcid=4420 host_traddr=1\&.1\&.1\&.2" + "Address" : "traddr=1\&.1\&.1\&.3,trsvcid=4420,host_traddr=1\&.1\&.1\&.2" }, { "Name" : "nvme3", "Transport" : "rdma", - "Address" : "traddr=1\&.1\&.1\&.3 trsvcid=4420 host_traddr=1\&.1\&.1\&.1" + "Address" : "traddr=1\&.1\&.1\&.3,trsvcid=4420,host_traddr=1\&.1\&.1\&.1" } ] } diff --git a/Documentation/nvme-list-subsys.html b/Documentation/nvme-list-subsys.html index c3d5d98..a2f6048 100644 --- a/Documentation/nvme-list-subsys.html +++ b/Documentation/nvme-list-subsys.html @@ -789,12 +789,12 @@ and subsystems leading to the device.

root@host# nvme list-subsys
 nvme-subsys0 - NQN=nvmf-test
 \
- +- nvme0 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.1
- +- nvme1 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.2
+ +- nvme0 rdma traddr=1.1.1.3,trsvcid=4420,host_traddr=1.1.1.1
+ +- nvme1 rdma traddr=1.1.1.3,trsvcid=4420,host_traddr=1.1.1.2
 nvme-subsys1 - NQN=nvmf-test2
 \
- +- nvme2 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.2
- +- nvme3 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.1
+ +- nvme2 rdma traddr=1.1.1.3,trsvcid=4420,host_traddr=1.1.1.2 + +- nvme3 rdma traddr=1.1.1.3,trsvcid=4420,host_traddr=1.1.1.1
@@ -810,12 +810,12 @@ nvme-subsys1 - NQN=nvmf-test2 { "Name" : "nvme0", "Transport" : "rdma", - "Address" : "traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.1" + "Address" : "traddr=1.1.1.3,trsvcid=4420,host_traddr=1.1.1.1" }, { "Name" : "nvme1", "Transport" : "rdma", - "Address" : "traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.2" + "Address" : "traddr=1.1.1.3,trsvcid=4420,host_traddr=1.1.1.2" } ] }, @@ -828,12 +828,12 @@ nvme-subsys1 - NQN=nvmf-test2 { "Name" : "nvme2", "Transport" : "rdma", - "Address" : "traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.2" + "Address" : "traddr=1.1.1.3,trsvcid=4420,host_traddr=1.1.1.2" }, { "Name" : "nvme3", "Transport" : "rdma", - "Address" : "traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.1" + "Address" : "traddr=1.1.1.3,trsvcid=4420,host_traddr=1.1.1.1" } ] } @@ -854,7 +854,7 @@ nvme-subsys1 - NQN=nvmf-test2 diff --git a/Documentation/nvme-list-subsys.txt b/Documentation/nvme-list-subsys.txt index 56045b8..6650bbe 100644 --- a/Documentation/nvme-list-subsys.txt +++ b/Documentation/nvme-list-subsys.txt @@ -30,12 +30,12 @@ EXAMPLES root@host# nvme list-subsys nvme-subsys0 - NQN=nvmf-test \ - +- nvme0 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.1 - +- nvme1 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.2 + +- nvme0 rdma traddr=1.1.1.3,trsvcid=4420,host_traddr=1.1.1.1 + +- nvme1 rdma traddr=1.1.1.3,trsvcid=4420,host_traddr=1.1.1.2 nvme-subsys1 - NQN=nvmf-test2 \ - +- nvme2 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.2 - +- nvme3 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.1 + +- nvme2 rdma traddr=1.1.1.3,trsvcid=4420,host_traddr=1.1.1.2 + +- nvme3 rdma traddr=1.1.1.3,trsvcid=4420,host_traddr=1.1.1.1 [verse] root@host# nvme list-subsys -o json @@ -50,12 +50,12 @@ root@host# nvme list-subsys -o json { "Name" : "nvme0", "Transport" : "rdma", - "Address" : "traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.1" + "Address" : "traddr=1.1.1.3,trsvcid=4420,host_traddr=1.1.1.1" }, { "Name" : "nvme1", "Transport" : "rdma", - "Address" : "traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.2" + "Address" : "traddr=1.1.1.3,trsvcid=4420,host_traddr=1.1.1.2" } ] }, @@ -68,12 +68,12 @@ root@host# nvme list-subsys -o json { "Name" : "nvme2", "Transport" : "rdma", - "Address" : "traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.2" + "Address" : "traddr=1.1.1.3,trsvcid=4420,host_traddr=1.1.1.2" }, { "Name" : "nvme3", "Transport" : "rdma", - "Address" : "traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.1" + "Address" : "traddr=1.1.1.3,trsvcid=4420,host_traddr=1.1.1.1" } ] } diff --git a/Documentation/nvme-list.1 b/Documentation/nvme-list.1 index d2d7edd..cb37b9f 100644 --- a/Documentation/nvme-list.1 +++ b/Documentation/nvme-list.1 @@ -2,12 +2,12 @@ .\" Title: nvme-list .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-LIST" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-LIST" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-list.html b/Documentation/nvme-list.html index ab448d2..14e43d0 100644 --- a/Documentation/nvme-list.html +++ b/Documentation/nvme-list.html @@ -816,7 +816,7 @@ for those devices as well as some pertinent information about them.

diff --git a/Documentation/nvme-lockdown.1 b/Documentation/nvme-lockdown.1 index 1489852..839ae60 100644 --- a/Documentation/nvme-lockdown.1 +++ b/Documentation/nvme-lockdown.1 @@ -2,12 +2,12 @@ .\" Title: nvme-lockdown .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-LOCKDOWN" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-LOCKDOWN" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-lockdown.html b/Documentation/nvme-lockdown.html index 9384877..76c1ce0 100644 --- a/Documentation/nvme-lockdown.html +++ b/Documentation/nvme-lockdown.html @@ -850,7 +850,7 @@ Identifier.

diff --git a/Documentation/nvme-mi-cmd-support-effects-log.1 b/Documentation/nvme-mi-cmd-support-effects-log.1 index d4b24f9..eb5119b 100644 --- a/Documentation/nvme-mi-cmd-support-effects-log.1 +++ b/Documentation/nvme-mi-cmd-support-effects-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-mi-cmd-support-effects-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-MI\-CMD\-SUPPO" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-MI\-CMD\-SUPPO" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-mi-cmd-support-effects-log.html b/Documentation/nvme-mi-cmd-support-effects-log.html index fb64b16..679ddda 100644 --- a/Documentation/nvme-mi-cmd-support-effects-log.html +++ b/Documentation/nvme-mi-cmd-support-effects-log.html @@ -815,7 +815,7 @@ raw buffer may be printed to stdout.

diff --git a/Documentation/nvme-micron-clear-pcie-errors.1 b/Documentation/nvme-micron-clear-pcie-errors.1 index 0914d6b..4b2a465 100644 --- a/Documentation/nvme-micron-clear-pcie-errors.1 +++ b/Documentation/nvme-micron-clear-pcie-errors.1 @@ -2,12 +2,12 @@ .\" Title: nvme-micron-clear-pcie-errors .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-MICRON\-CLEAR\" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-MICRON\-CLEAR\" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-micron-clear-pcie-errors.html b/Documentation/nvme-micron-clear-pcie-errors.html index 8544e15..d9f9ee4 100644 --- a/Documentation/nvme-micron-clear-pcie-errors.html +++ b/Documentation/nvme-micron-clear-pcie-errors.html @@ -798,7 +798,7 @@ Retrieve NAND statistics information diff --git a/Documentation/nvme-micron-internal-log.1 b/Documentation/nvme-micron-internal-log.1 index 8bca8a9..1edfea1 100644 --- a/Documentation/nvme-micron-internal-log.1 +++ b/Documentation/nvme-micron-internal-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-micron-internal-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-MICRON\-INTERN" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-MICRON\-INTERN" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-micron-internal-log.html b/Documentation/nvme-micron-internal-log.html index 8f7d565..c9625cd 100644 --- a/Documentation/nvme-micron-internal-log.html +++ b/Documentation/nvme-micron-internal-log.html @@ -813,7 +813,7 @@ Gets the logs from the device and saves to micron_logs.zip file diff --git a/Documentation/nvme-micron-nand-stats.1 b/Documentation/nvme-micron-nand-stats.1 index fb820e1..0b0c11a 100644 --- a/Documentation/nvme-micron-nand-stats.1 +++ b/Documentation/nvme-micron-nand-stats.1 @@ -2,12 +2,12 @@ .\" Title: nvme-micron-nand-stats .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-MICRON\-NAND\-" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-MICRON\-NAND\-" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-micron-nand-stats.html b/Documentation/nvme-micron-nand-stats.html index 7be9eda..d796172 100644 --- a/Documentation/nvme-micron-nand-stats.html +++ b/Documentation/nvme-micron-nand-stats.html @@ -799,7 +799,7 @@ Retrieve NAND statistics information diff --git a/Documentation/nvme-micron-pcie-stats.1 b/Documentation/nvme-micron-pcie-stats.1 index f6947d7..a674c24 100644 --- a/Documentation/nvme-micron-pcie-stats.1 +++ b/Documentation/nvme-micron-pcie-stats.1 @@ -2,12 +2,12 @@ .\" Title: nvme-micron-pcie-stats .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-MICRON\-PCIE\-" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-MICRON\-PCIE\-" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-micron-pcie-stats.html b/Documentation/nvme-micron-pcie-stats.html index 20f6be2..d341dad 100644 --- a/Documentation/nvme-micron-pcie-stats.html +++ b/Documentation/nvme-micron-pcie-stats.html @@ -799,7 +799,7 @@ Retrieve PCIe error information diff --git a/Documentation/nvme-micron-selective-download.1 b/Documentation/nvme-micron-selective-download.1 index de56701..4ae235a 100644 --- a/Documentation/nvme-micron-selective-download.1 +++ b/Documentation/nvme-micron-selective-download.1 @@ -2,12 +2,12 @@ .\" Title: nvme-micron-selective-download .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-MICRON\-SELECT" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-MICRON\-SELECT" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-micron-selective-download.html b/Documentation/nvme-micron-selective-download.html index 7ae5e2a..4b6358b 100644 --- a/Documentation/nvme-micron-selective-download.html +++ b/Documentation/nvme-micron-selective-download.html @@ -867,7 +867,7 @@ Update eeprom, OOB and main firmware diff --git a/Documentation/nvme-micron-smart-add-log.1 b/Documentation/nvme-micron-smart-add-log.1 index 56da6d8..e5e31d5 100644 --- a/Documentation/nvme-micron-smart-add-log.1 +++ b/Documentation/nvme-micron-smart-add-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-micron-smart-add-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-MICRON\-SMART\" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-MICRON\-SMART\" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-micron-smart-add-log.html b/Documentation/nvme-micron-smart-add-log.html index ad6e58d..f763a2d 100644 --- a/Documentation/nvme-micron-smart-add-log.html +++ b/Documentation/nvme-micron-smart-add-log.html @@ -808,7 +808,7 @@ Retrieve NAND/extended SMART data and display in json format diff --git a/Documentation/nvme-micron-temperature-stats.1 b/Documentation/nvme-micron-temperature-stats.1 index 225588c..b222514 100644 --- a/Documentation/nvme-micron-temperature-stats.1 +++ b/Documentation/nvme-micron-temperature-stats.1 @@ -2,12 +2,12 @@ .\" Title: nvme-micron-temperature-stats .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-MICRON\-TEMPER" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-MICRON\-TEMPER" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-micron-temperature-stats.html b/Documentation/nvme-micron-temperature-stats.html index baa045f..6317613 100644 --- a/Documentation/nvme-micron-temperature-stats.html +++ b/Documentation/nvme-micron-temperature-stats.html @@ -799,7 +799,7 @@ Retrieve temperature information diff --git a/Documentation/nvme-netapp-ontapdevices.1 b/Documentation/nvme-netapp-ontapdevices.1 index d810b05..38cf1b8 100644 --- a/Documentation/nvme-netapp-ontapdevices.1 +++ b/Documentation/nvme-netapp-ontapdevices.1 @@ -2,12 +2,12 @@ .\" Title: nvme-netapp-ontapdevices .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-NETAPP\-ONTAPD" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-NETAPP\-ONTAPD" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-netapp-ontapdevices.html b/Documentation/nvme-netapp-ontapdevices.html index 0587640..308046b 100644 --- a/Documentation/nvme-netapp-ontapdevices.html +++ b/Documentation/nvme-netapp-ontapdevices.html @@ -807,7 +807,7 @@ Display information, in a column-based format, for ONTAP devices. diff --git a/Documentation/nvme-netapp-smdevices.1 b/Documentation/nvme-netapp-smdevices.1 index 2df22e2..9b50f46 100644 --- a/Documentation/nvme-netapp-smdevices.1 +++ b/Documentation/nvme-netapp-smdevices.1 @@ -2,12 +2,12 @@ .\" Title: nvme-netapp-smdevices .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-NETAPP\-SMDEVI" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-NETAPP\-SMDEVI" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-netapp-smdevices.html b/Documentation/nvme-netapp-smdevices.html index d974e9d..f1c7fb8 100644 --- a/Documentation/nvme-netapp-smdevices.html +++ b/Documentation/nvme-netapp-smdevices.html @@ -809,7 +809,7 @@ namespace. diff --git a/Documentation/nvme-ns-descs.1 b/Documentation/nvme-ns-descs.1 index 5e30c33..fe7f914 100644 --- a/Documentation/nvme-ns-descs.1 +++ b/Documentation/nvme-ns-descs.1 @@ -2,12 +2,12 @@ .\" Title: nvme-ns-descs .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-NS\-DESCS" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-NS\-DESCS" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-ns-descs.html b/Documentation/nvme-ns-descs.html index 8e3a4b8..4f0a4b9 100644 --- a/Documentation/nvme-ns-descs.html +++ b/Documentation/nvme-ns-descs.html @@ -857,7 +857,7 @@ Have the program return the raw structure in binary: diff --git a/Documentation/nvme-ns-rescan.1 b/Documentation/nvme-ns-rescan.1 index c8ba887..729b0c6 100644 --- a/Documentation/nvme-ns-rescan.1 +++ b/Documentation/nvme-ns-rescan.1 @@ -2,12 +2,12 @@ .\" Title: nvme-ns-rescan .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-NS\-RESCAN" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-NS\-RESCAN" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-ns-rescan.html b/Documentation/nvme-ns-rescan.html index b9af4b3..245d99e 100644 --- a/Documentation/nvme-ns-rescan.html +++ b/Documentation/nvme-ns-rescan.html @@ -794,7 +794,7 @@ Rescans the nvme namespaces. diff --git a/Documentation/nvme-nvm-id-ctrl.1 b/Documentation/nvme-nvm-id-ctrl.1 index 0472c0e..2d5ab5c 100644 --- a/Documentation/nvme-nvm-id-ctrl.1 +++ b/Documentation/nvme-nvm-id-ctrl.1 @@ -2,12 +2,12 @@ .\" Title: nvme-nvm-id-ctrl .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-NVM\-ID\-CTRL" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-NVM\-ID\-CTRL" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-nvm-id-ctrl.html b/Documentation/nvme-nvm-id-ctrl.html index ef1b59b..53488bc 100644 --- a/Documentation/nvme-nvm-id-ctrl.html +++ b/Documentation/nvme-nvm-id-ctrl.html @@ -821,7 +821,7 @@ Show the output in json format diff --git a/Documentation/nvme-ocp-latency-monitor-log.1 b/Documentation/nvme-ocp-latency-monitor-log.1 index c5a2963..7e06919 100644 --- a/Documentation/nvme-ocp-latency-monitor-log.1 +++ b/Documentation/nvme-ocp-latency-monitor-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-ocp-latency-monitor-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-OCP\-LATENCY\-" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-OCP\-LATENCY\-" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-ocp-latency-monitor-log.html b/Documentation/nvme-ocp-latency-monitor-log.html index 8e3ec2a..e774030 100644 --- a/Documentation/nvme-ocp-latency-monitor-log.html +++ b/Documentation/nvme-ocp-latency-monitor-log.html @@ -811,7 +811,7 @@ Displays the get latency monitor log for the device: diff --git a/Documentation/nvme-ocp-smart-add-log.1 b/Documentation/nvme-ocp-smart-add-log.1 index f5c2fc4..d5a666d 100644 --- a/Documentation/nvme-ocp-smart-add-log.1 +++ b/Documentation/nvme-ocp-smart-add-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-ocp-smart-add-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-OCP\-SMART\-AD" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-OCP\-SMART\-AD" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-ocp-smart-add-log.html b/Documentation/nvme-ocp-smart-add-log.html index 8fd92d6..c9213c8 100644 --- a/Documentation/nvme-ocp-smart-add-log.html +++ b/Documentation/nvme-ocp-smart-add-log.html @@ -812,7 +812,7 @@ Has the program issue a smart-add-log command to retrieve the 0xC0 log page. diff --git a/Documentation/nvme-persistent-event-log.1 b/Documentation/nvme-persistent-event-log.1 index 94f145b..89e8549 100644 --- a/Documentation/nvme-persistent-event-log.1 +++ b/Documentation/nvme-persistent-event-log.1 @@ -2,12 +2,12 @@ .\" Title: persistent-event-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "PERSISTENT\-EVENT\-L" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "PERSISTENT\-EVENT\-L" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-persistent-event-log.html b/Documentation/nvme-persistent-event-log.html index a89cca4..c0bfba2 100644 --- a/Documentation/nvme-persistent-event-log.html +++ b/Documentation/nvme-persistent-event-log.html @@ -867,7 +867,7 @@ Print the raw persistent event log to a file: diff --git a/Documentation/nvme-pred-lat-event-agg-log.1 b/Documentation/nvme-pred-lat-event-agg-log.1 index 2bf5b6b..a918a0c 100644 --- a/Documentation/nvme-pred-lat-event-agg-log.1 +++ b/Documentation/nvme-pred-lat-event-agg-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-pred-lat-event-agg-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-PRED\-LAT\-EVE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-PRED\-LAT\-EVE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-pred-lat-event-agg-log.html b/Documentation/nvme-pred-lat-event-agg-log.html index a49054b..ca0fe95 100644 --- a/Documentation/nvme-pred-lat-event-agg-log.html +++ b/Documentation/nvme-pred-lat-event-agg-log.html @@ -863,7 +863,7 @@ Print the raw Predictable Latency Event Aggregate log to a file: diff --git a/Documentation/nvme-predictable-lat-log.1 b/Documentation/nvme-predictable-lat-log.1 index 0b7e4bc..8b8ea1a 100644 --- a/Documentation/nvme-predictable-lat-log.1 +++ b/Documentation/nvme-predictable-lat-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-predictable-lat-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-PREDICTABLE\-L" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-PREDICTABLE\-L" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-predictable-lat-log.html b/Documentation/nvme-predictable-lat-log.html index f66c376..d2ff242 100644 --- a/Documentation/nvme-predictable-lat-log.html +++ b/Documentation/nvme-predictable-lat-log.html @@ -850,7 +850,7 @@ Print the raw Predictable latency per NVM set log to a file: diff --git a/Documentation/nvme-primary-ctrl-caps.1 b/Documentation/nvme-primary-ctrl-caps.1 index 6a9d215..5d58131 100644 --- a/Documentation/nvme-primary-ctrl-caps.1 +++ b/Documentation/nvme-primary-ctrl-caps.1 @@ -2,12 +2,12 @@ .\" Title: nvme-primary-ctrl-caps .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-PRIMARY\-CTRL\" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-PRIMARY\-CTRL\" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-primary-ctrl-caps.html b/Documentation/nvme-primary-ctrl-caps.html index 0c85a41..ed4212a 100644 --- a/Documentation/nvme-primary-ctrl-caps.html +++ b/Documentation/nvme-primary-ctrl-caps.html @@ -835,7 +835,7 @@ fields in a human readable format: diff --git a/Documentation/nvme-read.1 b/Documentation/nvme-read.1 index db0eb59..5183aac 100644 --- a/Documentation/nvme-read.1 +++ b/Documentation/nvme-read.1 @@ -2,12 +2,12 @@ .\" Title: nvme-read .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-READ" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-READ" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-read.html b/Documentation/nvme-read.html index 8c37390..4165407 100644 --- a/Documentation/nvme-read.html +++ b/Documentation/nvme-read.html @@ -1056,7 +1056,7 @@ metadata is passes.

diff --git a/Documentation/nvme-reset.1 b/Documentation/nvme-reset.1 index 287d477..512735e 100644 --- a/Documentation/nvme-reset.1 +++ b/Documentation/nvme-reset.1 @@ -2,12 +2,12 @@ .\" Title: nvme-reset .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-RESET" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-RESET" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-reset.html b/Documentation/nvme-reset.html index d55fd0f..d08c1bb 100644 --- a/Documentation/nvme-reset.html +++ b/Documentation/nvme-reset.html @@ -794,7 +794,7 @@ Resets the controller. diff --git a/Documentation/nvme-resv-acquire.1 b/Documentation/nvme-resv-acquire.1 index 7bf7e05..211cb35 100644 --- a/Documentation/nvme-resv-acquire.1 +++ b/Documentation/nvme-resv-acquire.1 @@ -2,12 +2,12 @@ .\" Title: nvme-resv-acquire .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-RESV\-ACQUIRE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-RESV\-ACQUIRE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-resv-acquire.html b/Documentation/nvme-resv-acquire.html index 23702b4..97a2018 100644 --- a/Documentation/nvme-resv-acquire.html +++ b/Documentation/nvme-resv-acquire.html @@ -948,7 +948,7 @@ cellspacing="0" cellpadding="4"> diff --git a/Documentation/nvme-resv-notif-log.1 b/Documentation/nvme-resv-notif-log.1 index 6b54042..6296f55 100644 --- a/Documentation/nvme-resv-notif-log.1 +++ b/Documentation/nvme-resv-notif-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-resv-notif-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-RESV\-NOTIF\-L" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-RESV\-NOTIF\-L" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-resv-notif-log.html b/Documentation/nvme-resv-notif-log.html index 8e582e9..e0d9a8d 100644 --- a/Documentation/nvme-resv-notif-log.html +++ b/Documentation/nvme-resv-notif-log.html @@ -822,7 +822,7 @@ Print the output in json format: diff --git a/Documentation/nvme-resv-register.1 b/Documentation/nvme-resv-register.1 index 3be6292..aab1d65 100644 --- a/Documentation/nvme-resv-register.1 +++ b/Documentation/nvme-resv-register.1 @@ -2,12 +2,12 @@ .\" Title: nvme-resv-register .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-RESV\-REGISTER" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-RESV\-REGISTER" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-resv-register.html b/Documentation/nvme-resv-register.html index b09c3f2..772bea8 100644 --- a/Documentation/nvme-resv-register.html +++ b/Documentation/nvme-resv-register.html @@ -937,7 +937,7 @@ cellspacing="0" cellpadding="4"> diff --git a/Documentation/nvme-resv-release.1 b/Documentation/nvme-resv-release.1 index 7466335..30ec55c 100644 --- a/Documentation/nvme-resv-release.1 +++ b/Documentation/nvme-resv-release.1 @@ -2,12 +2,12 @@ .\" Title: nvme-resv-release .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-RESV\-RELEASE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-RESV\-RELEASE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-resv-release.html b/Documentation/nvme-resv-release.html index 3878661..0e25e72 100644 --- a/Documentation/nvme-resv-release.html +++ b/Documentation/nvme-resv-release.html @@ -930,7 +930,7 @@ cellspacing="0" cellpadding="4"> diff --git a/Documentation/nvme-resv-report.1 b/Documentation/nvme-resv-report.1 index a1e3db3..84bc4e2 100644 --- a/Documentation/nvme-resv-report.1 +++ b/Documentation/nvme-resv-report.1 @@ -2,12 +2,12 @@ .\" Title: nvme-resv-report .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-RESV\-REPORT" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-RESV\-REPORT" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-resv-report.html b/Documentation/nvme-resv-report.html index 2b5da01..e861375 100644 --- a/Documentation/nvme-resv-report.html +++ b/Documentation/nvme-resv-report.html @@ -855,7 +855,7 @@ Controller data structure for each such controller).

diff --git a/Documentation/nvme-rpmb.1 b/Documentation/nvme-rpmb.1 index 7a44cde..fa18eca 100644 --- a/Documentation/nvme-rpmb.1 +++ b/Documentation/nvme-rpmb.1 @@ -2,12 +2,12 @@ .\" Title: nvme-rpmb .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-RPMB" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-RPMB" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-rpmb.html b/Documentation/nvme-rpmb.html index 5d9879a..cfcd2f1 100644 --- a/Documentation/nvme-rpmb.html +++ b/Documentation/nvme-rpmb.html @@ -1001,7 +1001,7 @@ data onto output.bin diff --git a/Documentation/nvme-sanitize-log.1 b/Documentation/nvme-sanitize-log.1 index e23f9ec..849e485 100644 --- a/Documentation/nvme-sanitize-log.1 +++ b/Documentation/nvme-sanitize-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-sanitize-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-SANITIZE\-LOG" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-SANITIZE\-LOG" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-sanitize-log.html b/Documentation/nvme-sanitize-log.html index 67b122e..73c9ec0 100644 --- a/Documentation/nvme-sanitize-log.html +++ b/Documentation/nvme-sanitize-log.html @@ -892,7 +892,7 @@ Has the program issue Sanitize-log Command : diff --git a/Documentation/nvme-sanitize.1 b/Documentation/nvme-sanitize.1 index c328d42..37da903 100644 --- a/Documentation/nvme-sanitize.1 +++ b/Documentation/nvme-sanitize.1 @@ -2,12 +2,12 @@ .\" Title: nvme-sanitize .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-SANITIZE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-SANITIZE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -71,7 +71,47 @@ Allow Unrestricted Sanitize Exit: If set, then the sanitize operation is perform .PP \-a , \-\-sanact= .RS 4 -Sanitize Action: 000b \- Reserved 001b \- Exit Failure Mode 010b \- Start a Block Erase sanitize operation 011b \- Start an Overwrite sanitize operation 100b \- Start a Crypto Erase sanitize operation +Sanitize Action: +.TS +allbox tab(:); +lt lt +lt lt +lt lt +lt lt +lt lt +lt lt. +T{ +Value +T}:T{ +Definition +T} +T{ +0x00 +T}:T{ +Reserved +T} +T{ +0x01 +T}:T{ +Exit Failure Mode +T} +T{ +0x02 +T}:T{ +Start a Block Erase sanitize operation +T} +T{ +0x03 +T}:T{ +Start an Overwrite sanitize operation +T} +T{ +0x04 +T}:T{ +Start a Crypto Erase sanitize operation +T} +.TE +.sp 1 .RE .PP \-p , \-\-ovrpat= diff --git a/Documentation/nvme-sanitize.html b/Documentation/nvme-sanitize.html index a620dc6..9d101f7 100644 --- a/Documentation/nvme-sanitize.html +++ b/Documentation/nvme-sanitize.html @@ -845,12 +845,42 @@ provides the result.

Sanitize Action: - 000b - Reserved - 001b - Exit Failure Mode - 010b - Start a Block Erase sanitize operation - 011b - Start an Overwrite sanitize operation - 100b - Start a Crypto Erase sanitize operation

+
+ +++ + + + + + + + + + + + + + + + + + + + + + + + + + +

Value

Definition

0x00

Reserved

0x01

Exit Failure Mode

0x02

Start a Block Erase sanitize operation

0x03

Start an Overwrite sanitize operation

0x04

Start a Crypto Erase sanitize operation

+
-p <overwrite-pattern> @@ -907,7 +937,7 @@ Has the program issue Sanitize Command : diff --git a/Documentation/nvme-sanitize.txt b/Documentation/nvme-sanitize.txt index 196983b..f98d039 100644 --- a/Documentation/nvme-sanitize.txt +++ b/Documentation/nvme-sanitize.txt @@ -65,11 +65,16 @@ OPTIONS -a :: --sanact=:: Sanitize Action: - 000b - Reserved - 001b - Exit Failure Mode - 010b - Start a Block Erase sanitize operation - 011b - Start an Overwrite sanitize operation - 100b - Start a Crypto Erase sanitize operation ++ +[] +|================= +|Value|Definition +|0x00| Reserved +|0x01| Exit Failure Mode +|0x02| Start a Block Erase sanitize operation +|0x03| Start an Overwrite sanitize operation +|0x04| Start a Crypto Erase sanitize operation +|================= -p :: --ovrpat=:: diff --git a/Documentation/nvme-seagate-clear-fw-activate-history.1 b/Documentation/nvme-seagate-clear-fw-activate-history.1 new file mode 100644 index 0000000..d2f1090 --- /dev/null +++ b/Documentation/nvme-seagate-clear-fw-activate-history.1 @@ -0,0 +1,60 @@ +'\" t +.\" Title: nvme-seagate-clear-fw-activate-history +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 11/02/2022 +.\" Manual: NVMe Manual +.\" Source: NVMe +.\" Language: English +.\" +.TH "NVME\-SEAGATE\-CLEAR" "1" "11/02/2022" "NVMe" "NVMe Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nvme-seagate-clear-fw-activate-history \- Clear the firmware activation history for a given Seagate device\&. +.SH "SYNOPSIS" +.sp +.nf +\fInvme seagate clear\-fw\-activate\-history [OPTIONS]\fR +.fi +.SH "DESCRIPTION" +.sp +This command will only work on Seagate devices supporting this feature\&. Not all commands work across all product families\&. +.sp +The \fI\fR may be either an NVMe character device (ex: /dev/nvme0) or an nvme block device (ex: /dev/nvme0n1)\&. +.SH "OPTIONS" +.sp +\-s \-\-save:: specifies that the controller shall save the attribute\&. +.SH "EXAMPLES" +.sp +Clear the FW Activation History for the given Seagate device\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +# nvme seagate clear\-fw\-activate\-history /dev/nvme0 +.fi +.if n \{\ +.RE +.\} +.SH "NVME" +.sp +Part of the nvme\-user suite diff --git a/Documentation/nvme-seagate-clear-fw-activate-history.html b/Documentation/nvme-seagate-clear-fw-activate-history.html new file mode 100644 index 0000000..4773712 --- /dev/null +++ b/Documentation/nvme-seagate-clear-fw-activate-history.html @@ -0,0 +1,799 @@ + + + + + + +nvme-seagate-clear-fw-activate-history (1) + + + + + +
+
+

SYNOPSIS

+
+
+
nvme seagate clear-fw-activate-history <device> [OPTIONS]
+
+
+
+
+
+

DESCRIPTION

+
+

This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families.

+

The <device> may be either an NVMe character device (ex: /dev/nvme0) or an +nvme block device (ex: /dev/nvme0n1).

+
+
+
+

OPTIONS

+
+

-s +--save:: + specifies that the controller shall save the attribute.

+
+
+
+

EXAMPLES

+
+

Clear the FW Activation History for the given Seagate device.

+
+
+
# nvme seagate clear-fw-activate-history /dev/nvme0
+
+
+
+
+

NVME

+
+

Part of the nvme-user suite

+
+
+
+

+ + + diff --git a/Documentation/nvme-seagate-clear-fw-activate-history.txt b/Documentation/nvme-seagate-clear-fw-activate-history.txt new file mode 100644 index 0000000..2b17222 --- /dev/null +++ b/Documentation/nvme-seagate-clear-fw-activate-history.txt @@ -0,0 +1,37 @@ +nvme-seagate-clear-fw-activate-history (1) +============================================ + +NAME +---- +nvme-seagate-clear-fw-activate-history - Clear the firmware activation history for a given Seagate device. + +SYNOPSIS +-------- +[verse] +'nvme seagate clear-fw-activate-history [OPTIONS]' + +DESCRIPTION +----------- +This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families. + +The '' may be either an NVMe character device (ex: /dev/nvme0) or an +nvme block device (ex: /dev/nvme0n1). + +OPTIONS +------- +-s +--save:: + specifies that the controller shall save the attribute. + +EXAMPLES +-------- +Clear the FW Activation History for the given Seagate device. + +------------ +# nvme seagate clear-fw-activate-history /dev/nvme0 +------------ + +NVME +---- +Part of the nvme-user suite diff --git a/Documentation/nvme-seagate-clear-pcie-correctable-errors.1 b/Documentation/nvme-seagate-clear-pcie-correctable-errors.1 new file mode 100644 index 0000000..637ef0b --- /dev/null +++ b/Documentation/nvme-seagate-clear-pcie-correctable-errors.1 @@ -0,0 +1,63 @@ +'\" t +.\" Title: nvme-seagate-clear-pcie-correctable-errors +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 11/02/2022 +.\" Manual: NVMe Manual +.\" Source: NVMe +.\" Language: English +.\" +.TH "NVME\-SEAGATE\-CLEAR" "1" "11/02/2022" "NVMe" "NVMe Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nvme-seagate-clear-pcie-correctable-errors \- Clear Seagate PCIe error statistics +.SH "SYNOPSIS" +.sp +.nf +\fInvme seagate clear\-pcie\-correctable\-errors [] [OPTIONS]\fR +.fi +.SH "DESCRIPTION" +.sp +This command will only work on Seagate devices supporting this feature\&. Not all commands work across all product families\&. +.sp +The \fI\fR parameter is mandatory and may be either an NVMe character device (ex: /dev/nvme0), or an nvme block device (ex: /dev/nvme0n1)\&. +.SH "OPTIONS" +.PP +\-s, \-\-save +.RS 4 +Specifies that the controller shall save the attribute +.RE +.SH "EXAMPLES" +.sp +Clears the PCIe error statistics from the device\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +# nvme seagate clear\-pcie\-correctable\-errors /dev/nvme0 +.fi +.if n \{\ +.RE +.\} +.SH "NVME" +.sp +Part of the nvme\-user suite diff --git a/Documentation/nvme-seagate-clear-pcie-correctable-errors.html b/Documentation/nvme-seagate-clear-pcie-correctable-errors.html new file mode 100644 index 0000000..e6127b9 --- /dev/null +++ b/Documentation/nvme-seagate-clear-pcie-correctable-errors.html @@ -0,0 +1,809 @@ + + + + + + +nvme-seagate-clear-pcie-correctable-errors(1) + + + + + +
+
+

SYNOPSIS

+
+
+
nvme seagate clear-pcie-correctable-errors [<device>]  [OPTIONS]
+
+
+
+
+
+

DESCRIPTION

+
+

This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families.

+

The <device> parameter is mandatory and may be either an NVMe character device (ex: /dev/nvme0), or an +nvme block device (ex: /dev/nvme0n1).

+
+
+
+

OPTIONS

+
+
+
+-s +
+
+--save +
+
+

+ Specifies that the controller shall save the attribute +

+
+
+
+
+
+

EXAMPLES

+
+

Clears the PCIe error statistics from the device.

+
+
+
# nvme seagate clear-pcie-correctable-errors /dev/nvme0
+
+
+
+
+

NVME

+
+

Part of the nvme-user suite

+
+
+
+

+ + + diff --git a/Documentation/nvme-seagate-clear-pcie-correctable-errors.txt b/Documentation/nvme-seagate-clear-pcie-correctable-errors.txt new file mode 100644 index 0000000..33952d3 --- /dev/null +++ b/Documentation/nvme-seagate-clear-pcie-correctable-errors.txt @@ -0,0 +1,38 @@ +nvme-seagate-clear-pcie-correctable-errors(1) +============================================= + +NAME +---- +nvme-seagate-clear-pcie-correctable-errors - Clear Seagate PCIe error statistics + +SYNOPSIS +-------- +[verse] +'nvme seagate clear-pcie-correctable-errors [] [OPTIONS]' + +DESCRIPTION +----------- + +This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families. + +The '' parameter is mandatory and may be either an NVMe character device (ex: /dev/nvme0), or an +nvme block device (ex: /dev/nvme0n1). + +OPTIONS +------- +-s:: +--save:: + Specifies that the controller shall save the attribute + +EXAMPLES +-------- +Clears the PCIe error statistics from the device. + +------------ +# nvme seagate clear-pcie-correctable-errors /dev/nvme0 +------------ + +NVME +---- +Part of the nvme-user suite diff --git a/Documentation/nvme-seagate-cloud-SSD-plugin-version.1 b/Documentation/nvme-seagate-cloud-SSD-plugin-version.1 new file mode 100644 index 0000000..dad16f5 --- /dev/null +++ b/Documentation/nvme-seagate-cloud-SSD-plugin-version.1 @@ -0,0 +1,58 @@ +'\" t +.\" Title: nvme-seagate-cloud-SSD-plugin-version +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 11/02/2022 +.\" Manual: NVMe Manual +.\" Source: NVMe +.\" Language: English +.\" +.TH "NVME\-SEAGATE\-CLOUD" "1" "11/02/2022" "NVMe" "NVMe Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nvme-seagate-cloud-SSD-plugin-version \- Shows OCP Seagate plugin\*(Aqs version information +.SH "SYNOPSIS" +.sp +.nf +\fInvme seagate cloud\-SSD\-plugin\-version\fR +.fi +.SH "DESCRIPTION" +.sp +Shows OCP Seagate plugin\(cqs version information +.SH "OPTIONS" +.sp +No Options +.SH "EXAMPLES" +.sp +Get the OCP plugin version of the specific nvme device\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +# nvme seagate cloud\-SSD\-plugin\-version +.fi +.if n \{\ +.RE +.\} +.SH "NVME" +.sp +Part of the nvme\-user suite diff --git a/Documentation/nvme-seagate-cloud-SSD-plugin-version.html b/Documentation/nvme-seagate-cloud-SSD-plugin-version.html new file mode 100644 index 0000000..fc096a6 --- /dev/null +++ b/Documentation/nvme-seagate-cloud-SSD-plugin-version.html @@ -0,0 +1,794 @@ + + + + + + +nvme-seagate-cloud-SSD-plugin-version (1) + + + + + +
+
+

SYNOPSIS

+
+
+
nvme seagate cloud-SSD-plugin-version
+
+
+
+
+
+

DESCRIPTION

+
+

Shows OCP Seagate plugin’s version information

+
+
+
+

OPTIONS

+
+

No Options

+
+
+
+

EXAMPLES

+
+

Get the OCP plugin version of the specific nvme device.

+
+
+
# nvme seagate cloud-SSD-plugin-version
+
+
+
+
+

NVME

+
+

Part of the nvme-user suite

+
+
+
+

+ + + diff --git a/Documentation/nvme-seagate-cloud-SSD-plugin-version.txt b/Documentation/nvme-seagate-cloud-SSD-plugin-version.txt new file mode 100644 index 0000000..f9a92af --- /dev/null +++ b/Documentation/nvme-seagate-cloud-SSD-plugin-version.txt @@ -0,0 +1,31 @@ +nvme-seagate-cloud-SSD-plugin-version (1) +========================================= + +NAME +---- +nvme-seagate-cloud-SSD-plugin-version - Shows OCP Seagate plugin's version information + +SYNOPSIS +-------- +[verse] +'nvme seagate cloud-SSD-plugin-version' + +DESCRIPTION +----------- +Shows OCP Seagate plugin's version information + +OPTIONS +------- +No Options + +EXAMPLES +-------- +Get the OCP plugin version of the specific nvme device. + +------------ +# nvme seagate cloud-SSD-plugin-version +------------ + +NVME +---- +Part of the nvme-user suite diff --git a/Documentation/nvme-seagate-get-ctrl-tele.1 b/Documentation/nvme-seagate-get-ctrl-tele.1 new file mode 100644 index 0000000..fc1d124 --- /dev/null +++ b/Documentation/nvme-seagate-get-ctrl-tele.1 @@ -0,0 +1,68 @@ +'\" t +.\" Title: nvme-seagate-get-ctrl-tele +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 11/02/2022 +.\" Manual: NVMe Manual +.\" Source: NVMe +.\" Language: English +.\" +.TH "NVME\-SEAGATE\-GET\-" "1" "11/02/2022" "NVMe" "NVMe Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nvme-seagate-get-ctrl-tele \- Retrieve Seagate Controller\-Initiated Telemetry in either hex\-dump (default) or binary format +.SH "SYNOPSIS" +.sp +.nf +\fInvme seagate get\-ctrl\-tele [OPTIONS]\fR +.fi +.SH "DESCRIPTION" +.sp +This command will only work on Seagate devices supporting this feature\&. Not all commands work across all product families\&. +.sp +The \*(Aq\*(Aqparameter is mandatory and may be either an NVMe character device (ex: /dev/nvme0) or an nvme block device (ex: /dev/nvme0n1)\&. +.SH "OPTIONS" +.PP +\-n , \-\-namespace\-id= +.RS 4 +Desired namespace +.RE +.PP +\-b, \-\-raw\-binary +.RS 4 +Output in raw format +.RE +.SH "EXAMPLES" +.sp +Get the controller initiated telemetry log in hexdump or binary format for the specified device\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +# nvme seagate get\-ctrl\-tele /dev/nvme0 +.fi +.if n \{\ +.RE +.\} +.SH "NVME" +.sp +Part of the nvme\-user suite diff --git a/Documentation/nvme-seagate-get-ctrl-tele.html b/Documentation/nvme-seagate-get-ctrl-tele.html new file mode 100644 index 0000000..34e0641 --- /dev/null +++ b/Documentation/nvme-seagate-get-ctrl-tele.html @@ -0,0 +1,820 @@ + + + + + + +nvme-seagate-get-ctrl-tele(1) + + + + + +
+
+

SYNOPSIS

+
+
+
nvme seagate get-ctrl-tele <device> [OPTIONS]
+
+
+
+
+
+

DESCRIPTION

+
+

This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families.

+

The '<device>'parameter is mandatory and may be either an NVMe character device (ex: /dev/nvme0) or an +nvme block device (ex: /dev/nvme0n1).

+
+
+
+

OPTIONS

+
+
+
+-n <NUM> +
+
+--namespace-id=<NUM> +
+
+

+ Desired namespace +

+
+
+-b +
+
+--raw-binary +
+
+

+ Output in raw format +

+
+
+
+
+
+

EXAMPLES

+
+

Get the controller initiated telemetry log in hexdump or binary format for the specified device.

+
+
+
# nvme seagate get-ctrl-tele /dev/nvme0
+
+
+
+
+

NVME

+
+

Part of the nvme-user suite

+
+
+
+

+ + + diff --git a/Documentation/nvme-seagate-get-ctrl-tele.txt b/Documentation/nvme-seagate-get-ctrl-tele.txt new file mode 100644 index 0000000..e170548 --- /dev/null +++ b/Documentation/nvme-seagate-get-ctrl-tele.txt @@ -0,0 +1,42 @@ +nvme-seagate-get-ctrl-tele(1) +============================= + +NAME +---- +nvme-seagate-get-ctrl-tele - Retrieve Seagate Controller-Initiated Telemetry in +either hex-dump (default) or binary format + +SYNOPSIS +-------- +[verse] +'nvme seagate get-ctrl-tele [OPTIONS]' + +DESCRIPTION +----------- +This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families. + +The ''parameter is mandatory and may be either an NVMe character device (ex: /dev/nvme0) or an +nvme block device (ex: /dev/nvme0n1). + +OPTIONS +------- +-n :: +--namespace-id=:: + Desired namespace + +-b:: +--raw-binary:: + Output in raw format + +EXAMPLES +-------- +Get the controller initiated telemetry log in hexdump or binary format for the specified device. + +------------ +# nvme seagate get-ctrl-tele /dev/nvme0 +------------ + +NVME +---- +Part of the nvme-user suite diff --git a/Documentation/nvme-seagate-get-host-tele.1 b/Documentation/nvme-seagate-get-host-tele.1 new file mode 100644 index 0000000..476f106 --- /dev/null +++ b/Documentation/nvme-seagate-get-host-tele.1 @@ -0,0 +1,73 @@ +'\" t +.\" Title: nvme-seagate-get-host-tele +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 11/02/2022 +.\" Manual: NVMe Manual +.\" Source: NVMe +.\" Language: English +.\" +.TH "NVME\-SEAGATE\-GET\-" "1" "11/02/2022" "NVMe" "NVMe Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nvme-seagate-get-host-tele \- Retrieve Seagate Host\-Initiated Telemetry in either hex\-dump (default) or binary format +.SH "SYNOPSIS" +.sp +.nf +\fInvme seagate get\-host\-tele [OPTIONS]\fR +.fi +.SH "DESCRIPTION" +.sp +This will only work on Seagate devices supporting this feature\&. Not all commands work across all product families\&. +.sp +The \fI\fR parameter is mandatory and may be either an NVMe character device (ex: /dev/nvme0) or an nvme block device (ex: /dev/nvme0n1)\&. +.SH "OPTIONS" +.PP +\-n , \-\-namespace\-id= +.RS 4 +desired namespace +.RE +.PP +\-i , \-\-log_specific= +.RS 4 +1 \- controller shall capture Data representing the internal state of the controller at the time the command is processed\&. 0 \- controller shall not update the Telemetry Host Initiated Data\&. +.RE +.PP +\-b, \-\-raw\-binary +.RS 4 +output in raw format +.RE +.SH "EXAMPLES" +.sp +Get the host initiated telemetry log in hexdump or binary format for the specified device\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +# nvme seagate get\-host\-tele /dev/nvme0 +.fi +.if n \{\ +.RE +.\} +.SH "NVME" +.sp +Part of the nvme\-user suite diff --git a/Documentation/nvme-seagate-get-host-tele.html b/Documentation/nvme-seagate-get-host-tele.html new file mode 100644 index 0000000..06589a4 --- /dev/null +++ b/Documentation/nvme-seagate-get-host-tele.html @@ -0,0 +1,832 @@ + + + + + + +nvme-seagate-get-host-tele(1) + + + + + +
+
+

SYNOPSIS

+
+
+
nvme seagate get-host-tele <device> [OPTIONS]
+
+
+
+
+
+

DESCRIPTION

+
+

This will only work on Seagate devices supporting this feature. Not all +commands work across all product families.

+

The <device> parameter is mandatory and may be either an NVMe character device (ex: /dev/nvme0) or an +nvme block device (ex: /dev/nvme0n1).

+
+
+
+

OPTIONS

+
+
+
+-n <NUM> +
+
+--namespace-id=<NUM> +
+
+

+ desired namespace +

+
+
+-i <NUM> +
+
+--log_specific=<NUM> +
+
+

+ 1 - controller shall capture Data representing the internal state of the controller at the time the command is processed. + 0 - controller shall not update the Telemetry Host Initiated Data. +

+
+
+-b +
+
+--raw-binary +
+
+

+ output in raw format +

+
+
+
+
+
+

EXAMPLES

+
+

Get the host initiated telemetry log in hexdump or binary format for the specified device.

+
+
+
# nvme seagate get-host-tele /dev/nvme0
+
+
+
+
+

NVME

+
+

Part of the nvme-user suite

+
+
+
+

+ + + diff --git a/Documentation/nvme-seagate-get-host-tele.txt b/Documentation/nvme-seagate-get-host-tele.txt new file mode 100644 index 0000000..2863c12 --- /dev/null +++ b/Documentation/nvme-seagate-get-host-tele.txt @@ -0,0 +1,47 @@ +nvme-seagate-get-host-tele(1) +============================= + +NAME +---- +nvme-seagate-get-host-tele - Retrieve Seagate Host-Initiated Telemetry in +either hex-dump (default) or binary format + +SYNOPSIS +-------- +[verse] +'nvme seagate get-host-tele [OPTIONS]' + +DESCRIPTION +----------- +This will only work on Seagate devices supporting this feature. Not all +commands work across all product families. + +The '' parameter is mandatory and may be either an NVMe character device (ex: /dev/nvme0) or an +nvme block device (ex: /dev/nvme0n1). + +OPTIONS +------- +-n :: +--namespace-id=:: + desired namespace + +-i :: +--log_specific=:: + 1 - controller shall capture Data representing the internal state of the controller at the time the command is processed. + 0 - controller shall not update the Telemetry Host Initiated Data. + +-b:: +--raw-binary:: + output in raw format + +EXAMPLES +-------- +Get the host initiated telemetry log in hexdump or binary format for the specified device. + +------------ +# nvme seagate get-host-tele /dev/nvme0 +------------ + +NVME +---- +Part of the nvme-user suite diff --git a/Documentation/nvme-seagate-help.1 b/Documentation/nvme-seagate-help.1 new file mode 100644 index 0000000..c380eb0 --- /dev/null +++ b/Documentation/nvme-seagate-help.1 @@ -0,0 +1,85 @@ +'\" t +.\" Title: nvme-seagate-help +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 11/02/2022 +.\" Manual: NVMe Manual +.\" Source: NVMe +.\" Language: English +.\" +.TH "NVME\-SEAGATE\-HELP" "1" "11/02/2022" "NVMe" "NVMe Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nvme-seagate-help \- Shows the Seagate plugin\*(Aqs help information +.SH "SYNOPSIS" +.sp +.nf +\fInvme seagate help\fR +.fi +.SH "DESCRIPTION" +.sp +Provides the help information for the Seagate plugin\&. +.SH "OPTIONS" +.sp +No Options +.SH "EXAMPLES" +.sp +Get help information for specific seagate sub\-commands\&. +.PP +Seagate vendor specific extensions +.RS 4 +The following are all implemented sub\-commands: +.sp +.if n \{\ +.RS 4 +.\} +.nf +vs\-temperature\-stats Retrieve Seagate temperature statistics +vs\-log\-page\-sup Retrieve Seagate Supported Log\-pages Information +vs\-smart\-add\-log Retrieve Seagate extended\-SMART Information +vs\-pcie\-stats Retrieve Seagate PCIe error statistics +clear\-pcie\-correctable\-errors Clear Seagate PCIe error statistics +get\-host\-tele Retrieve Seagate Host\-Initiated Telemetry +get\-ctrl\-tele Retrieve Seagate Controller\-Initiated Telemetry +vs\-internal\-log Retrieve Seagate Controller\-Initiated Telemetry in binary format +plugin\-version Shows Seagate plugin\*(Aqs version information +version Shows the program version +help Display this help +.fi +.if n \{\ +.RE +.\} +.RE +.sp +See \fInvme seagate help \fR for more information on a specific command +.sp +.if n \{\ +.RS 4 +.\} +.nf +# nvme seagate help +.fi +.if n \{\ +.RE +.\} +.SH "NVME" +.sp +Part of the nvme\-user suite diff --git a/Documentation/nvme-seagate-help.html b/Documentation/nvme-seagate-help.html new file mode 100644 index 0000000..6e98d72 --- /dev/null +++ b/Documentation/nvme-seagate-help.html @@ -0,0 +1,819 @@ + + + + + + +nvme-seagate-help(1) + + + + + +
+
+

SYNOPSIS

+
+
+
nvme seagate help
+
+
+
+
+
+

DESCRIPTION

+
+

Provides the help information for the Seagate plugin.

+
+
+
+

OPTIONS

+
+

No Options

+
+
+
+

EXAMPLES

+
+

Get help information for specific seagate sub-commands.

+
+
+Seagate vendor specific extensions +
+
+

+The following are all implemented sub-commands: +

+
+
+
vs-temperature-stats            Retrieve Seagate temperature statistics
+vs-log-page-sup                 Retrieve Seagate Supported Log-pages Information
+vs-smart-add-log                Retrieve Seagate extended-SMART Information
+vs-pcie-stats                   Retrieve Seagate PCIe error statistics
+clear-pcie-correctable-errors   Clear Seagate PCIe error statistics
+get-host-tele                   Retrieve Seagate Host-Initiated Telemetry
+get-ctrl-tele                   Retrieve Seagate Controller-Initiated Telemetry
+vs-internal-log                 Retrieve Seagate Controller-Initiated Telemetry in binary format
+plugin-version                  Shows Seagate plugin's version information
+version                         Shows the program version
+help                            Display this help
+
+
+
+

See nvme seagate help <command> for more information on a specific command

+
+
+
# nvme seagate help
+
+
+
+
+

NVME

+
+

Part of the nvme-user suite

+
+
+
+

+ + + diff --git a/Documentation/nvme-seagate-help.txt b/Documentation/nvme-seagate-help.txt new file mode 100644 index 0000000..0a077a8 --- /dev/null +++ b/Documentation/nvme-seagate-help.txt @@ -0,0 +1,49 @@ +nvme-seagate-help(1) +==================== + +NAME +---- +nvme-seagate-help - Shows the Seagate plugin's help information + +SYNOPSIS +-------- +[verse] +'nvme seagate help' + +DESCRIPTION +----------- +Provides the help information for the Seagate plugin. + +OPTIONS +------- +No Options + +EXAMPLES +-------- +Get help information for specific seagate sub-commands. + +Seagate vendor specific extensions:: + +The following are all implemented sub-commands: + + vs-temperature-stats Retrieve Seagate temperature statistics + vs-log-page-sup Retrieve Seagate Supported Log-pages Information + vs-smart-add-log Retrieve Seagate extended-SMART Information + vs-pcie-stats Retrieve Seagate PCIe error statistics + clear-pcie-correctable-errors Clear Seagate PCIe error statistics + get-host-tele Retrieve Seagate Host-Initiated Telemetry + get-ctrl-tele Retrieve Seagate Controller-Initiated Telemetry + vs-internal-log Retrieve Seagate Controller-Initiated Telemetry in binary format + plugin-version Shows Seagate plugin's version information + version Shows the program version + help Display this help + +See 'nvme seagate help ' for more information on a specific command + +------------ +# nvme seagate help +------------ + +NVME +---- +Part of the nvme-user suite diff --git a/Documentation/nvme-seagate-plugin-version.1 b/Documentation/nvme-seagate-plugin-version.1 new file mode 100644 index 0000000..3f60389 --- /dev/null +++ b/Documentation/nvme-seagate-plugin-version.1 @@ -0,0 +1,58 @@ +'\" t +.\" Title: nvme-seagate-plugin-version +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 11/02/2022 +.\" Manual: NVMe Manual +.\" Source: NVMe +.\" Language: English +.\" +.TH "NVME\-SEAGATE\-PLUGI" "1" "11/02/2022" "NVMe" "NVMe Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nvme-seagate-plugin-version \- Shows Seagate plugin\*(Aqs version information +.SH "SYNOPSIS" +.sp +.nf +\fInvme seagate plugin\-version\fR +.fi +.SH "DESCRIPTION" +.sp +Provides the help information for the Seagate plugin\&. +.SH "OPTIONS" +.sp +No Options +.SH "EXAMPLES" +.sp +Get the plugin version of the specific nvme device\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +# nvme seagate plugin\-version +.fi +.if n \{\ +.RE +.\} +.SH "NVME" +.sp +Part of the nvme\-user suite diff --git a/Documentation/nvme-seagate-plugin-version.html b/Documentation/nvme-seagate-plugin-version.html new file mode 100644 index 0000000..f194008 --- /dev/null +++ b/Documentation/nvme-seagate-plugin-version.html @@ -0,0 +1,794 @@ + + + + + + +nvme-seagate-plugin-version(1) + + + + + +
+
+

SYNOPSIS

+
+
+
nvme seagate plugin-version
+
+
+
+
+
+

DESCRIPTION

+
+

Provides the help information for the Seagate plugin.

+
+
+
+

OPTIONS

+
+

No Options

+
+
+
+

EXAMPLES

+
+

Get the plugin version of the specific nvme device.

+
+
+
# nvme seagate plugin-version
+
+
+
+
+

NVME

+
+

Part of the nvme-user suite

+
+
+
+

+ + + diff --git a/Documentation/nvme-seagate-plugin-version.txt b/Documentation/nvme-seagate-plugin-version.txt new file mode 100644 index 0000000..5e4a759 --- /dev/null +++ b/Documentation/nvme-seagate-plugin-version.txt @@ -0,0 +1,31 @@ +nvme-seagate-plugin-version(1) +============================== + +NAME +---- +nvme-seagate-plugin-version - Shows Seagate plugin's version information + +SYNOPSIS +-------- +[verse] +'nvme seagate plugin-version' + +DESCRIPTION +----------- +Provides the help information for the Seagate plugin. + +OPTIONS +------- +No Options + +EXAMPLES +-------- +Get the plugin version of the specific nvme device. + +------------ +# nvme seagate plugin-version +------------ + +NVME +---- +Part of the nvme-user suite diff --git a/Documentation/nvme-seagate-version.1 b/Documentation/nvme-seagate-version.1 new file mode 100644 index 0000000..920a9fa --- /dev/null +++ b/Documentation/nvme-seagate-version.1 @@ -0,0 +1,58 @@ +'\" t +.\" Title: nvme-seagate-version +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 11/02/2022 +.\" Manual: NVMe Manual +.\" Source: NVMe +.\" Language: English +.\" +.TH "NVME\-SEAGATE\-VERSI" "1" "11/02/2022" "NVMe" "NVMe Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nvme-seagate-version \- Shows the Seagate version information for nvme\-cli +.SH "SYNOPSIS" +.sp +.nf +\fInvme seagate version\fR +.fi +.SH "DESCRIPTION" +.sp +Provides the git version information for the Seagate version for nvme\-cli\&. This is for the nvme\-cli tool\&. +.SH "OPTIONS" +.sp +No Options +.SH "EXAMPLES" +.sp +Get the Seagate version information for nvme\-cli\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +# nvme seagate version +.fi +.if n \{\ +.RE +.\} +.SH "NVME" +.sp +Part of the nvme\-user suite diff --git a/Documentation/nvme-seagate-version.html b/Documentation/nvme-seagate-version.html new file mode 100644 index 0000000..466c0fe --- /dev/null +++ b/Documentation/nvme-seagate-version.html @@ -0,0 +1,794 @@ + + + + + + +nvme-seagate-version(1) + + + + + +
+
+

SYNOPSIS

+
+
+
nvme seagate version
+
+
+
+
+
+

DESCRIPTION

+
+

Provides the git version information for the Seagate version for nvme-cli. This is for the nvme-cli tool.

+
+
+
+

OPTIONS

+
+

No Options

+
+
+
+

EXAMPLES

+
+

Get the Seagate version information for nvme-cli.

+
+
+
# nvme seagate version
+
+
+
+
+

NVME

+
+

Part of the nvme-user suite

+
+
+
+

+ + + diff --git a/Documentation/nvme-seagate-version.txt b/Documentation/nvme-seagate-version.txt new file mode 100644 index 0000000..2d5c7ce --- /dev/null +++ b/Documentation/nvme-seagate-version.txt @@ -0,0 +1,31 @@ +nvme-seagate-version(1) +======================= + +NAME +---- +nvme-seagate-version - Shows the Seagate version information for nvme-cli + +SYNOPSIS +-------- +[verse] +'nvme seagate version' + +DESCRIPTION +----------- +Provides the git version information for the Seagate version for nvme-cli. This is for the nvme-cli tool. + +OPTIONS +------- +No Options + +EXAMPLES +-------- +Get the Seagate version information for nvme-cli. + +------------ +# nvme seagate version +------------ + +NVME +---- +Part of the nvme-user suite diff --git a/Documentation/nvme-seagate-vs-fw-activate-history.1 b/Documentation/nvme-seagate-vs-fw-activate-history.1 new file mode 100644 index 0000000..d74bde3 --- /dev/null +++ b/Documentation/nvme-seagate-vs-fw-activate-history.1 @@ -0,0 +1,68 @@ +'\" t +.\" Title: nvme-seagate-vs-fw-activate-history +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 11/02/2022 +.\" Manual: NVMe Manual +.\" Source: NVMe +.\" Language: English +.\" +.TH "NVME\-SEAGATE\-VS\-F" "1" "11/02/2022" "NVMe" "NVMe Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nvme-seagate-vs-fw-activate-history \- Retrieve Seagate vendor specific Controller\-Initiated Telemetry in binary +.SH "SYNOPSIS" +.sp +.nf +\fInvme seagate vs\-fw\-activate\-history [OPTIONS]\fR +.fi +.SH "DESCRIPTION" +.sp +This command will only work on Seagate devices supporting this feature\&. Not all commands work across all product families\&. +.sp +The \fI\fR may be either an NVMe character device (ex: /dev/nvme0) or an nvme block device (ex: /dev/nvme0n1)\&. +.SH "OPTIONS" +.PP +\-n , \-\-namespace\-id= +.RS 4 +Desired namespace +.RE +.PP +\-f , \-\-dump\-file= +.RS 4 +Dump file +.RE +.SH "EXAMPLES" +.sp +Get the Seagate vendor specific Controller\-Initiated telemetry log for the specified device\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +# nvme seagate vs\-fw\-activate\-history /dev/nvme0 +.fi +.if n \{\ +.RE +.\} +.SH "NVME" +.sp +Part of the nvme\-user suite diff --git a/Documentation/nvme-seagate-vs-fw-activate-history.html b/Documentation/nvme-seagate-vs-fw-activate-history.html new file mode 100644 index 0000000..0ee2f23 --- /dev/null +++ b/Documentation/nvme-seagate-vs-fw-activate-history.html @@ -0,0 +1,820 @@ + + + + + + +nvme-seagate-vs-fw-activate-history (1) + + + + + +
+
+

SYNOPSIS

+
+
+
nvme seagate vs-fw-activate-history <device> [OPTIONS]
+
+
+
+
+
+

DESCRIPTION

+
+

This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families.

+

The <device> may be either an NVMe character device (ex: /dev/nvme0) or an +nvme block device (ex: /dev/nvme0n1).

+
+
+
+

OPTIONS

+
+
+
+-n <NUM> +
+
+--namespace-id=<NUM> +
+
+

+ Desired namespace +

+
+
+-f <FILE> +
+
+--dump-file=<FILE> +
+
+

+ Dump file +

+
+
+
+
+
+

EXAMPLES

+
+

Get the Seagate vendor specific Controller-Initiated telemetry log for the specified device.

+
+
+
# nvme seagate vs-fw-activate-history /dev/nvme0
+
+
+
+
+

NVME

+
+

Part of the nvme-user suite

+
+
+
+

+ + + diff --git a/Documentation/nvme-seagate-vs-fw-activate-history.txt b/Documentation/nvme-seagate-vs-fw-activate-history.txt new file mode 100644 index 0000000..e6b030d --- /dev/null +++ b/Documentation/nvme-seagate-vs-fw-activate-history.txt @@ -0,0 +1,42 @@ +nvme-seagate-vs-fw-activate-history (1) +======================================= + +NAME +---- +nvme-seagate-vs-fw-activate-history - Retrieve Seagate vendor specific +Controller-Initiated Telemetry in binary + +SYNOPSIS +-------- +[verse] +'nvme seagate vs-fw-activate-history [OPTIONS]' + +DESCRIPTION +----------- +This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families. + +The '' may be either an NVMe character device (ex: /dev/nvme0) or an +nvme block device (ex: /dev/nvme0n1). + +OPTIONS +------- +-n :: +--namespace-id=:: + Desired namespace + +-f :: +--dump-file=:: + Dump file + +EXAMPLES +-------- +Get the Seagate vendor specific Controller-Initiated telemetry log for the specified device. + +------------ +# nvme seagate vs-fw-activate-history /dev/nvme0 +------------ + +NVME +---- +Part of the nvme-user suite diff --git a/Documentation/nvme-seagate-vs-internal-log.1 b/Documentation/nvme-seagate-vs-internal-log.1 new file mode 100644 index 0000000..5167cfe --- /dev/null +++ b/Documentation/nvme-seagate-vs-internal-log.1 @@ -0,0 +1,68 @@ +'\" t +.\" Title: nvme-seagate-vs-internal-log +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 11/02/2022 +.\" Manual: NVMe Manual +.\" Source: NVMe +.\" Language: English +.\" +.TH "NVME\-SEAGATE\-VS\-I" "1" "11/02/2022" "NVMe" "NVMe Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nvme-seagate-vs-internal-log \- Retrieve Seagate vendor specific Controller\-Initiated Telemetry in binary +.SH "SYNOPSIS" +.sp +.nf +\fInvme seagate vs\-internal\-log [OPTIONS]\fR +.fi +.SH "DESCRIPTION" +.sp +This command will only work on Seagate devices supporting this feature\&. Not all commands work across all product families\&. +.sp +The \fI\fR parameter is mandatory and may be either an NVMe character device (ex: /dev/nvme0) or an nvme block device (ex: /dev/nvme0n1)\&. +.SH "OPTIONS" +.PP +\-n , \-\-namespace\-id= +.RS 4 +Desired namespace +.RE +.PP +\-f , \-\-dump\-file= +.RS 4 +Dump file +.RE +.SH "EXAMPLES" +.sp +Get the Seagate vendor specific Controller\-Initiated telemetry log for the specified device\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +# nvme seagate vs\-internal\-log /dev/nvme0 +.fi +.if n \{\ +.RE +.\} +.SH "NVME" +.sp +Part of the nvme\-user suite diff --git a/Documentation/nvme-seagate-vs-internal-log.html b/Documentation/nvme-seagate-vs-internal-log.html new file mode 100644 index 0000000..feeadd0 --- /dev/null +++ b/Documentation/nvme-seagate-vs-internal-log.html @@ -0,0 +1,820 @@ + + + + + + +nvme-seagate-vs-internal-log(1) + + + + + +
+
+

SYNOPSIS

+
+
+
nvme seagate vs-internal-log <device> [OPTIONS]
+
+
+
+
+
+

DESCRIPTION

+
+

This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families.

+

The <device> parameter is mandatory and may be either an NVMe character device (ex: /dev/nvme0) or an +nvme block device (ex: /dev/nvme0n1).

+
+
+
+

OPTIONS

+
+
+
+-n <NUM> +
+
+--namespace-id=<NUM> +
+
+

+ Desired namespace +

+
+
+-f <FILE> +
+
+--dump-file=<FILE> +
+
+

+ Dump file +

+
+
+
+
+
+

EXAMPLES

+
+

Get the Seagate vendor specific Controller-Initiated telemetry log for the specified device.

+
+
+
# nvme seagate vs-internal-log /dev/nvme0
+
+
+
+
+

NVME

+
+

Part of the nvme-user suite

+
+
+
+

+ + + diff --git a/Documentation/nvme-seagate-vs-internal-log.txt b/Documentation/nvme-seagate-vs-internal-log.txt new file mode 100644 index 0000000..3284020 --- /dev/null +++ b/Documentation/nvme-seagate-vs-internal-log.txt @@ -0,0 +1,42 @@ +nvme-seagate-vs-internal-log(1) +=============================== + +NAME +---- +nvme-seagate-vs-internal-log - Retrieve Seagate vendor specific +Controller-Initiated Telemetry in binary + +SYNOPSIS +-------- +[verse] +'nvme seagate vs-internal-log [OPTIONS]' + +DESCRIPTION +----------- +This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families. + +The '' parameter is mandatory and may be either an NVMe character device (ex: /dev/nvme0) or an +nvme block device (ex: /dev/nvme0n1). + +OPTIONS +------- +-n :: +--namespace-id=:: + Desired namespace + +-f :: +--dump-file=:: + Dump file + +EXAMPLES +-------- +Get the Seagate vendor specific Controller-Initiated telemetry log for the specified device. + +------------ +# nvme seagate vs-internal-log /dev/nvme0 +------------ + +NVME +---- +Part of the nvme-user suite diff --git a/Documentation/nvme-seagate-vs-log-page-sup.1 b/Documentation/nvme-seagate-vs-log-page-sup.1 new file mode 100644 index 0000000..aa3cb79 --- /dev/null +++ b/Documentation/nvme-seagate-vs-log-page-sup.1 @@ -0,0 +1,75 @@ +'\" t +.\" Title: nvme-seagate-vs-log-page-sup +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 11/02/2022 +.\" Manual: NVMe Manual +.\" Source: NVMe +.\" Language: English +.\" +.TH "NVME\-SEAGATE\-VS\-L" "1" "11/02/2022" "NVMe" "NVMe Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nvme-seagate-vs-log-page-sup \- Retrieve Seagate vendor specific Supported Log\-pages Information +.SH "SYNOPSIS" +.sp +.nf +\fInvme seagate vs\-log\-page\-sup [OPTIONS]\fR +.fi +.SH "DESCRIPTION" +.sp +This command will only work on Seagate devices supporting this feature\&. Not all commands work across all product families\&. +.sp +The \fI\fR may be either an NVMe character device (ex: /dev/nvme0) or an NVMe block device (ex: /dev/nvme0n1)\&. +.SH "OPTIONS" +.PP +\-o , \-\-output\-format= +.RS 4 +Output in binary format +.RE +.SH "EXAMPLES" +.sp +Get the vendor specific log page information for a particular device\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +# nvme seagate vs\-log\-page\-sup /dev/nvme0 +Output: +Seagate Supported Log\-pages count :8 +LogPage\-Id LogPage\-Name + +0x1 ERROR_INFORMATION +0x2 SMART_INFORMATION +0x3 FW_SLOT_INFORMATION +0x5 COMMANDS_SUPPORTED_AND_EFFECTS +0xC8 VS_RECENT_DRIVE_HISTORY +0xC4 VS_EXTENDED_SMART_INFO +0xC5 VS_LIST_SUPPORTED_LOG_PAGE +0xCB VS_PCIE_ERROR_LOG_PAGE +.fi +.if n \{\ +.RE +.\} +.SH "NVME" +.sp +Part of the nvme\-user suite diff --git a/Documentation/nvme-seagate-vs-log-page-sup.html b/Documentation/nvme-seagate-vs-log-page-sup.html new file mode 100644 index 0000000..be821cf --- /dev/null +++ b/Documentation/nvme-seagate-vs-log-page-sup.html @@ -0,0 +1,821 @@ + + + + + + +nvme-seagate-vs-log-page-sup(1) + + + + + +
+
+

SYNOPSIS

+
+
+
nvme seagate vs-log-page-sup <device> [OPTIONS]
+
+
+
+
+
+

DESCRIPTION

+
+

This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families.

+

The <device> may be either an NVMe character device (ex: /dev/nvme0) or an +NVMe block device (ex: /dev/nvme0n1).

+
+
+
+

OPTIONS

+
+
+
+-o <FMT> +
+
+--output-format=<FMT> +
+
+

+ Output in binary format +

+
+
+
+
+
+

EXAMPLES

+
+

Get the vendor specific log page information for a particular device.

+
+
+
# nvme seagate vs-log-page-sup /dev/nvme0
+Output:
+Seagate Supported Log-pages count :8
+LogPage-Id      LogPage-Name
+
+0x1              ERROR_INFORMATION
+0x2              SMART_INFORMATION
+0x3              FW_SLOT_INFORMATION
+0x5              COMMANDS_SUPPORTED_AND_EFFECTS
+0xC8             VS_RECENT_DRIVE_HISTORY
+0xC4             VS_EXTENDED_SMART_INFO
+0xC5             VS_LIST_SUPPORTED_LOG_PAGE
+0xCB             VS_PCIE_ERROR_LOG_PAGE
+
+
+
+
+

NVME

+
+

Part of the nvme-user suite

+
+
+
+

+ + + diff --git a/Documentation/nvme-seagate-vs-log-page-sup.txt b/Documentation/nvme-seagate-vs-log-page-sup.txt new file mode 100644 index 0000000..a5d1488 --- /dev/null +++ b/Documentation/nvme-seagate-vs-log-page-sup.txt @@ -0,0 +1,50 @@ +nvme-seagate-vs-log-page-sup(1) +=============================== + +NAME +---- +nvme-seagate-vs-log-page-sup - Retrieve Seagate vendor specific Supported +Log-pages Information + +SYNOPSIS +-------- +[verse] +'nvme seagate vs-log-page-sup [OPTIONS]' + +DESCRIPTION +----------- +This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families. + +The '' may be either an NVMe character device (ex: /dev/nvme0) or an +NVMe block device (ex: /dev/nvme0n1). + +OPTIONS +------- +-o :: +--output-format=:: + Output in binary format + +EXAMPLES +-------- +Get the vendor specific log page information for a particular device. + +------------ +# nvme seagate vs-log-page-sup /dev/nvme0 +Output: +Seagate Supported Log-pages count :8 +LogPage-Id LogPage-Name + +0x1 ERROR_INFORMATION +0x2 SMART_INFORMATION +0x3 FW_SLOT_INFORMATION +0x5 COMMANDS_SUPPORTED_AND_EFFECTS +0xC8 VS_RECENT_DRIVE_HISTORY +0xC4 VS_EXTENDED_SMART_INFO +0xC5 VS_LIST_SUPPORTED_LOG_PAGE +0xCB VS_PCIE_ERROR_LOG_PAGE +------------ + +NVME +---- +Part of the nvme-user suite diff --git a/Documentation/nvme-seagate-vs-pcie-stats.1 b/Documentation/nvme-seagate-vs-pcie-stats.1 new file mode 100644 index 0000000..03dace8 --- /dev/null +++ b/Documentation/nvme-seagate-vs-pcie-stats.1 @@ -0,0 +1,63 @@ +'\" t +.\" Title: nvme-seagate-vs-pcie-stats +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 11/02/2022 +.\" Manual: NVMe Manual +.\" Source: NVMe +.\" Language: English +.\" +.TH "NVME\-SEAGATE\-VS\-P" "1" "11/02/2022" "NVMe" "NVMe Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nvme-seagate-vs-pcie-stats \- Retrieve Seagate vendor specific PCIe error statistics +.SH "SYNOPSIS" +.sp +.nf +\fInvme seagate vs\-pcie\-stats [OPTIONS]\fR +.fi +.SH "DESCRIPTION" +.sp +This command will only work on Seagate devices supporting this feature\&. Not all commands work across all product families\&. +.sp +The \fI\fR parameter is mandatory and it may be either an NVMe character device (ex: /dev/nvme0) or an nvme block device (ex: /dev/nvme0n1)\&. +.SH "OPTIONS" +.PP +\-o , \-\-output\-format= +.RS 4 +Output in binary format +.RE +.SH "EXAMPLES" +.sp +Get the vendor specific PCIe error statistics for the specified device\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +# nvme seagate vs\-pcie\-stats /dev/nvme0 +.fi +.if n \{\ +.RE +.\} +.SH "NVME" +.sp +Part of the nvme\-user suite diff --git a/Documentation/nvme-seagate-vs-pcie-stats.html b/Documentation/nvme-seagate-vs-pcie-stats.html new file mode 100644 index 0000000..eb41df8 --- /dev/null +++ b/Documentation/nvme-seagate-vs-pcie-stats.html @@ -0,0 +1,809 @@ + + + + + + +nvme-seagate-vs-pcie-stats(1) + + + + + +
+
+

SYNOPSIS

+
+
+
nvme seagate vs-pcie-stats <device> [OPTIONS]
+
+
+
+
+
+

DESCRIPTION

+
+

This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families.

+

The <device> parameter is mandatory and it may be either an NVMe character device (ex: /dev/nvme0) or an +nvme block device (ex: /dev/nvme0n1).

+
+
+
+

OPTIONS

+
+
+
+-o <FMT> +
+
+--output-format=<FMT> +
+
+

+ Output in binary format +

+
+
+
+
+
+

EXAMPLES

+
+

Get the vendor specific PCIe error statistics for the specified device.

+
+
+
# nvme seagate vs-pcie-stats /dev/nvme0
+
+
+
+
+

NVME

+
+

Part of the nvme-user suite

+
+
+
+

+ + + diff --git a/Documentation/nvme-seagate-vs-pcie-stats.txt b/Documentation/nvme-seagate-vs-pcie-stats.txt new file mode 100644 index 0000000..74599bf --- /dev/null +++ b/Documentation/nvme-seagate-vs-pcie-stats.txt @@ -0,0 +1,38 @@ +nvme-seagate-vs-pcie-stats(1) +============================= + +NAME +---- +nvme-seagate-vs-pcie-stats - Retrieve Seagate vendor specific PCIe error +statistics + +SYNOPSIS +-------- +[verse] +'nvme seagate vs-pcie-stats [OPTIONS]' + +DESCRIPTION +----------- +This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families. + +The '' parameter is mandatory and it may be either an NVMe character device (ex: /dev/nvme0) or an +nvme block device (ex: /dev/nvme0n1). + +OPTIONS +------- +-o :: +--output-format=:: + Output in binary format + +EXAMPLES +-------- +Get the vendor specific PCIe error statistics for the specified device. + +------------ +# nvme seagate vs-pcie-stats /dev/nvme0 +------------ + +NVME +---- +Part of the nvme-user suite diff --git a/Documentation/nvme-seagate-vs-smart-add-log.1 b/Documentation/nvme-seagate-vs-smart-add-log.1 new file mode 100644 index 0000000..6d92b88 --- /dev/null +++ b/Documentation/nvme-seagate-vs-smart-add-log.1 @@ -0,0 +1,79 @@ +'\" t +.\" Title: nvme-seagate-vs-smart-add-log +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 11/02/2022 +.\" Manual: NVMe Manual +.\" Source: NVMe +.\" Language: English +.\" +.TH "NVME\-SEAGATE\-VS\-S" "1" "11/02/2022" "NVMe" "NVMe Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nvme-seagate-vs-smart-add-log \- Retrieve Seagate vendor specific extended\-SMART Information +.SH "SYNOPSIS" +.sp +.nf +\fInvme seagate vs\-smart\-add\-log [OPTIONS]\fR +.fi +.SH "DESCRIPTION" +.sp +For the NVMe device given, sends the Seagate vendor log request and either saves the result to a file or dumps the content to stdout\&. +.sp +The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. +.sp +The log contents may be associated with the controller, in which case the namespace parameter is ignored\&. +.sp +Two logs exist, page 0xC4 (Extended SMART log page) and page 0xCF (DRAM Supercap SMART log page) +.sp +This command will only work on Seagate devices supporting this feature\&. Not all commands work across all product families\&. +.SH "OPTIONS" +.PP +\-l , \-\-log= +.RS 4 +Log number, page 0xC4 (Extended SMART log page) and page 0xCF (DRAM Supercap SMART log page) +.RE +.PP +\-n , \-\-namespace\-id= +.RS 4 +Namespace number +.RE +.PP +\-o , \-\-output\-file= +.RS 4 +Output in binary format\&. Defaults to text\-formatted dump to stdout +.RE +.SH "EXAMPLES" +.sp +Get the vendor specific extended SMART information for the specified device\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +# nvme seagate vs\-smart\-add\-log /dev/nvme0 +.fi +.if n \{\ +.RE +.\} +.SH "NVME" +.sp +Part of the nvme\-user suite diff --git a/Documentation/nvme-seagate-vs-smart-add-log.html b/Documentation/nvme-seagate-vs-smart-add-log.html new file mode 100644 index 0000000..682f379 --- /dev/null +++ b/Documentation/nvme-seagate-vs-smart-add-log.html @@ -0,0 +1,837 @@ + + + + + + +nvme-seagate-vs-smart-add-log(1) + + + + + +
+
+

SYNOPSIS

+
+
+
nvme seagate vs-smart-add-log <device> [OPTIONS]
+
+
+
+
+
+

DESCRIPTION

+
+

For the NVMe device given, sends the Seagate vendor log +request and either saves the result to a file or dumps the content to stdout.

+

The <device> parameter is mandatory and may be either the NVMe +character device (ex: /dev/nvme0), or a namespace block device (ex: +/dev/nvme0n1).

+

The log contents may be associated with the controller, in which case the namespace parameter is ignored.

+

Two logs exist, page 0xC4 (Extended SMART log page) and page 0xCF (DRAM Supercap SMART log page)

+

This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families.

+
+
+
+

OPTIONS

+
+
+
+-l <NUM> +
+
+--log=<NUM> +
+
+

+ Log number, page 0xC4 (Extended SMART log page) and page 0xCF (DRAM + Supercap SMART log page) +

+
+
+-n <NUM> +
+
+--namespace-id=<NUM> +
+
+

+ Namespace number +

+
+
+-o <FILE> +
+
+--output-file=<FILE> +
+
+

+ Output in binary format. Defaults to text-formatted dump to stdout +

+
+
+
+
+
+

EXAMPLES

+
+

Get the vendor specific extended SMART information for the specified device.

+
+
+
# nvme seagate vs-smart-add-log /dev/nvme0
+
+
+
+
+

NVME

+
+

Part of the nvme-user suite

+
+
+
+

+ + + diff --git a/Documentation/nvme-seagate-vs-smart-add-log.txt b/Documentation/nvme-seagate-vs-smart-add-log.txt new file mode 100644 index 0000000..962a109 --- /dev/null +++ b/Documentation/nvme-seagate-vs-smart-add-log.txt @@ -0,0 +1,55 @@ +nvme-seagate-vs-smart-add-log(1) +================================ + +NAME +---- +nvme-seagate-vs-smart-add-log - Retrieve Seagate vendor specific extended-SMART +Information + +SYNOPSIS +-------- +[verse] +'nvme seagate vs-smart-add-log [OPTIONS]' + +DESCRIPTION +----------- +For the NVMe device given, sends the Seagate vendor log +request and either saves the result to a file or dumps the content to stdout. + +The parameter is mandatory and may be either the NVMe +character device (ex: /dev/nvme0), or a namespace block device (ex: +/dev/nvme0n1). + +The log contents may be associated with the controller, in which case the namespace parameter is ignored. + +Two logs exist, page 0xC4 (Extended SMART log page) and page 0xCF (DRAM Supercap SMART log page) + +This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families. + +OPTIONS +------- +-l :: +--log=:: + Log number, page 0xC4 (Extended SMART log page) and page 0xCF (DRAM + Supercap SMART log page) + +-n :: +--namespace-id=:: + Namespace number + +-o :: +--output-file=:: + Output in binary format. Defaults to text-formatted dump to stdout + +EXAMPLES +-------- +Get the vendor specific extended SMART information for the specified device. + +------------ +# nvme seagate vs-smart-add-log /dev/nvme0 +------------ + +NVME +---- +Part of the nvme-user suite diff --git a/Documentation/nvme-seagate-vs-temperature-stats.1 b/Documentation/nvme-seagate-vs-temperature-stats.1 new file mode 100644 index 0000000..4b875af --- /dev/null +++ b/Documentation/nvme-seagate-vs-temperature-stats.1 @@ -0,0 +1,63 @@ +'\" t +.\" Title: nvme-seagate-vs-temperature-stats +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 11/02/2022 +.\" Manual: NVMe Manual +.\" Source: NVMe +.\" Language: English +.\" +.TH "NVME\-SEAGATE\-VS\-T" "1" "11/02/2022" "NVMe" "NVMe Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nvme-seagate-vs-temperature-stats \- Retrieve Seagate vendor specific temperature statistics +.SH "SYNOPSIS" +.sp +.nf +\fInvme seagate vs\-temperature\-stats [OPTIONS]\fR +.fi +.SH "DESCRIPTION" +.sp +This command will only work on Seagate devices supporting this feature\&. Not all commands work across all product families\&. +.sp +The \*(Aq\*(Aqparameter is mandatory and it may be either an NVMe character device (ex: /dev/nvme0) or an nvme block device (ex: /dev/nvme0n1)\&. +.SH "OPTIONS" +.PP +\-o , \-\-output\-format= +.RS 4 +Output in binary format +.RE +.SH "EXAMPLES" +.sp +Get vendor specific temperature statistics for the specified device\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +# nvme seagate vs\-temperature\-stats /dev/nvme0 +.fi +.if n \{\ +.RE +.\} +.SH "NVME" +.sp +Part of the nvme\-user suite diff --git a/Documentation/nvme-seagate-vs-temperature-stats.html b/Documentation/nvme-seagate-vs-temperature-stats.html new file mode 100644 index 0000000..74712e0 --- /dev/null +++ b/Documentation/nvme-seagate-vs-temperature-stats.html @@ -0,0 +1,809 @@ + + + + + + +nvme-seagate-vs-temperature-stats(1) + + + + + +
+
+

SYNOPSIS

+
+
+
nvme seagate vs-temperature-stats <device> [OPTIONS]
+
+
+
+
+
+

DESCRIPTION

+
+

This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families.

+

The '<device>'parameter is mandatory and it may be either an NVMe character device (ex: /dev/nvme0) or an +nvme block device (ex: /dev/nvme0n1).

+
+
+
+

OPTIONS

+
+
+
+-o <FMT> +
+
+--output-format=<FMT> +
+
+

+ Output in binary format +

+
+
+
+
+
+

EXAMPLES

+
+

Get vendor specific temperature statistics for the specified device.

+
+
+
# nvme seagate vs-temperature-stats /dev/nvme0
+
+
+
+
+

NVME

+
+

Part of the nvme-user suite

+
+
+
+

+ + + diff --git a/Documentation/nvme-seagate-vs-temperature-stats.txt b/Documentation/nvme-seagate-vs-temperature-stats.txt new file mode 100644 index 0000000..2691e30 --- /dev/null +++ b/Documentation/nvme-seagate-vs-temperature-stats.txt @@ -0,0 +1,38 @@ +nvme-seagate-vs-temperature-stats(1) +==================================== + +NAME +---- +nvme-seagate-vs-temperature-stats - Retrieve Seagate vendor specific +temperature statistics + +SYNOPSIS +-------- +[verse] +'nvme seagate vs-temperature-stats [OPTIONS]' + +DESCRIPTION +----------- +This command will only work on Seagate devices supporting this feature. Not +all commands work across all product families. + +The ''parameter is mandatory and it may be either an NVMe character device (ex: /dev/nvme0) or an +nvme block device (ex: /dev/nvme0n1). + +OPTIONS +------- +-o :: +--output-format=:: + Output in binary format + +EXAMPLES +-------- +Get vendor specific temperature statistics for the specified device. + +------------ +# nvme seagate vs-temperature-stats /dev/nvme0 +------------ + +NVME +---- +Part of the nvme-user suite diff --git a/Documentation/nvme-security-recv.1 b/Documentation/nvme-security-recv.1 index 5e9af12..b3589a7 100644 --- a/Documentation/nvme-security-recv.1 +++ b/Documentation/nvme-security-recv.1 @@ -2,12 +2,12 @@ .\" Title: nvme-security-recv .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-SECURITY\-RECV" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-SECURITY\-RECV" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-security-recv.html b/Documentation/nvme-security-recv.html index 22adf1e..8f5750b 100644 --- a/Documentation/nvme-security-recv.html +++ b/Documentation/nvme-security-recv.html @@ -886,7 +886,7 @@ controller reset occurs.

diff --git a/Documentation/nvme-security-send.1 b/Documentation/nvme-security-send.1 index f4e4583..6ad98dd 100644 --- a/Documentation/nvme-security-send.1 +++ b/Documentation/nvme-security-send.1 @@ -2,12 +2,12 @@ .\" Title: nvme-security-send .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-SECURITY\-SEND" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-SECURITY\-SEND" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-security-send.html b/Documentation/nvme-security-send.html index b468950..0c9afb7 100644 --- a/Documentation/nvme-security-send.html +++ b/Documentation/nvme-security-send.html @@ -872,7 +872,7 @@ Receive command is Security Protocol field dependent as defined in SPC-4.

diff --git a/Documentation/nvme-self-test-log.1 b/Documentation/nvme-self-test-log.1 index 0a2f6e8..e3e3576 100644 --- a/Documentation/nvme-self-test-log.1 +++ b/Documentation/nvme-self-test-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-self-test-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-SELF\-TEST\-LO" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-SELF\-TEST\-LO" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-self-test-log.html b/Documentation/nvme-self-test-log.html index 6343bdf..5d2e381 100644 --- a/Documentation/nvme-self-test-log.html +++ b/Documentation/nvme-self-test-log.html @@ -847,7 +847,7 @@ Get the self-test-log and print it in a json format: diff --git a/Documentation/nvme-set-feature.1 b/Documentation/nvme-set-feature.1 index 841b684..eae48a5 100644 --- a/Documentation/nvme-set-feature.1 +++ b/Documentation/nvme-set-feature.1 @@ -2,12 +2,12 @@ .\" Title: nvme-set-feature .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-SET\-FEATURE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-SET\-FEATURE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-set-feature.html b/Documentation/nvme-set-feature.html index 67dc354..116cced 100644 --- a/Documentation/nvme-set-feature.html +++ b/Documentation/nvme-set-feature.html @@ -899,7 +899,7 @@ Sets the host id to the ascii string. diff --git a/Documentation/nvme-set-property.1 b/Documentation/nvme-set-property.1 index 2dc3510..6c3b82b 100644 --- a/Documentation/nvme-set-property.1 +++ b/Documentation/nvme-set-property.1 @@ -2,12 +2,12 @@ .\" Title: nvme-set-property .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-SET\-PROPERTY" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-SET\-PROPERTY" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-set-property.html b/Documentation/nvme-set-property.html index 7166ab6..fa50a2c 100644 --- a/Documentation/nvme-set-property.html +++ b/Documentation/nvme-set-property.html @@ -805,7 +805,7 @@ nvme-set-property(1) Manual Page diff --git a/Documentation/nvme-show-hostnqn.1 b/Documentation/nvme-show-hostnqn.1 index d079005..6a5aee6 100644 --- a/Documentation/nvme-show-hostnqn.1 +++ b/Documentation/nvme-show-hostnqn.1 @@ -2,12 +2,12 @@ .\" Title: nvme-show-hostnqn .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-SHOW\-HOSTNQN" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-SHOW\-HOSTNQN" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-show-hostnqn.html b/Documentation/nvme-show-hostnqn.html index 22fdfa1..f23f289 100644 --- a/Documentation/nvme-show-hostnqn.html +++ b/Documentation/nvme-show-hostnqn.html @@ -785,7 +785,7 @@ this will show the systemd-generated host NQN for the system.

diff --git a/Documentation/nvme-show-regs.1 b/Documentation/nvme-show-regs.1 index 714f47e..1af9fff 100644 --- a/Documentation/nvme-show-regs.1 +++ b/Documentation/nvme-show-regs.1 @@ -2,12 +2,12 @@ .\" Title: nvme-id-ns .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ID\-NS" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ID\-NS" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-show-regs.html b/Documentation/nvme-show-regs.html index 1ff71b5..1687ca1 100644 --- a/Documentation/nvme-show-regs.html +++ b/Documentation/nvme-show-regs.html @@ -848,7 +848,7 @@ in a json format: diff --git a/Documentation/nvme-show-topology.1 b/Documentation/nvme-show-topology.1 new file mode 100644 index 0000000..99b1595 --- /dev/null +++ b/Documentation/nvme-show-topology.1 @@ -0,0 +1,70 @@ +'\" t +.\" Title: nvme-show-topology +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 11/02/2022 +.\" Manual: NVMe Manual +.\" Source: NVMe +.\" Language: English +.\" +.TH "NVME\-SHOW\-TOPOLOGY" "1" "11/02/2022" "NVMe" "NVMe Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nvme-show-topology \- Show topology of all NVMe subsystems +.SH "SYNOPSIS" +.sp +.nf +\fInvme show\-topology\fR +.fi +.SH "DESCRIPTION" +.sp +Show the topology of all NVMe subsystems\&. +.SH "OPTIONS" +.PP +\-o , \-\-output\-format= +.RS 4 +Set the reporting format to +\fInormal\fR +or +\fIjson\fR\&. Only one output format can be used at a time\&. +.RE +.PP +\-v, \-\-verbose +.RS 4 +Increase the information in the output, showing nvme subsystems, controllers and namespaces separately and how they\(cqre related to each other\&. +.RE +.PP +\-r , \-\-ranking= +.RS 4 +Set the ranking orer to +\fInamespace\fR +(default) or +\fIctrl\fR\&. This option has only an effect for output format +\fInormal\fR\&. The JSON output is always +\fInamespace\fR +ordered\&. +.RE +.SH "EXAMPLES" +.sp +nvme show\-topology +.SH "NVME" +.sp +Part of the nvme\-user suite diff --git a/Documentation/nvme-show-topology.html b/Documentation/nvme-show-topology.html new file mode 100644 index 0000000..96611a4 --- /dev/null +++ b/Documentation/nvme-show-topology.html @@ -0,0 +1,829 @@ + + + + + + +nvme-show-topology(1) + + + + + +
+
+

SYNOPSIS

+
+
+
nvme show-topology
+
+
+
+
+
+

DESCRIPTION

+
+

Show the topology of all NVMe subsystems.

+
+
+
+

OPTIONS

+
+
+
+-o <format> +
+
+--output-format=<format> +
+
+

+ Set the reporting format to normal or json. Only one output + format can be used at a time. +

+
+
+-v +
+
+--verbose +
+
+

+ Increase the information in the output, showing nvme subsystems, + controllers and namespaces separately and how they’re related to each + other. +

+
+
+-r <order> +
+
+--ranking=<order> +
+
+

+ Set the ranking orer to namespace (default) or ctrl. This option + has only an effect for output format normal. The JSON output is + always namespace ordered. +

+
+
+
+
+
+

EXAMPLES

+
+

nvme show-topology

+
+
+
+

NVME

+
+

Part of the nvme-user suite

+
+
+
+

+ + + diff --git a/Documentation/nvme-show-topology.txt b/Documentation/nvme-show-topology.txt new file mode 100644 index 0000000..f0583fb --- /dev/null +++ b/Documentation/nvme-show-topology.txt @@ -0,0 +1,42 @@ +nvme-show-topology(1) +===================== + +NAME +---- +nvme-show-topology - Show topology of all NVMe subsystems + +SYNOPSIS +-------- +[verse] +'nvme show-topology' + +DESCRIPTION +----------- +Show the topology of all NVMe subsystems. + +OPTIONS +------- +-o :: +--output-format=:: + Set the reporting format to 'normal' or 'json'. Only one output + format can be used at a time. + +-v:: +--verbose:: + Increase the information in the output, showing nvme subsystems, + controllers and namespaces separately and how they're related to each + other. + +-r :: +--ranking=:: + Set the ranking orer to 'namespace' (default) or 'ctrl'. This option + has only an effect for output format 'normal'. The JSON output is + always 'namespace' ordered. + +EXAMPLES +-------- +nvme show-topology + +NVME +---- +Part of the nvme-user suite diff --git a/Documentation/nvme-smart-log.1 b/Documentation/nvme-smart-log.1 index c75bda0..d315ed7 100644 --- a/Documentation/nvme-smart-log.1 +++ b/Documentation/nvme-smart-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-smart-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-SMART\-LOG" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-SMART\-LOG" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-smart-log.html b/Documentation/nvme-smart-log.html index de628f1..65a5a56 100644 --- a/Documentation/nvme-smart-log.html +++ b/Documentation/nvme-smart-log.html @@ -850,7 +850,7 @@ Print the raw SMART log to a file: diff --git a/Documentation/nvme-subsystem-reset.1 b/Documentation/nvme-subsystem-reset.1 index 476592d..17ed93a 100644 --- a/Documentation/nvme-subsystem-reset.1 +++ b/Documentation/nvme-subsystem-reset.1 @@ -2,12 +2,12 @@ .\" Title: nvme-subsystem-reset .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-SUBSYSTEM\-RES" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-SUBSYSTEM\-RES" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-subsystem-reset.html b/Documentation/nvme-subsystem-reset.html index 0270817..27ba2dd 100644 --- a/Documentation/nvme-subsystem-reset.html +++ b/Documentation/nvme-subsystem-reset.html @@ -794,7 +794,7 @@ Resets the subsystem. diff --git a/Documentation/nvme-supported-log-pages.1 b/Documentation/nvme-supported-log-pages.1 index b6944a7..710185a 100644 --- a/Documentation/nvme-supported-log-pages.1 +++ b/Documentation/nvme-supported-log-pages.1 @@ -2,12 +2,12 @@ .\" Title: nvme-supported-log-pages .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-SUPPORTED\-LOG" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-SUPPORTED\-LOG" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-supported-log-pages.html b/Documentation/nvme-supported-log-pages.html index 5b2b63a..dc854cf 100644 --- a/Documentation/nvme-supported-log-pages.html +++ b/Documentation/nvme-supported-log-pages.html @@ -814,7 +814,7 @@ for each command that is supported.

diff --git a/Documentation/nvme-telemetry-log.1 b/Documentation/nvme-telemetry-log.1 index 7ab19d0..e4a45d8 100644 --- a/Documentation/nvme-telemetry-log.1 +++ b/Documentation/nvme-telemetry-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-telemetry-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-TELEMETRY\-LOG" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-TELEMETRY\-LOG" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-telemetry-log.html b/Documentation/nvme-telemetry-log.html index 9716064..8d5cf60 100644 --- a/Documentation/nvme-telemetry-log.html +++ b/Documentation/nvme-telemetry-log.html @@ -838,7 +838,7 @@ Retrieve Telemetry Host-Initiated data to telemetry_log.bin diff --git a/Documentation/nvme-toshiba-clear-pcie-correctable-errors.1 b/Documentation/nvme-toshiba-clear-pcie-correctable-errors.1 index 1ac275e..071926c 100644 --- a/Documentation/nvme-toshiba-clear-pcie-correctable-errors.1 +++ b/Documentation/nvme-toshiba-clear-pcie-correctable-errors.1 @@ -2,12 +2,12 @@ .\" Title: nvme-toshiba-clear-pcie-correctable-errors .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-TOSHIBA\-CLEAR" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-TOSHIBA\-CLEAR" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-toshiba-clear-pcie-correctable-errors.html b/Documentation/nvme-toshiba-clear-pcie-correctable-errors.html index 7726499..b3170d1 100644 --- a/Documentation/nvme-toshiba-clear-pcie-correctable-errors.html +++ b/Documentation/nvme-toshiba-clear-pcie-correctable-errors.html @@ -791,7 +791,7 @@ Clear the PCIe correctable errors count: diff --git a/Documentation/nvme-toshiba-vs-internal-log.1 b/Documentation/nvme-toshiba-vs-internal-log.1 index a2a2f8a..aef2a91 100644 --- a/Documentation/nvme-toshiba-vs-internal-log.1 +++ b/Documentation/nvme-toshiba-vs-internal-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-toshiba-vs-internal-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-TOSHIBA\-VS\-I" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-TOSHIBA\-VS\-I" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-toshiba-vs-internal-log.html b/Documentation/nvme-toshiba-vs-internal-log.html index 78fbc65..87cf982 100644 --- a/Documentation/nvme-toshiba-vs-internal-log.html +++ b/Documentation/nvme-toshiba-vs-internal-log.html @@ -837,7 +837,7 @@ Get the previous log from the device and save to a binary file: diff --git a/Documentation/nvme-toshiba-vs-smart-add-log.1 b/Documentation/nvme-toshiba-vs-smart-add-log.1 index 6bc35da..dcdfd4b 100644 --- a/Documentation/nvme-toshiba-vs-smart-add-log.1 +++ b/Documentation/nvme-toshiba-vs-smart-add-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-toshiba-vs-smart-add-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-TOSHIBA\-VS\-S" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-TOSHIBA\-VS\-S" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-toshiba-vs-smart-add-log.html b/Documentation/nvme-toshiba-vs-smart-add-log.html index be7e926..8476085 100644 --- a/Documentation/nvme-toshiba-vs-smart-add-log.html +++ b/Documentation/nvme-toshiba-vs-smart-add-log.html @@ -840,7 +840,7 @@ Get the contents of log page 0xC0 from the device and save to a binary file: diff --git a/Documentation/nvme-transcend-badblock.1 b/Documentation/nvme-transcend-badblock.1 index c509b2b..0eedebc 100644 --- a/Documentation/nvme-transcend-badblock.1 +++ b/Documentation/nvme-transcend-badblock.1 @@ -2,12 +2,12 @@ .\" Title: nvme-transcend-badblock .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-TRANSCEND\-BAD" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-TRANSCEND\-BAD" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-transcend-badblock.html b/Documentation/nvme-transcend-badblock.html index 12be15a..0c665cf 100644 --- a/Documentation/nvme-transcend-badblock.html +++ b/Documentation/nvme-transcend-badblock.html @@ -796,7 +796,7 @@ Print the Transcend device’s bad blocks in a human readable format: diff --git a/Documentation/nvme-transcend-healthvalue.1 b/Documentation/nvme-transcend-healthvalue.1 index 52c3182..7ded0c2 100644 --- a/Documentation/nvme-transcend-healthvalue.1 +++ b/Documentation/nvme-transcend-healthvalue.1 @@ -2,12 +2,12 @@ .\" Title: nvme-transcend-healthvalue .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-TRANSCEND\-HEA" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-TRANSCEND\-HEA" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-transcend-healthvalue.html b/Documentation/nvme-transcend-healthvalue.html index 2a41c46..b5fe0d6 100644 --- a/Documentation/nvme-transcend-healthvalue.html +++ b/Documentation/nvme-transcend-healthvalue.html @@ -796,7 +796,7 @@ Print the Transcend Device health value in a human readable format: diff --git a/Documentation/nvme-verify.1 b/Documentation/nvme-verify.1 index 059f282..bf7616c 100644 --- a/Documentation/nvme-verify.1 +++ b/Documentation/nvme-verify.1 @@ -2,12 +2,12 @@ .\" Title: nvme-verify .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-VERIFY" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-VERIFY" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-verify.html b/Documentation/nvme-verify.html index b46216f..da27c8c 100644 --- a/Documentation/nvme-verify.html +++ b/Documentation/nvme-verify.html @@ -953,7 +953,7 @@ metadata is passes.

diff --git a/Documentation/nvme-virtium-save-smart-to-vtview-log.1 b/Documentation/nvme-virtium-save-smart-to-vtview-log.1 index ef7475f..3472f9c 100644 --- a/Documentation/nvme-virtium-save-smart-to-vtview-log.1 +++ b/Documentation/nvme-virtium-save-smart-to-vtview-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-virtium-save-smart-to-vtview-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-VIRTIUM\-SAVE\" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-VIRTIUM\-SAVE\" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-virtium-save-smart-to-vtview-log.html b/Documentation/nvme-virtium-save-smart-to-vtview-log.html index 3541b26..b140c59 100644 --- a/Documentation/nvme-virtium-save-smart-to-vtview-log.html +++ b/Documentation/nvme-virtium-save-smart-to-vtview-log.html @@ -876,7 +876,7 @@ Just logging: Default logging is run for 20 hours and log every 10 hours. diff --git a/Documentation/nvme-virtium-show-identify.1 b/Documentation/nvme-virtium-show-identify.1 index 9489368..ca6311b 100644 --- a/Documentation/nvme-virtium-show-identify.1 +++ b/Documentation/nvme-virtium-show-identify.1 @@ -2,12 +2,12 @@ .\" Title: nvme-virtium-show-identify .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-VIRTIUM\-SHOW\" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-VIRTIUM\-SHOW\" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-virtium-show-identify.html b/Documentation/nvme-virtium-show-identify.html index 28577b0..f7d824e 100644 --- a/Documentation/nvme-virtium-show-identify.html +++ b/Documentation/nvme-virtium-show-identify.html @@ -798,7 +798,7 @@ Show Identify Device: diff --git a/Documentation/nvme-wdc-cap-diag.1 b/Documentation/nvme-wdc-cap-diag.1 index a362884..a3e4d02 100644 --- a/Documentation/nvme-wdc-cap-diag.1 +++ b/Documentation/nvme-wdc-cap-diag.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-cap-diag .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-CAP\-DIAG" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-CAP\-DIAG" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-cap-diag.html b/Documentation/nvme-wdc-cap-diag.html index b5c244a..cc5dbe0 100644 --- a/Documentation/nvme-wdc-cap-diag.html +++ b/Documentation/nvme-wdc-cap-diag.html @@ -856,7 +856,7 @@ Gets the capture diagnostics log from the device transferring the data in 16k ch diff --git a/Documentation/nvme-wdc-capabilities.1 b/Documentation/nvme-wdc-capabilities.1 index 6b767b0..5818295 100644 --- a/Documentation/nvme-wdc-capabilities.1 +++ b/Documentation/nvme-wdc-capabilities.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-capabilities .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-CAPABILIT" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-CAPABILIT" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-capabilities.html b/Documentation/nvme-wdc-capabilities.html index e3c2f60..0497740 100644 --- a/Documentation/nvme-wdc-capabilities.html +++ b/Documentation/nvme-wdc-capabilities.html @@ -789,7 +789,7 @@ Displays the capabilities for the device: diff --git a/Documentation/nvme-wdc-clear-assert-dump.1 b/Documentation/nvme-wdc-clear-assert-dump.1 index ea5ebcc..c8d4fdf 100644 --- a/Documentation/nvme-wdc-clear-assert-dump.1 +++ b/Documentation/nvme-wdc-clear-assert-dump.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-clear-assert-dump .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-CLEAR\-AS" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-CLEAR\-AS" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-clear-assert-dump.html b/Documentation/nvme-wdc-clear-assert-dump.html index e2b1662..f96c4f6 100644 --- a/Documentation/nvme-wdc-clear-assert-dump.html +++ b/Documentation/nvme-wdc-clear-assert-dump.html @@ -798,7 +798,7 @@ Clears the assert dump (if present): diff --git a/Documentation/nvme-wdc-clear-fw-activate-history.1 b/Documentation/nvme-wdc-clear-fw-activate-history.1 index 1a81717..b6eb51b 100644 --- a/Documentation/nvme-wdc-clear-fw-activate-history.1 +++ b/Documentation/nvme-wdc-clear-fw-activate-history.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-clear-fw-activate-history .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-CLEAR\-FW" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-CLEAR\-FW" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-clear-fw-activate-history.html b/Documentation/nvme-wdc-clear-fw-activate-history.html index 6e40eec..1fd7fe5 100644 --- a/Documentation/nvme-wdc-clear-fw-activate-history.html +++ b/Documentation/nvme-wdc-clear-fw-activate-history.html @@ -797,7 +797,7 @@ Clears the firmware activate history table: diff --git a/Documentation/nvme-wdc-clear-pcie-correctable-errors.1 b/Documentation/nvme-wdc-clear-pcie-correctable-errors.1 index a1131db..7f7dc3f 100644 --- a/Documentation/nvme-wdc-clear-pcie-correctable-errors.1 +++ b/Documentation/nvme-wdc-clear-pcie-correctable-errors.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-clear-pcie-correctable-errors .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-CLEAR\-PC" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-CLEAR\-PC" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-clear-pcie-correctable-errors.html b/Documentation/nvme-wdc-clear-pcie-correctable-errors.html index 9e219c9..a3b617b 100644 --- a/Documentation/nvme-wdc-clear-pcie-correctable-errors.html +++ b/Documentation/nvme-wdc-clear-pcie-correctable-errors.html @@ -799,7 +799,7 @@ Clears the PCIe Correctable Error Count field returned in the smart-log-add comm diff --git a/Documentation/nvme-wdc-cloud-SSD-plugin-version.1 b/Documentation/nvme-wdc-cloud-SSD-plugin-version.1 index a354435..8a4fa7a 100644 --- a/Documentation/nvme-wdc-cloud-SSD-plugin-version.1 +++ b/Documentation/nvme-wdc-cloud-SSD-plugin-version.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-cloud-SSD-plugin-version .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-CLOUD\-SS" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-CLOUD\-SS" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-cloud-SSD-plugin-version.html b/Documentation/nvme-wdc-cloud-SSD-plugin-version.html index cd932e4..18fbb2d 100644 --- a/Documentation/nvme-wdc-cloud-SSD-plugin-version.html +++ b/Documentation/nvme-wdc-cloud-SSD-plugin-version.html @@ -790,7 +790,7 @@ Displays the cloud ssd plugin version for the device: diff --git a/Documentation/nvme-wdc-cloud-boot-SSD-version.1 b/Documentation/nvme-wdc-cloud-boot-SSD-version.1 index b6079dd..da41e13 100644 --- a/Documentation/nvme-wdc-cloud-boot-SSD-version.1 +++ b/Documentation/nvme-wdc-cloud-boot-SSD-version.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-cloud-boot-SSD-version .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-CLOUD\-BO" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-CLOUD\-BO" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-cloud-boot-SSD-version.html b/Documentation/nvme-wdc-cloud-boot-SSD-version.html index f48f2d9..37a38b5 100644 --- a/Documentation/nvme-wdc-cloud-boot-SSD-version.html +++ b/Documentation/nvme-wdc-cloud-boot-SSD-version.html @@ -790,7 +790,7 @@ Displays the cloud boot ssd version for the device: diff --git a/Documentation/nvme-wdc-drive-essentials.1 b/Documentation/nvme-wdc-drive-essentials.1 index 220e78b..d69d384 100644 --- a/Documentation/nvme-wdc-drive-essentials.1 +++ b/Documentation/nvme-wdc-drive-essentials.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-drive-essentials .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-DRIVE\-ES" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-DRIVE\-ES" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-drive-essentials.html b/Documentation/nvme-wdc-drive-essentials.html index 75bd9d3..a07196b 100644 --- a/Documentation/nvme-wdc-drive-essentials.html +++ b/Documentation/nvme-wdc-drive-essentials.html @@ -821,7 +821,7 @@ Gets the drive essentials data files from the device and saves the tar file to s diff --git a/Documentation/nvme-wdc-drive-log.1 b/Documentation/nvme-wdc-drive-log.1 index d61b061..d37b495 100644 --- a/Documentation/nvme-wdc-drive-log.1 +++ b/Documentation/nvme-wdc-drive-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-drive-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-DRIVE\-LO" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-DRIVE\-LO" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-drive-log.html b/Documentation/nvme-wdc-drive-log.html index 095a9da..9cc233e 100644 --- a/Documentation/nvme-wdc-drive-log.html +++ b/Documentation/nvme-wdc-drive-log.html @@ -829,7 +829,7 @@ Gets the drive log from the device and saves to defined file with pathname (e.g. diff --git a/Documentation/nvme-wdc-drive-resize.1 b/Documentation/nvme-wdc-drive-resize.1 index f13c5c3..745801b 100644 --- a/Documentation/nvme-wdc-drive-resize.1 +++ b/Documentation/nvme-wdc-drive-resize.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-drive-resize .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-DRIVE\-RE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-DRIVE\-RE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-drive-resize.html b/Documentation/nvme-wdc-drive-resize.html index 25020fe..e29b34a 100644 --- a/Documentation/nvme-wdc-drive-resize.html +++ b/Documentation/nvme-wdc-drive-resize.html @@ -810,7 +810,7 @@ Has the program issue WDC Resize Vendor Unique Command : diff --git a/Documentation/nvme-wdc-enc-get-log.1 b/Documentation/nvme-wdc-enc-get-log.1 index e136652..4bc956e 100644 --- a/Documentation/nvme-wdc-enc-get-log.1 +++ b/Documentation/nvme-wdc-enc-get-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-enc-get-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-ENC\-GET\" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-ENC\-GET\" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-enc-get-log.html b/Documentation/nvme-wdc-enc-get-log.html index 94a9250..afe6119 100644 --- a/Documentation/nvme-wdc-enc-get-log.html +++ b/Documentation/nvme-wdc-enc-get-log.html @@ -832,7 +832,7 @@ Gets the enclosure log from the device based on the log id(0xd2) with default tr diff --git a/Documentation/nvme-wdc-get-crash-dump.1 b/Documentation/nvme-wdc-get-crash-dump.1 index 22b3615..c18daba 100644 --- a/Documentation/nvme-wdc-get-crash-dump.1 +++ b/Documentation/nvme-wdc-get-crash-dump.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-get-crash-dump .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-GET\-CRAS" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-GET\-CRAS" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-get-crash-dump.html b/Documentation/nvme-wdc-get-crash-dump.html index 75d9943..a95fed6 100644 --- a/Documentation/nvme-wdc-get-crash-dump.html +++ b/Documentation/nvme-wdc-get-crash-dump.html @@ -830,7 +830,7 @@ Gets the crash dump from the device and saves to defined file with pathname (e.g diff --git a/Documentation/nvme-wdc-get-dev-capabilities-log.1 b/Documentation/nvme-wdc-get-dev-capabilities-log.1 index b1152ce..00b40c8 100644 --- a/Documentation/nvme-wdc-get-dev-capabilities-log.1 +++ b/Documentation/nvme-wdc-get-dev-capabilities-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-get-dev-capabilities-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-GET\-DEV\" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-GET\-DEV\" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-get-dev-capabilities-log.html b/Documentation/nvme-wdc-get-dev-capabilities-log.html index 585e4a6..7ad56c7 100644 --- a/Documentation/nvme-wdc-get-dev-capabilities-log.html +++ b/Documentation/nvme-wdc-get-dev-capabilities-log.html @@ -816,7 +816,7 @@ Has the program issue WDC get-dev-capabilities-log plugin command : diff --git a/Documentation/nvme-wdc-get-drive-status.1 b/Documentation/nvme-wdc-get-drive-status.1 index 27728ce..a042701 100644 --- a/Documentation/nvme-wdc-get-drive-status.1 +++ b/Documentation/nvme-wdc-get-drive-status.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-get-drive-status .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-GET\-DRIV" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-GET\-DRIV" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-get-drive-status.html b/Documentation/nvme-wdc-get-drive-status.html index 255ec6f..413af93 100644 --- a/Documentation/nvme-wdc-get-drive-status.html +++ b/Documentation/nvme-wdc-get-drive-status.html @@ -836,7 +836,7 @@ Has the program issue WDC get-drive-status command : diff --git a/Documentation/nvme-wdc-get-error-recovery-log.1 b/Documentation/nvme-wdc-get-error-recovery-log.1 index d027e4e..971b880 100644 --- a/Documentation/nvme-wdc-get-error-recovery-log.1 +++ b/Documentation/nvme-wdc-get-error-recovery-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-get-error-recovery-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-GET\-ERRO" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-GET\-ERRO" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-get-error-recovery-log.html b/Documentation/nvme-wdc-get-error-recovery-log.html index 502a08f..6655a71 100644 --- a/Documentation/nvme-wdc-get-error-recovery-log.html +++ b/Documentation/nvme-wdc-get-error-recovery-log.html @@ -816,7 +816,7 @@ Has the program issue WDC get-error-recovery-log plugin command : diff --git a/Documentation/nvme-wdc-get-latency-monitor-log.1 b/Documentation/nvme-wdc-get-latency-monitor-log.1 index 7351c18..8d53cb5 100644 --- a/Documentation/nvme-wdc-get-latency-monitor-log.1 +++ b/Documentation/nvme-wdc-get-latency-monitor-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-get-latency-monitor-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-GET\-LATE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-GET\-LATE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-get-latency-monitor-log.html b/Documentation/nvme-wdc-get-latency-monitor-log.html index dc27611..d17ea07 100644 --- a/Documentation/nvme-wdc-get-latency-monitor-log.html +++ b/Documentation/nvme-wdc-get-latency-monitor-log.html @@ -810,7 +810,7 @@ Displays the get latency monitor log for the device: diff --git a/Documentation/nvme-wdc-get-pfail-dump.1 b/Documentation/nvme-wdc-get-pfail-dump.1 index a52d23e..29ba533 100644 --- a/Documentation/nvme-wdc-get-pfail-dump.1 +++ b/Documentation/nvme-wdc-get-pfail-dump.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-get-pfail-dump .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-GET\-PFAI" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-GET\-PFAI" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-get-pfail-dump.html b/Documentation/nvme-wdc-get-pfail-dump.html index 6426f64..82e3d84 100644 --- a/Documentation/nvme-wdc-get-pfail-dump.html +++ b/Documentation/nvme-wdc-get-pfail-dump.html @@ -832,7 +832,7 @@ Gets the pfail crash dump from the device and saves to defined file with pathnam diff --git a/Documentation/nvme-wdc-get-unsupported-reqs-log.1 b/Documentation/nvme-wdc-get-unsupported-reqs-log.1 index eb1da67..0472708 100644 --- a/Documentation/nvme-wdc-get-unsupported-reqs-log.1 +++ b/Documentation/nvme-wdc-get-unsupported-reqs-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-get-unsupported-reqs-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-GET\-UNSU" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-GET\-UNSU" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-get-unsupported-reqs-log.html b/Documentation/nvme-wdc-get-unsupported-reqs-log.html index 34b8568..4e10f8f 100644 --- a/Documentation/nvme-wdc-get-unsupported-reqs-log.html +++ b/Documentation/nvme-wdc-get-unsupported-reqs-log.html @@ -816,7 +816,7 @@ Has the program issue WDC get-unsupported-reqs-log plugin command : diff --git a/Documentation/nvme-wdc-id-ctrl.1 b/Documentation/nvme-wdc-id-ctrl.1 index 2e74a20..16f38dc 100644 --- a/Documentation/nvme-wdc-id-ctrl.1 +++ b/Documentation/nvme-wdc-id-ctrl.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-id-ctrl .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-ID\-CTRL" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-ID\-CTRL" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-id-ctrl.html b/Documentation/nvme-wdc-id-ctrl.html index fb9df9b..2d23de2 100644 --- a/Documentation/nvme-wdc-id-ctrl.html +++ b/Documentation/nvme-wdc-id-ctrl.html @@ -856,7 +856,7 @@ fields in a human readable format: diff --git a/Documentation/nvme-wdc-log-page-directory.1 b/Documentation/nvme-wdc-log-page-directory.1 index 1a8ee5b..4f5c09b 100644 --- a/Documentation/nvme-wdc-log-page-directory.1 +++ b/Documentation/nvme-wdc-log-page-directory.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-log-page-directory .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-LOG\-PAGE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-LOG\-PAGE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-log-page-directory.html b/Documentation/nvme-wdc-log-page-directory.html index 0cfe7cb..7613d8d 100644 --- a/Documentation/nvme-wdc-log-page-directory.html +++ b/Documentation/nvme-wdc-log-page-directory.html @@ -812,7 +812,7 @@ WDC log-page-directory example command : diff --git a/Documentation/nvme-wdc-namespace-resize.1 b/Documentation/nvme-wdc-namespace-resize.1 index bdd4c2b..dc69436 100644 --- a/Documentation/nvme-wdc-namespace-resize.1 +++ b/Documentation/nvme-wdc-namespace-resize.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-namespace-resize .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-NAMESPACE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-NAMESPACE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-namespace-resize.html b/Documentation/nvme-wdc-namespace-resize.html index 0649267..e4243c4 100644 --- a/Documentation/nvme-wdc-namespace-resize.html +++ b/Documentation/nvme-wdc-namespace-resize.html @@ -838,7 +838,7 @@ Resizes namespace 2 to 7% of the original TNVMCAP reported value: diff --git a/Documentation/nvme-wdc-purge-monitor.1 b/Documentation/nvme-wdc-purge-monitor.1 index a1bd2dc..b43f006 100644 --- a/Documentation/nvme-wdc-purge-monitor.1 +++ b/Documentation/nvme-wdc-purge-monitor.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-purge-monitor .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-PURGE\-MO" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-PURGE\-MO" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-purge-monitor.html b/Documentation/nvme-wdc-purge-monitor.html index ccb8a22..fb52d6e 100644 --- a/Documentation/nvme-wdc-purge-monitor.html +++ b/Documentation/nvme-wdc-purge-monitor.html @@ -837,7 +837,7 @@ Has the program issue WDC Purge-Monitor Vendor Unique Command : diff --git a/Documentation/nvme-wdc-purge.1 b/Documentation/nvme-wdc-purge.1 index 7b65965..33e81c7 100644 --- a/Documentation/nvme-wdc-purge.1 +++ b/Documentation/nvme-wdc-purge.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-purge .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-PURGE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-PURGE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-purge.html b/Documentation/nvme-wdc-purge.html index 7f02da7..0a4fbd2 100644 --- a/Documentation/nvme-wdc-purge.html +++ b/Documentation/nvme-wdc-purge.html @@ -799,7 +799,7 @@ Has the program issue WDC Purge Vendor Unique Command : diff --git a/Documentation/nvme-wdc-vs-cloud-log.1 b/Documentation/nvme-wdc-vs-cloud-log.1 index 7f2dee1..87b8dee 100644 --- a/Documentation/nvme-wdc-vs-cloud-log.1 +++ b/Documentation/nvme-wdc-vs-cloud-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-vs-cloud-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-VS\-CLOUD" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-VS\-CLOUD" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-vs-cloud-log.html b/Documentation/nvme-wdc-vs-cloud-log.html index a6b91e0..c1ebb49 100644 --- a/Documentation/nvme-wdc-vs-cloud-log.html +++ b/Documentation/nvme-wdc-vs-cloud-log.html @@ -828,7 +828,7 @@ Has the program issue WDC vs-cloud-log Vendor Unique Command : diff --git a/Documentation/nvme-wdc-vs-device-waf.1 b/Documentation/nvme-wdc-vs-device-waf.1 index 31c57e1..393d290 100644 --- a/Documentation/nvme-wdc-vs-device-waf.1 +++ b/Documentation/nvme-wdc-vs-device-waf.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-vs-device-waf .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-VS\-DEVIC" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-VS\-DEVIC" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-vs-device-waf.html b/Documentation/nvme-wdc-vs-device-waf.html index 8b26fa2..c4a9cea 100644 --- a/Documentation/nvme-wdc-vs-device-waf.html +++ b/Documentation/nvme-wdc-vs-device-waf.html @@ -828,7 +828,7 @@ Has the program issue WDC vs-device-waf plugin Command : diff --git a/Documentation/nvme-wdc-vs-drive-info.1 b/Documentation/nvme-wdc-vs-drive-info.1 index 7bbbad5..a314a94 100644 --- a/Documentation/nvme-wdc-vs-drive-info.1 +++ b/Documentation/nvme-wdc-vs-drive-info.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-vs-drive-info .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-VS\-DRIVE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-VS\-DRIVE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-vs-drive-info.html b/Documentation/nvme-wdc-vs-drive-info.html index b650aca..9fadd7d 100644 --- a/Documentation/nvme-wdc-vs-drive-info.html +++ b/Documentation/nvme-wdc-vs-drive-info.html @@ -795,7 +795,7 @@ on the drive:

diff --git a/Documentation/nvme-wdc-vs-error-reason-identifier.1 b/Documentation/nvme-wdc-vs-error-reason-identifier.1 index f05e920..5bd9913 100644 --- a/Documentation/nvme-wdc-vs-error-reason-identifier.1 +++ b/Documentation/nvme-wdc-vs-error-reason-identifier.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-vs-error-reason-identifier .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-VS\-ERROR" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-VS\-ERROR" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-vs-error-reason-identifier.html b/Documentation/nvme-wdc-vs-error-reason-identifier.html index 1aa0e4f..aad1677 100644 --- a/Documentation/nvme-wdc-vs-error-reason-identifier.html +++ b/Documentation/nvme-wdc-vs-error-reason-identifier.html @@ -836,7 +836,7 @@ Retrieves the controller initiated error reason identifier field and save it in diff --git a/Documentation/nvme-wdc-vs-fw-activate-history.1 b/Documentation/nvme-wdc-vs-fw-activate-history.1 index 3528a73..edb0bc9 100644 --- a/Documentation/nvme-wdc-vs-fw-activate-history.1 +++ b/Documentation/nvme-wdc-vs-fw-activate-history.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-vs-fw-activate-history .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-VS\-FW\-A" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-VS\-FW\-A" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-vs-fw-activate-history.html b/Documentation/nvme-wdc-vs-fw-activate-history.html index 0c4fbfd..2ecd323 100644 --- a/Documentation/nvme-wdc-vs-fw-activate-history.html +++ b/Documentation/nvme-wdc-vs-fw-activate-history.html @@ -868,7 +868,7 @@ Has the program issue WDC vs-fw-activate-history Vendor Unique Command : diff --git a/Documentation/nvme-wdc-vs-hw-rev-log.1 b/Documentation/nvme-wdc-vs-hw-rev-log.1 index 8ec057c..8e8e0c3 100644 --- a/Documentation/nvme-wdc-vs-hw-rev-log.1 +++ b/Documentation/nvme-wdc-vs-hw-rev-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-vs-hw-rev-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-VS\-HW\-R" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-VS\-HW\-R" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-vs-hw-rev-log.html b/Documentation/nvme-wdc-vs-hw-rev-log.html index cee784b..5c4c7da 100644 --- a/Documentation/nvme-wdc-vs-hw-rev-log.html +++ b/Documentation/nvme-wdc-vs-hw-rev-log.html @@ -827,7 +827,7 @@ Has the program issue WDC vs-hw-rev-log plugin Command : diff --git a/Documentation/nvme-wdc-vs-internal-log.1 b/Documentation/nvme-wdc-vs-internal-log.1 index e2f439b..a977943 100644 --- a/Documentation/nvme-wdc-vs-internal-log.1 +++ b/Documentation/nvme-wdc-vs-internal-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-vs-internal-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-VS\-INTER" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-VS\-INTER" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-vs-internal-log.html b/Documentation/nvme-wdc-vs-internal-log.html index 90d3f0f..664ad96 100644 --- a/Documentation/nvme-wdc-vs-internal-log.html +++ b/Documentation/nvme-wdc-vs-internal-log.html @@ -950,7 +950,7 @@ Gets the controller telemetry log page to data area 3 from the device and stores diff --git a/Documentation/nvme-wdc-vs-nand-stats.1 b/Documentation/nvme-wdc-vs-nand-stats.1 index 3b5a3fa..cd44619 100644 --- a/Documentation/nvme-wdc-vs-nand-stats.1 +++ b/Documentation/nvme-wdc-vs-nand-stats.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-vs-nand-stats .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-VS\-NAND\" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-VS\-NAND\" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-vs-nand-stats.html b/Documentation/nvme-wdc-vs-nand-stats.html index c051795..cd07a5f 100644 --- a/Documentation/nvme-wdc-vs-nand-stats.html +++ b/Documentation/nvme-wdc-vs-nand-stats.html @@ -814,7 +814,7 @@ Has the program issue WDC vs-nand-stats Vendor Unique Command : diff --git a/Documentation/nvme-wdc-vs-smart-add-log.1 b/Documentation/nvme-wdc-vs-smart-add-log.1 index 144b795..ce42747 100644 --- a/Documentation/nvme-wdc-vs-smart-add-log.1 +++ b/Documentation/nvme-wdc-vs-smart-add-log.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-vs-smart-add-log .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-VS\-SMART" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-VS\-SMART" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-vs-smart-add-log.html b/Documentation/nvme-wdc-vs-smart-add-log.html index c73875f..1e62851 100644 --- a/Documentation/nvme-wdc-vs-smart-add-log.html +++ b/Documentation/nvme-wdc-vs-smart-add-log.html @@ -927,7 +927,7 @@ Has the program issue WDC vs-smart-add-log Vendor Unique Command for 0xC0 and 0x diff --git a/Documentation/nvme-wdc-vs-telemetry-controller-option.1 b/Documentation/nvme-wdc-vs-telemetry-controller-option.1 index 82506e4..80e059b 100644 --- a/Documentation/nvme-wdc-vs-telemetry-controller-option.1 +++ b/Documentation/nvme-wdc-vs-telemetry-controller-option.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-vs-telemetry-controller-option .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-VS\-TELEM" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-VS\-TELEM" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-vs-telemetry-controller-option.html b/Documentation/nvme-wdc-vs-telemetry-controller-option.html index 87e8c38..8752d97 100644 --- a/Documentation/nvme-wdc-vs-telemetry-controller-option.html +++ b/Documentation/nvme-wdc-vs-telemetry-controller-option.html @@ -853,7 +853,7 @@ Gets the current status (enabled or disabled) of the controller initiated option diff --git a/Documentation/nvme-wdc-vs-temperature-stats.1 b/Documentation/nvme-wdc-vs-temperature-stats.1 index b34350e..695eb6a 100644 --- a/Documentation/nvme-wdc-vs-temperature-stats.1 +++ b/Documentation/nvme-wdc-vs-temperature-stats.1 @@ -2,12 +2,12 @@ .\" Title: nvme-wdc-vs-temperature-stats .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WDC\-VS\-TEMPE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WDC\-VS\-TEMPE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-wdc-vs-temperature-stats.html b/Documentation/nvme-wdc-vs-temperature-stats.html index ad18037..1d166fa 100644 --- a/Documentation/nvme-wdc-vs-temperature-stats.html +++ b/Documentation/nvme-wdc-vs-temperature-stats.html @@ -857,7 +857,7 @@ Displays the temperature stats for the device: diff --git a/Documentation/nvme-write-uncor.1 b/Documentation/nvme-write-uncor.1 index e41697c..e277dc7 100644 --- a/Documentation/nvme-write-uncor.1 +++ b/Documentation/nvme-write-uncor.1 @@ -2,12 +2,12 @@ .\" Title: nvme-uncor .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-UNCOR" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-UNCOR" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-write-uncor.html b/Documentation/nvme-write-uncor.html index 9cedd43..714a664 100644 --- a/Documentation/nvme-write-uncor.html +++ b/Documentation/nvme-write-uncor.html @@ -830,7 +830,7 @@ blocks.

diff --git a/Documentation/nvme-write-zeroes.1 b/Documentation/nvme-write-zeroes.1 index 8d2161e..9a9ab08 100644 --- a/Documentation/nvme-write-zeroes.1 +++ b/Documentation/nvme-write-zeroes.1 @@ -2,12 +2,12 @@ .\" Title: nvme-write-zeroes .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WRITE\-ZEROES" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WRITE\-ZEROES" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-write-zeroes.html b/Documentation/nvme-write-zeroes.html index 1155a61..b982cc1 100644 --- a/Documentation/nvme-write-zeroes.html +++ b/Documentation/nvme-write-zeroes.html @@ -975,7 +975,7 @@ metadata is passes.

diff --git a/Documentation/nvme-write.1 b/Documentation/nvme-write.1 index 62e1349..4cd1452 100644 --- a/Documentation/nvme-write.1 +++ b/Documentation/nvme-write.1 @@ -2,12 +2,12 @@ .\" Title: nvme-write .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-WRITE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-WRITE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-write.html b/Documentation/nvme-write.html index 0f609c7..a0aa250 100644 --- a/Documentation/nvme-write.html +++ b/Documentation/nvme-write.html @@ -1078,7 +1078,7 @@ metadata is passes.

diff --git a/Documentation/nvme-zns-changed-zone-list.1 b/Documentation/nvme-zns-changed-zone-list.1 index 46bb70b..447936a 100644 --- a/Documentation/nvme-zns-changed-zone-list.1 +++ b/Documentation/nvme-zns-changed-zone-list.1 @@ -2,12 +2,12 @@ .\" Title: nvme-zns-changed-zone-list .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ZNS\-CHANGED\-" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ZNS\-CHANGED\-" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-zns-changed-zone-list.html b/Documentation/nvme-zns-changed-zone-list.html index c551af0..816309a 100644 --- a/Documentation/nvme-zns-changed-zone-list.html +++ b/Documentation/nvme-zns-changed-zone-list.html @@ -833,7 +833,7 @@ Show the output in json format diff --git a/Documentation/nvme-zns-close-zone.1 b/Documentation/nvme-zns-close-zone.1 index f105592..d7c42f2 100644 --- a/Documentation/nvme-zns-close-zone.1 +++ b/Documentation/nvme-zns-close-zone.1 @@ -2,12 +2,12 @@ .\" Title: nvme-zns-close-zone .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ZNS\-CLOSE\-ZO" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ZNS\-CLOSE\-ZO" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-zns-close-zone.html b/Documentation/nvme-zns-close-zone.html index 4239844..7dcd2d2 100644 --- a/Documentation/nvme-zns-close-zone.html +++ b/Documentation/nvme-zns-close-zone.html @@ -846,7 +846,7 @@ Close all zones on namespace 1: diff --git a/Documentation/nvme-zns-finish-zone.1 b/Documentation/nvme-zns-finish-zone.1 index 0e1bd25..e49f897 100644 --- a/Documentation/nvme-zns-finish-zone.1 +++ b/Documentation/nvme-zns-finish-zone.1 @@ -2,12 +2,12 @@ .\" Title: nvme-zns-finish-zone .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ZNS\-FINISH\-Z" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ZNS\-FINISH\-Z" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-zns-finish-zone.html b/Documentation/nvme-zns-finish-zone.html index b6e6815..3a2bbab 100644 --- a/Documentation/nvme-zns-finish-zone.html +++ b/Documentation/nvme-zns-finish-zone.html @@ -847,7 +847,7 @@ Finish all zones on namespace 1: diff --git a/Documentation/nvme-zns-id-ctrl.1 b/Documentation/nvme-zns-id-ctrl.1 index f9e920a..031103f 100644 --- a/Documentation/nvme-zns-id-ctrl.1 +++ b/Documentation/nvme-zns-id-ctrl.1 @@ -2,12 +2,12 @@ .\" Title: nvme-zns-id-ctrl .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ZNS\-ID\-CTRL" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ZNS\-ID\-CTRL" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-zns-id-ctrl.html b/Documentation/nvme-zns-id-ctrl.html index 0ec955d..1caaa11 100644 --- a/Documentation/nvme-zns-id-ctrl.html +++ b/Documentation/nvme-zns-id-ctrl.html @@ -821,7 +821,7 @@ Show the output in json format diff --git a/Documentation/nvme-zns-id-ns.1 b/Documentation/nvme-zns-id-ns.1 index 6aa126b..53b17b0 100644 --- a/Documentation/nvme-zns-id-ns.1 +++ b/Documentation/nvme-zns-id-ns.1 @@ -2,12 +2,12 @@ .\" Title: nvme-zns-id-ns .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ZNS\-ID\-NS" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ZNS\-ID\-NS" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-zns-id-ns.html b/Documentation/nvme-zns-id-ns.html index 140075f..fae15a7 100644 --- a/Documentation/nvme-zns-id-ns.html +++ b/Documentation/nvme-zns-id-ns.html @@ -847,7 +847,7 @@ Show the output in json format with extra details diff --git a/Documentation/nvme-zns-offline-zone.1 b/Documentation/nvme-zns-offline-zone.1 index 91a99e9..94761cc 100644 --- a/Documentation/nvme-zns-offline-zone.1 +++ b/Documentation/nvme-zns-offline-zone.1 @@ -2,12 +2,12 @@ .\" Title: nvme-zns-offline-zone .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ZNS\-OFFLINE\-" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ZNS\-OFFLINE\-" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-zns-offline-zone.html b/Documentation/nvme-zns-offline-zone.html index ba39c26..e3ad35a 100644 --- a/Documentation/nvme-zns-offline-zone.html +++ b/Documentation/nvme-zns-offline-zone.html @@ -846,7 +846,7 @@ Offline all zones on namespace 1: diff --git a/Documentation/nvme-zns-open-zone.1 b/Documentation/nvme-zns-open-zone.1 index f549268..de3e8f2 100644 --- a/Documentation/nvme-zns-open-zone.1 +++ b/Documentation/nvme-zns-open-zone.1 @@ -2,12 +2,12 @@ .\" Title: nvme-zns-open-zone .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ZNS\-OPEN\-ZON" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ZNS\-OPEN\-ZON" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-zns-open-zone.html b/Documentation/nvme-zns-open-zone.html index 6163f05..e66997a 100644 --- a/Documentation/nvme-zns-open-zone.html +++ b/Documentation/nvme-zns-open-zone.html @@ -858,7 +858,7 @@ Open the first zone on namespace 1: diff --git a/Documentation/nvme-zns-report-zones.1 b/Documentation/nvme-zns-report-zones.1 index 38e137e..e51f24d 100644 --- a/Documentation/nvme-zns-report-zones.1 +++ b/Documentation/nvme-zns-report-zones.1 @@ -2,12 +2,12 @@ .\" Title: nvme-zns-report-zones .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ZNS\-REPORT\-Z" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ZNS\-REPORT\-Z" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-zns-report-zones.html b/Documentation/nvme-zns-report-zones.html index 4a9d476..e015edd 100644 --- a/Documentation/nvme-zns-report-zones.html +++ b/Documentation/nvme-zns-report-zones.html @@ -957,7 +957,7 @@ Show the output in json format with extra details diff --git a/Documentation/nvme-zns-reset-zone.1 b/Documentation/nvme-zns-reset-zone.1 index 973c89b..b28e94e 100644 --- a/Documentation/nvme-zns-reset-zone.1 +++ b/Documentation/nvme-zns-reset-zone.1 @@ -2,12 +2,12 @@ .\" Title: nvme-zns-reset-zone .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ZNS\-RESET\-ZO" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ZNS\-RESET\-ZO" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-zns-reset-zone.html b/Documentation/nvme-zns-reset-zone.html index bfa0e15..633cc45 100644 --- a/Documentation/nvme-zns-reset-zone.html +++ b/Documentation/nvme-zns-reset-zone.html @@ -847,7 +847,7 @@ Reset the first zone on namespace 1: diff --git a/Documentation/nvme-zns-set-zone-desc.1 b/Documentation/nvme-zns-set-zone-desc.1 index 163db51..ee04f7e 100644 --- a/Documentation/nvme-zns-set-zone-desc.1 +++ b/Documentation/nvme-zns-set-zone-desc.1 @@ -2,12 +2,12 @@ .\" Title: nvme-zns-set-zone-desc .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ZNS\-SET\-ZONE" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ZNS\-SET\-ZONE" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-zns-set-zone-desc.html b/Documentation/nvme-zns-set-zone-desc.html index 34ca7e2..7587d8a 100644 --- a/Documentation/nvme-zns-set-zone-desc.html +++ b/Documentation/nvme-zns-set-zone-desc.html @@ -859,7 +859,7 @@ Write "hello world" into the zone descriptor for namespace 1’s first zone diff --git a/Documentation/nvme-zns-zone-append.1 b/Documentation/nvme-zns-zone-append.1 index 802ec32..1de897b 100644 --- a/Documentation/nvme-zns-zone-append.1 +++ b/Documentation/nvme-zns-zone-append.1 @@ -2,12 +2,12 @@ .\" Title: nvme-zns-zone-append .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ZNS\-ZONE\-APP" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ZNS\-ZONE\-APP" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-zns-zone-append.html b/Documentation/nvme-zns-zone-append.html index 99a64f9..de48205 100644 --- a/Documentation/nvme-zns-zone-append.html +++ b/Documentation/nvme-zns-zone-append.html @@ -940,7 +940,7 @@ Append the data "hello world" into 4k worth of blocks into the zone starting diff --git a/Documentation/nvme-zns-zone-mgmt-recv.1 b/Documentation/nvme-zns-zone-mgmt-recv.1 index af54f05..95af07f 100644 --- a/Documentation/nvme-zns-zone-mgmt-recv.1 +++ b/Documentation/nvme-zns-zone-mgmt-recv.1 @@ -2,12 +2,12 @@ .\" Title: nvme-zns-zone-mgmt-recv .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ZNS\-ZONE\-MGM" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ZNS\-ZONE\-MGM" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-zns-zone-mgmt-recv.html b/Documentation/nvme-zns-zone-mgmt-recv.html index aa4cdda..0ddc298 100644 --- a/Documentation/nvme-zns-zone-mgmt-recv.html +++ b/Documentation/nvme-zns-zone-mgmt-recv.html @@ -882,7 +882,7 @@ Binary dump of a report all zones diff --git a/Documentation/nvme-zns-zone-mgmt-send.1 b/Documentation/nvme-zns-zone-mgmt-send.1 index 85c805c..60d4f86 100644 --- a/Documentation/nvme-zns-zone-mgmt-send.1 +++ b/Documentation/nvme-zns-zone-mgmt-send.1 @@ -2,12 +2,12 @@ .\" Title: nvme-zns-zone-mgmt-send .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME\-ZNS\-ZONE\-MGM" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME\-ZNS\-ZONE\-MGM" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/Documentation/nvme-zns-zone-mgmt-send.html b/Documentation/nvme-zns-zone-mgmt-send.html index ac42948..b35735e 100644 --- a/Documentation/nvme-zns-zone-mgmt-send.html +++ b/Documentation/nvme-zns-zone-mgmt-send.html @@ -916,7 +916,7 @@ Write "hello world" into the zone descriptor for namespace 1’s first zone diff --git a/Documentation/nvme.1 b/Documentation/nvme.1 index 64c5b41..1ccbbea 100644 --- a/Documentation/nvme.1 +++ b/Documentation/nvme.1 @@ -2,12 +2,12 @@ .\" Title: nvme .\" Author: [see the "Authors" section] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 08/01/2022 +.\" Date: 11/02/2022 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" -.TH "NVME" "1" "08/01/2022" "NVMe" "NVMe Manual" +.TH "NVME" "1" "11/02/2022" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -507,6 +507,11 @@ Retrieve the Supported Log pages details .RS 4 verify command .RE +.PP +\fBnvme-show-topology\fR(1) +.RS 4 +Show NVMe topology +.RE .SS "Plugins/Vendor extension commands" .PP \fBnvme-intel-id-ctrl\fR(1) diff --git a/Documentation/nvme.html b/Documentation/nvme.html index 8a1b510..3ccb107 100644 --- a/Documentation/nvme.html +++ b/Documentation/nvme.html @@ -1514,6 +1514,14 @@ available, run "nvme help".

verify command

+
+nvme-show-topology(1) +
+
+

+ Show NVMe topology +

+
@@ -2098,7 +2106,7 @@ NVM-Express Site.

diff --git a/Makefile b/Makefile index 085adf8..10d16f0 100644 --- a/Makefile +++ b/Makefile @@ -34,6 +34,10 @@ endif install dist: ${BUILD-DIR} cd ${BUILD-DIR} && meson $@ +.PHONY: uninstall +uninstall: + cd ${BUILD-DIR} && meson --internal uninstall + .PHONY: test test: ${BUILD-DIR} ninja -C ${BUILD-DIR} $@ @@ -45,3 +49,8 @@ rpm: -Dsystemddir=$(shell rpm --eval '%{_unitdir}') \ -Ddocs=man -Ddocs-build=true rpmbuild -ba ${BUILD-DIR}/nvme.spec --define "_builddir ${BUILD-DIR}" -v + +.PHONY: debug +debug: + meson ${BUILD-DIR} --buildtype=debug + ninja -C ${BUILD-DIR} diff --git a/README.md b/README.md index 20623c1..20fbd2e 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ run following commands $ meson .build $ ninja -C .build -nvme-cli depends on zlib, json-c and libuuid. +nvme-cli depends on zlib and json-c To install, run: @@ -263,3 +263,49 @@ introduced in the Linux kernel release v4.15. Hence nvme-cli 2.x is only working on kernels >= v4.15. For older kernels nvme-cli 1.x is recommended to be used. +## How to contribute + +There are two ways to send code changes to the project. The first one +is by sending the changes to linux-nvme@lists.infradead.org. The +second one is by posting a pull request on github. In both cases +please follow the Linux contributions guidelines as documented in + +https://docs.kernel.org/process/submitting-patches.html# + +That means the changes should be a clean series (no merges should be +present in a github PR for example) and every commit should build. + +See also https://opensource.com/article/19/7/create-pull-request-github + +### How to cleanup your series before creating PR + +This example here assumes, the changes are in a branch called +fix-something, which branched away from master in the past. In the +meantime the upstream project has changed, hence the fix-something +branch is not based on the current HEAD. Before posting the PR, the +branch should be rebased on the current HEAD and retest everything. + +For example rebasing can be done by following steps + +```shell +# Update master branch +# upstream == https://github.com/linux-nvme/nvme-cli.git +$ git switch master +$ git fetch --all +$ git reset --hard upstream/master + +# Make sure all dependencies are up to date and make a sanity build +$ meson subprojects update +$ ninja -C .build + +# Go back to the fix-something branch +$ git switch fix-something + +# Rebase it to the current HEAD +$ git rebase master +[fixup all merge conflicts] +[retest] + +# Push your changes to github and trigger a PR +$ git push -u origin fix-something +``` diff --git a/completions/_nvme b/completions/_nvme index fc6b967..16c9b7c 100644 --- a/completions/_nvme +++ b/completions/_nvme @@ -63,6 +63,7 @@ _nvme () { 'lockdown:submit a lockdown command' 'media-unit-stat-log: retrieve media unit status log pages details' 'supported-cap-config-log: retrieve support log pages details' + 'show-topology: show subystem topology' 'help:print brief descriptions of all nvme commands' ) @@ -971,6 +972,19 @@ _nvme () { _arguments '*:: :->subcmds' _describe -t commands "nvme fid-support-effects-log options" _fidsupporteffectslog ;; + (show-topology) + local _showtopology + _showtopology=( + --output-format=':Output format: normal|json|binary' + -o':alias for --output-format' + --verbose':show infos verbosely' + -v':alias of --verbose' + --ranking=':Ranking order: namespace|ctrl' + -r':alias for --ranking' + ) + _arguments '*:: :->subcmds' + _describe -t commands "nvme show-topology options" _showtopology + ;; (help) local _h _h=( id-ctrl id-ns list-ns id-iocs create-ns delete-ns attach-ns detach-ns @@ -981,7 +995,7 @@ _nvme () { pred-lat-event-agg-log nvm-id-ctrl endurance-event-agg-log lba-status-log resv-notif-log capacity-mgmt id-domain boot-part-log fid-support-effects-log supported-log-pages lockdown media-unit-stat-log id-ns-lba-format nvm-id-ns - nvm-id-ns-lba-format supported-cap-config-log + nvm-id-ns-lba-format supported-cap-config-log show-topology ) _arguments '*:: :->subcmds' _describe -t commands "help: infos on a specific nvme command, or provide no option to see a synopsis of all nvme commands" _h diff --git a/completions/bash-nvme-completion.sh b/completions/bash-nvme-completion.sh index e817701..f067940 100644 --- a/completions/bash-nvme-completion.sh +++ b/completions/bash-nvme-completion.sh @@ -103,7 +103,7 @@ _cmds="list list-subsys id-ctrl id-ns \ show-hostnqn dir-receive dir-send virt-mgmt \ rpmb boot-part-log fid-support-effects-log \ supported-log-pages lockdown media-unit-stat-log \ - supported-cap-config-log dim" + supported-cap-config-log dim show-topology" # Add plugins: for plugin in "${!_plugin_subcmds[@]}"; do @@ -524,6 +524,9 @@ nvme_list_opts () { --key= -k --msg= -d --address= -o --blocks= -b \ --target= -t" ;; + "show-topology") + opts+=" --output-format= -o --verbose -v --ranking= -r" + ;; "version") opts+=$NO_OPTS ;; diff --git a/fabrics.c b/fabrics.c index 43ca5f4..5560b72 100644 --- a/fabrics.c +++ b/fabrics.c @@ -104,12 +104,12 @@ static const char *nvmf_config_file = "Use specified JSON configuration file or OPT_FLAG("data-digest", 'G', &c.data_digest, nvmf_data_digest) \ struct tr_config { - char *subsysnqn; - char *transport; - char *traddr; - char *host_traddr; - char *host_iface; - char *trsvcid; + const char *subsysnqn; + const char *transport; + const char *traddr; + const char *host_traddr; + const char *host_iface; + const char *trsvcid; }; static void space_strip_len(int max, char *str) @@ -607,6 +607,78 @@ out: return ret; } +static int discover_from_json_config_file(nvme_root_t r, nvme_host_t h, + const char *desc, bool connect, + const struct nvme_fabrics_config *defcfg, + enum nvme_print_flags flags, + bool force) +{ + const char *transport, *traddr, *trsvcid, *subsysnqn; + nvme_subsystem_t s; + nvme_ctrl_t c, cn; + struct nvme_fabrics_config cfg; + int ret = 0; + + nvme_for_each_subsystem(h, s) { + nvme_subsystem_for_each_ctrl(s, c) { + transport = nvme_ctrl_get_transport(c); + traddr = nvme_ctrl_get_traddr(c); + + if (!transport && !traddr) + continue; + + /* ignore none fabric transports */ + if (strcmp(transport, "tcp") && + strcmp(transport, "rdma") && + strcmp(transport, "fc")) + continue; + + trsvcid = nvme_ctrl_get_trsvcid(c); + if (!trsvcid || !strcmp(trsvcid, "")) + trsvcid = get_default_trsvcid(transport, true); + + if (force) + subsysnqn = nvme_ctrl_get_subsysnqn(c); + else + subsysnqn = NVME_DISC_SUBSYS_NAME; + + if (nvme_ctrl_is_persistent(c)) + persistent = true; + + memcpy(&cfg, defcfg, sizeof(cfg)); + + struct tr_config trcfg = { + .subsysnqn = subsysnqn, + .transport = transport, + .traddr = traddr, + .host_traddr = cfg.host_traddr, + .host_iface = cfg.host_iface, + .trsvcid = trsvcid, + }; + + if (!force) { + cn = lookup_discover_ctrl(r, &trcfg); + if (cn) { + __discover(c, &cfg, raw, connect, + true, flags); + continue; + } + } + + cn = create_discover_ctrl(r, h, &cfg, &trcfg); + if (!cn) + continue; + + __discover(cn, &cfg, raw, connect, persistent, flags); + if (!persistent) + ret = nvme_disconnect_ctrl(cn); + nvme_free_ctrl(cn); + } + } + + return ret; +} + int nvmf_discover(const char *desc, int argc, char **argv, bool connect) { char *subsysnqn = NVME_DISC_SUBSYS_NAME; @@ -624,6 +696,7 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) struct nvme_fabrics_config cfg; char *device = NULL; bool force = false; + bool json_config = false; OPT_ARGS(opts) = { OPT_STRING("device", 'd', "DEV", &device, "use existing discovery controller device"), @@ -665,7 +738,8 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) nvme_free_tree(r); return ret; } - nvme_read_config(r, config_file); + if (!nvme_read_config(r, config_file)) + json_config = true; if (!hostnqn) hostnqn = hnqn = nvmf_hostnqn_from_file(); @@ -688,6 +762,13 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) nvme_host_set_dhchap_key(h, hostkey); if (!device && !transport && !traddr) { + if (json_config) + ret = discover_from_json_config_file(r, h, desc, + connect, &cfg, + flags, force); + if (ret || access(PATH_NVMF_DISC, F_OK)) + goto out_free; + ret = discover_from_conf_file(r, h, desc, connect, &cfg); goto out_free; } @@ -1134,6 +1215,18 @@ int nvmf_config(const char *desc, int argc, char **argv) nvme_subsystem_t s; nvme_ctrl_t c; + if (!subsysnqn) { + fprintf(stderr, + "required argument [--nqn | -n] needed with --modify\n"); + return -EINVAL; + } + + if (!transport) { + fprintf(stderr, + "required argument [--transport | -t] needed with --modify\n"); + return EINVAL; + } + if (!hostnqn) hostnqn = hnqn = nvmf_hostnqn_from_file(); if (!hostid && hnqn) diff --git a/libnvme-wrap.c b/libnvme-wrap.c new file mode 100644 index 0000000..354e7f7 --- /dev/null +++ b/libnvme-wrap.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * This file is part of nvme-cli + * + * Copyright (c) 2022 Daniel Wagner, SUSE + */ + +#include +#include + +#include + +#define PROTO(args...) args +#define ARGS(args...) args + +#define VOID_FN(name, proto, args) \ +void __attribute__((weak)) name(proto) \ +{ \ + void (*fn)(proto); \ + fn = dlsym(RTLD_NEXT, #name); \ + if (fn) \ + fn(args); \ +} + +#define FN(name, rtype, proto, args, defret) \ +rtype __attribute__((weak)) name(proto) \ +{ \ + rtype (*fn)(proto); \ + fn = dlsym(RTLD_NEXT, #name); \ + if (fn) \ + return fn(args); \ + return defret; \ +} + +FN(nvme_get_version, + const char *, PROTO(enum nvme_version type), + ARGS(type), "n/a") + +VOID_FN(nvme_init_copy_range_f1, + PROTO(struct nvme_copy_range_f1 *copy, __u16 *nlbs, + __u64 *slbas, __u64 *eilbrts, __u32 *elbatms, + __u32 *elbats, __u16 nr), + ARGS(copy, nlbs, slbas, eilbrts, elbatms, elbats, nr)) + +FN(nvme_get_feature_length2, + int, + PROTO(int fid, __u32 cdw11, enum nvme_data_tfr dir, + __u32 *len), + ARGS(fid, cdw11, dir, len), + -EEXIST) + +FN(nvme_ctrl_is_persistent, + bool, + PROTO(nvme_ctrl_t c), + ARGS(c), + false) diff --git a/meson.build b/meson.build index 3ae318e..cd85a98 100644 --- a/meson.build +++ b/meson.build @@ -2,9 +2,9 @@ ################################################################################ project( 'nvme-cli', ['c'], - meson_version: '>= 0.47.0', + meson_version: '>= 0.48.0', license: 'GPL-2.0-only', - version: '2.1.2', + version: '2.2.1', default_options: [ 'c_std=gnu99', 'buildtype=release', @@ -44,13 +44,10 @@ endif conf.set('SYSCONFDIR', '"@0@"'.format(sysconfdir)) # Check for libnvme availability -libnvme_dep = dependency('libnvme', version: '>=1.1', required: true, +libnvme_dep = dependency('libnvme', version: '>=1.2', required: true, fallback : ['libnvme', 'libnvme_dep']) - -# Check for libuuid availability -libuuid_dep = dependency('uuid', required: true, - fallback : ['uuid', 'uuid_dep']) -conf.set('CONFIG_LIBUUID', libuuid_dep.found(), description: 'Is libuuid available?') +libnvme_mi_dep = dependency('libnvme-mi', required: true, + fallback : ['libnvme', 'libnvme_mi_dep']) # Check for libjson-c availability json_c_dep = dependency('json-c', required: true, version: '>=0.13', @@ -127,12 +124,12 @@ conf.set10( ) conf.set10( 'HAVE_LITTLE_ENDIAN', - build_machine.endian() == 'little', + host_machine.endian() == 'little', description: 'Building for little-endian' ) conf.set10( 'HAVE_BIG_ENDIAN', - build_machine.endian() == 'big', + host_machine.endian() == 'big', description: 'Building for big-endian' ) conf.set10( @@ -245,8 +242,9 @@ sources = [ 'nvme-models.c', 'nvme-print.c', 'nvme-rpmb.c', + 'nvme-wrap.c', 'plugin.c', - 'wrapper.c', + 'libnvme-wrap.c', ] subdir('ccan') @@ -258,7 +256,7 @@ subdir('Documentation') executable( 'nvme', sources, - dependencies: [ libnvme_dep, libuuid_dep, json_c_dep, libz_dep, + dependencies: [ libnvme_dep, libnvme_mi_dep, json_c_dep, libz_dep, libhugetlbfs_dep ], link_args: '-ldl', include_directories: incdir, diff --git a/nvme-builtin.h b/nvme-builtin.h index 43041ca..c501b74 100644 --- a/nvme-builtin.h +++ b/nvme-builtin.h @@ -105,7 +105,8 @@ COMMAND_LIST( ENTRY("virt-mgmt", "Manage Flexible Resources between Primary and Secondary Controller ", virtual_mgmt) ENTRY("rpmb", "Replay Protection Memory Block commands", rpmb_cmd) ENTRY("lockdown", "Submit a Lockdown command,return result", lockdown_cmd) - ENTRY("dim", "Send Discovery Information Management command to a Discovery Controller", dim_cmd) + ENTRY("dim", "Send Discovery Information Management command to a Discovery Controller", dim_cmd) \ + ENTRY("show-topology", "Show the topology", show_topology_cmd) \ ); #endif diff --git a/nvme-print.c b/nvme-print.c index e92ba82..c27f087 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -6,22 +6,15 @@ #include #include #include -#include #include "nvme.h" #include "libnvme.h" #include "nvme-print.h" #include "nvme-models.h" #include "util/suffix.h" +#include "util/types.h" #include "common.h" -#define ABSOLUTE_ZERO_CELSIUS -273 - -static inline long kelvin_to_celsius(long t) -{ - return t + ABSOLUTE_ZERO_CELSIUS; -} - static const uint8_t zero_uuid[16] = { 0 }; static const uint8_t invalid_uuid[16] = {[0 ... 15] = 0xff }; static const char dash[100] = {[0 ... 99] = '-'}; @@ -35,18 +28,6 @@ struct nvme_bar_cap { __u8 rsvd_crms_nsss_cmbs_pmrs; }; -static long double int128_to_double(__u8 *data) -{ - int i; - long double result = 0; - - for (i = 0; i < 16; i++) { - result *= 256; - result += data[15 - i]; - } - return result; -} - static const char *nvme_ana_state_to_string(enum nvme_ana_state state) { switch (state) { @@ -120,17 +101,6 @@ const char *nvme_cmd_to_string(int admin, __u8 opcode) return "Unknown"; } -static const char *fw_to_string(char *c) -{ - static char ret[9]; - int i; - - for (i = 0; i < 8; i++) - ret[i] = c[i] >= '!' && c[i] <= '~' ? c[i] : '.'; - ret[i] = '\0'; - return ret; -} - static const char *get_sanitize_log_sstat_status_str(__u16 status) { switch (status & NVME_SANITIZE_SSTAT_STATUS_MASK) { @@ -158,7 +128,7 @@ static void json_nvme_id_ns(struct nvme_id_ns *ns, bool cap_only) struct json_object *lbafs; int i; - long double nvmcap = int128_to_double(ns->nvmcap); + nvme_uint128_t nvmcap = le128_to_cpu(ns->nvmcap); root = json_create_object(); @@ -186,7 +156,7 @@ static void json_nvme_id_ns(struct nvme_id_ns *ns, bool cap_only) json_object_add_value_int(root, "nabo", le16_to_cpu(ns->nabo)); json_object_add_value_int(root, "nabspf", le16_to_cpu(ns->nabspf)); json_object_add_value_int(root, "noiob", le16_to_cpu(ns->noiob)); - json_object_add_value_double(root, "nvmcap", nvmcap); + json_object_add_value_uint128(root, "nvmcap", nvmcap); json_object_add_value_int(root, "nsattr", ns->nsattr); json_object_add_value_int(root, "nvmsetid", le16_to_cpu(ns->nvmsetid)); @@ -245,10 +215,10 @@ static void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl, struct json_object *root; struct json_object *psds; - long double tnvmcap = int128_to_double(ctrl->tnvmcap); - long double unvmcap = int128_to_double(ctrl->unvmcap); - long double megcap = int128_to_double(ctrl->megcap); - long double maxdna = int128_to_double(ctrl->maxdna); + nvme_uint128_t tnvmcap = le128_to_cpu(ctrl->tnvmcap); + nvme_uint128_t unvmcap = le128_to_cpu(ctrl->unvmcap); + nvme_uint128_t megcap = le128_to_cpu(ctrl->megcap); + nvme_uint128_t maxdna = le128_to_cpu(ctrl->maxdna); char sn[sizeof(ctrl->sn) + 1], mn[sizeof(ctrl->mn) + 1], fr[sizeof(ctrl->fr) + 1], subnqn[sizeof(ctrl->subnqn) + 1]; @@ -279,6 +249,8 @@ static void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl, json_object_add_value_uint(root, "oaes", le32_to_cpu(ctrl->oaes)); json_object_add_value_int(root, "ctratt", le32_to_cpu(ctrl->ctratt)); json_object_add_value_int(root, "rrls", le16_to_cpu(ctrl->rrls)); + json_object_add_value_int(root, "cntrltype", ctrl->cntrltype); + json_object_add_value_string(root, "fguid", util_uuid_to_string(ctrl->fguid)); json_object_add_value_int(root, "crdt1", le16_to_cpu(ctrl->crdt1)); json_object_add_value_int(root, "crdt2", le16_to_cpu(ctrl->crdt2)); json_object_add_value_int(root, "crdt3", le16_to_cpu(ctrl->crdt3)); @@ -299,8 +271,8 @@ static void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl, json_object_add_value_int(root, "mtfa", le16_to_cpu(ctrl->mtfa)); json_object_add_value_uint(root, "hmpre", le32_to_cpu(ctrl->hmpre)); json_object_add_value_uint(root, "hmmin", le32_to_cpu(ctrl->hmmin)); - json_object_add_value_double(root, "tnvmcap", tnvmcap); - json_object_add_value_double(root, "unvmcap", unvmcap); + json_object_add_value_uint128(root, "tnvmcap", tnvmcap); + json_object_add_value_uint128(root, "unvmcap", unvmcap); json_object_add_value_uint(root, "rpmbs", le32_to_cpu(ctrl->rpmbs)); json_object_add_value_int(root, "edstt", le16_to_cpu(ctrl->edstt)); json_object_add_value_int(root, "dsto", ctrl->dsto); @@ -314,15 +286,16 @@ static void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl, json_object_add_value_int(root, "hmmaxd", le16_to_cpu(ctrl->hmmaxd)); json_object_add_value_int(root, "nsetidmax", le16_to_cpu(ctrl->nsetidmax)); - + json_object_add_value_int(root, "endgidmax", le16_to_cpu(ctrl->endgidmax)); json_object_add_value_int(root, "anatt",ctrl->anatt); json_object_add_value_int(root, "anacap", ctrl->anacap); json_object_add_value_int(root, "anagrpmax", le32_to_cpu(ctrl->anagrpmax)); json_object_add_value_int(root, "nanagrpid", le32_to_cpu(ctrl->nanagrpid)); + json_object_add_value_int(root, "pels", le32_to_cpu(ctrl->pels)); json_object_add_value_int(root, "domainid", le16_to_cpu(ctrl->domainid)); - json_object_add_value_double(root, "megcap", megcap); + json_object_add_value_uint128(root, "megcap", megcap); json_object_add_value_int(root, "sqes", ctrl->sqes); json_object_add_value_int(root, "cqes", ctrl->cqes); json_object_add_value_int(root, "maxcmd", le16_to_cpu(ctrl->maxcmd)); @@ -338,7 +311,8 @@ static void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl, json_object_add_value_int(root, "acwu", le16_to_cpu(ctrl->acwu)); json_object_add_value_int(root, "ocfs", le16_to_cpu(ctrl->ocfs)); json_object_add_value_int(root, "sgls", le32_to_cpu(ctrl->sgls)); - json_object_add_value_double(root, "maxdna", maxdna); + json_object_add_value_int(root, "mnan", le32_to_cpu(ctrl->mnan)); + json_object_add_value_uint128(root, "maxdna", maxdna); json_object_add_value_int(root, "maxcna", le32_to_cpu(ctrl->maxcna)); if (strlen(subnqn)) @@ -532,7 +506,7 @@ static void json_fw_log(struct nvme_firmware_slot *fw_log, const char *devname) frs = (__le64 *)&fw_log->frs[i]; snprintf(str, sizeof(str), "%"PRIu64" (%s)", le64_to_cpu(*frs), - fw_to_string(fw_log->frs[i])); + util_fw_to_string(fw_log->frs[i])); json_object_add_value_string(fwsi, fmt, str); } } @@ -585,22 +559,22 @@ static void json_endurance_log(struct nvme_endurance_group_log *endurance_group, { struct json_object *root; - long double endurance_estimate = - int128_to_double(endurance_group->endurance_estimate); - long double data_units_read = - int128_to_double(endurance_group->data_units_read); - long double data_units_written = - int128_to_double(endurance_group->data_units_written); - long double media_units_written = - int128_to_double(endurance_group->media_units_written); - long double host_read_cmds = - int128_to_double(endurance_group->host_read_cmds); - long double host_write_cmds = - int128_to_double(endurance_group->host_write_cmds); - long double media_data_integrity_err = - int128_to_double(endurance_group->media_data_integrity_err); - long double num_err_info_log_entries = - int128_to_double(endurance_group->num_err_info_log_entries); + nvme_uint128_t endurance_estimate = + le128_to_cpu(endurance_group->endurance_estimate); + nvme_uint128_t data_units_read = + le128_to_cpu(endurance_group->data_units_read); + nvme_uint128_t data_units_written = + le128_to_cpu(endurance_group->data_units_written); + nvme_uint128_t media_units_written = + le128_to_cpu(endurance_group->media_units_written); + nvme_uint128_t host_read_cmds = + le128_to_cpu(endurance_group->host_read_cmds); + nvme_uint128_t host_write_cmds = + le128_to_cpu(endurance_group->host_write_cmds); + nvme_uint128_t media_data_integrity_err = + le128_to_cpu(endurance_group->media_data_integrity_err); + nvme_uint128_t num_err_info_log_entries = + le128_to_cpu(endurance_group->num_err_info_log_entries); root = json_create_object(); @@ -612,18 +586,18 @@ static void json_endurance_log(struct nvme_endurance_group_log *endurance_group, endurance_group->avl_spare_threshold); json_object_add_value_int(root, "percent_used", endurance_group->percent_used); - json_object_add_value_double(root, "endurance_estimate", + json_object_add_value_uint128(root, "endurance_estimate", endurance_estimate); - json_object_add_value_double(root, "data_units_read", data_units_read); - json_object_add_value_double(root, "data_units_written", + json_object_add_value_uint128(root, "data_units_read", data_units_read); + json_object_add_value_uint128(root, "data_units_written", data_units_written); - json_object_add_value_double(root, "mediate_write_commands", + json_object_add_value_uint128(root, "media_units_written", media_units_written); - json_object_add_value_double(root, "host_read_cmds", host_read_cmds); - json_object_add_value_double(root, "host_write_cmds", host_write_cmds); - json_object_add_value_double(root, "media_data_integrity_err", + json_object_add_value_uint128(root, "host_read_cmds", host_read_cmds); + json_object_add_value_uint128(root, "host_write_cmds", host_write_cmds); + json_object_add_value_uint128(root, "media_data_integrity_err", media_data_integrity_err); - json_object_add_value_double(root, "num_err_info_log_entries", + json_object_add_value_uint128(root, "num_err_info_log_entries", num_err_info_log_entries); json_print_object(root, NULL); @@ -641,16 +615,16 @@ static void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid, unsigned int temperature = ((smart->temperature[1] << 8) | smart->temperature[0]); - long double data_units_read = int128_to_double(smart->data_units_read); - long double data_units_written = int128_to_double(smart->data_units_written); - long double host_read_commands = int128_to_double(smart->host_reads); - long double host_write_commands = int128_to_double(smart->host_writes); - long double controller_busy_time = int128_to_double(smart->ctrl_busy_time); - long double power_cycles = int128_to_double(smart->power_cycles); - long double power_on_hours = int128_to_double(smart->power_on_hours); - long double unsafe_shutdowns = int128_to_double(smart->unsafe_shutdowns); - long double media_errors = int128_to_double(smart->media_errors); - long double num_err_log_entries = int128_to_double(smart->num_err_log_entries); + nvme_uint128_t data_units_read = le128_to_cpu(smart->data_units_read); + nvme_uint128_t data_units_written = le128_to_cpu(smart->data_units_written); + nvme_uint128_t host_read_commands = le128_to_cpu(smart->host_reads); + nvme_uint128_t host_write_commands = le128_to_cpu(smart->host_writes); + nvme_uint128_t controller_busy_time = le128_to_cpu(smart->ctrl_busy_time); + nvme_uint128_t power_cycles = le128_to_cpu(smart->power_cycles); + nvme_uint128_t power_on_hours = le128_to_cpu(smart->power_on_hours); + nvme_uint128_t unsafe_shutdowns = le128_to_cpu(smart->unsafe_shutdowns); + nvme_uint128_t media_errors = le128_to_cpu(smart->media_errors); + nvme_uint128_t num_err_log_entries = le128_to_cpu(smart->num_err_log_entries); root = json_create_object(); @@ -676,20 +650,20 @@ static void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid, json_object_add_value_int(root, "percent_used", smart->percent_used); json_object_add_value_int(root, "endurance_grp_critical_warning_summary", smart->endu_grp_crit_warn_sumry); - json_object_add_value_double(root, "data_units_read", data_units_read); - json_object_add_value_double(root, "data_units_written", + json_object_add_value_uint128(root, "data_units_read", data_units_read); + json_object_add_value_uint128(root, "data_units_written", data_units_written); - json_object_add_value_double(root, "host_read_commands", + json_object_add_value_uint128(root, "host_read_commands", host_read_commands); - json_object_add_value_double(root, "host_write_commands", + json_object_add_value_uint128(root, "host_write_commands", host_write_commands); - json_object_add_value_double(root, "controller_busy_time", + json_object_add_value_uint128(root, "controller_busy_time", controller_busy_time); - json_object_add_value_double(root, "power_cycles", power_cycles); - json_object_add_value_double(root, "power_on_hours", power_on_hours); - json_object_add_value_double(root, "unsafe_shutdowns", unsafe_shutdowns); - json_object_add_value_double(root, "media_errors", media_errors); - json_object_add_value_double(root, "num_err_log_entries", + json_object_add_value_uint128(root, "power_cycles", power_cycles); + json_object_add_value_uint128(root, "power_on_hours", power_on_hours); + json_object_add_value_uint128(root, "unsafe_shutdowns", unsafe_shutdowns); + json_object_add_value_uint128(root, "media_errors", media_errors); + json_object_add_value_uint128(root, "num_err_log_entries", num_err_log_entries); json_object_add_value_uint(root, "warning_temp_time", le32_to_cpu(smart->warning_temp_time)); @@ -1110,6 +1084,8 @@ static const char *nvme_show_nss_hw_error(__u16 error_code) return "Controller Fatal Status"; case 0xA: return "Media and Data Integrity Status"; + case 0xB: + return "Controller Ready Timeout Exceeded"; default: return "Reserved"; } @@ -1191,8 +1167,8 @@ static void json_persistent_event_log(void *pevent_log_info, __u32 size) le16_to_cpu(pevent_log_head->lhl)); json_object_add_value_uint64(root, "timestamp", le64_to_cpu(pevent_log_head->ts)); - json_object_add_value_double(root, "power_on_hours", - int128_to_double(pevent_log_head->poh)); + json_object_add_value_uint128(root, "power_on_hours", + le128_to_cpu(pevent_log_head->poh)); json_object_add_value_uint64(root, "power_cycle_count", le64_to_cpu(pevent_log_head->pcc)); json_object_add_value_uint(root, "pci_vid", @@ -1256,16 +1232,16 @@ static void json_persistent_event_log(void *pevent_log_info, __u32 size) unsigned int temperature = ((smart_event->temperature[1] << 8) | smart_event->temperature[0]); - long double data_units_read = int128_to_double(smart_event->data_units_read); - long double data_units_written = int128_to_double(smart_event->data_units_written); - long double host_read_commands = int128_to_double(smart_event->host_reads); - long double host_write_commands = int128_to_double(smart_event->host_writes); - long double controller_busy_time = int128_to_double(smart_event->ctrl_busy_time); - long double power_cycles = int128_to_double(smart_event->power_cycles); - long double power_on_hours = int128_to_double(smart_event->power_on_hours); - long double unsafe_shutdowns = int128_to_double(smart_event->unsafe_shutdowns); - long double media_errors = int128_to_double(smart_event->media_errors); - long double num_err_log_entries = int128_to_double(smart_event->num_err_log_entries); + nvme_uint128_t data_units_read = le128_to_cpu(smart_event->data_units_read); + nvme_uint128_t data_units_written = le128_to_cpu(smart_event->data_units_written); + nvme_uint128_t host_read_commands = le128_to_cpu(smart_event->host_reads); + nvme_uint128_t host_write_commands = le128_to_cpu(smart_event->host_writes); + nvme_uint128_t controller_busy_time = le128_to_cpu(smart_event->ctrl_busy_time); + nvme_uint128_t power_cycles = le128_to_cpu(smart_event->power_cycles); + nvme_uint128_t power_on_hours = le128_to_cpu(smart_event->power_on_hours); + nvme_uint128_t unsafe_shutdowns = le128_to_cpu(smart_event->unsafe_shutdowns); + nvme_uint128_t media_errors = le128_to_cpu(smart_event->media_errors); + nvme_uint128_t num_err_log_entries = le128_to_cpu(smart_event->num_err_log_entries); json_object_add_value_int(valid_attrs, "critical_warning", smart_event->critical_warning); @@ -1280,25 +1256,25 @@ static void json_persistent_event_log(void *pevent_log_info, __u32 size) json_object_add_value_int(valid_attrs, "endurance_grp_critical_warning_summary", smart_event->endu_grp_crit_warn_sumry); - json_object_add_value_double(valid_attrs, "data_units_read", + json_object_add_value_uint128(valid_attrs, "data_units_read", data_units_read); - json_object_add_value_double(valid_attrs, "data_units_written", + json_object_add_value_uint128(valid_attrs, "data_units_written", data_units_written); - json_object_add_value_double(valid_attrs, "host_read_commands", + json_object_add_value_uint128(valid_attrs, "host_read_commands", host_read_commands); - json_object_add_value_double(valid_attrs, "host_write_commands", + json_object_add_value_uint128(valid_attrs, "host_write_commands", host_write_commands); - json_object_add_value_double(valid_attrs, "controller_busy_time", + json_object_add_value_uint128(valid_attrs, "controller_busy_time", controller_busy_time); - json_object_add_value_double(valid_attrs, "power_cycles", + json_object_add_value_uint128(valid_attrs, "power_cycles", power_cycles); - json_object_add_value_double(valid_attrs, "power_on_hours", + json_object_add_value_uint128(valid_attrs, "power_on_hours", power_on_hours); - json_object_add_value_double(valid_attrs, "unsafe_shutdowns", + json_object_add_value_uint128(valid_attrs, "unsafe_shutdowns", unsafe_shutdowns); - json_object_add_value_double(valid_attrs, "media_errors", + json_object_add_value_uint128(valid_attrs, "media_errors", media_errors); - json_object_add_value_double(valid_attrs, "num_err_log_entries", + json_object_add_value_uint128(valid_attrs, "num_err_log_entries", num_err_log_entries); json_object_add_value_uint(valid_attrs, "warning_temp_time", le32_to_cpu(smart_event->warning_temp_time)); @@ -1326,11 +1302,11 @@ static void json_persistent_event_log(void *pevent_log_info, __u32 size) fw_commit_event = pevent_log_info + offset; snprintf(fw_str, sizeof(fw_str), "%"PRIu64" (%s)", le64_to_cpu(fw_commit_event->old_fw_rev), - fw_to_string((char *)&fw_commit_event->old_fw_rev)); + util_fw_to_string((char *)&fw_commit_event->old_fw_rev)); json_object_add_value_string(valid_attrs, "old_fw_rev", fw_str); snprintf(fw_str, sizeof(fw_str), "%"PRIu64" (%s)", le64_to_cpu(fw_commit_event->new_fw_rev), - fw_to_string((char *)&fw_commit_event->new_fw_rev)); + util_fw_to_string((char *)&fw_commit_event->new_fw_rev)); json_object_add_value_string(valid_attrs, "new_fw_rev", fw_str); json_object_add_value_uint(valid_attrs, "fw_commit_action", fw_commit_event->fw_commit_action); @@ -1361,7 +1337,7 @@ static void json_persistent_event_log(void *pevent_log_info, __u32 size) fw_rev = pevent_log_info + offset; snprintf(fw_str, sizeof(fw_str), "%"PRIu64" (%s)", le64_to_cpu(*fw_rev), - fw_to_string((char *)fw_rev)); + util_fw_to_string((char *)fw_rev)); json_object_add_value_string(valid_attrs, "fw_rev", fw_str); for (int i = 0; i < por_info_list; i++) { por_event = pevent_log_info + offset + @@ -1541,8 +1517,8 @@ void nvme_show_persistent_event_log(void *pevent_log_info, printf("Log Header Length: %u\n", pevent_log_head->lhl); printf("Timestamp: %"PRIu64"\n", le64_to_cpu(pevent_log_head->ts)); - printf("Power On Hours (POH): %'.0Lf\n", - int128_to_double(pevent_log_head->poh)); + printf("Power On Hours (POH): %s", + uint128_t_to_string(le128_to_cpu(pevent_log_head->poh))); printf("Power Cycle Count: %"PRIu64"\n", le64_to_cpu(pevent_log_head->pcc)); printf("PCI Vendor ID (VID): %u\n", @@ -1615,10 +1591,10 @@ void nvme_show_persistent_event_log(void *pevent_log_info, printf("FW Commit Event Entry: \n"); printf("Old Firmware Revision: %"PRIu64" (%s)\n", le64_to_cpu(fw_commit_event->old_fw_rev), - fw_to_string((char *)&fw_commit_event->old_fw_rev)); + util_fw_to_string((char *)&fw_commit_event->old_fw_rev)); printf("New Firmware Revision: %"PRIu64" (%s)\n", le64_to_cpu(fw_commit_event->new_fw_rev), - fw_to_string((char *)&fw_commit_event->new_fw_rev)); + util_fw_to_string((char *)&fw_commit_event->new_fw_rev)); printf("FW Commit Action: %u\n", fw_commit_event->fw_commit_action); printf("FW Slot: %u\n", fw_commit_event->fw_slot); @@ -1646,7 +1622,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info, printf("Power On Reset Event Entry: \n"); fw_rev = pevent_log_info + offset; printf("Firmware Revision: %"PRIu64" (%s)\n", le64_to_cpu(*fw_rev), - fw_to_string((char *)fw_rev)); + util_fw_to_string((char *)fw_rev)); printf("Reset Information List: \n"); for (int i = 0; i < por_info_list; i++) { @@ -2263,10 +2239,10 @@ static void json_supported_cap_config_log( le16_to_cpu(cap_log->cap_config_desc[i].egcd[j].endgid)); json_object_add_value_uint(endurance, "cap_adj_factor", le16_to_cpu(cap_log->cap_config_desc[i].egcd[j].cap_adj_factor)); - json_object_add_value_double(endurance, "tegcap", - int128_to_double(cap_log->cap_config_desc[i].egcd[j].tegcap)); - json_object_add_value_double(endurance, "segcap", - int128_to_double(cap_log->cap_config_desc[i].egcd[j].segcap)); + json_object_add_value_uint128(endurance, "tegcap", + le128_to_cpu(cap_log->cap_config_desc[i].egcd[j].tegcap)); + json_object_add_value_uint128(endurance, "segcap", + le128_to_cpu(cap_log->cap_config_desc[i].egcd[j].segcap)); json_object_add_value_uint(endurance, "egsets", le16_to_cpu(cap_log->cap_config_desc[i].egcd[j].egsets)); egsets = le16_to_cpu(cap_log->cap_config_desc[i].egcd[j].egsets); @@ -2343,12 +2319,15 @@ void nvme_show_supported_cap_config_log( le16_to_cpu(cap->cap_config_desc[i].egcd[j].endgid)); printf("Capacity Adjustment Factor: %u\n", le16_to_cpu(cap->cap_config_desc[i].egcd[j].cap_adj_factor)); - printf("Total Endurance Group Capacity: %'.0Lf\n", - int128_to_double(cap->cap_config_desc[i].egcd[j].tegcap)); - printf("Spare Endurance Group Capacity: %'.0Lf\n", - int128_to_double(cap->cap_config_desc[i].egcd[j].segcap)); - printf("Endurance Estimate: %'.0Lf\n", - int128_to_double(cap->cap_config_desc[i].egcd[j].end_est)); + printf("Total Endurance Group Capacity: %s\n", + uint128_t_to_string(le128_to_cpu( + cap->cap_config_desc[i].egcd[j].tegcap))); + printf("Spare Endurance Group Capacity: %s\n", + uint128_t_to_string(le128_to_cpu( + cap->cap_config_desc[i].egcd[j].segcap))); + printf("Endurance Estimate: %s\n", + uint128_t_to_string(le128_to_cpu( + cap->cap_config_desc[i].egcd[j].end_est))); egsets = le16_to_cpu(cap->cap_config_desc[i].egcd[j].egsets); printf("Number of NVM Sets: %u\n", egsets); for(k = 0; k < egsets; k++) { @@ -2503,12 +2482,14 @@ static void json_print_nvme_subsystem_list(nvme_root_t r, bool show_ana) nvme_for_each_host(r, h) { nvme_subsystem_t s; + const char *hostid; host_attrs = json_create_object(); json_object_add_value_string(host_attrs, "HostNQN", nvme_host_get_hostnqn(h)); - json_object_add_value_string(host_attrs, "HostID", - nvme_host_get_hostid(h)); + hostid = nvme_host_get_hostid(h); + if (hostid) + json_object_add_value_string(host_attrs, "HostID", hostid); subsystems = json_create_array(); nvme_for_each_subsystem(h, s) { subsystem_attrs = json_create_object(); @@ -3274,20 +3255,32 @@ void d_raw(unsigned char *buf, unsigned len) putchar(*(buf+i)); } -void nvme_show_status(__u16 status) -{ - fprintf(stderr, "NVMe status: %s(%#x)\n", - nvme_status_to_string(status, false), status); -} - -static const char *nvme_uuid_to_string(uuid_t uuid) +void nvme_show_status(int status) { - /* large enough to hold uuid str (37) + null-termination byte */ - static char uuid_str[40]; + int val = nvme_status_get_value(status); + int type = nvme_status_get_type(status); - uuid_unparse_lower(uuid, uuid_str); + /* Callers should be checking for negative values first, but provide a + * sensible fallback anyway + */ + if (status < 0) { + fprintf(stderr, "Error: %s\n", nvme_strerror(errno)); + return; + } - return uuid_str; + switch (type) { + case NVME_STATUS_TYPE_NVME: + fprintf(stderr, "NVMe status: %s(%#x)\n", + nvme_status_to_string(val, false), val); + break; + case NVME_STATUS_TYPE_MI: + fprintf(stderr, "NVMe-MI status: %s(%#x)\n", + nvme_mi_status_to_string(val), val); + break; + default: + fprintf(stderr, "Unknown status type %d, value %#x\n", + type, val); + } } static void nvme_show_id_ctrl_cmic(__u8 cmic) @@ -3618,16 +3611,14 @@ static void nvme_show_id_ctrl_cctemp(__le16 cctemp) static void nvme_show_id_ctrl_tnvmcap(__u8 *tnvmcap) { - printf("[127:0] : %.0Lf\tTotal NVM Capacity (TNVMCAP)\n", - int128_to_double(tnvmcap)); - printf("\n"); + printf("[127:0] : %s\n", uint128_t_to_string(le128_to_cpu(tnvmcap))); + printf("\tTotal NVM Capacity (TNVMCAP)\n\n"); } static void nvme_show_id_ctrl_unvmcap(__u8 *unvmcap) { - printf("[127:0] : %.0Lf\tUnallocated NVM Capacity (UNVMCAP)\n", - int128_to_double(unvmcap)); - printf("\n"); + printf("[127:0] : %s\n", uint128_t_to_string(le128_to_cpu(unvmcap))); + printf("\tUnallocated NVM Capacity (UNVMCAP)\n\n"); } void nvme_show_id_ctrl_rpmbs(__le32 ctrl_rpmbs) @@ -4208,7 +4199,8 @@ void nvme_show_id_ns(struct nvme_id_ns *ns, unsigned int nsid, printf("nabo : %d\n", le16_to_cpu(ns->nabo)); printf("nabspf : %d\n", le16_to_cpu(ns->nabspf)); printf("noiob : %d\n", le16_to_cpu(ns->noiob)); - printf("nvmcap : %.0Lf\n", int128_to_double(ns->nvmcap)); + printf("nvmcap : %s\n", + uint128_t_to_string(le128_to_cpu(ns->nvmcap))); if (ns->nsfeat & 0x10) { printf("npwg : %u\n", le16_to_cpu(ns->npwg)); printf("npwa : %u\n", le16_to_cpu(ns->npwa)); @@ -4355,7 +4347,7 @@ static void json_nvme_id_ns_descs(void *data) union { __u8 eui64[NVME_NIDT_EUI64_LEN]; __u8 nguid[NVME_NIDT_NGUID_LEN]; - uuid_t uuid; + __u8 uuid[NVME_UUID_LEN]; __u8 csi; } desc; @@ -4396,7 +4388,7 @@ static void json_nvme_id_ns_descs(void *data) case NVME_NIDT_UUID: memcpy(desc.uuid, data + off, sizeof(desc.uuid)); - uuid_unparse_lower(desc.uuid, json_str); + nvme_uuid_to_string(desc.uuid, json_str); len = sizeof(desc.uuid); nidt_name = "uuid"; break; @@ -4446,8 +4438,8 @@ void nvme_show_id_ns_descs(void *data, unsigned nsid, enum nvme_print_flags flag { int pos, len = 0; int i; - uuid_t uuid; - char uuid_str[37]; + __u8 uuid[NVME_UUID_LEN]; + char uuid_str[NVME_UUID_LEN_STRING]; __u8 eui64[8]; __u8 nguid[16]; __u8 csi; @@ -4483,7 +4475,7 @@ void nvme_show_id_ns_descs(void *data, unsigned nsid, enum nvme_print_flags flag break; case NVME_NIDT_UUID: memcpy(uuid, data + pos + sizeof(*cur), 16); - uuid_unparse_lower(uuid, uuid_str); + nvme_uuid_to_string(uuid, uuid_str); printf("uuid : %s\n", uuid_str); len = sizeof(uuid); break; @@ -4622,7 +4614,7 @@ void nvme_show_id_ctrl(struct nvme_id_ctrl *ctrl, enum nvme_print_flags flags, printf("cntrltype : %d\n", ctrl->cntrltype); if (human) nvme_show_id_ctrl_cntrltype(ctrl->cntrltype); - printf("fguid : %-.*s\n", (int)sizeof(ctrl->fguid), ctrl->fguid); + printf("fguid : %s\n", util_uuid_to_string(ctrl->fguid)); printf("crdt1 : %u\n", le16_to_cpu(ctrl->crdt1)); printf("crdt2 : %u\n", le16_to_cpu(ctrl->crdt2)); printf("crdt3 : %u\n", le16_to_cpu(ctrl->crdt3)); @@ -4668,10 +4660,12 @@ void nvme_show_id_ctrl(struct nvme_id_ctrl *ctrl, enum nvme_print_flags flags, printf("mtfa : %d\n", le16_to_cpu(ctrl->mtfa)); printf("hmpre : %d\n", le32_to_cpu(ctrl->hmpre)); printf("hmmin : %d\n", le32_to_cpu(ctrl->hmmin)); - printf("tnvmcap : %.0Lf\n", int128_to_double(ctrl->tnvmcap)); + printf("tnvmcap : %s\n", + uint128_t_to_string(le128_to_cpu(ctrl->tnvmcap))); if (human) nvme_show_id_ctrl_tnvmcap(ctrl->tnvmcap); - printf("unvmcap : %.0Lf\n", int128_to_double(ctrl->unvmcap)); + printf("unvmcap : %s\n", + uint128_t_to_string(le128_to_cpu(ctrl->unvmcap))); if (human) nvme_show_id_ctrl_unvmcap(ctrl->unvmcap); printf("rpmbs : %#x\n", le32_to_cpu(ctrl->rpmbs)); @@ -4705,7 +4699,8 @@ void nvme_show_id_ctrl(struct nvme_id_ctrl *ctrl, enum nvme_print_flags flags, printf("nanagrpid : %d\n", le32_to_cpu(ctrl->nanagrpid)); printf("pels : %d\n", le32_to_cpu(ctrl->pels)); printf("domainid : %d\n", le16_to_cpu(ctrl->domainid)); - printf("megcap : %.0Lf\n", int128_to_double(ctrl->megcap)); + printf("megcap : %s\n", + uint128_t_to_string(le128_to_cpu(ctrl->megcap))); printf("sqes : %#x\n", ctrl->sqes); if (human) nvme_show_id_ctrl_sqes(ctrl->sqes); @@ -4742,7 +4737,8 @@ void nvme_show_id_ctrl(struct nvme_id_ctrl *ctrl, enum nvme_print_flags flags, if (human) nvme_show_id_ctrl_sgls(ctrl->sgls); printf("mnan : %d\n", le32_to_cpu(ctrl->mnan)); - printf("maxdna : %.0Lf\n", int128_to_double(ctrl->maxdna)); + printf("maxdna : %s\n", + uint128_t_to_string(le128_to_cpu(ctrl->maxdna))); printf("maxcna : %d\n", le32_to_cpu(ctrl->maxcna)); printf("subnqn : %-.*s\n", (int)sizeof(ctrl->subnqn), ctrl->subnqn); printf("ioccsz : %d\n", le32_to_cpu(ctrl->ioccsz)); @@ -5366,10 +5362,10 @@ static void json_nvme_id_nvmset(struct nvme_id_nvmset_list *nvmset) le32_to_cpu(nvmset->ent[i].rr4kt)); json_object_add_value_int(entry, "optimal_write_size", le32_to_cpu(nvmset->ent[i].ows)); - json_object_add_value_double(entry, "total_nvmset_cap", - int128_to_double(nvmset->ent[i].tnvmsetcap)); - json_object_add_value_double(entry, "unalloc_nvmset_cap", - int128_to_double(nvmset->ent[i].unvmsetcap)); + json_object_add_value_uint128(entry, "total_nvmset_cap", + le128_to_cpu(nvmset->ent[i].tnvmsetcap)); + json_object_add_value_uint128(entry, "unalloc_nvmset_cap", + le128_to_cpu(nvmset->ent[i].unvmsetcap)); json_array_add_value_object(entries, entry); } @@ -5403,10 +5399,12 @@ void nvme_show_id_nvmset(struct nvme_id_nvmset_list *nvmset, unsigned nvmset_id, le32_to_cpu(nvmset->ent[i].rr4kt)); printf("optimal_write_size : %u\n", le32_to_cpu(nvmset->ent[i].ows)); - printf("total_nvmset_cap : %.0Lf\n", - int128_to_double(nvmset->ent[i].tnvmsetcap)); - printf("unalloc_nvmset_cap : %.0Lf\n", - int128_to_double(nvmset->ent[i].unvmsetcap)); + printf("total_nvmset_cap : %s\n", + uint128_t_to_string( + le128_to_cpu(nvmset->ent[i].tnvmsetcap))); + printf("unalloc_nvmset_cap : %s\n", + uint128_t_to_string( + le128_to_cpu(nvmset->ent[i].unvmsetcap))); printf(".................\n"); } } @@ -5630,7 +5628,7 @@ static void json_nvme_id_uuid_list(const struct nvme_id_uuid_list *uuid_list) entries = json_create_array(); /* The 0th entry is reserved */ for (i = 1; i < NVME_ID_UUID_LIST_MAX; i++) { - uuid_t uuid; + __u8 uuid[NVME_UUID_LEN]; struct json_object *entry = json_create_object(); /* The list is terminated by a zero UUID value */ @@ -5640,7 +5638,7 @@ static void json_nvme_id_uuid_list(const struct nvme_id_uuid_list *uuid_list) json_object_add_value_int(entry, "association", uuid_list->entry[i].header & 0x3); json_object_add_value_string(entry, "uuid", - nvme_uuid_to_string(uuid)); + util_uuid_to_string(uuid)); json_array_add_value_object(entries, entry); } json_object_add_value_array(root, "UUID-list", entries); @@ -5662,13 +5660,13 @@ void nvme_show_id_uuid_list(const struct nvme_id_uuid_list *uuid_list, /* The 0th entry is reserved */ printf("NVME Identify UUID:\n"); for (i = 0; i < NVME_ID_UUID_LIST_MAX; i++) { - uuid_t uuid; + __u8 uuid[NVME_UUID_LEN]; char *association = ""; uint8_t identifier_association = uuid_list->entry[i].header & 0x3; /* The list is terminated by a zero UUID value */ - if (memcmp(uuid_list->entry[i].uuid, zero_uuid, sizeof(zero_uuid)) == 0) + if (memcmp(uuid_list->entry[i].uuid, zero_uuid, NVME_UUID_LEN) == 0) break; - memcpy(&uuid, uuid_list->entry[i].uuid, sizeof(uuid)); + memcpy(&uuid, uuid_list->entry[i].uuid, NVME_UUID_LEN); if (human) { switch (identifier_association) { case 0x0: @@ -5688,7 +5686,7 @@ void nvme_show_id_uuid_list(const struct nvme_id_uuid_list *uuid_list, printf(" Entry[%3d]\n", i+1); printf(".................\n"); printf("association : 0x%x %s\n", identifier_association, association); - printf("UUID : %s", nvme_uuid_to_string(uuid)); + printf("UUID : %s", util_uuid_to_string(uuid)); if (memcmp(uuid_list->entry[i].uuid, invalid_uuid, sizeof(zero_uuid)) == 0) printf(" (Invalid UUID)"); @@ -5702,7 +5700,7 @@ static void json_id_domain_list(struct nvme_id_domain_list *id_dom) struct json_object *entries; struct json_object *entry; int i; - long double dom_cap, unalloc_dom_cap, max_egrp_dom_cap; + nvme_uint128_t dom_cap, unalloc_dom_cap, max_egrp_dom_cap; root = json_create_object(); entries = json_create_array(); @@ -5711,14 +5709,14 @@ static void json_id_domain_list(struct nvme_id_domain_list *id_dom) for (i = 0; i < id_dom->num; i++) { entry = json_create_object(); - dom_cap = int128_to_double(id_dom->domain_attr[i].dom_cap); - unalloc_dom_cap = int128_to_double(id_dom->domain_attr[i].unalloc_dom_cap); - max_egrp_dom_cap = int128_to_double(id_dom->domain_attr[i].max_egrp_dom_cap); + dom_cap = le128_to_cpu(id_dom->domain_attr[i].dom_cap); + unalloc_dom_cap = le128_to_cpu(id_dom->domain_attr[i].unalloc_dom_cap); + max_egrp_dom_cap = le128_to_cpu(id_dom->domain_attr[i].max_egrp_dom_cap); json_object_add_value_uint(entry, "dom_id", le16_to_cpu(id_dom->domain_attr[i].dom_id)); - json_object_add_value_double(entry, "dom_cap", dom_cap); - json_object_add_value_double(entry, "unalloc_dom_cap", unalloc_dom_cap); - json_object_add_value_double(entry, "max_egrp_dom_cap", max_egrp_dom_cap); + json_object_add_value_uint128(entry, "dom_cap", dom_cap); + json_object_add_value_uint128(entry, "unalloc_dom_cap", unalloc_dom_cap); + json_object_add_value_uint128(entry, "max_egrp_dom_cap", max_egrp_dom_cap); json_array_add_value_object(entries, entry); } @@ -5742,12 +5740,15 @@ void nvme_show_id_domain_list(struct nvme_id_domain_list *id_dom, for (i = 0; i < id_dom->num; i++) { printf("Domain Id for Attr Entry[%u]: %u\n", i, le16_to_cpu(id_dom->domain_attr[i].dom_id)); - printf("Domain Capacity for Attr Entry[%u]: %.0Lf\\n", i, - int128_to_double(id_dom->domain_attr[i].dom_cap)); - printf("Unallocated Domain Capacity for Attr Entry[%u]: %.0Lf\n", i, - int128_to_double(id_dom->domain_attr[i].unalloc_dom_cap)); - printf("Max Endurance Group Domain Capacity for Attr Entry[%u]: %.0Lf\n", i, - int128_to_double(id_dom->domain_attr[i].max_egrp_dom_cap)); + printf("Domain Capacity for Attr Entry[%u]: %s\n", i, + uint128_t_to_string( + le128_to_cpu(id_dom->domain_attr[i].dom_cap))); + printf("Unallocated Domain Capacity for Attr Entry[%u]: %s\n", i, + uint128_t_to_string( + le128_to_cpu(id_dom->domain_attr[i].unalloc_dom_cap))); + printf("Max Endurance Group Domain Capacity for Attr Entry[%u]: %s\n", i, + uint128_t_to_string( + le128_to_cpu(id_dom->domain_attr[i].max_egrp_dom_cap))); } } @@ -5938,7 +5939,7 @@ void nvme_show_fw_log(struct nvme_firmware_slot *fw_log, frs = (__le64 *)&fw_log->frs[i]; printf("frs%d : %#016"PRIx64" (%s)\n", i + 1, le64_to_cpu(*frs), - fw_to_string(fw_log->frs[i])); + util_fw_to_string(fw_log->frs[i])); } } } @@ -6175,18 +6176,6 @@ void nvme_show_supported_log(struct nvme_supported_log_pages *support_log, } } -uint64_t int48_to_long(__u8 *data) -{ - int i; - uint64_t result = 0; - - for (i = 0; i < 6; i++) { - result *= 256; - result += data[5 - i]; - } - return result; -} - void nvme_show_endurance_log(struct nvme_endurance_group_log *endurance_log, __u16 group_id, const char *devname, enum nvme_print_flags flags) @@ -6205,22 +6194,30 @@ void nvme_show_endurance_log(struct nvme_endurance_group_log *endurance_log, printf("avl_spare_threshold : %u\n", endurance_log->avl_spare_threshold); printf("percent_used : %u%%\n", endurance_log->percent_used); - printf("endurance_estimate : %'.0Lf\n", - int128_to_double(endurance_log->endurance_estimate)); - printf("data_units_read : %'.0Lf\n", - int128_to_double(endurance_log->data_units_read)); - printf("data_units_written : %'.0Lf\n", - int128_to_double(endurance_log->data_units_written)); - printf("media_units_written : %'.0Lf\n", - int128_to_double(endurance_log->media_units_written)); - printf("host_read_cmds : %'.0Lf\n", - int128_to_double(endurance_log->host_read_cmds)); - printf("host_write_cmds : %'.0Lf\n", - int128_to_double(endurance_log->host_write_cmds)); - printf("media_data_integrity_err: %'.0Lf\n", - int128_to_double(endurance_log->media_data_integrity_err)); - printf("num_err_info_log_entries: %'.0Lf\n", - int128_to_double(endurance_log->num_err_info_log_entries)); + printf("endurance_estimate : %s\n", + uint128_t_to_string( + le128_to_cpu(endurance_log->endurance_estimate))); + printf("data_units_read : %s\n", + uint128_t_to_string( + le128_to_cpu(endurance_log->data_units_read))); + printf("data_units_written : %s\n", + uint128_t_to_string( + le128_to_cpu(endurance_log->data_units_written))); + printf("media_units_written : %s\n", + uint128_t_to_string( + le128_to_cpu(endurance_log->media_units_written))); + printf("host_read_cmds : %s\n", + uint128_t_to_string( + le128_to_cpu(endurance_log->host_read_cmds))); + printf("host_write_cmds : %s\n", + uint128_t_to_string( + le128_to_cpu(endurance_log->host_write_cmds))); + printf("media_data_integrity_err: %s\n", + uint128_t_to_string( + le128_to_cpu(endurance_log->media_data_integrity_err))); + printf("num_err_info_log_entries: %s\n", + uint128_t_to_string( + le128_to_cpu(endurance_log->num_err_info_log_entries))); } void nvme_show_smart_log(struct nvme_smart_log *smart, unsigned int nsid, @@ -6258,26 +6255,26 @@ void nvme_show_smart_log(struct nvme_smart_log *smart, unsigned int nsid, smart->percent_used); printf("endurance group critical warning summary: %#x\n", smart->endu_grp_crit_warn_sumry); - printf("data_units_read : %'.0Lf\n", - int128_to_double(smart->data_units_read)); - printf("data_units_written : %'.0Lf\n", - int128_to_double(smart->data_units_written)); - printf("host_read_commands : %'.0Lf\n", - int128_to_double(smart->host_reads)); - printf("host_write_commands : %'.0Lf\n", - int128_to_double(smart->host_writes)); - printf("controller_busy_time : %'.0Lf\n", - int128_to_double(smart->ctrl_busy_time)); - printf("power_cycles : %'.0Lf\n", - int128_to_double(smart->power_cycles)); - printf("power_on_hours : %'.0Lf\n", - int128_to_double(smart->power_on_hours)); - printf("unsafe_shutdowns : %'.0Lf\n", - int128_to_double(smart->unsafe_shutdowns)); - printf("media_errors : %'.0Lf\n", - int128_to_double(smart->media_errors)); - printf("num_err_log_entries : %'.0Lf\n", - int128_to_double(smart->num_err_log_entries)); + printf("data_units_read : %s\n", + uint128_t_to_string(le128_to_cpu(smart->data_units_read))); + printf("data_units_written : %s\n", + uint128_t_to_string(le128_to_cpu(smart->data_units_written))); + printf("host_read_commands : %s\n", + uint128_t_to_string(le128_to_cpu(smart->host_reads))); + printf("host_write_commands : %s\n", + uint128_t_to_string(le128_to_cpu(smart->host_writes))); + printf("controller_busy_time : %s\n", + uint128_t_to_string(le128_to_cpu(smart->ctrl_busy_time))); + printf("power_cycles : %s\n", + uint128_t_to_string(le128_to_cpu(smart->power_cycles))); + printf("power_on_hours : %s\n", + uint128_t_to_string(le128_to_cpu(smart->power_on_hours))); + printf("unsafe_shutdowns : %s\n", + uint128_t_to_string(le128_to_cpu(smart->unsafe_shutdowns))); + printf("media_errors : %s\n", + uint128_t_to_string(le128_to_cpu(smart->media_errors))); + printf("num_err_log_entries : %s\n", + uint128_t_to_string(le128_to_cpu(smart->num_err_log_entries))); printf("Warning Temperature Time : %u\n", le32_to_cpu(smart->warning_temp_time)); printf("Critical Composite Temperature Time : %u\n", @@ -6500,7 +6497,7 @@ void nvme_show_sanitize_log(struct nvme_sanitize_log_page *sanitize, printf("\n"); printf("Sanitize Status (SSTAT) : %#x\n", - le16_to_cpu(sanitize->sstat)); + le16_to_cpu(sanitize->sstat) & NVME_SANITIZE_SSTAT_STATUS_MASK); if (human) nvme_show_sanitize_log_sstat(le16_to_cpu(sanitize->sstat)); @@ -7385,9 +7382,12 @@ static void json_detail_list(nvme_root_t r) nvme_for_each_host(r, h) { struct json_object *hss = json_create_object(); struct json_object *jsslist = json_create_array(); + const char *hostid; json_object_add_value_string(hss, "HostNQN", nvme_host_get_hostnqn(h)); - json_object_add_value_string(hss, "HostID", nvme_host_get_hostid(h)); + hostid = nvme_host_get_hostid(h); + if (hostid) + json_object_add_value_string(hss, "HostID", hostid); nvme_for_each_subsystem(h , s) { struct json_object *jss = json_create_object(); @@ -7540,3 +7540,247 @@ void nvme_show_list_items(nvme_root_t r, enum nvme_print_flags flags) else nvme_show_simple_list(r); } + +static unsigned int json_subsystem_topology_multipath(nvme_subsystem_t s, + json_object *namespaces) +{ + nvme_ns_t n; + nvme_path_t p; + unsigned int i = 0; + + nvme_subsystem_for_each_ns(s, n) { + struct json_object *ns_attrs; + struct json_object *paths; + + ns_attrs = json_create_object(); + json_object_add_value_int(ns_attrs, "NSID", + nvme_ns_get_nsid(n)); + + paths = json_create_array(); + nvme_namespace_for_each_path(n, p) { + struct json_object *path_attrs; + + nvme_ctrl_t c = nvme_path_get_ctrl(p); + + path_attrs = json_create_object(); + json_object_add_value_string(path_attrs, "Name", + nvme_ctrl_get_name(c)); + json_object_add_value_string(path_attrs, "Transport", + nvme_ctrl_get_transport(c)); + json_object_add_value_string(path_attrs, "Address", + nvme_ctrl_get_address(c)); + json_object_add_value_string(path_attrs, "State", + nvme_ctrl_get_state(c)); + json_object_add_value_string(path_attrs, "ANAState", + nvme_path_get_ana_state(p)); + json_array_add_value_object(paths, path_attrs); + } + json_object_add_value_array(ns_attrs, "Paths", paths); + json_array_add_value_object(namespaces, ns_attrs); + i++; + } + + return i; +} + +static void json_print_nvme_subsystem_topology(nvme_subsystem_t s, + json_object *namespaces) +{ + nvme_ctrl_t c; + nvme_ns_t n; + + nvme_subsystem_for_each_ctrl(s, c) { + nvme_ctrl_for_each_ns(c, n) { + struct json_object *ctrl_attrs; + struct json_object *ns_attrs; + struct json_object *ctrl; + + ns_attrs = json_create_object(); + json_object_add_value_int(ns_attrs, "NSID", + nvme_ns_get_nsid(n)); + + ctrl = json_create_array(); + ctrl_attrs = json_create_object(); + json_object_add_value_string(ctrl_attrs, "Name", + nvme_ctrl_get_name(c)); + json_object_add_value_string(ctrl_attrs, "Transport", + nvme_ctrl_get_transport(c)); + json_object_add_value_string(ctrl_attrs, "Address", + nvme_ctrl_get_address(c)); + json_object_add_value_string(ctrl_attrs, "State", + nvme_ctrl_get_state(c)); + + json_array_add_value_object(ctrl, ctrl_attrs); + json_object_add_value_array(ns_attrs, "Controller", ctrl); + json_array_add_value_object(namespaces, ns_attrs); + } + } +} + +static void json_simple_topology(nvme_root_t r) +{ + struct json_object *host_attrs, *subsystem_attrs; + struct json_object *subsystems, *namespaces; + struct json_object *root; + nvme_host_t h; + + root = json_create_array(); + + nvme_for_each_host(r, h) { + nvme_subsystem_t s; + const char *hostid; + + host_attrs = json_create_object(); + json_object_add_value_string(host_attrs, "HostNQN", + nvme_host_get_hostnqn(h)); + hostid = nvme_host_get_hostid(h); + if (hostid) + json_object_add_value_string(host_attrs, "HostID", hostid); + subsystems = json_create_array(); + nvme_for_each_subsystem(h, s) { + subsystem_attrs = json_create_object(); + json_object_add_value_string(subsystem_attrs, "Name", + nvme_subsystem_get_name(s)); + json_object_add_value_string(subsystem_attrs, "NQN", + nvme_subsystem_get_nqn(s)); + + json_array_add_value_object(subsystems, subsystem_attrs); + namespaces = json_create_array(); + + if (!json_subsystem_topology_multipath(s, namespaces)) + json_print_nvme_subsystem_topology(s, namespaces); + + json_object_add_value_array(subsystem_attrs, "Namespaces", + namespaces); + } + json_object_add_value_array(host_attrs, "Subsystems", subsystems); + json_array_add_value_object(root, host_attrs); + } + json_print_object(root, NULL); + printf("\n"); + json_free_object(root); +} + +static bool nvme_is_multipath(nvme_subsystem_t s) +{ + nvme_ns_t n; + nvme_path_t p; + + nvme_subsystem_for_each_ns(s, n) + nvme_namespace_for_each_path(n, p) + return true; + + return false; +} + +static void nvme_show_subsystem_topology_multipath(nvme_subsystem_t s, + enum nvme_cli_topo_ranking ranking) +{ + nvme_ns_t n; + nvme_path_t p; + nvme_ctrl_t c; + + if (ranking == NVME_CLI_TOPO_NAMESPACE) { + nvme_subsystem_for_each_ns(s, n) { + printf(" +- ns %d\n", nvme_ns_get_nsid(n)); + printf(" \\\n"); + + nvme_namespace_for_each_path(n, p) { + c = nvme_path_get_ctrl(p); + + printf(" +- %s %s %s %s %s\n", + nvme_ctrl_get_name(c), + nvme_ctrl_get_transport(c), + nvme_ctrl_get_address(c), + nvme_ctrl_get_state(c), + nvme_path_get_ana_state(p)); + } + } + } else { + /* NVME_CLI_TOPO_CTRL */ + nvme_subsystem_for_each_ctrl(s, c) { + printf(" +- %s %s %s\n", + nvme_ctrl_get_name(c), + nvme_ctrl_get_transport(c), + nvme_ctrl_get_address(c)); + printf(" \\\n"); + + nvme_subsystem_for_each_ns(s, n) { + nvme_namespace_for_each_path(n, p) { + if (nvme_path_get_ctrl(p) != c) + continue; + + printf(" +- ns %d %s %s\n", + nvme_ns_get_nsid(n), + nvme_ctrl_get_state(c), + nvme_path_get_ana_state(p)); + } + } + } + } +} + +static void nvme_show_subsystem_topology(nvme_subsystem_t s, + enum nvme_cli_topo_ranking ranking) +{ + nvme_ctrl_t c; + nvme_ns_t n; + + if (ranking == NVME_CLI_TOPO_NAMESPACE) { + nvme_subsystem_for_each_ctrl(s, c) { + nvme_ctrl_for_each_ns(c, n) { + printf(" +- ns %d\n", nvme_ns_get_nsid(n)); + printf(" \\\n"); + printf(" +- %s %s %s %s\n", + nvme_ctrl_get_name(c), + nvme_ctrl_get_transport(c), + nvme_ctrl_get_address(c), + nvme_ctrl_get_state(c)); + } + } + } else { + /* NVME_CLI_TOPO_CTRL */ + nvme_subsystem_for_each_ctrl(s, c) { + printf(" +- %s %s %s\n", + nvme_ctrl_get_name(c), + nvme_ctrl_get_transport(c), + nvme_ctrl_get_address(c)); + printf(" \\\n"); + nvme_ctrl_for_each_ns(c, n) { + printf(" +- ns %d %s\n", + nvme_ns_get_nsid(n), + nvme_ctrl_get_state(c)); + } + } + } +} + +static void nvme_show_simple_topology(nvme_root_t r, + enum nvme_cli_topo_ranking ranking) +{ + nvme_host_t h; + nvme_subsystem_t s; + + nvme_for_each_host(r, h) { + nvme_for_each_subsystem(h, s) { + + printf("%s - NQN=%s\n", nvme_subsystem_get_name(s), + nvme_subsystem_get_nqn(s)); + printf("\\\n"); + + if (nvme_is_multipath(s)) + nvme_show_subsystem_topology_multipath(s, ranking); + else + nvme_show_subsystem_topology(s, ranking); + } + } +} + +void nvme_show_topology(nvme_root_t r, enum nvme_print_flags flags, + enum nvme_cli_topo_ranking ranking) +{ + if (flags & JSON) + json_simple_topology(r); + else + nvme_show_simple_topology(r, ranking); +} diff --git a/nvme-print.h b/nvme-print.h index a318862..f30f63e 100644 --- a/nvme-print.h +++ b/nvme-print.h @@ -15,9 +15,8 @@ typedef struct nvme_effects_log_node { void d(unsigned char *buf, int len, int width, int group); void d_raw(unsigned char *buf, unsigned len); -uint64_t int48_to_long(__u8 *data); -void nvme_show_status(__u16 status); +void nvme_show_status(int status); void nvme_show_lba_status_info(__u32 result); void nvme_show_relatives(const char *name); @@ -108,6 +107,8 @@ void nvme_show_endurance_group_list(struct nvme_id_endurance_group_list *endgrp_ enum nvme_print_flags flags); void nvme_show_list_ns(struct nvme_ns_list *ns_list, enum nvme_print_flags flags); +void nvme_show_topology(nvme_root_t t, enum nvme_print_flags flags, + enum nvme_cli_topo_ranking ranking); void nvme_feature_show_fields(enum nvme_features_id fid, unsigned int result, unsigned char *buf); void nvme_directive_show(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __u32 result, diff --git a/nvme-rpmb.c b/nvme-rpmb.c index 8f6e6a0..40ddb5b 100644 --- a/nvme-rpmb.c +++ b/nvme-rpmb.c @@ -872,8 +872,9 @@ int rpmb_cmd_option(int argc, char **argv, struct command *cmd, struct plugin *p unsigned char *msg_buf = NULL; unsigned int msg_size = 0; unsigned int key_size = 0; - int fd = -1, err = -1; struct nvme_id_ctrl ctrl; + struct nvme_dev *dev; + int err = -1; union ctrl_rpmbs_reg { struct { @@ -886,11 +887,11 @@ int rpmb_cmd_option(int argc, char **argv, struct command *cmd, struct plugin *p unsigned int rpmbs; } regs; - if ((fd = parse_and_open(argc, argv, desc, opts)) < 0) - return fd; + if ((err = parse_and_open(&dev, argc, argv, desc, opts))) + return err; /* before parsing commands, check if controller supports any RPMB targets */ - err = nvme_identify_ctrl(fd, &ctrl); + err = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (err) goto out; @@ -959,13 +960,15 @@ int rpmb_cmd_option(int argc, char **argv, struct command *cmd, struct plugin *p switch (cfg.opt) { case RPMB_REQ_READ_WRITE_CNTR: - err = rpmb_read_write_counter(fd, cfg.target, &write_cntr); + err = rpmb_read_write_counter(dev_fd(dev), cfg.target, + &write_cntr); if (err == 0) printf("Write Counter is: %u\n", write_cntr); break; case RPMB_REQ_AUTH_DCB_READ: - write_cntr = rpmb_read_config_block(fd, &msg_buf); + write_cntr = rpmb_read_config_block(dev_fd(dev), + &msg_buf); if (msg_buf == NULL) { fprintf(stderr, "failed read config blk\n"); goto out; @@ -997,8 +1000,9 @@ int rpmb_cmd_option(int argc, char **argv, struct command *cmd, struct plugin *p msg_size); break; } - err = rpmb_auth_data_read(fd, cfg.target, cfg.address, - &msg_buf, cfg.blocks, + err = rpmb_auth_data_read(dev_fd(dev), cfg.target, + cfg.address, &msg_buf, + cfg.blocks, (regs.access_size + 1)); if (err > 0 && msg_buf != NULL) { printf("Writting %d bytes to file %s\n", @@ -1017,7 +1021,8 @@ int rpmb_cmd_option(int argc, char **argv, struct command *cmd, struct plugin *p } else if ((cfg.blocks * 512) < msg_size) { msg_size = cfg.blocks * 512; } - err = rpmb_auth_data_write(fd, cfg.target, cfg.address, + err = rpmb_auth_data_write(dev_fd(dev), cfg.target, + cfg.address, ((regs.access_size + 1) * 512), msg_buf, msg_size, key_buf, key_size); @@ -1028,11 +1033,13 @@ int rpmb_cmd_option(int argc, char **argv, struct command *cmd, struct plugin *p break; case RPMB_REQ_AUTH_DCB_WRITE: - err = rpmb_write_config_block(fd, msg_buf, key_buf, key_size); + err = rpmb_write_config_block(dev_fd(dev), msg_buf, + key_buf, key_size); break; case RPMB_REQ_AUTH_KEY_PROGRAM: - err = rpmb_program_auth_key(fd, cfg.target, key_buf, key_size); + err = rpmb_program_auth_key(dev_fd(dev), cfg.target, + key_buf, key_size); break; default: break; @@ -1043,8 +1050,8 @@ out: free(key_buf); free(msg_buf); - /* close file descriptor */ - close(fd); + /* close device */ + dev_close(dev); return err; } diff --git a/nvme-wrap.c b/nvme-wrap.c new file mode 100644 index 0000000..c31ec11 --- /dev/null +++ b/nvme-wrap.c @@ -0,0 +1,362 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Definitions for the NVM Express interface: libnvme/libnvme-mi device + * wrappers. + */ + +#include + +#include +#include + +#include "nvme.h" +#include "nvme-wrap.h" + +/* + * Helper for libnvme functions that pass the fd/ep separately. These just + * pass the correct handle to the direct/MI function. + * @op: the name of the libnvme function, without the nvme_/nvme_mi prefix + * @d: device handle: struct nvme_dev + */ +#define do_admin_op(op, d, ...) ({ \ + int __rc; \ + if (d->type == NVME_DEV_DIRECT) \ + __rc = nvme_ ## op(d->direct.fd, __VA_ARGS__); \ + else if (d->type == NVME_DEV_MI) \ + __rc = nvme_mi_admin_ ## op (d->mi.ctrl, __VA_ARGS__); \ + else \ + __rc = -ENODEV; \ + __rc; }) + +/* + * Helper for libnvme functions use the 'struct _args' pattern. These need + * the fd and timeout set for the direct interface, and pass the ep as + * an argument for the MI interface + * @op: the name of the libnvme function, without the nvme_/nvme_mi prefix + * @d: device handle: struct nvme_dev + * @args: op-specific args struct + */ +#define do_admin_args_op(op, d, args) ({ \ + int __rc; \ + if (d->type == NVME_DEV_DIRECT) { \ + args->fd = d->direct.fd; \ + args->timeout = NVME_DEFAULT_IOCTL_TIMEOUT; \ + __rc = nvme_ ## op(args); \ + } else if (d->type == NVME_DEV_MI) \ + __rc = nvme_mi_admin_ ## op (d->mi.ctrl, args); \ + else \ + __rc = -ENODEV; \ + __rc; }) + +int nvme_cli_identify(struct nvme_dev *dev, struct nvme_identify_args *args) +{ + return do_admin_args_op(identify, dev, args); +} + +int nvme_cli_identify_ctrl(struct nvme_dev *dev, struct nvme_id_ctrl *ctrl) +{ + return do_admin_op(identify_ctrl, dev, ctrl); +} + +int nvme_cli_identify_ctrl_list(struct nvme_dev *dev, __u16 ctrl_id, + struct nvme_ctrl_list *list) +{ + return do_admin_op(identify_ctrl_list, dev, ctrl_id, list); +} + +int nvme_cli_identify_nsid_ctrl_list(struct nvme_dev *dev, __u32 nsid, + __u16 ctrl_id, + struct nvme_ctrl_list *list) +{ + return do_admin_op(identify_nsid_ctrl_list, dev, nsid, ctrl_id, list); +} + +int nvme_cli_identify_ns(struct nvme_dev *dev, __u32 nsid, + struct nvme_id_ns *ns) +{ + return do_admin_op(identify_ns, dev, nsid, ns); +} + +int nvme_cli_identify_allocated_ns(struct nvme_dev *dev, __u32 nsid, + struct nvme_id_ns *ns) +{ + return do_admin_op(identify_allocated_ns, dev, nsid, ns); +} + +int nvme_cli_identify_active_ns_list(struct nvme_dev *dev, __u32 nsid, + struct nvme_ns_list *list) +{ + return do_admin_op(identify_active_ns_list, dev, nsid, list); +} + +int nvme_cli_identify_allocated_ns_list(struct nvme_dev *dev, __u32 nsid, + struct nvme_ns_list *list) +{ + return do_admin_op(identify_allocated_ns_list, dev, nsid, list); +} + +int nvme_cli_get_features(struct nvme_dev *dev, + struct nvme_get_features_args *args) +{ + return do_admin_args_op(get_features, dev, args); +} + +int nvme_cli_ns_mgmt_delete(struct nvme_dev *dev, __u32 nsid) +{ + return do_admin_op(ns_mgmt_delete, dev, nsid); +} + +int nvme_cli_ns_attach(struct nvme_dev *dev, struct nvme_ns_attach_args *args) +{ + return do_admin_args_op(ns_attach, dev, args); +} + +int nvme_cli_ns_attach_ctrls(struct nvme_dev *dev, __u32 nsid, + struct nvme_ctrl_list *ctrlist) +{ + return do_admin_op(ns_attach_ctrls, dev, nsid, ctrlist); +} + +int nvme_cli_ns_detach_ctrls(struct nvme_dev *dev, __u32 nsid, + struct nvme_ctrl_list *ctrlist) +{ + return do_admin_op(ns_detach_ctrls, dev, nsid, ctrlist); +} + +int nvme_cli_format_nvm(struct nvme_dev *dev, struct nvme_format_nvm_args *args) +{ + return do_admin_args_op(format_nvm, dev, args); +} + +int nvme_cli_sanitize_nvm(struct nvme_dev *dev, struct nvme_sanitize_nvm_args *args) +{ + return do_admin_args_op(sanitize_nvm, dev, args); +} + +int nvme_cli_get_log(struct nvme_dev *dev, struct nvme_get_log_args *args) +{ + return do_admin_args_op(get_log, dev, args); +} + +int nvme_cli_get_nsid_log(struct nvme_dev *dev, bool rae, + enum nvme_cmd_get_log_lid lid, + __u32 nsid, __u32 len, void *log) +{ + return do_admin_op(get_nsid_log, dev, rae, lid, nsid, len, log); +} + +int nvme_cli_get_log_simple(struct nvme_dev *dev, + enum nvme_cmd_get_log_lid lid, + __u32 len, void *log) +{ + return do_admin_op(get_log_simple, dev, lid, len, log); +} + +int nvme_cli_get_log_supported_log_pages(struct nvme_dev *dev, bool rae, + struct nvme_supported_log_pages *log) +{ + return do_admin_op(get_log_supported_log_pages, dev, rae, log); +} + +int nvme_cli_get_log_error(struct nvme_dev *dev, unsigned int nr_entries, + bool rae, struct nvme_error_log_page *err_log) +{ + return do_admin_op(get_log_error, dev, nr_entries, rae, err_log); +} + +int nvme_cli_get_log_smart(struct nvme_dev *dev, __u32 nsid, bool rae, + struct nvme_smart_log *smart_log) +{ + return do_admin_op(get_log_smart, dev, nsid, rae, smart_log); +} + +int nvme_cli_get_log_fw_slot(struct nvme_dev *dev, bool rae, + struct nvme_firmware_slot *fw_log) +{ + return do_admin_op(get_log_fw_slot, dev, rae, fw_log); +} + +int nvme_cli_get_log_changed_ns_list(struct nvme_dev *dev, bool rae, + struct nvme_ns_list *ns_log) +{ + return do_admin_op(get_log_changed_ns_list, dev, rae, ns_log); +} + +int nvme_cli_get_log_cmd_effects(struct nvme_dev *dev, enum nvme_csi csi, + struct nvme_cmd_effects_log *effects_log) +{ + return do_admin_op(get_log_cmd_effects, dev, csi, effects_log); +} + +int nvme_cli_get_log_device_self_test(struct nvme_dev *dev, + struct nvme_self_test_log *log) +{ + return do_admin_op(get_log_device_self_test, dev, log); +} + +int nvme_cli_get_log_create_telemetry_host(struct nvme_dev *dev, + struct nvme_telemetry_log *log) +{ + return do_admin_op(get_log_create_telemetry_host, dev, log); +} + +int nvme_cli_get_log_telemetry_host(struct nvme_dev *dev, __u64 offset, + __u32 len, void *log) +{ + return do_admin_op(get_log_telemetry_host, dev, offset, len, log); +} + +int nvme_cli_get_log_telemetry_ctrl(struct nvme_dev *dev, bool rae, + __u64 offset, __u32 len, void *log) +{ + return do_admin_op(get_log_telemetry_ctrl, dev, rae, offset, len, log); +} + +int nvme_cli_get_log_endurance_group(struct nvme_dev *dev, __u16 endgid, + struct nvme_endurance_group_log *log) +{ + return do_admin_op(get_log_endurance_group, dev, endgid, log); +} + +int nvme_cli_get_log_predictable_lat_nvmset(struct nvme_dev *dev, + __u16 nvmsetid, + struct nvme_nvmset_predictable_lat_log *log) +{ + return do_admin_op(get_log_predictable_lat_nvmset, dev, nvmsetid, log); +} + +int nvme_cli_get_log_predictable_lat_event(struct nvme_dev *dev, bool rae, + __u32 offset, __u32 len, void *log) +{ + return do_admin_op(get_log_predictable_lat_event, dev, rae, offset, + len, log); +} + +int nvme_cli_get_log_ana(struct nvme_dev *dev, + enum nvme_log_ana_lsp lsp, bool rae, + __u64 offset, __u32 len, void *log) +{ + return do_admin_op(get_log_ana, dev, lsp, rae, offset, len, log); +} + +int nvme_cli_get_log_ana_groups(struct nvme_dev *dev, bool rae, __u32 len, + struct nvme_ana_group_desc *log) +{ + return do_admin_op(get_log_ana_groups, dev, rae, len, log); +} + +int nvme_cli_get_log_lba_status(struct nvme_dev *dev, bool rae, + __u64 offset, __u32 len, void *log) +{ + return do_admin_op(get_log_lba_status, dev, rae, offset, len, log); +} + +int nvme_cli_get_log_endurance_grp_evt(struct nvme_dev *dev, bool rae, + __u32 offset, __u32 len, void *log) +{ + return do_admin_op(get_log_endurance_grp_evt, dev, rae, offset, len, + log); +} + +int nvme_cli_get_log_fid_supported_effects(struct nvme_dev *dev, bool rae, + struct nvme_fid_supported_effects_log *log) +{ + return do_admin_op(get_log_fid_supported_effects, dev, rae, log); +} + +int nvme_cli_get_log_mi_cmd_supported_effects(struct nvme_dev *dev, bool rae, + struct nvme_mi_cmd_supported_effects_log *log) +{ + return do_admin_op(get_log_mi_cmd_supported_effects, dev, rae, log); +} + +int nvme_cli_get_log_boot_partition(struct nvme_dev *dev, bool rae, __u8 lsp, + __u32 len, + struct nvme_boot_partition *part) +{ + return do_admin_op(get_log_boot_partition, dev, rae, lsp, len, part); +} + +int nvme_cli_get_log_discovery(struct nvme_dev *dev, bool rae, + __u32 offset, __u32 len, void *log) +{ + return do_admin_op(get_log_discovery, dev, rae, offset, len, log); +} + +int nvme_cli_get_log_media_unit_stat(struct nvme_dev *dev, __u16 domid, + struct nvme_media_unit_stat_log *mus) +{ + return do_admin_op(get_log_media_unit_stat, dev, domid, mus); +} + +int nvme_cli_get_log_support_cap_config_list(struct nvme_dev *dev, + __u16 domid, + struct nvme_supported_cap_config_list_log *cap) +{ + return do_admin_op(get_log_support_cap_config_list, dev, domid, cap); +} + +int nvme_cli_get_log_reservation(struct nvme_dev *dev, bool rae, + struct nvme_resv_notification_log *log) +{ + return do_admin_op(get_log_reservation, dev, rae, log); +} + +int nvme_cli_get_log_sanitize(struct nvme_dev *dev, bool rae, + struct nvme_sanitize_log_page *log) +{ + return do_admin_op(get_log_sanitize, dev, rae, log); +} + +int nvme_cli_get_log_zns_changed_zones(struct nvme_dev *dev, __u32 nsid, + bool rae, + struct nvme_zns_changed_zone_log *log) +{ + return do_admin_op(get_log_zns_changed_zones, dev, nsid, rae, log); +} + +int nvme_cli_get_log_persistent_event(struct nvme_dev *dev, + enum nvme_pevent_log_action action, + __u32 size, void *pevent_log) +{ + return do_admin_op(get_log_persistent_event, dev, action, size, + pevent_log); +} + +int nvme_cli_fw_download(struct nvme_dev *dev, + struct nvme_fw_download_args *args) +{ + return do_admin_args_op(fw_download, dev, args); +} + +int nvme_cli_fw_commit(struct nvme_dev *dev, + struct nvme_fw_commit_args *args) +{ + return do_admin_args_op(fw_commit, dev, args); +} + +/* The MI & direct interfaces don't have an exactly-matching API for + * ns_mgmt_create, as we don't support a timeout for MI. + */ +int nvme_cli_ns_mgmt_create(struct nvme_dev *dev, struct nvme_id_ns *ns, + __u32 *nsid, __u32 timeout, __u8 csi) +{ + if (dev->type == NVME_DEV_DIRECT) + return nvme_ns_mgmt_create(dev_fd(dev), ns, nsid, timeout, csi); + if (dev->type == NVME_DEV_MI) + return nvme_mi_admin_ns_mgmt_create(dev->mi.ctrl, ns, + csi, nsid); + + return -ENODEV; +} + +int nvme_cli_get_feature_length2(int fid, __u32 cdw11, enum nvme_data_tfr dir, + __u32 *len) +{ + int err; + + err = nvme_get_feature_length2(fid, cdw11, dir, len); + if (err != -EEXIST) + return err; + return nvme_get_feature_length(fid, cdw11, len); +} diff --git a/nvme-wrap.h b/nvme-wrap.h new file mode 100644 index 0000000..fe89391 --- /dev/null +++ b/nvme-wrap.h @@ -0,0 +1,125 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Definitions for the NVM Express interface: libnvme/libnvme-mi device + * wrappers. + */ + +#ifndef _NVME_WRAP_H +#define _NVME_WRAP_H + +#include "nvme.h" + +int nvme_cli_identify(struct nvme_dev *dev, struct nvme_identify_args *args); +int nvme_cli_identify_ctrl(struct nvme_dev *dev, struct nvme_id_ctrl *ctrl); +int nvme_cli_identify_ctrl_list(struct nvme_dev *dev, __u16 ctrl_id, + struct nvme_ctrl_list *list); +int nvme_cli_identify_nsid_ctrl_list(struct nvme_dev *dev, __u32 nsid, + __u16 ctrl_id, + struct nvme_ctrl_list *list); +int nvme_cli_identify_ns(struct nvme_dev *dev, __u32 nsid, + struct nvme_id_ns *ns); +int nvme_cli_identify_allocated_ns(struct nvme_dev *dev, __u32 nsid, + struct nvme_id_ns *ns); +int nvme_cli_identify_active_ns_list(struct nvme_dev *dev, __u32 nsid, + struct nvme_ns_list *list); +int nvme_cli_identify_allocated_ns_list(struct nvme_dev *dev, __u32 nsid, + struct nvme_ns_list *list); + +int nvme_cli_ns_mgmt_delete(struct nvme_dev *dev, __u32 nsid); +int nvme_cli_ns_mgmt_create(struct nvme_dev *dev, struct nvme_id_ns *ns, + __u32 *nsid, __u32 timeout, __u8 csi); + +int nvme_cli_ns_attach(struct nvme_dev *dev, struct nvme_ns_attach_args *args); + +int nvme_cli_ns_attach_ctrls(struct nvme_dev *dev, __u32 nsid, + struct nvme_ctrl_list *ctrlist); +int nvme_cli_ns_detach_ctrls(struct nvme_dev *dev, __u32 nsid, + struct nvme_ctrl_list *ctrlist); + +int nvme_cli_format_nvm(struct nvme_dev *dev, struct nvme_format_nvm_args *args); +int nvme_cli_sanitize_nvm(struct nvme_dev *dev, + struct nvme_sanitize_nvm_args *args); + +int nvme_cli_get_features(struct nvme_dev *dev, + struct nvme_get_features_args *args); + + +int nvme_cli_get_log(struct nvme_dev *dev, struct nvme_get_log_args *args); + +int nvme_cli_get_nsid_log(struct nvme_dev *dev, bool rae, + enum nvme_cmd_get_log_lid lid, + __u32 nsid, __u32 len, void *log); +int nvme_cli_get_log_simple(struct nvme_dev *dev, + enum nvme_cmd_get_log_lid lid, + __u32 len, void *log); +int nvme_cli_get_log_supported_log_pages(struct nvme_dev *dev, bool rae, + struct nvme_supported_log_pages *log); +int nvme_cli_get_log_error(struct nvme_dev *dev, unsigned int nr_entries, + bool rae, struct nvme_error_log_page *err_log); +int nvme_cli_get_log_smart(struct nvme_dev *dev, __u32 nsid, bool rae, + struct nvme_smart_log *smart_log); +int nvme_cli_get_log_fw_slot(struct nvme_dev *dev, bool rae, + struct nvme_firmware_slot *fw_log); +int nvme_cli_get_log_changed_ns_list(struct nvme_dev *dev, bool rae, + struct nvme_ns_list *ns_log); +int nvme_cli_get_log_cmd_effects(struct nvme_dev *dev, enum nvme_csi csi, + struct nvme_cmd_effects_log *effects_log); +int nvme_cli_get_log_device_self_test(struct nvme_dev *dev, + struct nvme_self_test_log *log); +int nvme_cli_get_log_create_telemetry_host(struct nvme_dev *dev, + struct nvme_telemetry_log *log); +int nvme_cli_get_log_telemetry_host(struct nvme_dev *dev, __u64 offset, + __u32 len, void *log); +int nvme_cli_get_log_telemetry_ctrl(struct nvme_dev *dev, bool rae, + __u64 offset, __u32 len, void *log); +int nvme_cli_get_log_endurance_group(struct nvme_dev *dev, __u16 endgid, + struct nvme_endurance_group_log *log); +int nvme_cli_get_log_predictable_lat_nvmset(struct nvme_dev *dev, + __u16 nvmsetid, + struct nvme_nvmset_predictable_lat_log *log); +int nvme_cli_get_log_predictable_lat_event(struct nvme_dev *dev, bool rae, + __u32 offset, __u32 len, void *log); +int nvme_cli_get_log_ana(struct nvme_dev *dev, + enum nvme_log_ana_lsp lsp, bool rae, + __u64 offset, __u32 len, void *log); +int nvme_cli_get_log_ana_groups(struct nvme_dev *dev, bool rae, __u32 len, + struct nvme_ana_group_desc *log); +int nvme_cli_get_log_lba_status(struct nvme_dev *dev, bool rae, + __u64 offset, __u32 len, void *log); +int nvme_cli_get_log_endurance_grp_evt(struct nvme_dev *dev, bool rae, + __u32 offset, __u32 len, void *log); +int nvme_cli_get_log_fid_supported_effects(struct nvme_dev *dev, bool rae, + struct nvme_fid_supported_effects_log *log); +int nvme_cli_get_log_mi_cmd_supported_effects(struct nvme_dev *dev, bool rae, + struct nvme_mi_cmd_supported_effects_log *log); +int nvme_cli_get_log_boot_partition(struct nvme_dev *dev, bool rae, __u8 lsp, + __u32 len, + struct nvme_boot_partition *part); +int nvme_cli_get_log_discovery(struct nvme_dev *dev, bool rae, + __u32 offset, __u32 len, void *log); +int nvme_cli_get_log_media_unit_stat(struct nvme_dev *dev, __u16 domid, + struct nvme_media_unit_stat_log *mus); +int nvme_cli_get_log_support_cap_config_list(struct nvme_dev *dev, + __u16 domid, + struct nvme_supported_cap_config_list_log *cap); +int nvme_cli_get_log_reservation(struct nvme_dev *dev, bool rae, + struct nvme_resv_notification_log *log); +int nvme_cli_get_log_sanitize(struct nvme_dev *dev, bool rae, + struct nvme_sanitize_log_page *log); +int nvme_cli_get_log_zns_changed_zones(struct nvme_dev *dev, __u32 nsid, + bool rae, + struct nvme_zns_changed_zone_log *log); +int nvme_cli_get_log_persistent_event(struct nvme_dev *dev, + enum nvme_pevent_log_action action, + __u32 size, void *pevent_log); + +int nvme_cli_fw_download(struct nvme_dev *dev, + struct nvme_fw_download_args *args); + +int nvme_cli_fw_commit(struct nvme_dev *dev, + struct nvme_fw_commit_args *args); + +int nvme_cli_get_feature_length2(int fid, __u32 cdw11, enum nvme_data_tfr dir, + __u32 *len); + +#endif /* _NVME_WRAP_H */ diff --git a/nvme.c b/nvme.c index 4096a91..df4d297 100644 --- a/nvme.c +++ b/nvme.c @@ -61,6 +61,7 @@ #include "nvme-print.h" #include "plugin.h" #include "util/base64.h" +#include "nvme-wrap.h" #include "util/argconfig.h" #include "fabrics.h" @@ -79,9 +80,6 @@ struct feat_cfg { bool human_readable; }; -static struct stat nvme_stat; -const char *devicename; - static const char nvme_version_string[] = NVME_VERSION; static struct plugin builtin = { @@ -97,15 +95,16 @@ static struct program nvme = { .version = nvme_version_string, .usage = " [] []", .desc = "The '' may be either an NVMe character "\ - "device (ex: /dev/nvme0) or an nvme block device "\ - "(ex: /dev/nvme0n1).", + "device (ex: /dev/nvme0), an nvme block device "\ + "(ex: /dev/nvme0n1), or a mctp address in the form "\ + "mctp:,[:ctrl-id]", .extensions = &builtin, }; const char *output_format = "Output format: normal|json|binary"; static const char *output_format_no_binary = "Output format: normal|json"; -static void *mmap_registers(nvme_root_t r, const char *dev); +static void *mmap_registers(nvme_root_t r, struct nvme_dev *dev); static void *__nvme_alloc(size_t len, bool *huge) { void *p; @@ -208,42 +207,119 @@ static ssize_t getrandom_bytes(void *buf, size_t buflen) #endif } -static bool is_chardev(void) +static bool is_chardev(struct nvme_dev *dev) { - return S_ISCHR(nvme_stat.st_mode); + return S_ISCHR(dev->direct.stat.st_mode); } -static bool is_blkdev(void) +static bool is_blkdev(struct nvme_dev *dev) { - return S_ISBLK(nvme_stat.st_mode); + return S_ISBLK(dev->direct.stat.st_mode); } -static int open_dev(char *dev, int flags) +static int open_dev_direct(struct nvme_dev **devp, char *devstr, int flags) { - int err, fd; + struct nvme_dev *dev; + int err; - devicename = basename(dev); - err = open(dev, flags); - if (err < 0) - goto perror; - fd = err; + dev = calloc(1, sizeof(*dev)); + if (!dev) + return -1; + + dev->type = NVME_DEV_DIRECT; + dev->name = basename(devstr); + err = open(devstr, flags); + if (err < 0) { + perror(devstr); + goto err_free; + } + dev->direct.fd = err; - err = fstat(fd, &nvme_stat); + err = fstat(dev_fd(dev), &dev->direct.stat); if (err < 0) { - close(fd); - goto perror; + perror(devstr); + goto err_close; } - if (!is_chardev() && !is_blkdev()) { - fprintf(stderr, "%s is not a block or character device\n", dev); - close(fd); - return -ENODEV; + if (!is_chardev(dev) && !is_blkdev(dev)) { + fprintf(stderr, "%s is not a block or character device\n", + devstr); + err = -ENODEV; + goto err_close; } - return fd; -perror: - perror(dev); + *devp = dev; + return 0; + +err_close: + close(dev_fd(dev)); +err_free: + free(dev); return err; } +static int parse_mi_dev(char *dev, unsigned int *net, uint8_t *eid, + unsigned int *ctrl) +{ + int rc; + + /* ,: form */ + rc = sscanf(dev, "mctp:%u,%hhu:%u", net, eid, ctrl); + if (rc == 3) + return 0; + + /* , form, implicit ctrl-id = 0 */ + *ctrl = 0; + rc = sscanf(dev, "mctp:%u,%hhu", net, eid); + if (rc == 2) + return 0; + + return -1; +} + +static int open_dev_mi_mctp(struct nvme_dev **devp, char *devstr) +{ + unsigned int net, ctrl_id; + struct nvme_dev *dev; + unsigned char eid; + int rc; + + rc = parse_mi_dev(devstr, &net, &eid, &ctrl_id); + if (rc) { + fprintf(stderr, "invalid device specifier '%s'\n", devstr); + return rc; + } + + dev = calloc(1, sizeof(*dev)); + if (!dev) + return -1; + + dev->type = NVME_DEV_MI; + dev->name = devstr; + + /* todo: verbose argument */ + dev->mi.root = nvme_mi_create_root(stderr, LOG_WARNING); + if (!dev->mi.root) + goto err_free; + + dev->mi.ep = nvme_mi_open_mctp(dev->mi.root, net, eid); + if (!dev->mi.ep) + goto err_free_root; + + dev->mi.ctrl = nvme_mi_init_ctrl(dev->mi.ep, ctrl_id); + if (!dev->mi.ctrl) + goto err_close_ep; + + *devp = dev; + return 0; + +err_close_ep: + nvme_mi_close(dev->mi.ep); +err_free_root: + nvme_mi_free_root(dev->mi.root); +err_free: + free(dev); + return -1; +} + static int check_arg_dev(int argc, char **argv) { if (optind >= argc) { @@ -254,19 +330,28 @@ static int check_arg_dev(int argc, char **argv) return 0; } -static int get_dev(int argc, char **argv, int flags) +static int get_dev(struct nvme_dev **dev, int argc, char **argv, int flags) { + char *devname; int ret; ret = check_arg_dev(argc, argv); if (ret) return ret; - return open_dev(argv[optind], flags); + devname = argv[optind]; + + if (!strncmp(devname, "mctp:", strlen("mctp:"))) + ret = open_dev_mi_mctp(dev, devname); + else + ret = open_dev_direct(dev, devname, flags); + + return ret; } -int parse_and_open(int argc, char **argv, const char *desc, - const struct argconfig_commandline_options *opts) +int parse_and_open(struct nvme_dev **dev, int argc, char **argv, + const char *desc, + const struct argconfig_commandline_options *opts) { int ret; @@ -274,21 +359,22 @@ int parse_and_open(int argc, char **argv, const char *desc, if (ret) return ret; - ret = get_dev(argc, argv, O_RDONLY); + ret = get_dev(dev, argc, argv, O_RDONLY); if (ret < 0) argconfig_print_help(desc, opts); return ret; } -int open_exclusive(int argc, char **argv, int ignore_exclusive) +int open_exclusive(struct nvme_dev **dev, int argc, char **argv, + int ignore_exclusive) { - int flags = O_RDONLY; + int flags = O_RDONLY; if (!ignore_exclusive) flags |= O_EXCL; - return get_dev(argc, argv, flags); + return get_dev(dev, argc, argv, flags); } enum nvme_print_flags validate_output_format(const char *format) @@ -304,6 +390,20 @@ enum nvme_print_flags validate_output_format(const char *format) return -EINVAL; } +void dev_close(struct nvme_dev *dev) +{ + switch (dev->type) { + case NVME_DEV_DIRECT: + close(dev_fd(dev)); + break; + case NVME_DEV_MI: + nvme_mi_close(dev->mi.ep); + nvme_mi_free_root(dev->mi.root); + break; + } + free(dev); +} + static int get_smart_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { struct nvme_smart_log smart_log; @@ -314,7 +414,8 @@ static int get_smart_log(int argc, char **argv, struct command *cmd, struct plug const char *raw = "output in binary format"; const char *human_readable = "show info in readable format"; enum nvme_print_flags flags; - int err = -1, fd; + struct nvme_dev *dev; + int err = -1; struct config { __u32 namespace_id; @@ -339,8 +440,8 @@ static int get_smart_log(int argc, char **argv, struct command *cmd, struct plug OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); @@ -351,16 +452,17 @@ static int get_smart_log(int argc, char **argv, struct command *cmd, struct plug if (cfg.human_readable) flags |= VERBOSE; - err = nvme_get_log_smart(fd, cfg.namespace_id, false, &smart_log); + err = nvme_cli_get_log_smart(dev, cfg.namespace_id, true, + &smart_log); if (!err) - nvme_show_smart_log(&smart_log, cfg.namespace_id, devicename, - flags); + nvme_show_smart_log(&smart_log, cfg.namespace_id, + dev->name, flags); else if (err > 0) nvme_show_status(err); else fprintf(stderr, "smart log: %s\n", nvme_strerror(errno)); close_fd: - close(fd); + dev_close(dev); ret: return err; } @@ -372,11 +474,12 @@ static int get_ana_log(int argc, char **argv, struct command *cmd, "decoded format (default), json or binary."; const char *groups = "Return ANA groups only."; void *ana_log; - int err = -1, fd; size_t ana_log_len; struct nvme_id_ctrl ctrl; enum nvme_print_flags flags; enum nvme_log_ana_lsp lsp; + struct nvme_dev *dev; + int err = -1; struct config { bool groups; @@ -394,15 +497,15 @@ static int get_ana_log(int argc, char **argv, struct command *cmd, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) goto close_fd; - err = nvme_identify_ctrl(fd, &ctrl); + err = nvme_cli_identify_ctrl(dev, &ctrl); if (err) { fprintf(stderr, "ERROR : nvme_identify_ctrl() failed: %s\n", nvme_strerror(errno)); @@ -423,16 +526,16 @@ static int get_ana_log(int argc, char **argv, struct command *cmd, lsp = cfg.groups ? NVME_LOG_ANA_LSP_RGO_GROUPS_ONLY : NVME_LOG_ANA_LSP_RGO_NAMESPACES; - err = nvme_get_log_ana(fd, lsp, true, 0, ana_log_len, ana_log); + err = nvme_cli_get_log_ana(dev, lsp, true, 0, ana_log_len, ana_log); if (!err) { - nvme_show_ana_log(ana_log, devicename, flags, ana_log_len); + nvme_show_ana_log(ana_log, dev->name, flags, ana_log_len); } else if (err > 0) nvme_show_status(err); else fprintf(stderr, "ana-log: %s", nvme_strerror(errno)); free(ana_log); close_fd: - close(fd); + dev_close(dev); ret: return err; } @@ -446,10 +549,11 @@ static int get_telemetry_log(int argc, char **argv, struct command *cmd, const char *cgen = "Gather report generated by the controller."; const char *dgen = "Pick which telemetry data area to report. Default is 3 to fetch areas 1-3. Valid options are 1, 2, 3, 4."; struct nvme_telemetry_log *log; - int err = 0, fd, output; + int err = 0, output; size_t total_size; __u8 *data_ptr = NULL; int data_written = 0, data_remaining = 0; + struct nvme_dev *dev; struct config { char *file_name; @@ -472,14 +576,14 @@ static int get_telemetry_log(int argc, char **argv, struct command *cmd, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (!cfg.file_name) { fprintf(stderr, "Please provide an output file!\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } cfg.host_gen = !!cfg.host_gen; @@ -488,15 +592,18 @@ static int get_telemetry_log(int argc, char **argv, struct command *cmd, fprintf(stderr, "Failed to open output file %s: %s!\n", cfg.file_name, strerror(errno)); err = output; - goto close_fd; + goto close_dev; } if (cfg.ctrl_init) - err = nvme_get_ctrl_telemetry(fd, true, &log, cfg.data_area, &total_size); + err = nvme_get_ctrl_telemetry(dev_fd(dev), true, &log, + cfg.data_area, &total_size); else if (cfg.host_gen) - err = nvme_get_new_host_telemetry(fd, &log, cfg.data_area, &total_size); + err = nvme_get_new_host_telemetry(dev_fd(dev), &log, + cfg.data_area, &total_size); else - err = nvme_get_host_telemetry(fd, &log, cfg.data_area, &total_size); + err = nvme_get_host_telemetry(dev_fd(dev), &log, + cfg.data_area, &total_size); if (err < 0) { fprintf(stderr, "get-telemetry-log: %s\n", @@ -536,8 +643,8 @@ static int get_telemetry_log(int argc, char **argv, struct command *cmd, close_output: close(output); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -548,7 +655,8 @@ static int get_endurance_log(int argc, char **argv, struct command *cmd, struct const char *desc = "Retrieves endurance groups log page and prints the log."; const char *group_id = "The endurance group identifier"; enum nvme_print_flags flags; - int err, fd; + struct nvme_dev *dev; + int err; struct config { char *output_format; @@ -566,28 +674,30 @@ static int get_endurance_log(int argc, char **argv, struct command *cmd, struct OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; - err = nvme_get_log_endurance_group(fd, cfg.group_id, &endurance_log); + err = nvme_cli_get_log_endurance_group(dev, cfg.group_id, + &endurance_log); if (!err) - nvme_show_endurance_log(&endurance_log, cfg.group_id, devicename, flags); + nvme_show_endurance_log(&endurance_log, cfg.group_id, + dev->name, flags); else if (err > 0) nvme_show_status(err); else fprintf(stderr, "endurance log: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } -static int collect_effects_log(int fd, enum nvme_csi csi, +static int collect_effects_log(struct nvme_dev *dev, enum nvme_csi csi, struct list_head *list, int flags) { nvme_effects_log_node_t *node; @@ -599,7 +709,7 @@ static int collect_effects_log(int fd, enum nvme_csi csi, node->csi = csi; - err = nvme_get_log_cmd_effects(fd, csi, &node->effects); + err = nvme_cli_get_log_cmd_effects(dev, csi, &node->effects); if (err) { free(node); return err; @@ -616,10 +726,11 @@ static int get_effects_log(int argc, char **argv, struct command *cmd, struct pl const char *csi = ""; struct list_head log_pages; nvme_effects_log_node_t *node; + struct nvme_dev *dev; void *bar = NULL; - int err = -1, fd; + int err = -1; enum nvme_print_flags flags; struct config { @@ -644,13 +755,13 @@ static int get_effects_log(int argc, char **argv, struct command *cmd, struct pl OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; if (cfg.human_readable) @@ -664,11 +775,11 @@ static int get_effects_log(int argc, char **argv, struct command *cmd, struct pl int nvme_command_set_supported; int other_command_sets_supported; nvme_root = nvme_scan(NULL); - bar = mmap_registers(nvme_root, devicename); + bar = mmap_registers(nvme_root, dev); nvme_free_tree(nvme_root); if (!bar) { - goto close_fd; + goto close_dev; } cap = mmio_read64(bar + NVME_REG_CAP); munmap(bar, getpagesize()); @@ -677,15 +788,15 @@ static int get_effects_log(int argc, char **argv, struct command *cmd, struct pl other_command_sets_supported = NVME_CAP_CSS(cap) & NVME_CAP_CSS_CSI; if (nvme_command_set_supported) - err = collect_effects_log(fd, NVME_CSI_NVM, + err = collect_effects_log(dev, NVME_CSI_NVM, &log_pages, flags); if (!err && other_command_sets_supported) - err = collect_effects_log(fd, NVME_CSI_ZNS, + err = collect_effects_log(dev, NVME_CSI_ZNS, &log_pages, flags); } else { - err = collect_effects_log(fd, cfg.csi, &log_pages, flags); + err = collect_effects_log(dev, cfg.csi, &log_pages, flags); } if (!err) @@ -695,10 +806,12 @@ static int get_effects_log(int argc, char **argv, struct command *cmd, struct pl else perror("effects log page"); -close_fd: - while ((node = list_pop(&log_pages, nvme_effects_log_node_t, node))) +close_dev: + while ((node = list_pop(&log_pages, nvme_effects_log_node_t, node))) { free(node); - close(fd); + } + + dev_close(dev); ret: return err; } @@ -709,9 +822,9 @@ static int get_supported_log_pages(int argc, char **argv, struct command *cmd, const char *desc = "Retrieve supported logs and print the table."; const char *verbose = "Increase output verbosity"; struct nvme_supported_log_pages supports; - - int err = -1, fd; enum nvme_print_flags flags; + struct nvme_dev *dev; + int err = -1; struct config { char *output_format; @@ -729,28 +842,28 @@ static int get_supported_log_pages(int argc, char **argv, struct command *cmd, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.verbose) flags |= VERBOSE; - err = nvme_get_log_supported_log_pages(fd, false, &supports); + err = nvme_cli_get_log_supported_log_pages(dev, false, &supports); if (!err) - nvme_show_supported_log(&supports, devicename, flags); + nvme_show_supported_log(&supports, dev->name, flags); else if (err > 0) nvme_show_status(err); else fprintf(stderr, "supported log pages: %s", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -765,7 +878,8 @@ static int get_error_log(int argc, char **argv, struct command *cmd, struct plug struct nvme_error_log_page *err_log; struct nvme_id_ctrl ctrl; enum nvme_print_flags flags; - int err = -1, fd; + struct nvme_dev *dev; + int err = -1; struct config { __u32 log_entries; @@ -786,49 +900,50 @@ static int get_error_log(int argc, char **argv, struct command *cmd, struct plug OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; if (!cfg.log_entries) { fprintf(stderr, "non-zero log-entries is required param\n"); err = -1; - goto close_fd; + goto close_dev; } - err = nvme_identify_ctrl(fd, &ctrl); + err = nvme_cli_identify_ctrl(dev, &ctrl); if (err < 0) { perror("identify controller"); - goto close_fd; + goto close_dev; } else if (err) { fprintf(stderr, "could not identify controller\n"); err = -1; - goto close_fd; + goto close_dev; } cfg.log_entries = min(cfg.log_entries, ctrl.elpe + 1); err_log = calloc(cfg.log_entries, sizeof(struct nvme_error_log_page)); if (!err_log) { err = -1; - goto close_fd; + goto close_dev; } - err = nvme_get_log_error(fd, cfg.log_entries, false, err_log); + err = nvme_cli_get_log_error(dev, cfg.log_entries, false, err_log); if (!err) - nvme_show_error_log(err_log, cfg.log_entries, devicename, flags); + nvme_show_error_log(err_log, cfg.log_entries, + dev->name, flags); else if (err > 0) nvme_show_status(err); else perror("error log"); free(err_log); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -840,7 +955,8 @@ static int get_fw_log(int argc, char **argv, struct command *cmd, struct plugin const char *raw = "use binary output"; struct nvme_firmware_slot fw_log; enum nvme_print_flags flags; - int err, fd; + struct nvme_dev *dev; + int err; struct config { char *output_format; @@ -858,25 +974,25 @@ static int get_fw_log(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; - err = nvme_get_log_fw_slot(fd, false, &fw_log); + err = nvme_cli_get_log_fw_slot(dev, false, &fw_log); if (!err) - nvme_show_fw_log(&fw_log, devicename, flags); + nvme_show_fw_log(&fw_log, dev->name, flags); else if (err > 0) nvme_show_status(err); else fprintf(stderr, "fw log: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -889,7 +1005,8 @@ static int get_changed_ns_list_log(int argc, char **argv, struct command *cmd, s const char *raw = "output in binary format"; struct nvme_ns_list changed_ns_list_log; enum nvme_print_flags flags; - int err, fd; + struct nvme_dev *dev; + int err; struct config { char *output_format; @@ -907,27 +1024,28 @@ static int get_changed_ns_list_log(int argc, char **argv, struct command *cmd, s OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; - err = nvme_get_log_changed_ns_list(fd, true, &changed_ns_list_log); + err = nvme_cli_get_log_changed_ns_list(dev, true, + &changed_ns_list_log); if (!err) - nvme_show_changed_ns_list_log(&changed_ns_list_log, devicename, - flags); + nvme_show_changed_ns_list_log(&changed_ns_list_log, + dev->name, flags); else if (err > 0) nvme_show_status(err); else fprintf(stderr, "changed ns list log: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -942,7 +1060,8 @@ static int get_pred_lat_per_nvmset_log(int argc, char **argv, const char *raw = "use binary output"; struct nvme_nvmset_predictable_lat_log plpns_log; enum nvme_print_flags flags; - int err, fd; + struct nvme_dev *dev; + int err; struct config { __u16 nvmset_id; @@ -963,28 +1082,29 @@ static int get_pred_lat_per_nvmset_log(int argc, char **argv, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; - err = nvme_get_log_predictable_lat_nvmset(fd, cfg.nvmset_id, &plpns_log); + err = nvme_cli_get_log_predictable_lat_nvmset(dev, cfg.nvmset_id, + &plpns_log); if (!err) nvme_show_predictable_latency_per_nvmset(&plpns_log, - cfg.nvmset_id, devicename, flags); + cfg.nvmset_id, dev->name, flags); else if (err > 0) nvme_show_status(err); else fprintf(stderr, "predictable latency per nvm set: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -1002,9 +1122,10 @@ static int get_pred_lat_event_agg_log(int argc, char **argv, const char *raw = "use binary output"; enum nvme_print_flags flags; struct nvme_id_ctrl ctrl; + struct nvme_dev *dev; __u32 log_size; void *pea_log; - int err, fd; + int err; struct config { __u64 log_entries; @@ -1028,30 +1149,30 @@ static int get_pred_lat_event_agg_log(int argc, char **argv, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; if (!cfg.log_entries) { fprintf(stderr, "non-zero log-entries is required param\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } - err = nvme_identify_ctrl(fd, &ctrl); + err = nvme_cli_identify_ctrl(dev, &ctrl); if (err < 0) { fprintf(stderr, "identify controller: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } else if (err) { nvme_show_status(err); - goto close_fd; + goto close_dev; } cfg.log_entries = min(cfg.log_entries, le32_to_cpu(ctrl.nsetidmax)); @@ -1059,13 +1180,14 @@ static int get_pred_lat_event_agg_log(int argc, char **argv, pea_log = calloc(log_size, 1); if (!pea_log) { err = -ENOMEM; - goto close_fd; + goto close_dev; } - err = nvme_get_log_predictable_lat_event(fd, cfg.rae, 0, log_size, pea_log); + err = nvme_cli_get_log_predictable_lat_event(dev, cfg.rae, 0, + log_size, pea_log); if (!err) nvme_show_predictable_latency_event_agg_log(pea_log, cfg.log_entries, - log_size, devicename, flags); + log_size, dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -1073,8 +1195,8 @@ static int get_pred_lat_event_agg_log(int argc, char **argv, nvme_strerror(errno)); free(pea_log); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -1092,8 +1214,9 @@ static int get_persistent_event_log(int argc, char **argv, struct nvme_persistent_event_log *pevent, *pevent_collected; enum nvme_print_flags flags; void *pevent_log_info; - int err, fd; + struct nvme_dev *dev; bool huge; + int err; struct config { __u8 action; @@ -1117,24 +1240,24 @@ static int get_persistent_event_log(int argc, char **argv, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; pevent = calloc(sizeof(*pevent), 1); if (!pevent) { err = -ENOMEM; - goto close_fd; + goto close_dev; } - err = nvme_get_log_persistent_event(fd, cfg.action, - sizeof(*pevent), pevent); + err = nvme_cli_get_log_persistent_event(dev, cfg.action, + sizeof(*pevent), pevent); if (err < 0) { fprintf(stderr, "persistent event log: %s\n", nvme_strerror(errno)); @@ -1171,11 +1294,12 @@ static int get_persistent_event_log(int argc, char **argv, err = -ENOMEM; goto free_pevent; } - err = nvme_get_log_persistent_event(fd, cfg.action, - cfg.log_len, pevent_log_info); + err = nvme_cli_get_log_persistent_event(dev, cfg.action, + cfg.log_len, pevent_log_info); if (!err) { - err = nvme_get_log_persistent_event(fd, cfg.action, - sizeof(*pevent), pevent); + err = nvme_cli_get_log_persistent_event(dev, cfg.action, + sizeof(*pevent), + pevent); if (err < 0) { fprintf(stderr, "persistent event log: %s\n", nvme_strerror(errno)); @@ -1192,7 +1316,7 @@ static int get_persistent_event_log(int argc, char **argv, } nvme_show_persistent_event_log(pevent_log_info, cfg.action, - cfg.log_len, devicename, flags); + cfg.log_len, dev->name, flags); } else if (err > 0) nvme_show_status(err); else @@ -1203,8 +1327,8 @@ free: nvme_free(pevent_log_info, huge); free_pevent: free(pevent); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -1223,8 +1347,9 @@ static int get_endurance_event_agg_log(int argc, char **argv, void *endurance_log; struct nvme_id_ctrl ctrl; enum nvme_print_flags flags; - int err, fd; + struct nvme_dev *dev; __u32 log_size; + int err; struct config { __u64 log_entries; @@ -1248,31 +1373,31 @@ static int get_endurance_event_agg_log(int argc, char **argv, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; if (!cfg.log_entries) { fprintf(stderr, "non-zero log-entries is required param\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } - err = nvme_identify_ctrl(fd, &ctrl); + err = nvme_cli_identify_ctrl(dev, &ctrl); if (err < 0) { fprintf(stderr, "identify controller: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } else if (err) { fprintf(stderr, "could not identify controller\n"); err = -ENODEV; - goto close_fd; + goto close_dev; } cfg.log_entries = min(cfg.log_entries, le16_to_cpu(ctrl.endgidmax)); @@ -1280,13 +1405,14 @@ static int get_endurance_event_agg_log(int argc, char **argv, endurance_log = calloc(log_size, 1); if (!endurance_log) { err = -ENOMEM; - goto close_fd; + goto close_dev; } - err = nvme_get_log_endurance_grp_evt(fd, cfg.rae, 0, log_size, endurance_log); + err = nvme_cli_get_log_endurance_grp_evt(dev, cfg.rae, 0, log_size, + endurance_log); if (!err) nvme_show_endurance_group_event_agg_log(endurance_log, cfg.log_entries, - log_size, devicename, flags); + log_size, dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -1294,8 +1420,8 @@ static int get_endurance_event_agg_log(int argc, char **argv, nvme_strerror(errno)); free(endurance_log); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -1309,8 +1435,9 @@ static int get_lba_status_log(int argc, char **argv, const char *rae = "Retain an Asynchronous Event"; void *lab_status; enum nvme_print_flags flags; - int err, fd; + struct nvme_dev *dev; __u32 lslplen; + int err; struct config { bool rae; @@ -1328,33 +1455,35 @@ static int get_lba_status_log(int argc, char **argv, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; - err = nvme_get_log_lba_status(fd, true, 0, sizeof(__u32), &lslplen); + err = nvme_cli_get_log_lba_status(dev, true, 0, sizeof(__u32), + &lslplen); if (err < 0) { fprintf(stderr, "lba status log page: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } else if (err) { nvme_show_status(err); - goto close_fd; + goto close_dev; } lab_status = calloc(lslplen, 1); if (!lab_status) { err = -ENOMEM; - goto close_fd; + goto close_dev; } - err = nvme_get_log_lba_status(fd, cfg.rae, 0, lslplen, lab_status); + err = nvme_cli_get_log_lba_status(dev, cfg.rae, 0, lslplen, + lab_status); if (!err) - nvme_show_lba_status_log(lab_status, lslplen, devicename, flags); + nvme_show_lba_status_log(lab_status, lslplen, dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -1362,8 +1491,8 @@ static int get_lba_status_log(int argc, char **argv, nvme_strerror(errno)); free(lab_status); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -1378,7 +1507,8 @@ static int get_resv_notif_log(int argc, char **argv, "json or binary."; struct nvme_resv_notification_log resv; enum nvme_print_flags flags; - int err, fd; + struct nvme_dev *dev; + int err; struct config { char *output_format; @@ -1393,25 +1523,25 @@ static int get_resv_notif_log(int argc, char **argv, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; - err = nvme_get_log_reservation(fd, false, &resv); + err = nvme_cli_get_log_reservation(dev, false, &resv); if (!err) - nvme_show_resv_notif_log(&resv, devicename, flags); + nvme_show_resv_notif_log(&resv, dev->name, flags); else if (err > 0) nvme_show_status(err); else fprintf(stderr, "resv notifi log: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; @@ -1428,7 +1558,8 @@ static int get_boot_part_log(int argc, char **argv, struct command *cmd, struct struct nvme_boot_partition boot; __u8 *bp_log; enum nvme_print_flags flags; - int err = -1, fd = 0, output = 0; + int err = -1, output = 0; + struct nvme_dev *dev; __u32 bpsz = 0; struct config { @@ -1450,24 +1581,24 @@ static int get_boot_part_log(int argc, char **argv, struct command *cmd, struct OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (!cfg.file_name) { fprintf(stderr, "Please provide an output file!\n"); err = -1; - goto close_fd; + goto close_dev; } if (cfg.lsp > 128) { fprintf(stderr, "invalid lsp param: %u\n", cfg.lsp); err = -1; - goto close_fd; + goto close_dev; } output = open(cfg.file_name, O_WRONLY | O_CREAT | O_TRUNC, 0666); @@ -1475,11 +1606,11 @@ static int get_boot_part_log(int argc, char **argv, struct command *cmd, struct fprintf(stderr, "Failed to open output file %s: %s!\n", cfg.file_name, strerror(errno)); err = output; - goto close_fd; + goto close_dev; } - err = nvme_get_log_boot_partition(fd, false, cfg.lsp, - sizeof(boot), &boot); + err = nvme_cli_get_log_boot_partition(dev, false, cfg.lsp, + sizeof(boot), &boot); if (err < 0) { fprintf(stderr, "boot partition log: %s\n", nvme_strerror(errno)); @@ -1496,11 +1627,12 @@ static int get_boot_part_log(int argc, char **argv, struct command *cmd, struct goto close_output; } - err = nvme_get_log_boot_partition(fd, false, cfg.lsp, - sizeof(boot) + bpsz, - (struct nvme_boot_partition *)bp_log); + err = nvme_cli_get_log_boot_partition(dev, false, cfg.lsp, + sizeof(boot) + bpsz, + (struct nvme_boot_partition *)bp_log); if (!err) - nvme_show_boot_part_log(&bp_log, devicename, flags, sizeof(boot) + bpsz); + nvme_show_boot_part_log(&bp_log, dev->name, flags, + sizeof(boot) + bpsz); else if (err > 0) nvme_show_status(err); else @@ -1519,8 +1651,8 @@ static int get_boot_part_log(int argc, char **argv, struct command *cmd, struct close_output: close(output); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -1532,9 +1664,9 @@ static int get_media_unit_stat_log(int argc, char **argv, struct command *cmd, const char *domainid = "Domain Identifier"; const char *raw = "use binary output"; struct nvme_media_unit_stat_log mus; - - int err = -1, fd; enum nvme_print_flags flags; + struct nvme_dev *dev; + int err = -1; struct config { __u16 domainid; @@ -1555,18 +1687,18 @@ static int get_media_unit_stat_log(int argc, char **argv, struct command *cmd, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; - err = nvme_get_log_media_unit_stat(fd, cfg.domainid, &mus); + err = nvme_cli_get_log_media_unit_stat(dev, cfg.domainid, &mus); if (!err) nvme_show_media_unit_stat_log(&mus, flags); else if (err > 0) @@ -1575,8 +1707,8 @@ static int get_media_unit_stat_log(int argc, char **argv, struct command *cmd, fprintf(stderr, "media unit status log: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -1588,9 +1720,9 @@ static int get_supp_cap_config_log(int argc, char **argv, struct command *cmd, const char *domainid = "Domain Identifier"; const char *raw = "use binary output"; struct nvme_supported_cap_config_list_log cap_log; - - int err = -1, fd; enum nvme_print_flags flags; + struct nvme_dev *dev; + int err = -1; struct config { __u16 domainid; @@ -1611,18 +1743,19 @@ static int get_supp_cap_config_log(int argc, char **argv, struct command *cmd, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; - err = nvme_get_log_support_cap_config_list(fd, cfg.domainid, &cap_log); + err = nvme_cli_get_log_support_cap_config_list(dev, cfg.domainid, + &cap_log); if (!err) nvme_show_supported_cap_config_log(&cap_log, flags); else if (err > 0) @@ -1630,8 +1763,8 @@ static int get_supp_cap_config_log(int argc, char **argv, struct command *cmd, else perror("supported capacity configuration list log"); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -1653,8 +1786,9 @@ static int get_log(int argc, char **argv, struct command *cmd, struct plugin *pl const char *uuid_index = "UUID index"; const char *csi = "command set identifier"; const char *offset_type = "offset type"; - int err, fd; + struct nvme_dev *dev; unsigned char *log; + int err; struct config { __u32 namespace_id; @@ -1702,8 +1836,8 @@ static int get_log(int argc, char **argv, struct command *cmd, struct plugin *pl OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (cfg.aen) { @@ -1714,31 +1848,30 @@ static int get_log(int argc, char **argv, struct command *cmd, struct plugin *pl if (!cfg.log_len) { perror("non-zero log-len is required param\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.lsp > 128) { perror("invalid lsp param\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.uuid_index > 128) { perror("invalid uuid index param\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } log = malloc(cfg.log_len); if (!log) { perror("could not alloc buffer for log\n"); err = -ENOMEM; - goto close_fd; + goto close_dev; } struct nvme_get_log_args args = { .args_size = sizeof(args), - .fd = fd, .lid = cfg.log_id, .nsid = cfg.namespace_id, .lpo = cfg.lpo, @@ -1750,14 +1883,13 @@ static int get_log(int argc, char **argv, struct command *cmd, struct plugin *pl .ot = cfg.ot, .len = cfg.log_len, .log = log, - .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, .result = NULL, }; - err = nvme_get_log(&args); + err = nvme_cli_get_log(dev, &args); if (!err) { if (!cfg.raw_binary) { printf("Device:%s log-id:%d namespace-id:%#x\n", - devicename, cfg.log_id, + dev->name, cfg.log_id, cfg.namespace_id); d(log, cfg.log_len, 16, 1); } else @@ -1768,8 +1900,8 @@ static int get_log(int argc, char **argv, struct command *cmd, struct plugin *pl fprintf(stderr, "log page: %s\n", nvme_strerror(errno)); free(log); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -1782,7 +1914,8 @@ static int sanitize_log(int argc, char **argv, struct command *command, struct p const char *human_readable = "show log in readable format"; struct nvme_sanitize_log_page sanitize_log; enum nvme_print_flags flags; - int fd, err; + struct nvme_dev *dev; + int err; struct config { bool rae; @@ -1806,28 +1939,28 @@ static int sanitize_log(int argc, char **argv, struct command *command, struct p OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; if (cfg.human_readable) flags |= VERBOSE; - err = nvme_get_log_sanitize(fd, cfg.rae, &sanitize_log); + err = nvme_cli_get_log_sanitize(dev, cfg.rae, &sanitize_log); if (!err) - nvme_show_sanitize_log(&sanitize_log, devicename, flags); + nvme_show_sanitize_log(&sanitize_log, dev->name, flags); else if (err > 0) nvme_show_status(err); else fprintf(stderr, "sanitize status log: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -1839,7 +1972,8 @@ static int get_fid_support_effects_log(int argc, char **argv, struct command *cm const char *human_readable = "show log in readable format"; struct nvme_fid_supported_effects_log fid_support_log; enum nvme_print_flags flags; - int fd, err = -1; + struct nvme_dev *dev; + int err = -1; struct config { char *output_format; @@ -1857,26 +1991,28 @@ static int get_fid_support_effects_log(int argc, char **argv, struct command *cm OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.human_readable) flags |= VERBOSE; - err = nvme_get_log_fid_supported_effects(fd, false, &fid_support_log); + err = nvme_cli_get_log_fid_supported_effects(dev, false, + &fid_support_log); if (!err) - nvme_show_fid_support_effects_log(&fid_support_log, devicename, flags); + nvme_show_fid_support_effects_log(&fid_support_log, + dev->name, flags); else if (err > 0) nvme_show_status(err); else fprintf(stderr, "fid support effects log: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -1888,7 +2024,8 @@ static int get_mi_cmd_support_effects_log(int argc, char **argv, struct command const char *human_readable = "show log in readable format"; struct nvme_mi_cmd_supported_effects_log mi_cmd_support_log; enum nvme_print_flags flags; - int fd, err = -1; + struct nvme_dev *dev; + int err = -1; struct config { char *output_format; @@ -1906,26 +2043,28 @@ static int get_mi_cmd_support_effects_log(int argc, char **argv, struct command OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.human_readable) flags |= VERBOSE; - err = nvme_get_log_mi_cmd_supported_effects(fd, false, &mi_cmd_support_log); + err = nvme_cli_get_log_mi_cmd_supported_effects(dev, false, + &mi_cmd_support_log); if (!err) - nvme_show_mi_cmd_support_effects_log(&mi_cmd_support_log, devicename, flags); + nvme_show_mi_cmd_support_effects_log(&mi_cmd_support_log, + dev->name, flags); else if (err > 0) nvme_show_status(err); else fprintf(stderr, "mi command support effects log: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -1936,9 +2075,10 @@ static int list_ctrl(int argc, char **argv, struct command *cmd, struct plugin * "given device is part of, or optionally controllers attached to a specific namespace."; const char *controller = "controller to display"; const char *namespace_id = "optional namespace attached to controller"; - int err, fd; struct nvme_ctrl_list *cntlist; enum nvme_print_flags flags; + struct nvme_dev *dev; + int err; struct config { __u16 cntid; @@ -1959,25 +2099,25 @@ static int list_ctrl(int argc, char **argv, struct command *cmd, struct plugin * OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (posix_memalign((void *)&cntlist, getpagesize(), 0x1000)) { fprintf(stderr, "can not allocate controller list payload\n"); err = -ENOMEM; - goto close_fd; + goto close_dev; } if (cfg.namespace_id == NVME_NSID_NONE) - err = nvme_identify_ctrl_list(fd, cfg.cntid, cntlist); - else - err = nvme_identify_nsid_ctrl_list(fd, cfg.namespace_id, - cfg.cntid, cntlist); + err = nvme_cli_identify_ctrl_list(dev, cfg.cntid, cntlist); + else + err = nvme_cli_identify_nsid_ctrl_list(dev, cfg.namespace_id, + cfg.cntid, cntlist); if (!err) nvme_show_list_ctrl(cntlist, flags); else if (err > 0) @@ -1987,8 +2127,8 @@ static int list_ctrl(int argc, char **argv, struct command *cmd, struct plugin * nvme_strerror(errno)); free(cntlist); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -2000,9 +2140,10 @@ static int list_ns(int argc, char **argv, struct command *cmd, struct plugin *pl const char *namespace_id = "first nsid returned list should start from"; const char *csi = "I/O command set identifier"; const char *all = "show all namespaces in the subsystem, whether attached or inactive"; - int err, fd; struct nvme_ns_list ns_list; enum nvme_print_flags flags; + struct nvme_dev *dev; + int err; struct config { __u32 namespace_id; @@ -2026,27 +2167,26 @@ static int list_ns(int argc, char **argv, struct command *cmd, struct plugin *pl OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (flags != JSON && flags != NORMAL) { err = -EINVAL; - goto close_fd; + goto close_dev; } if (!cfg.namespace_id) { err = -EINVAL; fprintf(stderr, "invalid nsid parameter\n"); - goto close_fd; + goto close_dev; } struct nvme_identify_args args = { .args_size = sizeof(args), - .fd = fd, .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, .data = &ns_list, .nsid = cfg.namespace_id - 1. @@ -2060,7 +2200,7 @@ static int list_ns(int argc, char **argv, struct command *cmd, struct plugin *pl args.csi = cfg.csi; } - err = nvme_identify(&args); + err = nvme_cli_identify(dev, &args); if (!err) nvme_show_list_ns(&ns_list, flags); @@ -2069,8 +2209,8 @@ static int list_ns(int argc, char **argv, struct command *cmd, struct plugin *pl else fprintf(stderr, "id namespace list: %s", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -2086,7 +2226,8 @@ static int id_ns_lba_format(int argc, char **argv, struct command *cmd, struct p const char *verbose = "Increase output verbosity"; enum nvme_print_flags flags; struct nvme_id_ns ns; - int err = -1, fd; + struct nvme_dev *dev; + int err = -1; struct config { __u16 lba_format_index; @@ -2110,18 +2251,19 @@ static int id_ns_lba_format(int argc, char **argv, struct command *cmd, struct p OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.verbose) flags |= VERBOSE; - err = nvme_identify_ns_csi_user_data_format(fd, cfg.lba_format_index, + err = nvme_identify_ns_csi_user_data_format(dev_fd(dev), + cfg.lba_format_index, cfg.uuid_index, NVME_CSI_NVM, &ns); if (!err) nvme_show_id_ns(&ns, 0, cfg.lba_format_index, true, flags); @@ -2129,8 +2271,8 @@ static int id_ns_lba_format(int argc, char **argv, struct command *cmd, struct p nvme_show_status(err); else perror("identify namespace for specific LBA format"); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return nvme_status_to_errno(err, false); } @@ -2141,9 +2283,10 @@ static int id_endurance_grp_list(int argc, char **argv, struct command *cmd, const char *desc = "Show endurance group list information for the given endurance "\ "group id"; const char *endurance_grp_id = "Endurance Group ID"; - int err = -1, fd; struct nvme_id_endurance_group_list *endgrp_list; enum nvme_print_flags flags; + struct nvme_dev *dev; + int err = -1; struct config { __u16 endgrp_id; @@ -2161,25 +2304,26 @@ static int id_endurance_grp_list(int argc, char **argv, struct command *cmd, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (flags != JSON && flags != NORMAL) { err = -EINVAL; fprintf(stderr, "invalid output format\n"); - goto close_fd; + goto close_dev; } if (posix_memalign((void *)&endgrp_list, getpagesize(), 0x1000)) { err = -1; - goto close_fd; + goto close_dev; } - err = nvme_identify_endurance_group_list(fd, cfg.endgrp_id, endgrp_list); + err = nvme_identify_endurance_group_list(dev_fd(dev), cfg.endgrp_id, + endgrp_list); if (!err) nvme_show_endurance_group_list(endgrp_list, flags); else if (err > 0) @@ -2189,8 +2333,8 @@ static int id_endurance_grp_list(int argc, char **argv, struct command *cmd, nvme_strerror(errno)); free(endgrp_list); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -2205,7 +2349,8 @@ static int delete_ns(int argc, char **argv, struct command *cmd, struct plugin * "the namespace is not already inactive, once deleted."; const char *namespace_id = "namespace to delete"; const char *timeout = "timeout value, in milliseconds"; - int err, fd; + struct nvme_dev *dev; + int err; struct config { __u32 namespace_id; @@ -2223,20 +2368,20 @@ static int delete_ns(int argc, char **argv, struct command *cmd, struct plugin * OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } } - err = nvme_ns_mgmt_delete(fd, cfg.namespace_id); + err = nvme_cli_ns_mgmt_delete(dev, cfg.namespace_id); if (!err) printf("%s: Success, deleted nsid:%d\n", cmd->name, cfg.namespace_id); @@ -2245,16 +2390,17 @@ static int delete_ns(int argc, char **argv, struct command *cmd, struct plugin * else fprintf(stderr, "delete namespace: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, struct command *cmd) { - int err, num, fd, i, list[2048]; struct nvme_ctrl_list cntlist; + int err, num, i, list[2048]; + struct nvme_dev *dev; __u16 ctrlist[2048]; const char *namespace_id = "namespace to attach"; @@ -2276,15 +2422,15 @@ static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, s OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (!cfg.namespace_id) { fprintf(stderr, "%s: namespace-id parameter required\n", cmd->name); err = -EINVAL; - goto close_fd; + goto close_dev; } num = argconfig_parse_comma_sep_array(cfg.cntlist, list, 2047); @@ -2296,7 +2442,7 @@ static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, s fprintf(stderr, "%s: controller id list is malformed\n", cmd->name); err = -EINVAL; - goto close_fd; + goto close_dev; } for (i = 0; i < num; i++) @@ -2305,9 +2451,11 @@ static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, s nvme_init_ctrl_list(&cntlist, num, ctrlist); if (attach) - err = nvme_ns_attach_ctrls(fd, cfg.namespace_id, &cntlist); + err = nvme_cli_ns_attach_ctrls(dev, cfg.namespace_id, + &cntlist); else - err = nvme_ns_detach_ctrls(fd, cfg.namespace_id, &cntlist); + err = nvme_cli_ns_detach_ctrls(dev, cfg.namespace_id, + &cntlist); if (!err) printf("%s: Success, nsid:%d\n", cmd->name, cfg.namespace_id); @@ -2316,8 +2464,8 @@ static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, s else perror(attach ? "attach namespace" : "detach namespace"); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -2362,8 +2510,9 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin * const char *bs = "target block size, specify only if \'FLBAS\' "\ "value not entered"; - int err = 0, fd, i; struct nvme_id_ns ns; + struct nvme_dev *dev; + int err = 0, i; __u32 nsid; struct config { @@ -2409,15 +2558,15 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin * OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (cfg.flbas != 0xff && cfg.bs != 0x00) { fprintf(stderr, "Invalid specification of both FLBAS and Block Size, please specify only one\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.bs) { if ((cfg.bs & (~cfg.bs + 1)) != cfg.bs) { @@ -2425,9 +2574,9 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin * "Invalid value for block size (%"PRIu64"). Block size must be a power of two\n", (uint64_t)cfg.bs); err = -EINVAL; - goto close_fd; + goto close_dev; } - err = nvme_identify_ns(fd, NVME_NSID_ALL, &ns); + err = nvme_cli_identify_ns(dev, NVME_NSID_ALL, &ns); if (err) { if (err < 0) fprintf(stderr, "identify-namespace: %s", @@ -2436,7 +2585,7 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin * fprintf(stderr, "identify failed\n"); nvme_show_status(err); } - goto close_fd; + goto close_dev; } for (i = 0; i <= ns.nlbaf; ++i) { if ((1 << ns.lbaf[i].ds) == cfg.bs && ns.lbaf[i].ms == 0) { @@ -2454,7 +2603,7 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin * "Please correct block size, or specify FLBAS directly\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } struct nvme_id_ns ns2 = { @@ -2468,7 +2617,7 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin * .lbstm = cpu_to_le64(cfg.lbstm), }; - err = nvme_ns_mgmt_create(fd, &ns2, &nsid, cfg.timeout, cfg.csi); + err = nvme_cli_ns_mgmt_create(dev, &ns2, &nsid, cfg.timeout, cfg.csi); if (!err) printf("%s: Success, created nsid:%d\n", cmd->name, nsid); else if (err > 0) @@ -2476,8 +2625,8 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin * else fprintf(stderr, "create namespace: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -2525,6 +2674,7 @@ static int list_subsys(int argc, char **argv, struct command *cmd, const char *desc = "Retrieve information for subsystems"; const char *verbose = "Increase output verbosity"; nvme_scan_filter_t filter = NULL; + char *devname; int err; int nsid = NVME_NSID_ALL; @@ -2548,9 +2698,9 @@ static int list_subsys(int argc, char **argv, struct command *cmd, if (err < 0) goto ret; - devicename = NULL; + devname = NULL; if (optind < argc) - devicename = basename(argv[optind++]); + devname = basename(argv[optind++]); err = flags = validate_output_format(cfg.output_format); if (flags < 0) @@ -2564,29 +2714,28 @@ static int list_subsys(int argc, char **argv, struct command *cmd, r = nvme_create_root(stderr, map_log_level(cfg.verbose, false)); if (!r) { - if (devicename) + if (devname) fprintf(stderr, "Failed to scan nvme subsystem for %s\n", - devicename); + devname); else fprintf(stderr, "Failed to scan nvme subsystem\n"); err = -errno; goto ret; } - if (devicename) { + if (devname) { int subsys_num; - if (sscanf(devicename,"nvme%dn%d", - &subsys_num, &nsid) != 2) { - fprintf(stderr, "Invalid device name %s\n", devicename); + if (sscanf(devname, "nvme%dn%d", &subsys_num, &nsid) != 2) { + fprintf(stderr, "Invalid device name %s\n", devname); err = -EINVAL; goto ret; } filter = nvme_match_device_filter; } - err = nvme_scan_topology(r, filter, (void *)devicename); + err = nvme_scan_topology(r, filter, (void *)devname); if (err) { fprintf(stderr, "Failed to scan topology: %s\n", nvme_strerror(errno)); @@ -2672,7 +2821,8 @@ int __id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin, const char *human_readable = "show identify in readable format"; enum nvme_print_flags flags; struct nvme_id_ctrl ctrl; - int err, fd; + struct nvme_dev *dev; + int err; struct config { bool vendor_specific; @@ -2696,13 +2846,13 @@ int __id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; if (cfg.vendor_specific) @@ -2710,15 +2860,15 @@ int __id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin, if (cfg.human_readable) flags |= VERBOSE; - err = nvme_identify_ctrl(fd, &ctrl); + err = nvme_cli_identify_ctrl(dev, &ctrl); if (!err) nvme_show_id_ctrl(&ctrl, flags, vs); else if (err > 0) nvme_show_status(err); else fprintf(stderr, "identify controller: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -2736,7 +2886,8 @@ static int nvm_id_ctrl(int argc, char **argv, struct command *cmd, "the specified controller in various formats."; enum nvme_print_flags flags; struct nvme_id_ctrl_nvm ctrl_nvm; - int fd, err = -1; + struct nvme_dev *dev; + int err = -1; struct config { char *output_format; @@ -2751,23 +2902,23 @@ static int nvm_id_ctrl(int argc, char **argv, struct command *cmd, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; - err = nvme_nvm_identify_ctrl(fd, &ctrl_nvm); + err = nvme_nvm_identify_ctrl(dev_fd(dev), &ctrl_nvm); if (!err) nvme_show_id_ctrl_nvm(&ctrl_nvm, flags); else if (err > 0) nvme_show_status(err); else fprintf(stderr, "nvm identify controller: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -2784,7 +2935,8 @@ static int nvm_id_ns(int argc, char **argv, struct command *cmd, enum nvme_print_flags flags; struct nvme_nvm_id_ns id_ns; struct nvme_id_ns ns; - int fd, err = -1; + struct nvme_dev *dev; + int err = -1; struct config { __u32 namespace_id; @@ -2808,32 +2960,33 @@ static int nvm_id_ns(int argc, char **argv, struct command *cmd, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.verbose) flags |= VERBOSE; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); - goto close_fd; + goto close_dev; } } - err = nvme_identify_ns(fd, cfg.namespace_id, &ns); + err = nvme_cli_identify_ns(dev, cfg.namespace_id, &ns); if (err) { nvme_show_status(err); - goto close_fd; + goto close_dev; } - err = nvme_identify_ns_csi(fd, cfg.namespace_id, cfg.uuid_index, + err = nvme_identify_ns_csi(dev_fd(dev), cfg.namespace_id, + cfg.uuid_index, NVME_CSI_NVM, &id_ns); if (!err) nvme_show_nvm_id_ns(&id_ns, cfg.namespace_id, &ns, 0, false, flags); @@ -2841,8 +2994,8 @@ static int nvm_id_ns(int argc, char **argv, struct command *cmd, nvme_show_status(err); else perror("nvm identify namespace"); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return nvme_status_to_errno(err, false); } @@ -2860,7 +3013,8 @@ static int nvm_id_ns_lba_format(int argc, char **argv, struct command *cmd, stru enum nvme_print_flags flags; struct nvme_id_ns ns; struct nvme_nvm_id_ns nvm_ns; - int err = -1, fd; + struct nvme_dev *dev; + int err = -1; struct config { __u16 lba_format_index; @@ -2884,23 +3038,24 @@ static int nvm_id_ns_lba_format(int argc, char **argv, struct command *cmd, stru OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.verbose) flags |= VERBOSE; - err = nvme_identify_ns(fd, NVME_NSID_ALL, &ns); + err = nvme_cli_identify_ns(dev, NVME_NSID_ALL, &ns); if (err) { ns.nlbaf = NVME_FEAT_LBA_RANGE_MAX - 1; ns.nulbaf = 0; } - err = nvme_identify_iocs_ns_csi_user_data_format(fd, cfg.lba_format_index, + err = nvme_identify_iocs_ns_csi_user_data_format(dev_fd(dev), + cfg.lba_format_index, cfg.uuid_index, NVME_CSI_NVM, &nvm_ns); if (!err) nvme_show_nvm_id_ns(&nvm_ns, 0, &ns, cfg.lba_format_index, true, @@ -2909,8 +3064,8 @@ static int nvm_id_ns_lba_format(int argc, char **argv, struct command *cmd, stru nvme_show_status(err); else perror("NVM identify namespace for specific LBA format"); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return nvme_status_to_errno(err, false); } @@ -2923,8 +3078,9 @@ static int ns_descs(int argc, char **argv, struct command *cmd, struct plugin *p const char *raw = "show descriptors in binary format"; const char *namespace_id = "identifier of desired namespace"; enum nvme_print_flags flags; - int err, fd; + struct nvme_dev *dev; void *nsdescs; + int err; struct config { __u32 namespace_id; @@ -2945,30 +3101,30 @@ static int ns_descs(int argc, char **argv, struct command *cmd, struct plugin *p OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } } if (posix_memalign(&nsdescs, getpagesize(), 0x1000)) { err = -ENOMEM; - goto close_fd; + goto close_dev; } - err = nvme_identify_ns_descs(fd, cfg.namespace_id, nsdescs); + err = nvme_identify_ns_descs(dev_fd(dev), cfg.namespace_id, nsdescs); if (!err) nvme_show_id_ns_descs(nsdescs, cfg.namespace_id, flags); else if (err > 0) @@ -2976,8 +3132,8 @@ static int ns_descs(int argc, char **argv, struct command *cmd, struct plugin *p else fprintf(stderr, "identify namespace: %s\n", nvme_strerror(errno)); free(nsdescs); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -2996,7 +3152,8 @@ static int id_ns(int argc, char **argv, struct command *cmd, struct plugin *plug enum nvme_print_flags flags; struct nvme_id_ns ns; - int err, fd; + struct nvme_dev *dev; + int err; struct config { __u32 namespace_id; @@ -3026,13 +3183,13 @@ static int id_ns(int argc, char **argv, struct command *cmd, struct plugin *plug OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; if (cfg.vendor_specific) @@ -3041,17 +3198,18 @@ static int id_ns(int argc, char **argv, struct command *cmd, struct plugin *plug flags |= VERBOSE; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } } if (cfg.force) - err = nvme_identify_allocated_ns(fd, cfg.namespace_id, &ns); + err = nvme_cli_identify_allocated_ns(dev, + cfg.namespace_id, &ns); else - err = nvme_identify_ns(fd, cfg.namespace_id, &ns); + err = nvme_cli_identify_ns(dev, cfg.namespace_id, &ns); if (!err) nvme_show_id_ns(&ns, cfg.namespace_id, 0, false, flags); @@ -3059,8 +3217,8 @@ static int id_ns(int argc, char **argv, struct command *cmd, struct plugin *plug nvme_show_status(err); else fprintf(stderr, "identify namespace: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -3077,7 +3235,8 @@ static int cmd_set_independent_id_ns(int argc, char **argv, enum nvme_print_flags flags; struct nvme_id_independent_id_ns ns; - int err = -1, fd; + struct nvme_dev *dev; + int err = -1; struct config { __u32 namespace_id; @@ -3101,35 +3260,37 @@ static int cmd_set_independent_id_ns(int argc, char **argv, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; if (cfg.human_readable) flags |= VERBOSE; if (!cfg.namespace_id) { - err = cfg.namespace_id = nvme_get_nsid(fd, &cfg.namespace_id); + err = cfg.namespace_id = nvme_get_nsid(dev_fd(dev), + &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); - goto close_fd; + goto close_dev; } } - err = nvme_identify_independent_identify_ns(fd, cfg.namespace_id, &ns); + err = nvme_identify_independent_identify_ns(dev_fd(dev), + cfg.namespace_id, &ns); if (!err) nvme_show_cmd_set_independent_id_ns(&ns, cfg.namespace_id, flags); else if (err > 0) nvme_show_status(err); else fprintf(stderr, "I/O command set independent identify namespace: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -3142,7 +3303,8 @@ static int id_ns_granularity(int argc, char **argv, struct command *cmd, struct struct nvme_id_ns_granularity_list *granularity_list; enum nvme_print_flags flags; - int err, fd; + struct nvme_dev *dev; + int err; struct config { char *output_format; @@ -3157,21 +3319,21 @@ static int id_ns_granularity(int argc, char **argv, struct command *cmd, struct OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (posix_memalign((void *)&granularity_list, getpagesize(), NVME_IDENTIFY_DATA_SIZE)) { fprintf(stderr, "can not allocate granularity list payload\n"); err = -ENOMEM; - goto close_fd; + goto close_dev; } - err = nvme_identify_ns_granularity(fd, granularity_list); + err = nvme_identify_ns_granularity(dev_fd(dev), granularity_list); if (!err) nvme_show_id_ns_granularity_list(granularity_list, flags); else if (err > 0) @@ -3179,8 +3341,8 @@ static int id_ns_granularity(int argc, char **argv, struct command *cmd, struct else fprintf(stderr, "identify namespace granularity: %s\n", nvme_strerror(errno)); free(granularity_list); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -3195,7 +3357,8 @@ static int id_nvmset(int argc, char **argv, struct command *cmd, struct plugin * struct nvme_id_nvmset_list nvmset; enum nvme_print_flags flags; - int err, fd; + struct nvme_dev *dev; + int err; struct config { __u16 nvmset_id; @@ -3213,15 +3376,15 @@ static int id_nvmset(int argc, char **argv, struct command *cmd, struct plugin * OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; - err = nvme_identify_nvmset_list(fd, cfg.nvmset_id, &nvmset); + err = nvme_identify_nvmset_list(dev_fd(dev), cfg.nvmset_id, &nvmset); if (!err) nvme_show_id_nvmset(&nvmset, cfg.nvmset_id, flags); else if (err > 0) @@ -3229,8 +3392,8 @@ static int id_nvmset(int argc, char **argv, struct command *cmd, struct plugin * else fprintf(stderr, "identify nvm set list: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -3245,7 +3408,8 @@ static int id_uuid(int argc, char **argv, struct command *cmd, struct plugin *pl struct nvme_id_uuid_list uuid_list; enum nvme_print_flags flags; - int err, fd; + struct nvme_dev *dev; + int err; struct config { char *output_format; @@ -3266,27 +3430,27 @@ static int id_uuid(int argc, char **argv, struct command *cmd, struct plugin *pl OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; if (cfg.human_readable) flags |= VERBOSE; - err = nvme_identify_uuid(fd, &uuid_list); + err = nvme_identify_uuid(dev_fd(dev), &uuid_list); if (!err) nvme_show_id_uuid_list(&uuid_list, flags); else if (err > 0) nvme_show_status(err); else fprintf(stderr, "identify UUID list: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err;; } @@ -3298,7 +3462,8 @@ static int id_iocs(int argc, char **argv, struct command *cmd, struct plugin *pl "in either human-readable or binary format."; const char *controller_id = "identifier of desired controller"; struct nvme_id_iocs iocs; - int err, fd; + struct nvme_dev *dev; + int err; struct config { __u16 cntid; @@ -3313,13 +3478,11 @@ static int id_iocs(int argc, char **argv, struct command *cmd, struct plugin *pl OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { - err = fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; - } - err = nvme_identify_iocs(fd, cfg.cntid, &iocs); + err = nvme_identify_iocs(dev_fd(dev), cfg.cntid, &iocs); if (!err) { printf("NVMe Identify I/O Command Set:\n"); nvme_show_id_iocs(&iocs); @@ -3328,7 +3491,7 @@ static int id_iocs(int argc, char **argv, struct command *cmd, struct plugin *pl else fprintf(stderr, "NVMe Identify I/O Command Set: %s\n", nvme_strerror(errno)); - close(fd); + dev_close(dev); ret: return err; } @@ -3340,7 +3503,8 @@ static int id_domain(int argc, char **argv, struct command *cmd, struct plugin * const char *domain_id = "identifier of desired domain"; struct nvme_id_domain_list id_domain; enum nvme_print_flags flags; - int err, fd; + struct nvme_dev *dev; + int err; struct config { __u16 dom_id; @@ -3358,17 +3522,15 @@ static int id_domain(int argc, char **argv, struct command *cmd, struct plugin * OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { - err = fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; - } err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; - err = nvme_identify_domain_list(fd, cfg.dom_id, &id_domain); + err = nvme_identify_domain_list(dev_fd(dev), cfg.dom_id, &id_domain); if (!err) { printf("NVMe Identify command for Domain List is successful:\n"); printf("NVMe Identify Domain List:\n"); @@ -3378,8 +3540,8 @@ static int id_domain(int argc, char **argv, struct command *cmd, struct plugin * else fprintf(stderr, "NVMe Identify Domain List: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -3387,28 +3549,29 @@ ret: static int get_ns_id(int argc, char **argv, struct command *cmd, struct plugin *plugin) { const char *desc = "Get namespace ID of a the block device."; - int err = 0, fd; + struct nvme_dev *dev; unsigned int nsid; + int err = 0; OPT_ARGS(opts) = { OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; - err = nvme_get_nsid(fd, &nsid); + err = nvme_get_nsid(dev_fd(dev), &nsid); if (err < 0) { fprintf(stderr, "get namespace ID: %s\n", nvme_strerror(errno)); err = errno; goto close_fd; } err = 0; - printf("%s: namespace-id:%d\n", devicename, nsid); + printf("%s: namespace-id:%d\n", dev->name, nsid); close_fd: - close(fd); + dev_close(dev); ret: return err; } @@ -3430,8 +3593,9 @@ static int virtual_mgmt(int argc, char **argv, struct command *cmd, struct plugi "8h: Secondary Assign\n"\ "9h: Secondary Online"; const char *nr = "Number of Controller Resources(NR)"; - int fd, err; + struct nvme_dev *dev; __u32 result; + int err; struct config { __u16 cntlid; @@ -3455,13 +3619,13 @@ static int virtual_mgmt(int argc, char **argv, struct command *cmd, struct plugi OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; struct nvme_virtual_mgmt_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .act = cfg.act, .rt = cfg.rt, .cntlid = cfg.cntlid, @@ -3478,7 +3642,7 @@ static int virtual_mgmt(int argc, char **argv, struct command *cmd, struct plugi } else fprintf(stderr, "virt-mgmt: %s\n", nvme_strerror(errno)); - close(fd); + dev_close(dev); ret: return err; } @@ -3491,9 +3655,9 @@ static int primary_ctrl_caps(int argc, char **argv, struct command *cmd, struct "decoded format (default), json or binary."; const char *human_readable = "show info in readable format"; struct nvme_primary_ctrl_cap caps; - - int err, fd; enum nvme_print_flags flags; + struct nvme_dev *dev; + int err; struct config { __u16 cntlid; @@ -3514,25 +3678,25 @@ static int primary_ctrl_caps(int argc, char **argv, struct command *cmd, struct OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.human_readable) flags |= VERBOSE; - err = nvme_identify_primary_ctrl(fd, cfg.cntlid, &caps); + err = nvme_identify_primary_ctrl(dev_fd(dev), cfg.cntlid, &caps); if (!err) nvme_show_primary_ctrl_cap(&caps, flags); else if (err > 0) nvme_show_status(err); else fprintf(stderr, "identify primary controller capabilities: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -3547,7 +3711,8 @@ static int list_secondary_ctrl(int argc, char **argv, struct command *cmd, struc struct nvme_secondary_ctrl_list *sc_list; enum nvme_print_flags flags; - int err, fd; + struct nvme_dev *dev; + int err; struct config { __u16 cntid; @@ -3571,27 +3736,28 @@ static int list_secondary_ctrl(int argc, char **argv, struct command *cmd, struc OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_err; if (!cfg.num_entries) { fprintf(stderr, "non-zero num-entries is required param\n"); err = -EINVAL; - goto close_fd; + goto close_err; } if (posix_memalign((void *)&sc_list, getpagesize(), sizeof(*sc_list))) { fprintf(stderr, "can not allocate controller list payload\n"); err = -ENOMEM; - goto close_fd; + goto close_err; } - err = nvme_identify_secondary_ctrl_list(fd, cfg.namespace_id, cfg.cntid, sc_list); + err = nvme_identify_secondary_ctrl_list(dev_fd(dev), cfg.namespace_id, + cfg.cntid, sc_list); if (!err) nvme_show_list_secondary_ctrl(sc_list, cfg.num_entries, flags); else if (err > 0) @@ -3601,8 +3767,8 @@ static int list_secondary_ctrl(int argc, char **argv, struct command *cmd, struc free(sc_list); -close_fd: - close(fd); +close_err: + dev_close(dev); ret: return err; } @@ -3618,7 +3784,8 @@ static int device_self_test(int argc, char **argv, struct command *cmd, struct p "2h Start a extended device self-test operation\n"\ "eh Start a vendor specific device self-test operation\n"\ "fh abort the device self-test operation\n"; - int fd, err; + struct nvme_dev *dev; + int err; struct config { __u32 namespace_id; @@ -3636,13 +3803,13 @@ static int device_self_test(int argc, char **argv, struct command *cmd, struct p OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; struct nvme_dev_self_test_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .stc = cfg.stc, .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, @@ -3661,7 +3828,7 @@ static int device_self_test(int argc, char **argv, struct command *cmd, struct p } else fprintf(stderr, "Device self-test: %s\n", nvme_strerror(errno)); - close(fd); + dev_close(dev); ret: return err; } @@ -3677,7 +3844,8 @@ static int self_test_log(int argc, char **argv, struct command *cmd, struct plug struct nvme_self_test_log log; enum nvme_print_flags flags; - int err, fd; + struct nvme_dev *dev; + int err; struct config { __u8 dst_entries; @@ -3698,32 +3866,32 @@ static int self_test_log(int argc, char **argv, struct command *cmd, struct plug OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.verbose) flags |= VERBOSE; - err = nvme_get_log_device_self_test(fd, &log); + err = nvme_cli_get_log_device_self_test(dev, &log); if (!err) nvme_show_self_test_log(&log, cfg.dst_entries, 0, - devicename, flags); + dev->name, flags); else if (err > 0) nvme_show_status(err); else fprintf(stderr, "self test log: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } -static int get_feature_id(int fd, struct feat_cfg *cfg, void **buf, - __u32 *result) +static int get_feature_id(struct nvme_dev *dev, struct feat_cfg *cfg, + void **buf, __u32 *result) { if (!cfg->data_len) nvme_get_feature_length(cfg->feature_id, cfg->cdw11, @@ -3745,7 +3913,6 @@ static int get_feature_id(int fd, struct feat_cfg *cfg, void **buf, struct nvme_get_features_args args = { .args_size = sizeof(args), - .fd = fd, .fid = cfg->feature_id, .nsid = cfg->namespace_id, .sel = cfg->sel, @@ -3756,7 +3923,7 @@ static int get_feature_id(int fd, struct feat_cfg *cfg, void **buf, .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, .result = result, }; - return nvme_get_features(&args); + return nvme_cli_get_features(dev, &args); } static void get_feature_id_print(struct feat_cfg cfg, int err, __u32 result, @@ -3780,14 +3947,16 @@ static void get_feature_id_print(struct feat_cfg cfg, int err, __u32 result, d_raw(buf, cfg.data_len); } } else if (err > 0) { - if (err != NVME_SC_INVALID_FIELD) + if (!nvme_status_equals(err, NVME_STATUS_TYPE_NVME, + NVME_SC_INVALID_FIELD)) nvme_show_status(err); } else { fprintf(stderr, "get-feature: %s\n", nvme_strerror(errno)); } } -static int get_feature_id_changed(int fd, struct feat_cfg cfg, bool changed) +static int get_feature_id_changed(struct nvme_dev *dev, struct feat_cfg cfg, + bool changed) { int err; int err_def = 0; @@ -3799,11 +3968,11 @@ static int get_feature_id_changed(int fd, struct feat_cfg cfg, bool changed) if (changed) cfg.sel = 0; - err = get_feature_id(fd, &cfg, &buf, &result); + err = get_feature_id(dev, &cfg, &buf, &result); if (!err && changed) { cfg.sel = 1; - err_def = get_feature_id(fd, &cfg, &buf_def, &result_def); + err_def = get_feature_id(dev, &cfg, &buf_def, &result_def); } if (changed) @@ -3819,7 +3988,7 @@ static int get_feature_id_changed(int fd, struct feat_cfg cfg, bool changed) return err; } -static int get_feature_ids(int fd, struct feat_cfg cfg) +static int get_feature_ids(struct nvme_dev *dev, struct feat_cfg cfg) { int err = 0; int i; @@ -3835,12 +4004,14 @@ static int get_feature_ids(int fd, struct feat_cfg cfg) for (i = cfg.feature_id; i < feat_max; i++, feat_num++) { cfg.feature_id = i; - err = get_feature_id_changed(fd, cfg, changed); - if (err && err != NVME_SC_INVALID_FIELD) + err = get_feature_id_changed(dev, cfg, changed); + if (err && !nvme_status_equals(err, NVME_STATUS_TYPE_NVME, + NVME_SC_INVALID_FIELD)) break; } - if (err == NVME_SC_INVALID_FIELD && feat_num == 1) + if (feat_num == 1 && nvme_status_equals(err, NVME_STATUS_TYPE_NVME, + NVME_SC_INVALID_FIELD)) nvme_show_status(err); return err; @@ -3866,8 +4037,8 @@ static int get_feature(int argc, char **argv, struct command *cmd, const char *cdw11 = "dword 11 for interrupt vector config"; const char *human_readable = "show feature in readable format"; const char *uuid_index = "specify uuid index"; + struct nvme_dev *dev; int err; - int fd; struct feat_cfg cfg = { .feature_id = 0, @@ -3892,16 +4063,16 @@ static int get_feature(int argc, char **argv, struct command *cmd, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { if (errno != ENOTTY) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } cfg.namespace_id = NVME_NSID_ALL; } @@ -3910,19 +4081,19 @@ static int get_feature(int argc, char **argv, struct command *cmd, if (cfg.sel > 8) { fprintf(stderr, "invalid 'select' param:%d\n", cfg.sel); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.uuid_index > 128) { fprintf(stderr, "invalid uuid index param: %u\n", cfg.uuid_index); err = -1; - goto close_fd; + goto close_dev; } - err = get_feature_ids(fd, cfg); + err = get_feature_ids(dev, cfg); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; @@ -3941,10 +4112,11 @@ static int fw_download(int argc, char **argv, struct command *cmd, struct plugin const char *fw = "firmware file (required)"; const char *xfer = "transfer chunksize limit"; const char *offset = "starting dword offset, default 0"; - int err, fd, fw_fd = -1; unsigned int fw_size; - struct stat sb; + struct nvme_dev *dev; void *fw_buf, *buf; + int err, fw_fd = -1; + struct stat sb; bool huge; struct config { @@ -3966,8 +4138,8 @@ static int fw_download(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; fw_fd = open(cfg.fw, O_RDONLY); @@ -3976,7 +4148,7 @@ static int fw_download(int argc, char **argv, struct command *cmd, struct plugin fprintf(stderr, "Failed to open firmware file %s: %s\n", cfg.fw, strerror(errno)); err = -EINVAL; - goto close_fd; + goto close_dev; } err = fstat(fw_fd, &sb); @@ -4017,14 +4189,13 @@ static int fw_download(int argc, char **argv, struct command *cmd, struct plugin struct nvme_fw_download_args args = { .args_size = sizeof(args), - .fd = fd, .offset = cfg.offset, .data_len = cfg.xfer, .data = fw_buf, .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, .result = NULL, }; - err = nvme_fw_download(&args); + err = nvme_cli_fw_download(dev, &args); if (err < 0) { fprintf(stderr, "fw-download: %s\n", nvme_strerror(errno)); break; @@ -4043,8 +4214,8 @@ free: nvme_free(buf, huge); close_fw_fd: close(fw_fd); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -4069,8 +4240,9 @@ static int fw_commit(int argc, char **argv, struct command *cmd, struct plugin * const char *slot = "[0-7]: firmware slot for commit action"; const char *action = "[0-7]: commit action"; const char *bpid = "[0,1]: boot partition identifier, if applicable (default: 0)"; - int err, fd; + struct nvme_dev *dev; __u32 result; + int err; struct config { __u8 slot; @@ -4091,54 +4263,62 @@ static int fw_commit(int argc, char **argv, struct command *cmd, struct plugin * OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (cfg.slot > 7) { fprintf(stderr, "invalid slot:%d\n", cfg.slot); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.action > 7 || cfg.action == 4 || cfg.action == 5) { fprintf(stderr, "invalid action:%d\n", cfg.action); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.bpid > 1) { fprintf(stderr, "invalid boot partition id:%d\n", cfg.bpid); err = -EINVAL; - goto close_fd; + goto close_dev; } struct nvme_fw_commit_args args = { .args_size = sizeof(args), - .fd = fd, .slot = cfg.slot, .action = cfg.action, .bpid = cfg.bpid, .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, .result = &result, }; - err = nvme_fw_commit(&args); + err = nvme_cli_fw_commit(dev, &args); + if (err < 0) fprintf(stderr, "fw-commit: %s\n", nvme_strerror(errno)); - else if (err != 0) - switch (err & 0x7ff) { - case NVME_SC_FW_NEEDS_CONV_RESET: - case NVME_SC_FW_NEEDS_SUBSYS_RESET: - case NVME_SC_FW_NEEDS_RESET: - printf("Success activating firmware action:%d slot:%d", - cfg.action, cfg.slot); - if (cfg.action == 6 || cfg.action == 7) - printf(" bpid:%d", cfg.bpid); - printf(", but firmware requires %s reset\n", nvme_fw_status_reset_type(err)); - break; - default: + else if (err != 0) { + __u32 val = nvme_status_get_value(err); + int type = nvme_status_get_type(err); + + if (type == NVME_STATUS_TYPE_NVME) { + switch (val & 0x7ff) { + case NVME_SC_FW_NEEDS_CONV_RESET: + case NVME_SC_FW_NEEDS_SUBSYS_RESET: + case NVME_SC_FW_NEEDS_RESET: + printf("Success activating firmware action:%d slot:%d", + cfg.action, cfg.slot); + if (cfg.action == 6 || cfg.action == 7) + printf(" bpid:%d", cfg.bpid); + printf(", but firmware requires %s reset\n", + nvme_fw_status_reset_type(val)); + break; + default: + nvme_show_status(err); + break; + } + } else { nvme_show_status(err); - break; } - else { + } else { printf("Success committing firmware action:%d slot:%d", cfg.action, cfg.slot); if (cfg.action == 6 || cfg.action == 7) @@ -4156,8 +4336,8 @@ static int fw_commit(int argc, char **argv, struct command *cmd, struct plugin * "sequence due to processing a command from an Admin SQ on a controller"); } -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -4165,17 +4345,18 @@ ret: static int subsystem_reset(int argc, char **argv, struct command *cmd, struct plugin *plugin) { const char *desc = "Resets the NVMe subsystem\n"; - int err, fd; + struct nvme_dev *dev; + int err; OPT_ARGS(opts) = { OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; - err = nvme_subsystem_reset(fd); + err = nvme_subsystem_reset(dev_fd(dev)); if (err < 0) { if (errno == ENOTTY) fprintf(stderr, @@ -4184,7 +4365,7 @@ static int subsystem_reset(int argc, char **argv, struct command *cmd, struct pl fprintf(stderr, "Subsystem-reset: %s\n", nvme_strerror(errno)); } - close(fd); + dev_close(dev); ret: return err; } @@ -4192,21 +4373,22 @@ ret: static int reset(int argc, char **argv, struct command *cmd, struct plugin *plugin) { const char *desc = "Resets the NVMe controller\n"; - int err, fd; + struct nvme_dev *dev; + int err; OPT_ARGS(opts) = { OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; - err = nvme_ctrl_reset(fd); + err = nvme_ctrl_reset(dev_fd(dev)); if (err < 0) fprintf(stderr, "Reset: %s\n", nvme_strerror(errno)); - close(fd); + dev_close(dev); ret: return err; } @@ -4214,21 +4396,22 @@ ret: static int ns_rescan(int argc, char **argv, struct command *cmd, struct plugin *plugin) { const char *desc = "Rescans the NVMe namespaces\n"; - int err, fd; + struct nvme_dev *dev; + int err; OPT_ARGS(opts) = { OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; - err = nvme_ns_rescan(fd); + err = nvme_ns_rescan(dev_fd(dev)); if (err < 0) fprintf(stderr, "Namespace Rescan"); - close(fd); + dev_close(dev); ret: return err; } @@ -4242,7 +4425,8 @@ static int sanitize(int argc, char **argv, struct command *cmd, struct plugin *p const char *ause_desc = "Allow unrestricted sanitize exit."; const char *sanact_desc = "Sanitize action."; const char *ovrpat_desc = "Overwrite pattern."; - int fd, err; + struct nvme_dev *dev; + int err; struct config { bool no_dealloc; @@ -4272,8 +4456,8 @@ static int sanitize(int argc, char **argv, struct command *cmd, struct plugin *p OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; switch (cfg.sanact) { @@ -4285,14 +4469,14 @@ static int sanitize(int argc, char **argv, struct command *cmd, struct plugin *p default: fprintf(stderr, "Invalid Sanitize Action\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.sanact == NVME_SANITIZE_SANACT_EXIT_FAILURE) { if (cfg.ause || cfg.no_dealloc) { fprintf(stderr, "SANACT is Exit Failure Mode\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } } @@ -4300,36 +4484,34 @@ static int sanitize(int argc, char **argv, struct command *cmd, struct plugin *p if (cfg.owpass > 16) { fprintf(stderr, "OWPASS out of range [0-16]\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } } else { if (cfg.owpass || cfg.oipbp || cfg.ovrpat) { fprintf(stderr, "SANACT is not Overwrite\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } } struct nvme_sanitize_nvm_args args = { .args_size = sizeof(args), - .fd = fd, .sanact = cfg.sanact, .ause = cfg.ause, .owpass = cfg.owpass, .oipbp = cfg.oipbp, .nodas = cfg.no_dealloc, .ovrpat = cfg.ovrpat, - .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, .result = NULL, }; - err = nvme_sanitize_nvm(&args); + err = nvme_cli_sanitize_nvm(dev, &args); if (err < 0) fprintf(stderr, "sanitize: %s\n", nvme_strerror(errno)); else if (err > 0) nvme_show_status(err); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -4354,8 +4536,10 @@ static int nvme_get_properties(int fd, void **pbar) .value = &value, .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, }; + err = nvme_get_property(&args); - if (err > 0 && (err & 0xff) == NVME_SC_INVALID_FIELD) { + if (nvme_status_equals(err, NVME_STATUS_TYPE_NVME, + NVME_SC_INVALID_FIELD)) { err = 0; value = -1; } else if (err) { @@ -4374,7 +4558,7 @@ static int nvme_get_properties(int fd, void **pbar) return err; } -static void *mmap_registers(nvme_root_t r, const char *dev) +static void *mmap_registers(nvme_root_t r, struct nvme_dev *dev) { nvme_ctrl_t c = NULL; nvme_ns_t n = NULL; @@ -4383,15 +4567,15 @@ static void *mmap_registers(nvme_root_t r, const char *dev) void *membase; int fd; - c = nvme_scan_ctrl(r, devicename); + c = nvme_scan_ctrl(r, dev->name); if (c) { snprintf(path, sizeof(path), "%s/device/resource0", nvme_ctrl_get_sysfs_dir(c)); nvme_free_ctrl(c); } else { - n = nvme_scan_namespace(devicename); + n = nvme_scan_namespace(dev->name); if (!n) { - fprintf(stderr, "Unable to find %s\n", devicename); + fprintf(stderr, "Unable to find %s\n", dev->name); return NULL; } snprintf(path, sizeof(path), "%s/device/device/resource0", @@ -4402,13 +4586,13 @@ static void *mmap_registers(nvme_root_t r, const char *dev) fd = open(path, O_RDONLY); if (fd < 0) { fprintf(stderr, "%s did not find a pci resource, open failed %s\n", - devicename, strerror(errno)); + dev->name, strerror(errno)); return NULL; } membase = mmap(NULL, getpagesize(), PROT_READ, MAP_SHARED, fd, 0); if (membase == MAP_FAILED) { - fprintf(stderr, "%s failed to map. ", devicename); + fprintf(stderr, "%s failed to map. ", dev->name); fprintf(stderr, "Did your kernel enable CONFIG_IO_STRICT_DEVMEM?\n"); membase = NULL; } @@ -4425,10 +4609,11 @@ static int show_registers(int argc, char **argv, struct command *cmd, struct plu "output_format == normal"; enum nvme_print_flags flags; - nvme_root_t r; + struct nvme_dev *dev; bool fabrics = true; - int fd, err; + nvme_root_t r; void *bar; + int err; struct config { char *output_format; @@ -4446,34 +4631,34 @@ static int show_registers(int argc, char **argv, struct command *cmd, struct plu OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; r = nvme_scan(NULL); err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.human_readable) flags |= VERBOSE; - err = nvme_get_properties(fd, &bar); + err = nvme_get_properties(dev_fd(dev), &bar); if (err) { - bar = mmap_registers(r, devicename); + bar = mmap_registers(r, dev); fabrics = false; if (bar) err = 0; } if (!bar) - goto close_fd; + goto close_dev; nvme_show_ctrl_registers(bar, fabrics, flags); if (fabrics) free(bar); else munmap(bar, getpagesize()); -close_fd: - close(fd); +close_dev: + dev_close(dev); nvme_free_tree(r); ret: return err; @@ -4487,8 +4672,9 @@ static int get_property(int argc, char **argv, struct command *cmd, struct plugi const char *offset = "offset of the requested property"; const char *human_readable = "show property in readable format"; - int fd, err; + struct nvme_dev *dev; __u64 value; + int err; struct config { int offset; @@ -4506,19 +4692,19 @@ static int get_property(int argc, char **argv, struct command *cmd, struct plugi OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (cfg.offset == -1) { fprintf(stderr, "offset required param\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } struct nvme_get_property_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .offset = cfg.offset, .value = &value, .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, @@ -4532,8 +4718,8 @@ static int get_property(int argc, char **argv, struct command *cmd, struct plugi nvme_show_status(err); } -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -4544,7 +4730,8 @@ static int set_property(int argc, char **argv, struct command *cmd, struct plugi "for NVMe over Fabric"; const char *offset = "the offset of the property"; const char *value = "the value of the property to be set"; - int fd, err; + struct nvme_dev *dev; + int err; struct config { int offset; @@ -4562,24 +4749,24 @@ static int set_property(int argc, char **argv, struct command *cmd, struct plugi OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (cfg.offset == -1) { fprintf(stderr, "offset required param\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.value == -1) { fprintf(stderr, "value required param\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } struct nvme_set_property_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .offset = cfg.offset, .value = cfg.value, .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, @@ -4595,8 +4782,8 @@ static int set_property(int argc, char **argv, struct command *cmd, struct plugi nvme_show_status(err); } -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -4619,9 +4806,10 @@ static int format(int argc, char **argv, struct command *cmd, struct plugin *plu const char *force = "The \"I know what I'm doing\" flag, skip confirmation before sending command"; struct nvme_id_ns ns; struct nvme_id_ctrl ctrl; - int err, fd, i; - int block_size; + struct nvme_dev *dev; __u8 prev_lbaf = 0; + int block_size; + int err, i; struct config { __u32 namespace_id; @@ -4667,8 +4855,8 @@ static int format(int argc, char **argv, struct command *cmd, struct plugin *plu if (err) goto ret; - err = fd = open_exclusive(argc, argv, cfg.force); - if (fd < 0) { + err = open_exclusive(&dev, argc, argv, cfg.force); + if (err) { if (errno == EBUSY) { fprintf(stderr, "Failed to open %s.\n", basename(argv[optind])); @@ -4687,7 +4875,7 @@ static int format(int argc, char **argv, struct command *cmd, struct plugin *plu fprintf(stderr, "Invalid specification of both LBAF and Block Size, please specify only one\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.bs) { if ((cfg.bs & (~cfg.bs + 1)) != cfg.bs) { @@ -4695,14 +4883,14 @@ static int format(int argc, char **argv, struct command *cmd, struct plugin *plu "Invalid value for block size (%"PRIu64"), must be a power of two\n", (uint64_t) cfg.bs); err = -EINVAL; - goto close_fd; + goto close_dev; } } - err = nvme_identify_ctrl(fd, &ctrl); + err = nvme_cli_identify_ctrl(dev, &ctrl); if (err) { fprintf(stderr, "identify-ctrl: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } if ((ctrl.fna & 1) == 1) { @@ -4713,10 +4901,10 @@ static int format(int argc, char **argv, struct command *cmd, struct plugin *plu */ cfg.namespace_id = NVME_NSID_ALL; } else if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } } @@ -4726,11 +4914,11 @@ static int format(int argc, char **argv, struct command *cmd, struct plugin *plu "specify a namespace to format or use '-n 0xffffffff' " "to format all namespaces on this controller.\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.namespace_id != NVME_NSID_ALL) { - err = nvme_identify_ns(fd, cfg.namespace_id, &ns); + err = nvme_cli_identify_ns(dev, cfg.namespace_id, &ns); if (err) { if (err < 0) fprintf(stderr, "identify-namespace: %s\n", nvme_strerror(errno)); @@ -4738,7 +4926,7 @@ static int format(int argc, char **argv, struct command *cmd, struct plugin *plu fprintf(stderr, "identify failed\n"); nvme_show_status(err); } - goto close_fd; + goto close_dev; } nvme_id_ns_flbas_to_lbaf_inuse(ns.flbas, &prev_lbaf); @@ -4757,7 +4945,7 @@ static int format(int argc, char **argv, struct command *cmd, struct plugin *plu fprintf(stderr, "Please correct block size, or specify LBAF directly\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } } else if (cfg.lbaf == 0xff) cfg.lbaf = prev_lbaf; @@ -4769,34 +4957,34 @@ static int format(int argc, char **argv, struct command *cmd, struct plugin *plu if (cfg.ses > 7) { fprintf(stderr, "invalid secure erase settings:%d\n", cfg.ses); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.lbaf > 63) { fprintf(stderr, "invalid lbaf:%d\n", cfg.lbaf); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.pi > 7) { fprintf(stderr, "invalid pi:%d\n", cfg.pi); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.pil > 1) { fprintf(stderr, "invalid pil:%d\n", cfg.pil); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.ms > 1) { fprintf(stderr, "invalid ms:%d\n", cfg.ms); err = -EINVAL; - goto close_fd; + goto close_dev; } if (!cfg.force) { fprintf(stderr, "You are about to format %s, namespace %#x%s.\n", - devicename, cfg.namespace_id, + dev->name, cfg.namespace_id, cfg.namespace_id == NVME_NSID_ALL ? "(ALL namespaces)" : ""); - nvme_show_relatives(devicename); + nvme_show_relatives(dev->name); fprintf(stderr, "WARNING: Format may irrevocably delete this device's data.\n" "You have 10 seconds to press Ctrl-C to cancel this operation.\n\n" "Use the force [--force] option to suppress this warning.\n"); @@ -4806,7 +4994,6 @@ static int format(int argc, char **argv, struct command *cmd, struct plugin *plu struct nvme_format_nvm_args args = { .args_size = sizeof(args), - .fd = fd, .nsid = cfg.namespace_id, .lbafu = (cfg.lbaf & NVME_NS_FLBAS_HIGHER_MASK) >> 4, .lbaf = cfg.lbaf & NVME_NS_FLBAS_LOWER_MASK, @@ -4817,19 +5004,19 @@ static int format(int argc, char **argv, struct command *cmd, struct plugin *plu .timeout = cfg.timeout, .result = NULL, }; - err = nvme_format_nvm(&args); + err = nvme_cli_format_nvm(dev, &args); if (err < 0) fprintf(stderr, "format: %s\n", nvme_strerror(errno)); else if (err != 0) nvme_show_status(err); else { printf("Success formatting namespace:%x\n", cfg.namespace_id); - if (cfg.lbaf != prev_lbaf){ - if (is_chardev()) { - if(ioctl(fd, NVME_IOCTL_RESCAN) < 0){ + if (dev->type == NVME_DEV_DIRECT && cfg.lbaf != prev_lbaf){ + if (is_chardev(dev)) { + if (ioctl(dev_fd(dev), NVME_IOCTL_RESCAN) < 0) { fprintf(stderr, "failed to rescan namespaces\n"); err = -errno; - goto close_fd; + goto close_dev; } } else { block_size = 1 << ns.lbaf[cfg.lbaf].ds; @@ -4841,26 +5028,26 @@ static int format(int argc, char **argv, struct command *cmd, struct plugin *plu * to the given one because blkdev will not * update by itself without re-opening fd. */ - if (ioctl(fd, BLKBSZSET, &block_size) < 0) { + if (ioctl(dev_fd(dev), BLKBSZSET, &block_size) < 0) { fprintf(stderr, "failed to set block size to %d\n", block_size); err = -errno; - goto close_fd; + goto close_dev; } - if(ioctl(fd, BLKRRPART) < 0) { + if (ioctl(dev_fd(dev), BLKRRPART) < 0) { fprintf(stderr, "failed to re-read partition table\n"); err = -errno; - goto close_fd; + goto close_dev; } } } - if (cfg.reset && is_chardev()) - nvme_ctrl_reset(fd); + if (dev->type == NVME_DEV_DIRECT && cfg.reset && is_chardev(dev)) + nvme_ctrl_reset(dev_fd(dev)); } -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -4887,10 +5074,11 @@ static int set_feature(int argc, char **argv, struct command *cmd, struct plugin const char *cdw12 = "feature cdw12, if used"; const char *save = "specifies that the controller shall save the attribute"; const char *uuid_index = "specify uuid index"; + struct nvme_dev *dev; int err; __u32 result; void *buf = NULL; - int fd, ffd = STDIN_FILENO; + int ffd = STDIN_FILENO; struct config { __u32 namespace_id; @@ -4925,16 +5113,16 @@ static int set_feature(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { if (errno != ENOTTY) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } cfg.namespace_id = NVME_NSID_ALL; @@ -4944,24 +5132,25 @@ static int set_feature(int argc, char **argv, struct command *cmd, struct plugin if (!cfg.feature_id) { fprintf(stderr, "feature-id required param\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.uuid_index > 128) { fprintf(stderr, "invalid uuid index param: %u\n", cfg.uuid_index); err = -1; - goto close_fd; + goto close_dev; } if (!cfg.data_len) - nvme_get_feature_length(cfg.feature_id, cfg.value, - &cfg.data_len); + nvme_cli_get_feature_length2(cfg.feature_id, cfg.value, + NVME_DATA_TFR_HOST_TO_CTRL, + &cfg.data_len); if (cfg.data_len) { if (posix_memalign(&buf, getpagesize(), cfg.data_len)) { fprintf(stderr, "can not allocate feature payload\n"); err = -ENOMEM; - goto close_fd; + goto close_dev; } memset(buf, 0, cfg.data_len); } @@ -4998,7 +5187,7 @@ static int set_feature(int argc, char **argv, struct command *cmd, struct plugin struct nvme_set_features_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .fid = cfg.feature_id, .nsid = cfg.namespace_id, .cdw11 = cfg.value, @@ -5038,8 +5227,8 @@ close_ffd: close(ffd); free: free(buf); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -5058,7 +5247,8 @@ static int sec_send(int argc, char **argv, struct command *cmd, struct plugin *p const char *tl = "transfer length (cf. SPC-4)"; const char *namespace_id = "desired namespace"; const char *nssf = "NVMe Security Specific Field"; - int err, fd, sec_fd = STDIN_FILENO; + int err, sec_fd = STDIN_FILENO; + struct nvme_dev *dev; void *sec_buf; unsigned int sec_size; @@ -5090,14 +5280,14 @@ static int sec_send(int argc, char **argv, struct command *cmd, struct plugin *p OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (cfg.tl == 0) { fprintf(stderr, "--tl unspecified or zero\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } if ((cfg.tl & 3) != 0) fprintf(stderr, "WARNING: --tl not dword aligned; unaligned bytes may be truncated\n"); @@ -5111,7 +5301,7 @@ static int sec_send(int argc, char **argv, struct command *cmd, struct plugin *p fprintf(stderr, "Failed to open %s: %s\n", cfg.file, strerror(errno)); err = -EINVAL; - goto close_fd; + goto close_dev; } err = fstat(sec_fd, &sb); @@ -5141,7 +5331,7 @@ static int sec_send(int argc, char **argv, struct command *cmd, struct plugin *p struct nvme_security_send_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .nssf = cfg.nssf, .spsp0 = cfg.spsp & 0xff, @@ -5165,8 +5355,8 @@ free: free(sec_buf); close_sec_fd: close(sec_fd); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -5185,11 +5375,12 @@ static int dir_send(int argc, char **argv, struct command *cmd, struct plugin *p const char *ttype = "target directive type to be enabled/disabled"; const char *human_readable = "show directive in readable format"; const char *input = "write/send file (default stdin)"; - int err, fd; + struct nvme_dev *dev; __u32 result; __u32 dw12 = 0; void *buf = NULL; int ffd = STDIN_FILENO; + int err; struct config { __u32 namespace_id; @@ -5231,8 +5422,8 @@ static int dir_send(int argc, char **argv, struct command *cmd, struct plugin *p OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; switch (cfg.dtype) { @@ -5242,14 +5433,14 @@ static int dir_send(int argc, char **argv, struct command *cmd, struct plugin *p if (!cfg.ttype) { fprintf(stderr, "target-dir required param\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } dw12 = cfg.ttype << 8 | cfg.endir; break; default: fprintf(stderr, "invalid directive operations for Identify Directives\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } break; case NVME_DIRECTIVE_DTYPE_STREAMS: @@ -5260,20 +5451,20 @@ static int dir_send(int argc, char **argv, struct command *cmd, struct plugin *p default: fprintf(stderr, "invalid directive operations for Streams Directives\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } break; default: fprintf(stderr, "invalid directive type\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.data_len) { if (posix_memalign(&buf, getpagesize(), cfg.data_len)) { err = -ENOMEM; - goto close_fd; + goto close_dev; } memset(buf, 0, cfg.data_len); } @@ -5299,7 +5490,7 @@ static int dir_send(int argc, char **argv, struct command *cmd, struct plugin *p struct nvme_directive_send_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .dspec = cfg.dspec, .doper = cfg.doper, @@ -5331,20 +5522,21 @@ close_ffd: close(ffd); free: free(buf); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } static int write_uncor(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - int err, fd; const char *desc = "The Write Uncorrectable command is used to set a "\ "range of logical blocks to invalid."; const char *namespace_id = "desired namespace"; const char *start_block = "64-bit LBA of first block to access"; const char *block_count = "number of blocks (zeroes based) on device to access"; + struct nvme_dev *dev; + int err; struct config { __u32 namespace_id; @@ -5365,21 +5557,21 @@ static int write_uncor(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } } struct nvme_io_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .slba = cfg.start_block, .nlb = cfg.block_count, @@ -5394,8 +5586,8 @@ static int write_uncor(int argc, char **argv, struct command *cmd, struct plugin else printf("NVME Write Uncorrectable Success\n"); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -5435,11 +5627,12 @@ static int invalid_tags(__u64 storage_tag, __u64 ref_tag, __u8 sts, __u8 pif) static int write_zeroes(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - int err, fd; __u16 control = 0; __u8 lba_index, sts = 0, pif = 0; struct nvme_id_ns ns; + struct nvme_dev *dev; struct nvme_nvm_id_ns nvm_ns; + int err; const char *desc = "The Write Zeroes command is used to set a "\ "range of logical blocks to zero."; @@ -5503,13 +5696,13 @@ static int write_zeroes(int argc, char **argv, struct command *cmd, struct plugi OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (cfg.prinfo > 0xf) { err = -EINVAL; - goto close_fd; + goto close_dev; } control |= (cfg.prinfo << 10); @@ -5522,23 +5715,24 @@ static int write_zeroes(int argc, char **argv, struct command *cmd, struct plugi if (cfg.storage_tag_check) control |= NVME_IO_STC; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } } - err = nvme_identify_ns(fd, cfg.namespace_id, &ns); + err = nvme_cli_identify_ns(dev, cfg.namespace_id, &ns); if (err) { nvme_show_status(err); - goto close_fd; + goto close_dev; } else if (err < 0) { fprintf(stderr, "identify namespace: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } - err = nvme_identify_ns_csi(fd, cfg.namespace_id, 0, NVME_CSI_NVM, &nvm_ns); + err = nvme_identify_ns_csi(dev_fd(dev), cfg.namespace_id, 0, + NVME_CSI_NVM, &nvm_ns); if (!err) { nvme_id_ns_flbas_to_lbaf_inuse(ns.flbas, &lba_index); sts = nvm_ns.elbaf[lba_index] & NVME_NVM_ELBAF_STS_MASK; @@ -5547,12 +5741,12 @@ static int write_zeroes(int argc, char **argv, struct command *cmd, struct plugi if (invalid_tags(cfg.storage_tag, cfg.ref_tag, sts, pif)) { err = -EINVAL; - goto close_fd; + goto close_dev; } struct nvme_io_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .slba = cfg.start_block, .nlb = cfg.block_count, @@ -5574,8 +5768,8 @@ static int write_zeroes(int argc, char **argv, struct command *cmd, struct plugi else printf("NVME Write Zeroes Success\n"); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -5595,12 +5789,13 @@ static int dsm(int argc, char **argv, struct command *cmd, struct plugin *plugin const char *idr = "Attribute Integral Dataset for Read"; const char *cdw11 = "All the command DWORD 11 attributes. Use instead of specifying individual attributes"; - int err, fd; uint16_t nr, nc, nb, ns; __u32 ctx_attrs[256] = {0,}; __u32 nlbs[256] = {0,}; __u64 slbas[256] = {0,}; struct nvme_dsm_range dsm[256]; + struct nvme_dev *dev; + int err; struct config { __u32 namespace_id; @@ -5636,8 +5831,8 @@ static int dsm(int argc, char **argv, struct command *cmd, struct plugin *plugin OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; nc = argconfig_parse_comma_sep_array(cfg.ctx_attrs, (int *)ctx_attrs, ARRAY_SIZE(ctx_attrs)); @@ -5647,14 +5842,14 @@ static int dsm(int argc, char **argv, struct command *cmd, struct plugin *plugin if (!nr || nr > 256) { fprintf(stderr, "No range definition provided\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } } if (!cfg.cdw11) @@ -5663,7 +5858,7 @@ static int dsm(int argc, char **argv, struct command *cmd, struct plugin *plugin nvme_init_dsm_range(dsm, ctx_attrs, nlbs, slbas, nr); struct nvme_dsm_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .attrs = cfg.cdw11, .nr_ranges = nr, @@ -5679,8 +5874,8 @@ static int dsm(int argc, char **argv, struct command *cmd, struct plugin *plugin else printf("NVMe DSM: success\n"); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -5710,10 +5905,11 @@ static int copy(int argc, char **argv, struct command *cmd, struct plugin *plugi const char *d_dspec = "directive specific (write part)"; const char *d_format = "source range entry format"; - int err, fd; uint16_t nr, nb, ns, nrts, natms, nats; __u16 nlbs[128] = { 0 }; unsigned long long slbas[128] = {0,}; + struct nvme_dev *dev; + int err; union { __u32 f0[128]; @@ -5789,23 +5985,21 @@ static int copy(int argc, char **argv, struct command *cmd, struct plugin *plugi OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { - err = fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; - } - nb = argconfig_parse_comma_sep_array(cfg.nlbs, (int *)nlbs, ARRAY_SIZE(nlbs)); + nb = argconfig_parse_comma_sep_array_short(cfg.nlbs, nlbs, ARRAY_SIZE(nlbs)); ns = argconfig_parse_comma_sep_array_long(cfg.slbas, slbas, ARRAY_SIZE(slbas)); if (cfg.format == 0) nrts = argconfig_parse_comma_sep_array(cfg.eilbrts, (int *)eilbrts.f0, ARRAY_SIZE(eilbrts.f0)); else if (cfg.format == 1) - nrts = argconfig_parse_comma_sep_array_long(cfg.eilbrts, (__u64 *)eilbrts.f1, ARRAY_SIZE(eilbrts.f1)); + nrts = argconfig_parse_comma_sep_array_long(cfg.eilbrts, (unsigned long long *)eilbrts.f1, ARRAY_SIZE(eilbrts.f1)); else { fprintf(stderr, "invalid format\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } natms = argconfig_parse_comma_sep_array(cfg.elbatms, (int *)elbatms, ARRAY_SIZE(elbatms)); @@ -5815,14 +6009,14 @@ static int copy(int argc, char **argv, struct command *cmd, struct plugin *plugi if (!nr || nr > 128 || (cfg.format == 1 && nr > 101)) { fprintf(stderr, "invalid range\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } } @@ -5835,7 +6029,7 @@ static int copy(int argc, char **argv, struct command *cmd, struct plugin *plugi struct nvme_copy_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .copy = copy.f0, .sdlba = cfg.sdlba, @@ -5861,8 +6055,8 @@ static int copy(int argc, char **argv, struct command *cmd, struct plugin *plugi else printf("NVMe Copy: success\n"); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -5875,7 +6069,8 @@ static int flush(int argc, char **argv, struct command *cmd, struct plugin *plug "flushed by the controller, from any namespace, depending on controller and "\ "associated namespace status."; const char *namespace_id = "identifier of desired namespace"; - int err, fd; + struct nvme_dev *dev; + int err; struct config { __u32 namespace_id; @@ -5890,27 +6085,27 @@ static int flush(int argc, char **argv, struct command *cmd, struct plugin *plug OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } } - err = nvme_flush(fd, cfg.namespace_id); + err = nvme_flush(dev_fd(dev), cfg.namespace_id); if (err < 0) fprintf(stderr, "flush: %s\n", nvme_strerror(errno)); else if (err != 0) nvme_show_status(err); else printf("NVMe Flush: success\n"); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -5929,7 +6124,8 @@ static int resv_acquire(int argc, char **argv, struct command *cmd, struct plugi const char *rtype = "reservation type"; const char *racqa = "reservation acquire action"; const char *iekey = "ignore existing res. key"; - int err, fd; + struct nvme_dev *dev; + int err; struct config { __u32 namespace_id; @@ -5959,26 +6155,26 @@ static int resv_acquire(int argc, char **argv, struct command *cmd, struct plugi OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } } if (cfg.racqa > 7) { fprintf(stderr, "invalid racqa:%d\n", cfg.racqa); err = -EINVAL; - goto close_fd; + goto close_dev; } struct nvme_resv_acquire_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .rtype = cfg.rtype, .racqa = cfg.racqa, @@ -5996,8 +6192,8 @@ static int resv_acquire(int argc, char **argv, struct command *cmd, struct plugi else printf("NVME Reservation Acquire success\n"); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -6013,7 +6209,8 @@ static int resv_register(int argc, char **argv, struct command *cmd, struct plug const char *nrkey = "new reservation key"; const char *rrega = "reservation registration action"; const char *cptpl = "change persistence through power loss setting"; - int err, fd; + struct nvme_dev *dev; + int err; struct config { __u32 namespace_id; @@ -6042,32 +6239,32 @@ static int resv_register(int argc, char **argv, struct command *cmd, struct plug OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } } if (cfg.cptpl > 3) { fprintf(stderr, "invalid cptpl:%d\n", cfg.cptpl); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.rrega > 7) { fprintf(stderr, "invalid rrega:%d\n", cfg.rrega); err = -EINVAL; - goto close_fd; + goto close_dev; } struct nvme_resv_register_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .rrega = cfg.rrega, .cptpl = cfg.cptpl, @@ -6085,8 +6282,8 @@ static int resv_register(int argc, char **argv, struct command *cmd, struct plug else printf("NVME Reservation success\n"); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -6106,7 +6303,8 @@ static int resv_release(int argc, char **argv, struct command *cmd, struct plugi const char *iekey = "ignore existing res. key"; const char *rtype = "reservation type"; const char *rrela = "reservation release action"; - int err, fd; + struct nvme_dev *dev; + int err; struct config { __u32 namespace_id; @@ -6133,26 +6331,26 @@ static int resv_release(int argc, char **argv, struct command *cmd, struct plugi OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } } if (cfg.rrela > 7) { fprintf(stderr, "invalid rrela:%d\n", cfg.rrela); err = -EINVAL; - goto close_fd; + goto close_dev; } struct nvme_resv_release_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .rtype = cfg.rtype, .rrela = cfg.rrela, @@ -6169,8 +6367,8 @@ static int resv_release(int argc, char **argv, struct command *cmd, struct plugi else printf("NVME Reservation Release success\n"); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -6189,7 +6387,8 @@ static int resv_report(int argc, char **argv, struct command *cmd, struct plugin struct nvme_resv_status *status; enum nvme_print_flags flags; - int err, fd, size; + struct nvme_dev *dev; + int err, size; struct config { __u32 namespace_id; @@ -6216,21 +6415,21 @@ static int resv_report(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.raw_binary) flags = BINARY; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } } @@ -6244,13 +6443,13 @@ static int resv_report(int argc, char **argv, struct command *cmd, struct plugin if (posix_memalign((void **)&status, getpagesize(), size)) { fprintf(stderr, "No memory for resv report:%d\n", size); err = -ENOMEM; - goto close_fd; + goto close_dev; } memset(status, 0, size); struct nvme_resv_report_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .eds = cfg.eds, .len = size, @@ -6266,8 +6465,8 @@ static int resv_report(int argc, char **argv, struct command *cmd, struct plugin else fprintf(stderr, "reservation report: %s\n", nvme_strerror(errno)); free(status); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -6286,7 +6485,7 @@ static int submit_io(int opcode, char *command, const char *desc, struct timeval start_time, end_time; void *buffer, *mbuffer = NULL; int err = 0; - int dfd, mfd, fd; + int dfd, mfd; int flags = opcode & 1 ? O_RDONLY : O_WRONLY | O_CREAT; int mode = S_IRUSR | S_IWUSR |S_IRGRP | S_IWGRP| S_IROTH; __u16 control = 0; @@ -6297,6 +6496,7 @@ static int submit_io(int opcode, char *command, const char *desc, struct nvme_id_ns ns; struct nvme_nvm_id_ns nvm_ns; __u8 lba_index, ms = 0, sts = 0, pif = 0; + struct nvme_dev *dev; const char *namespace_id = "Identifier of desired namespace"; const char *start_block = "64-bit addr of first block to access"; @@ -6399,15 +6599,15 @@ static int submit_io(int opcode, char *command, const char *desc, }; if (opcode != nvme_cmd_write) { - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; } else { err = argconfig_parse(argc, argv, desc, opts); if (err) goto ret; - err = fd = open_exclusive(argc, argv, cfg.force); - if (err < 0) { + err = open_exclusive(&dev, argc, argv, cfg.force); + if (err) { if (errno == EBUSY) { fprintf(stderr, "Failed to open %s.\n", basename(argv[optind])); @@ -6424,17 +6624,17 @@ static int submit_io(int opcode, char *command, const char *desc, } if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } } dfd = mfd = opcode & 1 ? STDIN_FILENO : STDOUT_FILENO; if (cfg.prinfo > 0xf) { err = -EINVAL; - goto close_fd; + goto close_dev; } dsmgmt = cfg.dsmgmt; @@ -6450,7 +6650,7 @@ static int submit_io(int opcode, char *command, const char *desc, fprintf(stderr, "Invalid directive type, %x\n", cfg.dtype); err = -EINVAL; - goto close_fd; + goto close_dev; } control |= cfg.dtype << 4; dsmgmt |= ((__u32)cfg.dspec) << 16; @@ -6461,7 +6661,7 @@ static int submit_io(int opcode, char *command, const char *desc, if (dfd < 0) { perror(cfg.data); err = -EINVAL; - goto close_fd; + goto close_dev; } } @@ -6480,9 +6680,9 @@ static int submit_io(int opcode, char *command, const char *desc, goto close_mfd; } - if (nvme_get_logical_block_size(fd, cfg.namespace_id, + if (nvme_get_logical_block_size(dev_fd(dev), cfg.namespace_id, &logical_block_size) < 0) - goto close_mfd; + goto close_mfd; buffer_size = ((long long)cfg.block_count + 1) * logical_block_size; if (cfg.data_size < buffer_size) { @@ -6499,7 +6699,7 @@ static int submit_io(int opcode, char *command, const char *desc, } if (cfg.metadata_size) { - err = nvme_identify_ns(fd, cfg.namespace_id, &ns); + err = nvme_cli_identify_ns(dev, cfg.namespace_id, &ns); if (err > 0) { nvme_show_status(err); goto free_buffer; @@ -6511,7 +6711,8 @@ static int submit_io(int opcode, char *command, const char *desc, nvme_id_ns_flbas_to_lbaf_inuse(ns.flbas, &lba_index); ms = ns.lbaf[lba_index].ms; - err = nvme_identify_ns_csi(fd, 1, 0, NVME_CSI_NVM, &nvm_ns); + err = nvme_identify_ns_csi(dev_fd(dev), 1, 0, NVME_CSI_NVM, + &nvm_ns); if (!err) { sts = nvm_ns.elbaf[lba_index] & NVME_NVM_ELBAF_STS_MASK; pif = (nvm_ns.elbaf[lba_index] & NVME_NVM_ELBAF_PIF_MASK) >> 7; @@ -6580,7 +6781,7 @@ static int submit_io(int opcode, char *command, const char *desc, struct nvme_io_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .slba = cfg.start_block, .nlb = cfg.block_count, @@ -6633,8 +6834,8 @@ close_mfd: close(mfd); close_dfd: close(dfd); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -6664,11 +6865,12 @@ static int write_cmd(int argc, char **argv, struct command *cmd, struct plugin * static int verify_cmd(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - int err, fd; __u16 control = 0; __u8 lba_index, sts = 0, pif = 0; struct nvme_id_ns ns; struct nvme_nvm_id_ns nvm_ns; + struct nvme_dev *dev; + int err; const char *desc = "Verify specified logical blocks on the given device."; const char *namespace_id = "desired namespace"; @@ -6727,13 +6929,13 @@ static int verify_cmd(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (cfg.prinfo > 0xf) { err = EINVAL; - goto close_fd; + goto close_dev; } control |= (cfg.prinfo << 10); @@ -6745,23 +6947,24 @@ static int verify_cmd(int argc, char **argv, struct command *cmd, struct plugin control |= NVME_IO_STC; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } } - err = nvme_identify_ns(fd, cfg.namespace_id, &ns); + err = nvme_cli_identify_ns(dev, cfg.namespace_id, &ns); if (err) { nvme_show_status(err); - goto close_fd; + goto close_dev; } else if (err < 0) { fprintf(stderr, "identify namespace: %s\n", nvme_strerror(errno)); - goto close_fd; + goto close_dev; } - err = nvme_identify_ns_csi(fd, cfg.namespace_id, 0, NVME_CSI_NVM, &nvm_ns); + err = nvme_identify_ns_csi(dev_fd(dev), cfg.namespace_id, 0, + NVME_CSI_NVM, &nvm_ns); if (!err) { nvme_id_ns_flbas_to_lbaf_inuse(ns.flbas, &lba_index); sts = nvm_ns.elbaf[lba_index] & NVME_NVM_ELBAF_STS_MASK; @@ -6770,12 +6973,12 @@ static int verify_cmd(int argc, char **argv, struct command *cmd, struct plugin if (invalid_tags(cfg.storage_tag, cfg.ref_tag, sts, pif)) { err = -EINVAL; - goto close_fd; + goto close_dev; } struct nvme_io_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .slba = cfg.start_block, .nlb = cfg.block_count, @@ -6797,8 +7000,8 @@ static int verify_cmd(int argc, char **argv, struct command *cmd, struct plugin else printf("NVME Verify Success\n"); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -6818,8 +7021,9 @@ static int sec_recv(int argc, char **argv, struct command *cmd, struct plugin *p const char *raw = "dump output in binary format"; const char *namespace_id = "desired namespace"; const char *nssf = "NVMe Security Specific Field"; - int err, fd; + struct nvme_dev *dev; void *sec_buf = NULL; + int err; struct config { __u32 namespace_id; @@ -6852,8 +7056,8 @@ static int sec_recv(int argc, char **argv, struct command *cmd, struct plugin *p OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (cfg.size) { @@ -6861,13 +7065,13 @@ static int sec_recv(int argc, char **argv, struct command *cmd, struct plugin *p fprintf(stderr, "No memory for security size:%d\n", cfg.size); err = -ENOMEM; - goto close_fd; + goto close_dev; } } struct nvme_security_receive_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .nssf = cfg.nssf, .spsp0 = cfg.spsp & 0xff, @@ -6894,8 +7098,8 @@ static int sec_recv(int argc, char **argv, struct command *cmd, struct plugin *p free(sec_buf); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -6918,8 +7122,9 @@ static int get_lba_status(int argc, char **argv, struct command *cmd, enum nvme_print_flags flags; unsigned long buf_len; - int err, fd; + struct nvme_dev *dev; void *buf; + int err; struct config { __u32 namespace_id; @@ -6952,30 +7157,30 @@ static int get_lba_status(int argc, char **argv, struct command *cmd, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto err; err = flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (!cfg.atype) { fprintf(stderr, "action type (--action) has to be given\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } buf_len = (cfg.mndw + 1) * 4; buf = calloc(1, buf_len); if (!buf) { err = -ENOMEM; - goto close_fd; + goto close_dev; } struct nvme_get_lba_status_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .slba = cfg.slba, .mndw = cfg.mndw, @@ -6993,8 +7198,8 @@ static int get_lba_status(int argc, char **argv, struct command *cmd, else fprintf(stderr, "get lba status: %s\n", nvme_strerror(errno)); free(buf); -close_fd: - close(fd); +close_dev: + dev_close(dev); err: return err; } @@ -7012,7 +7217,8 @@ static int capacity_mgmt(int argc, char **argv, struct command *cmd, struct plug const char *cap_upper = "Most significant 32 bits of the capacity in bytes of the "\ "Endurance Group or NVM Set to be created"; - int err = -1, fd; + struct nvme_dev *dev; + int err = -1; __u32 result; struct config { @@ -7037,19 +7243,19 @@ static int capacity_mgmt(int argc, char **argv, struct command *cmd, struct plug OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (cfg.operation > 0xf) { fprintf(stderr, "invalid operation field: %u\n", cfg.operation); err = -1; - goto close_fd; + goto close_dev; } struct nvme_capacity_mgmt_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .op = cfg.operation, .element_id = cfg.element_id, .cdw11 = cfg.dw11, @@ -7070,8 +7276,8 @@ static int capacity_mgmt(int argc, char **argv, struct command *cmd, struct plug else if (err < 0) fprintf(stderr, "capacity management: %s\n", nvme_strerror(errno)); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -7090,10 +7296,11 @@ static int dir_receive(int argc, char **argv, struct command *cmd, struct plugin const char *human_readable = "show directive in readable format"; enum nvme_print_flags flags = NORMAL; - int err, fd; + struct nvme_dev *dev; __u32 result; __u32 dw12 = 0; void *buf = NULL; + int err; struct config { __u32 namespace_id; @@ -7129,8 +7336,8 @@ static int dir_receive(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (cfg.human_readable) @@ -7148,7 +7355,7 @@ static int dir_receive(int argc, char **argv, struct command *cmd, struct plugin default: fprintf(stderr, "invalid directive operations for Identify Directives\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } break; case NVME_DIRECTIVE_DTYPE_STREAMS: @@ -7167,26 +7374,26 @@ static int dir_receive(int argc, char **argv, struct command *cmd, struct plugin default: fprintf(stderr, "invalid directive operations for Streams Directives\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } break; default: fprintf(stderr, "invalid directive type\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.data_len) { if (posix_memalign(&buf, getpagesize(), cfg.data_len)) { err = -ENOMEM; - goto close_fd; + goto close_dev; } memset(buf, 0, cfg.data_len); } struct nvme_directive_recv_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .dspec = cfg.dspec, .doper = cfg.doper, @@ -7208,8 +7415,8 @@ static int dir_receive(int argc, char **argv, struct command *cmd, struct plugin fprintf(stderr, "dir-receive: %s\n", nvme_strerror(errno)); free(buf); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -7242,7 +7449,8 @@ static int lockdown_cmd(int argc, char **argv, struct command *cmd, struct plugi "List that is used by the command.If this field is cleared to 0h,"\ "then no UUID index is specified"; - int fd, err = -1; + struct nvme_dev *dev; + int err = -1; struct config { __u8 ofi; @@ -7269,35 +7477,35 @@ static int lockdown_cmd(int argc, char **argv, struct command *cmd, struct plugi OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; /* check for input argument limit */ if (cfg.ifc > 3) { fprintf(stderr, "invalid interface settings:%d\n", cfg.ifc); err = -1; - goto close_fd; + goto close_dev; } if (cfg.prhbt > 1) { fprintf(stderr, "invalid prohibit settings:%d\n", cfg.prhbt); err = -1; - goto close_fd; + goto close_dev; } if (cfg.scp > 15) { fprintf(stderr, "invalid scope settings:%d\n", cfg.scp); err = -1; - goto close_fd; + goto close_dev; } if (cfg.uuid > 127) { fprintf(stderr, "invalid UUID index settings:%d\n", cfg.uuid); err = -1; - goto close_fd; + goto close_dev; } struct nvme_lockdown_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .scp = cfg.scp, .prhbt = cfg.prhbt, .ifc = cfg.ifc, @@ -7314,8 +7522,8 @@ static int lockdown_cmd(int argc, char **argv, struct command *cmd, struct plugi else printf("Lockdown Command is Successful\n"); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -7351,7 +7559,8 @@ static int passthru(int argc, char **argv, bool admin, int flags; int mode = S_IRUSR | S_IWUSR |S_IRGRP | S_IWGRP| S_IROTH; void *data = NULL, *mdata = NULL; - int err = 0, dfd, mfd, fd; + int err = 0, dfd, mfd; + struct nvme_dev *dev; __u32 result; bool huge = false; const char *cmd_name = NULL; @@ -7439,8 +7648,8 @@ static int passthru(int argc, char **argv, bool admin, OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; if (cfg.opcode & 0x01) @@ -7464,7 +7673,7 @@ static int passthru(int argc, char **argv, bool admin, if (dfd < 0) { perror(cfg.input_file); err = -EINVAL; - goto close_fd; + goto close_dev; } } @@ -7541,17 +7750,25 @@ static int passthru(int argc, char **argv, bool admin, gettimeofday(&start_time, NULL); if (admin) - err = nvme_admin_passthru(fd, cfg.opcode, cfg.flags, cfg.rsvd, - cfg.namespace_id, cfg.cdw2, cfg.cdw3, cfg.cdw10, - cfg.cdw11, cfg.cdw12, cfg.cdw13, cfg.cdw14, - cfg.cdw15, cfg.data_len, data, cfg.metadata_len, - mdata, cfg.timeout, &result); + err = nvme_admin_passthru(dev_fd(dev), cfg.opcode, cfg.flags, + cfg.rsvd, + cfg.namespace_id, cfg.cdw2, + cfg.cdw3, cfg.cdw10, + cfg.cdw11, cfg.cdw12, cfg.cdw13, + cfg.cdw14, + cfg.cdw15, cfg.data_len, data, + cfg.metadata_len, + mdata, cfg.timeout, &result); else - err = nvme_io_passthru(fd, cfg.opcode, cfg.flags, cfg.rsvd, - cfg.namespace_id, cfg.cdw2, cfg.cdw3, cfg.cdw10, - cfg.cdw11, cfg.cdw12, cfg.cdw13, cfg.cdw14, - cfg.cdw15, cfg.data_len, data, cfg.metadata_len, - mdata, cfg.timeout, &result); + err = nvme_io_passthru(dev_fd(dev), cfg.opcode, cfg.flags, + cfg.rsvd, + cfg.namespace_id, cfg.cdw2, cfg.cdw3, + cfg.cdw10, + cfg.cdw11, cfg.cdw12, cfg.cdw13, + cfg.cdw14, + cfg.cdw15, cfg.data_len, data, + cfg.metadata_len, + mdata, cfg.timeout, &result); gettimeofday(&end_time, NULL); cmd_name = nvme_cmd_to_string(admin, cfg.opcode); @@ -7590,10 +7807,10 @@ close_dfd: if (strlen(cfg.input_file)) close(dfd); close_mfd: - if (strlen(cfg.metadata)) + if (cfg.metadata && strlen(cfg.metadata)) close(mfd); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -8006,14 +8223,14 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct switch (hmac) { case 1: if (strlen(cfg.key) != 65) { - fprintf(stderr, "Invalid key length %lu for SHA(256)\n", + fprintf(stderr, "Invalid key length %zu for SHA(256)\n", strlen(cfg.key)); return -EINVAL; } break; case 2: if (strlen(cfg.key) != 89) { - fprintf(stderr, "Invalid key length %lu for SHA(384)\n", + fprintf(stderr, "Invalid key length %zu for SHA(384)\n", strlen(cfg.key)); return -EINVAL; } @@ -8052,6 +8269,76 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct return 0; } +static int show_topology_cmd(int argc, char **argv, struct command *command, struct plugin *plugin) +{ + const char *desc = "Show the topolog\n"; + const char *verbose = "Increase output verbosity"; + const char *ranking = "Ranking order: namespace|ctrl"; + enum nvme_print_flags flags; + nvme_root_t r; + enum nvme_cli_topo_ranking rank; + int err; + + struct config { + char *output_format; + int verbose; + char *ranking; + }; + + struct config cfg = { + .output_format = "normal", + .verbose = 0, + .ranking = "namespace", + }; + + OPT_ARGS(opts) = { + OPT_FMT("output-format", 'o', &cfg.output_format, output_format), + OPT_INCR("verbose", 'v', &cfg.verbose, verbose), + OPT_FMT("ranking", 'r', &cfg.ranking, ranking), + OPT_END() + }; + + err = argconfig_parse(argc, argv, desc, opts); + if (err) + return err; + + err = flags = validate_output_format(cfg.output_format); + if (flags < 0) + return err; + if (cfg.verbose) + flags |= VERBOSE; + + if (!strcmp(cfg.ranking, "namespace")) + rank = NVME_CLI_TOPO_NAMESPACE; + else if (!strcmp(cfg.ranking, "ctrl")) + rank = NVME_CLI_TOPO_CTRL; + else { + fprintf(stderr, "Invalid ranking argument: %s\n", + cfg.ranking); + return -EINVAL; + } + + r = nvme_create_root(stderr, map_log_level(cfg.verbose, false)); + if (!r) { + fprintf(stderr, "Failed to create topology root: %s\n", + nvme_strerror(errno)); + return -errno; + } + + err = nvme_scan_topology(r, NULL, NULL); + if (err < 0) { + fprintf(stderr, "Failed to scan topology: %s\n", + nvme_strerror(errno)); + nvme_free_tree(r); + return err; + } + + nvme_show_topology(r, flags, rank); + nvme_free_tree(r); + + return err; +} + static int discover_cmd(int argc, char **argv, struct command *command, struct plugin *plugin) { const char *desc = "Send Get Log Page request to Discovery Controller."; diff --git a/nvme.h b/nvme.h index 5afeece..c13ca8e 100644 --- a/nvme.h +++ b/nvme.h @@ -19,8 +19,12 @@ #include #include #include +#include #include #include +#include + +#include #include "plugin.h" #include "util/json.h" @@ -34,13 +38,68 @@ enum nvme_print_flags { BINARY = 1 << 3, /* binary dump raw bytes */ }; +enum nvme_cli_topo_ranking { + NVME_CLI_TOPO_NAMESPACE, + NVME_CLI_TOPO_CTRL, +}; + #define SYS_NVME "/sys/class/nvme" +enum nvme_dev_type { + NVME_DEV_DIRECT, + NVME_DEV_MI, +}; + +struct nvme_dev { + enum nvme_dev_type type; + union { + struct { + int fd; + struct stat stat; + } direct; + struct { + nvme_root_t root; + nvme_mi_ep_t ep; + nvme_mi_ctrl_t ctrl; + } mi; + }; + + const char *name; +}; + +#define dev_fd(d) __dev_fd(d, __func__, __LINE__) + +static inline int __dev_fd(struct nvme_dev *dev, const char *func, int line) +{ + if (dev->type != NVME_DEV_DIRECT) { + fprintf(stderr, + "warning: %s:%d not a direct transport!\n", + func, line); + return -1; + } + return dev->direct.fd; +} + +static inline nvme_mi_ep_t dev_mi_ep(struct nvme_dev *dev) +{ + if (dev->type != NVME_DEV_MI) { + fprintf(stderr, + "warning: not a MI transport!\n"); + return NULL; + } + return dev->mi.ep; +} + void register_extension(struct plugin *plugin); -int parse_and_open(int argc, char **argv, const char *desc, + +/* + * parse_and_open - parses arguments and opens the NVMe device, populating @dev + */ +int parse_and_open(struct nvme_dev **dev, int argc, char **argv, const char *desc, const struct argconfig_commandline_options *clo); -extern const char *devicename; +void dev_close(struct nvme_dev *dev); + extern const char *output_format; enum nvme_print_flags validate_output_format(const char *format); diff --git a/nvmf-autoconnect/systemd/nvmf-autoconnect.service.in b/nvmf-autoconnect/systemd/nvmf-autoconnect.service.in index d83d9a1..c57ff71 100644 --- a/nvmf-autoconnect/systemd/nvmf-autoconnect.service.in +++ b/nvmf-autoconnect/systemd/nvmf-autoconnect.service.in @@ -1,6 +1,7 @@ [Unit] Description=Connect NVMe-oF subsystems automatically during boot -ConditionPathExists=@SYSCONFDIR@/nvme/discovery.conf +ConditionPathExists=|!@SYSCONFDIR@/nvme/config.json +ConditionPathExists=|!@SYSCONFDIR@/nvme/discovery.conf After=network-online.target Before=remote-fs-pre.target diff --git a/nvmf-autoconnect/udev-rules/70-nvmf-autoconnect.rules.in b/nvmf-autoconnect/udev-rules/70-nvmf-autoconnect.rules.in index 434cc08..e751ee0 100644 --- a/nvmf-autoconnect/udev-rules/70-nvmf-autoconnect.rules.in +++ b/nvmf-autoconnect/udev-rules/70-nvmf-autoconnect.rules.in @@ -4,16 +4,29 @@ # controller and connect to elements in the discovery log. # # +ACTION!="change", GOTO="autoconnect_end" + +# For backwards compatibility. Make sure HOST_IFACE is not an empty string. +ENV{NVME_HOST_IFACE}=="", ENV{NVME_HOST_IFACE}="none" # Events from persistent discovery controllers or nvme-fc transport events # NVME_AEN: # type 0x2 (NOTICE) info 0xf0 (DISCOVERY_LOG_CHANGE) log-page-id 0x70 (DISCOVERY_LOG_PAGE) ACTION=="change", SUBSYSTEM=="nvme", ENV{NVME_AEN}=="0x70f002",\ ENV{NVME_TRTYPE}=="*", ENV{NVME_TRADDR}=="*", \ - ENV{NVME_TRSVCID}=="*", ENV{NVME_HOST_TRADDR}=="*", \ - RUN+="@SYSTEMCTL@ --no-block start nvmf-connect@--device=$kernel\t--transport=$env{NVME_TRTYPE}\t--traddr=$env{NVME_TRADDR}\t--trsvcid=$env{NVME_TRSVCID}\t--host-traddr=$env{NVME_HOST_TRADDR}.service" + ENV{NVME_TRSVCID}=="*", ENV{NVME_HOST_TRADDR}=="*", ENV{NVME_HOST_IFACE}=="*", \ + RUN+="@SYSTEMCTL@ --no-block start nvmf-connect@--device=$kernel\t--transport=$env{NVME_TRTYPE}\t--traddr=$env{NVME_TRADDR}\t--trsvcid=$env{NVME_TRSVCID}\t--host-traddr=$env{NVME_HOST_TRADDR}\t--host-iface=$env{NVME_HOST_IFACE}.service" # nvme-fc transport generated events (old-style for compatibility) ACTION=="change", SUBSYSTEM=="fc", ENV{FC_EVENT}=="nvmediscovery", \ ENV{NVMEFC_HOST_TRADDR}=="*", ENV{NVMEFC_TRADDR}=="*", \ RUN+="@SYSTEMCTL@ --no-block start nvmf-connect@--device=none\t--transport=fc\t--traddr=$env{NVMEFC_TRADDR}\t--trsvcid=none\t--host-traddr=$env{NVMEFC_HOST_TRADDR}.service" + +# A discovery controller just (re)connected, re-read the discovery log change to +# check if there were any changes since it was last connected. +ACTION=="change", SUBSYSTEM=="nvme", ENV{NVME_EVENT}=="rediscover", ATTR{cntrltype}=="discovery", \ + ENV{NVME_TRTYPE}=="*", ENV{NVME_TRADDR}=="*", \ + ENV{NVME_TRSVCID}=="*", ENV{NVME_HOST_TRADDR}=="*", ENV{NVME_HOST_IFACE}=="*", \ + RUN+="@SYSTEMCTL@ --no-block start nvmf-connect@--device=$kernel\t--transport=$env{NVME_TRTYPE}\t--traddr=$env{NVME_TRADDR}\t--trsvcid=$env{NVME_TRSVCID}\t--host-traddr=$env{NVME_HOST_TRADDR}\t--host-iface=$env{NVME_HOST_IFACE}.service" + +LABEL="autoconnect_end" diff --git a/plugins/dera/dera-nvme.c b/plugins/dera/dera-nvme.c index 1390be0..9408e50 100644 --- a/plugins/dera/dera-nvme.c +++ b/plugins/dera/dera-nvme.c @@ -117,20 +117,21 @@ static int nvme_dera_get_device_status(int fd, enum dera_device_status *result) static int get_status(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - int fd, err; struct nvme_dera_smart_info_log log; enum dera_device_status state = DEVICE_STATUS_FATAL_ERROR; char *desc = "Get the Dera device status"; + struct nvme_dev *dev; + int err; OPT_ARGS(opts) = { OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; - err = nvme_get_log_simple(fd, 0xc0, sizeof(log), &log); + err = nvme_get_log_simple(dev_fd(dev), 0xc0, sizeof(log), &log); if (err) { goto exit; } @@ -153,7 +154,7 @@ static int get_status(int argc, char **argv, struct command *cmd, struct plugin "Runtime Low", }; - err = nvme_dera_get_device_status(fd, &state); + err = nvme_dera_get_device_status(dev_fd(dev), &state); if (!err){ if (state > 0 && state < 4){ printf("device_status : %s %d%% completed\n", dev_status[state], log.rebuild_percent); @@ -205,7 +206,7 @@ exit: if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } diff --git a/plugins/innogrit/innogrit-nvme.c b/plugins/innogrit/innogrit-nvme.c index 220a5a7..b5d40dd 100644 --- a/plugins/innogrit/innogrit-nvme.c +++ b/plugins/innogrit/innogrit-nvme.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "common.h" #include "nvme.h" @@ -20,10 +21,11 @@ static int innogrit_smart_log_additional(int argc, char **argv, struct plugin *plugin) { struct nvme_smart_log smart_log = { 0 }; - int fd, i, iindex; struct vsc_smart_log *pvsc_smart = (struct vsc_smart_log *)smart_log.rsvd232; const char *desc = "Retrieve additional SMART log for the given device "; const char *namespace = "(optional) desired namespace"; + struct nvme_dev *dev; + int err, i, iindex; struct config { __u32 namespace_id; @@ -38,12 +40,12 @@ static int innogrit_smart_log_additional(int argc, char **argv, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; - nvme_get_log_smart(fd, cfg.namespace_id, false, &smart_log); - nvme_show_smart_log(&smart_log, cfg.namespace_id, devicename, NORMAL); + nvme_get_log_smart(dev_fd(dev), cfg.namespace_id, false, &smart_log); + nvme_show_smart_log(&smart_log, cfg.namespace_id, dev->name, NORMAL); printf("DW0[0-1] Defect Cnt : %u\n", pvsc_smart->defect_cnt); printf("DW0[2-3] Slc Spb Cnt : %u\n", pvsc_smart->slc_spb_cnt); @@ -69,11 +71,15 @@ static int innogrit_smart_log_additional(int argc, char **argv, printf("DW17 weight_ec : %u\n", pvsc_smart->weight_ec); printf("DW18 slc_cap_mb : %u\n", pvsc_smart->slc_cap_mb); printf("DW19-20 nand_page_write_cnt : %llu\n", pvsc_smart->nand_page_write_cnt); - - iindex = 21; - for (i = 0; i < (sizeof(pvsc_smart->reserved2)/4); i++) { - if (pvsc_smart->reserved2[i] != 0) - printf("DW%-37d : %u\n", iindex, pvsc_smart->reserved2[i]); + printf("DW21 program_error_cnt : %u\n", pvsc_smart->program_error_cnt); + printf("DW22 erase_error_cnt : %u\n", pvsc_smart->erase_error_cnt); + printf("DW23[0] flash_type : %u\n", pvsc_smart->flash_type); + printf("DW24 hs_crc_err_cnt : %u\n", pvsc_smart->hs_crc_err_cnt); + printf("DW25 ddr_ecc_err_cnt : %u\n", pvsc_smart->ddr_ecc_err_cnt); + iindex = 26; + for (i = 0; i < (sizeof(pvsc_smart->reserved3)/4); i++) { + if (pvsc_smart->reserved3[i] != 0) + printf("DW%-37d : %u\n", iindex, pvsc_smart->reserved3[i]); iindex++; } @@ -163,9 +169,10 @@ static int innogrit_vsc_geteventlog(int argc, char **argv, unsigned int isize, icheck_stopvalue, iend; unsigned char bSortLog = false, bget_nextlog = true; struct evlg_flush_hdr *pevlog = (struct evlg_flush_hdr *)data; - int fd, ret = -1; const char *desc = "Recrieve event log for the given device "; const char *clean_opt = "(optional) 1 for clean event log"; + struct nvme_dev *dev; + int ret = -1; struct config { __u32 clean_flg; @@ -180,9 +187,9 @@ static int innogrit_vsc_geteventlog(int argc, char **argv, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; if (getcwd(currentdir, 128) == NULL) @@ -211,8 +218,10 @@ static int innogrit_vsc_geteventlog(int argc, char **argv, icount++; memset(data, 0, 4096); - ret = nvme_vucmd(fd, NVME_VSC_GET_EVENT_LOG, 0, 0, (SRB_SIGNATURE >> 32), - (SRB_SIGNATURE & 0xFFFFFFFF), (char *)data, 4096); + ret = nvme_vucmd(dev_fd(dev), NVME_VSC_GET_EVENT_LOG, 0, 0, + (SRB_SIGNATURE >> 32), + (SRB_SIGNATURE & 0xFFFFFFFF), + (char *)data, 4096); if (ret == -1) return ret; @@ -277,10 +286,13 @@ static int innogrit_vsc_geteventlog(int argc, char **argv, if (cfg.clean_flg == 1) { printf("Clean eventlog\n"); - nvme_vucmd(fd, NVME_VSC_CLEAN_EVENT_LOG, 0, 0, (SRB_SIGNATURE >> 32), - (SRB_SIGNATURE & 0xFFFFFFFF), (char *)NULL, 0); + nvme_vucmd(dev_fd(dev), NVME_VSC_CLEAN_EVENT_LOG, 0, 0, + (SRB_SIGNATURE >> 32), + (SRB_SIGNATURE & 0xFFFFFFFF), (char *)NULL, 0); } + dev_close(dev); + return ret; } @@ -296,16 +308,17 @@ static int innogrit_vsc_getcdump(int argc, char **argv, struct command *command, unsigned char busevsc = false; unsigned int ipackcount, ipackindex; char fwvera[32]; - int fd, ret = -1; const char *desc = "Recrieve cdump data for the given device "; + struct nvme_dev *dev; + int ret = -1; OPT_ARGS(opts) = { OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; if (getcwd(currentdir, 128) == NULL) return -1; @@ -315,8 +328,9 @@ static int innogrit_vsc_getcdump(int argc, char **argv, struct command *command, ipackindex = 0; memset(data, 0, 4096); - if (nvme_vucmd(fd, NVME_VSC_GET, VSC_FN_GET_CDUMP, 0x00, (SRB_SIGNATURE >> 32), - (SRB_SIGNATURE & 0xFFFFFFFF), (char *)data, 4096) == 0) { + if (nvme_vucmd(dev_fd(dev), NVME_VSC_GET, VSC_FN_GET_CDUMP, 0x00, + (SRB_SIGNATURE >> 32), (SRB_SIGNATURE & 0xFFFFFFFF), + (char *)data, 4096) == 0) { memcpy(&cdumpinfo, &data[3072], sizeof(cdumpinfo)); if (cdumpinfo.sig == 0x5a5b5c5d) { busevsc = true; @@ -337,7 +351,9 @@ static int innogrit_vsc_getcdump(int argc, char **argv, struct command *command, if (busevsc == false) { memset(data, 0, 4096); - ret = nvme_get_nsid_log(fd, true, 0x07, NVME_NSID_ALL, 4096, data); + ret = nvme_get_nsid_log(dev_fd(dev), true, 0x07, + NVME_NSID_ALL, + 4096, data); if (ret != 0) return ret; @@ -360,10 +376,15 @@ static int innogrit_vsc_getcdump(int argc, char **argv, struct command *command, for (icur = 0; icur < itotal; icur += 4096) { memset(data, 0, 4096); if (busevsc) - ret = nvme_vucmd(fd, NVME_VSC_GET, VSC_FN_GET_CDUMP, 0x00, (SRB_SIGNATURE >> 32), - (SRB_SIGNATURE & 0xFFFFFFFF), (char *)data, 4096); + ret = nvme_vucmd(dev_fd(dev), NVME_VSC_GET, + VSC_FN_GET_CDUMP, 0x00, + (SRB_SIGNATURE >> 32), + (SRB_SIGNATURE & 0xFFFFFFFF), + (char *)data, 4096); else - ret = nvme_get_nsid_log(fd, true, 0x07, NVME_NSID_ALL, 4096, data); + ret = nvme_get_nsid_log(dev_fd(dev), true, + 0x07, + NVME_NSID_ALL, 4096, data); if (ret != 0) return ret; @@ -379,10 +400,16 @@ static int innogrit_vsc_getcdump(int argc, char **argv, struct command *command, if (ipackindex != ipackcount) { memset(data, 0, 4096); if (busevsc) - ret = nvme_vucmd(fd, NVME_VSC_GET, VSC_FN_GET_CDUMP, 0x00, (SRB_SIGNATURE >> 32), - (SRB_SIGNATURE & 0xFFFFFFFF), (char *)data, 4096); + ret = nvme_vucmd(dev_fd(dev), NVME_VSC_GET, + VSC_FN_GET_CDUMP, 0x00, + (SRB_SIGNATURE >> 32), + (SRB_SIGNATURE & 0xFFFFFFFF), + (char *)data, 4096); else - ret = nvme_get_nsid_log(fd, true, 0x07, NVME_NSID_ALL, 4096, data); + ret = nvme_get_nsid_log(dev_fd(dev), true, + 0x07, + NVME_NSID_ALL, 4096, + data); if (ret != 0) return ret; @@ -398,5 +425,6 @@ static int innogrit_vsc_getcdump(int argc, char **argv, struct command *command, } printf("\n"); + dev_close(dev); return ret; } diff --git a/plugins/innogrit/typedef.h b/plugins/innogrit/typedef.h index d4ea269..a97a008 100644 --- a/plugins/innogrit/typedef.h +++ b/plugins/innogrit/typedef.h @@ -56,7 +56,13 @@ struct vsc_smart_log { unsigned int weight_ec; unsigned int slc_cap_mb; unsigned long long nand_page_write_cnt; - unsigned int reserved2[49]; + unsigned int program_error_cnt; + unsigned int erase_error_cnt; + u_char flash_type; + u_char reserved2[3]; + unsigned int hs_crc_err_cnt; + unsigned int ddr_ecc_err_cnt; + unsigned int reserved3[44]; }; #pragma pack(pop) diff --git a/plugins/intel/intel-nvme.c b/plugins/intel/intel-nvme.c index 1bf6627..f660b84 100644 --- a/plugins/intel/intel-nvme.c +++ b/plugins/intel/intel-nvme.c @@ -344,7 +344,8 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd, const char *json= "Dump output in json format"; struct nvme_additional_smart_log smart_log; - int err, fd; + struct nvme_dev *dev; + int err; struct config { __u32 namespace_id; @@ -363,22 +364,25 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; - err = nvme_get_log_simple(fd, 0xca, sizeof(smart_log), &smart_log); + err = nvme_get_log_simple(dev_fd(dev), 0xca, sizeof(smart_log), + &smart_log); if (!err) { if (cfg.json) - show_intel_smart_log_jsn(&smart_log, cfg.namespace_id, devicename); + show_intel_smart_log_jsn(&smart_log, cfg.namespace_id, + dev->name); else if (!cfg.raw_binary) - show_intel_smart_log(&smart_log, cfg.namespace_id, devicename); + show_intel_smart_log(&smart_log, cfg.namespace_id, + dev->name); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } else if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } @@ -386,9 +390,9 @@ static int get_market_log(int argc, char **argv, struct command *cmd, struct plu { const char *desc = "Get Intel Marketing Name log and show it."; const char *raw = "dump output in binary format"; - + struct nvme_dev *dev; char log[512]; - int err, fd; + int err; struct config { bool raw_binary; @@ -402,11 +406,11 @@ static int get_market_log(int argc, char **argv, struct command *cmd, struct plu OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; - err = nvme_get_log_simple(fd, 0xdd, sizeof(log), log); + err = nvme_get_log_simple(dev_fd(dev), 0xdd, sizeof(log), log); if (!err) { if (!cfg.raw_binary) printf("Intel Marketing Name Log:\n%s\n", log); @@ -414,7 +418,7 @@ static int get_market_log(int argc, char **argv, struct command *cmd, struct plu d_raw((unsigned char *)&log, sizeof(log)); } else if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } @@ -447,7 +451,8 @@ static void show_temp_stats(struct intel_temp_stats *stats) static int get_temp_stats_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { struct intel_temp_stats stats; - int err, fd; + struct nvme_dev *dev; + int err; const char *desc = "Get Temperature Statistics log and show it."; const char *raw = "dump output in binary format"; @@ -463,11 +468,11 @@ static int get_temp_stats_log(int argc, char **argv, struct command *cmd, struct OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; - err = nvme_get_log_simple(fd, 0xc5, sizeof(stats), &stats); + err = nvme_get_log_simple(dev_fd(dev), 0xc5, sizeof(stats), &stats); if (!err) { if (!cfg.raw_binary) show_temp_stats(&stats); @@ -475,7 +480,7 @@ static int get_temp_stats_log(int argc, char **argv, struct command *cmd, struct d_raw((unsigned char *)&stats, sizeof(stats)); } else if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } @@ -1024,9 +1029,9 @@ static void show_lat_stats(int write) static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - - int err, fd; __u8 data[NAND_LAT_STATS_LEN]; + struct nvme_dev *dev; + int err; const char *desc = "Get Intel Latency Statistics log and show it."; const char *raw = "Dump output in binary format"; @@ -1049,15 +1054,15 @@ static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; /* For optate, latency stats are deleted every time their LID is pulled. * Therefore, we query the longest lat_stats log page first. */ - err = nvme_get_log_simple(fd, cfg.write ? 0xc2 : 0xc1, - sizeof(data), &data); + err = nvme_get_log_simple(dev_fd(dev), cfg.write ? 0xc2 : 0xc1, + sizeof(data), &data); media_version[0] = (data[1] << 8) | data[0]; media_version[1] = (data[3] << 8) | data[2]; @@ -1071,7 +1076,7 @@ static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct struct nvme_get_features_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .fid = 0xf7, .nsid = 0, .sel = 0, @@ -1123,7 +1128,7 @@ static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct } close_fd: - close(fd); + dev_close(dev); return err; } @@ -1338,13 +1343,14 @@ static int get_internal_log(int argc, char **argv, struct command *command, { __u8 buf[0x2000]; char f[0x100]; - int err, fd, output, i, j, count = 0, core_num = 1; + int err, output, i, j, count = 0, core_num = 1; struct nvme_passthru_cmd cmd; struct intel_cd_log cdlog; struct intel_vu_log *intel = malloc(sizeof(struct intel_vu_log)); struct intel_vu_nlog *intel_nlog = (struct intel_vu_nlog *)buf; struct intel_assert_dump *ad = (struct intel_assert_dump *) intel->reserved; struct intel_event_header *ehdr = (struct intel_event_header *)intel->reserved; + struct nvme_dev *dev; const char *desc = "Get Intel Firmware Log and save it."; const char *log = "Log type: 0, 1, or 2 for nlog, event log, and assert log, respectively."; @@ -1380,10 +1386,10 @@ static int get_internal_log(int argc, char **argv, struct command *command, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) { free(intel); - return fd; + return err; } if (cfg.log > 2 || cfg.core > 4 || cfg.lnum > 255) { @@ -1392,7 +1398,7 @@ static int get_internal_log(int argc, char **argv, struct command *command, } if (!cfg.file) { - err = setup_file(f, cfg.file, fd, cfg.log); + err = setup_file(f, cfg.file, dev_fd(dev), cfg.log); if (err) goto out_free; cfg.file = f; @@ -1410,7 +1416,8 @@ static int get_internal_log(int argc, char **argv, struct command *command, goto out_free; } - err = read_header(&cmd, buf, fd, cdlog.u.entireDword, cfg.namespace_id); + err = read_header(&cmd, buf, dev_fd(dev), cdlog.u.entireDword, + cfg.namespace_id); if (err) goto out; memcpy(intel, buf, sizeof(*intel)); @@ -1419,7 +1426,7 @@ static int get_internal_log(int argc, char **argv, struct command *command, if ((intel->ver.major < 1 && intel->ver.minor < 1) || (intel->ver.major <= 1 && intel->ver.minor <= 1 && cfg.log == 0)) { cmd.addr = (unsigned long)(void *)buf; - err = get_internal_log_old(buf, output, fd, &cmd); + err = get_internal_log_old(buf, output, dev_fd(dev), &cmd); goto out; } @@ -1463,7 +1470,9 @@ static int get_internal_log(int argc, char **argv, struct command *command, cmd.cdw10 = 0x400; cmd.data_len = min(0x400, ad[i].assertsize) * 4; err = read_entire_cmd(&cmd, ad[i].assertsize, - 0x400, output, fd, buf); + 0x400, output, + dev_fd(dev), + buf); if (err) goto out; @@ -1472,8 +1481,9 @@ static int get_internal_log(int argc, char **argv, struct command *command, if (count > 1) cdlog.u.fields.selectNlog = i; - err = read_header(&cmd, buf, fd, cdlog.u.entireDword, - cfg.namespace_id); + err = read_header(&cmd, buf, dev_fd(dev), + cdlog.u.entireDword, + cfg.namespace_id); if (err) goto out; err = write_header(buf, output, sizeof(*intel_nlog)); @@ -1485,7 +1495,9 @@ static int get_internal_log(int argc, char **argv, struct command *command, cmd.cdw10 = 0x400; cmd.data_len = min(0x1000, intel_nlog->nlogbytesize); err = read_entire_cmd(&cmd, intel_nlog->nlogbytesize / 4, - 0x400, output, fd, buf); + 0x400, output, + dev_fd(dev), + buf); if (err) goto out; } else if (cfg.log == 1) { @@ -1493,7 +1505,9 @@ static int get_internal_log(int argc, char **argv, struct command *command, cmd.cdw10 = 0x400; cmd.data_len = 0x400; err = read_entire_cmd(&cmd, ehdr->edumps[j].coresize, - 0x400, output, fd, buf); + 0x400, output, + dev_fd(dev), + buf); if (err) goto out; } @@ -1511,14 +1525,13 @@ out: close(output); out_free: free(intel); - close(fd); + dev_close(dev); return err; } static int enable_lat_stats_tracking(int argc, char **argv, struct command *command, struct plugin *plugin) { - int err, fd; const char *desc = ( "Enable/Disable Intel Latency Statistics Tracking.\n" "No argument prints current status."); @@ -1531,8 +1544,10 @@ static int enable_lat_stats_tracking(int argc, char **argv, const __u32 cdw12 = 0x0; const __u32 data_len = 32; const __u32 save = 0; - __u32 result; + struct nvme_dev *dev; void *buf = NULL; + __u32 result; + int err; struct config { bool enable, disable; @@ -1549,7 +1564,7 @@ static int enable_lat_stats_tracking(int argc, char **argv, {NULL} }; - fd = parse_and_open(argc, argv, desc, command_line_options); + err = parse_and_open(&dev, argc, argv, desc, command_line_options); enum Option { None = -1, @@ -1564,12 +1579,12 @@ static int enable_lat_stats_tracking(int argc, char **argv, else if (cfg.enable || cfg.disable) option = cfg.enable; - if (fd < 0) - return fd; + if (err) + return err; struct nvme_get_features_args args_get = { .args_size = sizeof(args_get), - .fd = fd, + .fd = dev_fd(dev), .fid = fid, .nsid = nsid, .sel = sel, @@ -1583,7 +1598,7 @@ static int enable_lat_stats_tracking(int argc, char **argv, struct nvme_set_features_args args_set = { .args_size = sizeof(args_set), - .fd = fd, + .fd = dev_fd(dev), .fid = fid, .nsid = nsid, .cdw11 = option, @@ -1606,7 +1621,7 @@ static int enable_lat_stats_tracking(int argc, char **argv, fid, result); } else { printf("Could not read feature id 0xE2.\n"); - close(fd); + dev_close(dev); return err; } break; @@ -1627,14 +1642,13 @@ static int enable_lat_stats_tracking(int argc, char **argv, printf("%d not supported.\n", option); return EINVAL; } - close(fd); - return fd; + dev_close(dev); + return err; } static int set_lat_stats_thresholds(int argc, char **argv, struct command *command, struct plugin *plugin) { - int err, fd, num; const char *desc = "Write Intel Bucket Thresholds for Latency Statistics Tracking"; const char *bucket_thresholds = "Bucket Threshold List, comma separated list: 0, 10, 20 ..."; const char *write = "Set write bucket Thresholds for latency tracking (read default)"; @@ -1643,7 +1657,9 @@ static int set_lat_stats_thresholds(int argc, char **argv, const __u8 fid = 0xf7; const __u32 cdw12 = 0x0; const __u32 save = 0; + struct nvme_dev *dev; __u32 result; + int err, num; struct config { bool write; @@ -1662,21 +1678,21 @@ static int set_lat_stats_thresholds(int argc, char **argv, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); + err = parse_and_open(&dev, argc, argv, desc, opts); - if (fd < 0) - return fd; + if (err) + return err; /* Query maj and minor version first to figure out the amount of * valid buckets a user is allowed to modify. Read or write doesn't * matter */ - err = nvme_get_log_simple(fd, 0xc2, - sizeof(media_version), media_version); + err = nvme_get_log_simple(dev_fd(dev), 0xc2, + sizeof(media_version), media_version); if (err) { fprintf(stderr, "Querying media version failed. "); nvme_show_status(err); - goto close_fd; + goto close_dev; } if (media_version[0] == 1000) { @@ -1686,13 +1702,13 @@ static int set_lat_stats_thresholds(int argc, char **argv, sizeof(thresholds)); if (num == -1) { fprintf(stderr, "ERROR: Bucket list is malformed\n"); - goto close_fd; + goto close_dev; } struct nvme_set_features_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .fid = fid, .nsid = nsid, .cdw11 = cfg.write ? 0x1 : 0x0, @@ -1717,8 +1733,8 @@ static int set_lat_stats_thresholds(int argc, char **argv, fprintf(stderr, "Unsupported command\n"); } -close_fd: - close(fd); +close_dev: + dev_close(dev); return err; } diff --git a/plugins/memblaze/memblaze-nvme.c b/plugins/memblaze/memblaze-nvme.c index a6a8ddf..6fdd675 100644 --- a/plugins/memblaze/memblaze-nvme.c +++ b/plugins/memblaze/memblaze-nvme.c @@ -453,15 +453,16 @@ int parse_params(char *str, int number, ...) static int mb_get_additional_smart_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { struct nvme_memblaze_smart_log smart_log; - int err, fd; char *desc = "Get Memblaze vendor specific additional smart log (optionally, "\ "for the specified namespace), and show it."; const char *namespace = "(optional) desired namespace"; const char *raw = "dump output in binary format"; + struct nvme_dev *dev; struct config { __u32 namespace_id; bool raw_binary; }; + int err; struct config cfg = { .namespace_id = NVME_NSID_ALL, @@ -473,22 +474,24 @@ static int mb_get_additional_smart_log(int argc, char **argv, struct command *cm OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; - err = nvme_get_nsid_log(fd, false, 0xca, cfg.namespace_id, - sizeof(smart_log), &smart_log); + err = nvme_get_nsid_log(dev_fd(dev), false, 0xca, cfg.namespace_id, + sizeof(smart_log), &smart_log); if (!err) { if (!cfg.raw_binary) - err = show_memblaze_smart_log(fd, cfg.namespace_id, devicename, &smart_log); + err = show_memblaze_smart_log(dev_fd(dev), + cfg.namespace_id, + dev->name, &smart_log); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } @@ -505,20 +508,22 @@ static char *mb_feature_to_string(int feature) static int mb_get_powermanager_status(int argc, char **argv, struct command *cmd, struct plugin *plugin) { const char *desc = "Get Memblaze power management ststus\n (value 0 - 25w, 1 - 20w, 2 - 15w)"; - int err, fd; __u32 result; __u32 feature_id = MB_FEAT_POWER_MGMT; + struct nvme_dev *dev; + int err; OPT_ARGS(opts) = { OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; struct nvme_get_features_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .fid = feature_id, .nsid = 0, .sel = 0, @@ -539,7 +544,7 @@ static int mb_get_powermanager_status(int argc, char **argv, struct command *cmd nvme_select_to_string(0), result); } else if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } @@ -548,8 +553,9 @@ static int mb_set_powermanager_status(int argc, char **argv, struct command *cmd const char *desc = "Set Memblaze power management status\n (value 0 - 25w, 1 - 20w, 2 - 15w)"; const char *value = "new value of feature (required)"; const char *save = "specifies that the controller shall save the attribute"; - int err, fd; + struct nvme_dev *dev; __u32 result; + int err; struct config { __u32 feature_id; @@ -569,12 +575,13 @@ static int mb_set_powermanager_status(int argc, char **argv, struct command *cmd OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; struct nvme_set_features_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .fid = cfg.feature_id, .nsid = 0, .cdw11 = cfg.value, @@ -597,7 +604,7 @@ static int mb_set_powermanager_status(int argc, char **argv, struct command *cmd } else if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } @@ -611,9 +618,10 @@ static int mb_set_high_latency_log(int argc, char **argv, struct command *cmd, s " p1 value: 0 is disable, 1 is enable\n"\ " p2 value: 1 .. 5000 ms"; const char *param = "input parameters"; - int err, fd; - __u32 result; int param1 = 0, param2 = 0; + struct nvme_dev *dev; + __u32 result; + int err; struct config { __u32 feature_id; @@ -632,24 +640,25 @@ static int mb_set_high_latency_log(int argc, char **argv, struct command *cmd, s OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; if (parse_params(cfg.param, 2, ¶m1, ¶m2)) { printf("setfeature: invalid formats %s\n", cfg.param); - close(fd); + dev_close(dev); return EINVAL; } if ((param1 == 1) && (param2 < P2MIN || param2 > P2MAX)) { printf("setfeature: invalid high io latency threshold %d\n", param2); - close(fd); + dev_close(dev); return EINVAL; } cfg.value = (param1 << MB_FEAT_HIGH_LATENCY_VALUE_SHIFT) | param2; struct nvme_set_features_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .fid = cfg.feature_id, .nsid = 0, .cdw11 = cfg.value, @@ -672,7 +681,7 @@ static int mb_set_high_latency_log(int argc, char **argv, struct command *cmd, s } else if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } @@ -774,25 +783,29 @@ static int glp_high_latency(FILE *fdi, char *buf, int buflen, int print) static int mb_high_latency_log_print(int argc, char **argv, struct command *cmd, struct plugin *plugin) { const char *desc = "Get Memblaze high latency log"; - int err, fd; char buf[LOG_PAGE_SIZE]; + struct nvme_dev *dev; FILE *fdi = NULL; + int err; OPT_ARGS(opts) = { OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; fdi = fopen(FID_C3_LOG_FILENAME, "w+"); glp_high_latency_show_bar(fdi, DO_PRINT_FLAG); - err = nvme_get_log_simple(fd, GLP_ID_VU_GET_HIGH_LATENCY_LOG, sizeof(buf), &buf); + err = nvme_get_log_simple(dev_fd(dev), GLP_ID_VU_GET_HIGH_LATENCY_LOG, + sizeof(buf), &buf); while (1) { if (!glp_high_latency(fdi, buf, LOG_PAGE_SIZE, DO_PRINT_FLAG)) break; - err = nvme_get_log_simple(fd, GLP_ID_VU_GET_HIGH_LATENCY_LOG, sizeof(buf), &buf); + err = nvme_get_log_simple(dev_fd(dev), GLP_ID_VU_GET_HIGH_LATENCY_LOG, + sizeof(buf), &buf); if ( err) { nvme_show_status(err); break; @@ -800,7 +813,7 @@ static int mb_high_latency_log_print(int argc, char **argv, struct command *cmd, } if (NULL != fdi) fclose(fdi); - close(fd); + dev_close(dev); return err; } @@ -829,7 +842,8 @@ static int mb_selective_download(int argc, char **argv, struct command *cmd, str const char *select = "FW Select (e.g., --select=OOB, EEP, ALL)"; int xfer = 4096; void *fw_buf; - int fd, selectNo,fw_fd,fw_size,err,offset = 0; + int selectNo,fw_fd,fw_size,err,offset = 0; + struct nvme_dev *dev; struct stat sb; int i; @@ -849,9 +863,9 @@ static int mb_selective_download(int argc, char **argv, struct command *cmd, str OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; if (strlen(cfg.select) != 3) { fprintf(stderr, "Invalid select flag\n"); @@ -912,7 +926,7 @@ static int mb_selective_download(int argc, char **argv, struct command *cmd, str struct nvme_fw_download_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .offset = offset, .data_len = xfer, .data = fw_buf, @@ -932,7 +946,7 @@ static int mb_selective_download(int argc, char **argv, struct command *cmd, str offset += xfer; } - err = memblaze_fw_commit(fd,selectNo); + err = memblaze_fw_commit(dev_fd(dev), selectNo); if(err == 0x10B || err == 0x20B) { err = 0; @@ -944,7 +958,7 @@ out_free: out_close: close(fw_fd); out: - close(fd); + dev_close(dev); return err; } @@ -1051,10 +1065,10 @@ int io_latency_histogram(char *file, char *buf, int print, int logid) static int mb_lat_stats_log_print(int argc, char **argv, struct command *cmd, struct plugin *plugin) { char stats[LOG_PAGE_SIZE]; - int err = 0; - int fd; char f1[] = FID_C1_LOG_FILENAME; char f2[] = FID_C2_LOG_FILENAME; + struct nvme_dev *dev; + int err; const char *desc = "Get Latency Statistics log and show it."; const char *write = "Get write statistics (read default)"; @@ -1071,17 +1085,19 @@ static int mb_lat_stats_log_print(int argc, char **argv, struct command *cmd, st OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; - err = nvme_get_log_simple(fd, cfg.write ? 0xc2 : 0xc1, sizeof(stats), &stats); + err = nvme_get_log_simple(dev_fd(dev), cfg.write ? 0xc2 : 0xc1, + sizeof(stats), &stats); if (!err) io_latency_histogram(cfg.write ? f2 : f1, stats, DO_PRINT_FLAG, cfg.write ? GLP_ID_VU_GET_WRITE_LATENCY_HISTOGRAM : GLP_ID_VU_GET_READ_LATENCY_HISTOGRAM); else nvme_show_status(err); - close(fd); + dev_close(dev); return err; } @@ -1089,8 +1105,9 @@ static int mb_lat_stats_log_print(int argc, char **argv, struct command *cmd, st #define FID 0x68 static int memblaze_clear_error_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - int err, fd; char *desc = "Clear Memblaze devices error log."; + struct nvme_dev *dev; + int err; //const char *value = "new value of feature (required)"; //const char *save = "specifies that the controller shall save the attribute"; @@ -1112,13 +1129,13 @@ static int memblaze_clear_error_log(int argc, char **argv, struct command *cmd, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; struct nvme_set_features_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .fid = cfg.feature_id, .nsid = 0, .cdw11 = cfg.value, @@ -1154,14 +1171,13 @@ static int memblaze_clear_error_log(int argc, char **argv, struct command *cmd, printf("NVMe Status:%s(%x)\n", nvme_status_to_string(err), err); }; */ - close(fd); + dev_close(dev); return err; } static int mb_set_lat_stats(int argc, char **argv, struct command *command, struct plugin *plugin) { - int err, fd; const char *desc = ( "Enable/Disable Latency Statistics Tracking.\n" "No argument prints current status."); @@ -1174,8 +1190,10 @@ static int mb_set_lat_stats(int argc, char **argv, const __u32 cdw12 = 0x0; const __u32 data_len = 32; const __u32 save = 0; - __u32 result; + struct nvme_dev *dev; void *buf = NULL; + __u32 result; + int err; struct config { bool enable, disable; @@ -1192,7 +1210,7 @@ static int mb_set_lat_stats(int argc, char **argv, {NULL} }; - fd = parse_and_open(argc, argv, desc, command_line_options); + err = parse_and_open(&dev, argc, argv, desc, command_line_options); enum Option { None = -1, @@ -1208,7 +1226,7 @@ static int mb_set_lat_stats(int argc, char **argv, struct nvme_get_features_args args_get = { .args_size = sizeof(args_get), - .fd = fd, + .fd = dev_fd(dev), .fid = fid, .nsid = nsid, .sel = sel, @@ -1222,7 +1240,7 @@ static int mb_set_lat_stats(int argc, char **argv, struct nvme_set_features_args args_set = { .args_size = sizeof(args_set), - .fd = fd, + .fd = dev_fd(dev), .fid = fid, .nsid = nsid, .cdw11 = option, @@ -1236,8 +1254,8 @@ static int mb_set_lat_stats(int argc, char **argv, .result = &result, }; - if (fd < 0) - return fd; + if (err) + return err; switch (option) { case None: err = nvme_get_features(&args_get); @@ -1247,7 +1265,7 @@ static int mb_set_lat_stats(int argc, char **argv, fid, result); } else { printf("Could not read feature id 0xE2.\n"); - close(fd); + dev_close(dev); return err; } break; @@ -1268,7 +1286,7 @@ static int mb_set_lat_stats(int argc, char **argv, printf("%d not supported.\n", option); err = EINVAL; } - close(fd); + dev_close(dev); return err; } diff --git a/plugins/micron/micron-nvme.c b/plugins/micron/micron-nvme.c index 1c3c51d..e6f3a8c 100644 --- a/plugins/micron/micron-nvme.c +++ b/plugins/micron/micron-nvme.c @@ -453,13 +453,15 @@ exit_status: /* * Plugin Commands */ -static int micron_parse_options(int argc, char **argv, const char *desc, - const struct argconfig_commandline_options *opts, eDriveModel *modelp) +static int micron_parse_options(struct nvme_dev **dev, int argc, char **argv, + const char *desc, + const struct argconfig_commandline_options *opts, + eDriveModel *modelp) { int idx = 0; - int fd = parse_and_open(argc, argv, desc, opts); + int err = parse_and_open(dev, argc, argv, desc, opts); - if (fd < 0) { + if (err) { perror("open"); return -1; } @@ -469,7 +471,7 @@ static int micron_parse_options(int argc, char **argv, const char *desc, *modelp = GetDriveModel(idx); } - return fd; + return 0; } static int micron_fw_commit(int fd, int select) @@ -496,7 +498,8 @@ static int micron_selective_download(int argc, char **argv, const char *select = "FW Select (e.g., --select=ALL)"; int xfer = 4096; void *fw_buf; - int fd, selectNo, fw_fd, fw_size, err, offset = 0; + int selectNo, fw_fd, fw_size, err, offset = 0; + struct nvme_dev *dev; struct stat sb; struct config { @@ -515,13 +518,13 @@ static int micron_selective_download(int argc, char **argv, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; if (strlen(cfg.select) != 3) { fprintf(stderr, "Invalid select flag\n"); - close(fd); + dev_close(dev); return EINVAL; } @@ -537,14 +540,14 @@ static int micron_selective_download(int argc, char **argv, selectNo = 26; } else { fprintf(stderr, "Invalid select flag\n"); - close(fd); + dev_close(dev); return EINVAL; } fw_fd = open(cfg.fw, O_RDONLY); if (fw_fd < 0) { fprintf(stderr, "no firmware file provided\n"); - close(fd); + dev_close(dev); return EINVAL; } @@ -578,7 +581,7 @@ static int micron_selective_download(int argc, char **argv, struct nvme_fw_download_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .offset = offset, .data_len = xfer, .data = fw_buf, @@ -598,7 +601,7 @@ static int micron_selective_download(int argc, char **argv, offset += xfer; } - err = micron_fw_commit(fd, selectNo); + err = micron_fw_commit(dev_fd(dev), selectNo); if (err == 0x10B || err == 0x20B) { err = 0; @@ -610,7 +613,7 @@ out_free: free(fw_buf); out: close(fw_fd); - close(fd); + dev_close(dev); return err; } @@ -625,10 +628,10 @@ static int micron_smbus_option(int argc, char **argv, "temperature (default) for enable option, 0 (current), " "1 (default), 2 (saved) for status options"; const char *save = "1 - persistent, 0 - non-persistent (default)"; - int err = 0; - int fd = 0; int fid = MICRON_FEATURE_SMBUS_OPTION; eDriveModel model = UNKNOWN_MODEL; + struct nvme_dev *dev; + int err = 0; struct { char *option; @@ -649,18 +652,20 @@ static int micron_smbus_option(int argc, char **argv, OPT_END() }; - if ((fd = micron_parse_options(argc, argv, desc, opts, &model)) < 0) + err = micron_parse_options(&dev, argc, argv, desc, opts, &model); + if (err < 0) return err; if (model != M5407 && model != M5411) { printf ("This option is not supported for specified drive\n"); - close(fd); + dev_close(dev); return err; } if (!strcmp(opt.option, "enable")) { cdw11 = opt.value << 1 | 1; - err = nvme_set_features_simple(fd, fid, 1, cdw11, opt.save, &result); + err = nvme_set_features_simple(dev_fd(dev), fid, 1, cdw11, opt.save, + &result); if (err == 0) { printf("successfully enabled SMBus on drive\n"); } else { @@ -670,7 +675,7 @@ static int micron_smbus_option(int argc, char **argv, else if (!strcmp(opt.option, "status")) { struct nvme_get_features_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .fid = fid, .nsid = 1, .sel = opt.value, @@ -692,7 +697,8 @@ static int micron_smbus_option(int argc, char **argv, } else if (!strcmp(opt.option, "disable")) { cdw11 = opt.value << 1 | 0; - err = nvme_set_features_simple(fd, fid, 1, cdw11, opt.save, &result); + err = nvme_set_features_simple(dev_fd(dev), fid, 1, cdw11, opt.save, + &result); if (err == 0) { printf("Successfully disabled SMBus on drive\n"); } else { @@ -701,11 +707,11 @@ static int micron_smbus_option(int argc, char **argv, } else { printf("Invalid option %s, valid values are enable, disable or status\n", opt.option); - close(fd); + dev_close(dev); return -1; } - close(fd); + close(dev_fd(dev)); return err; } @@ -727,15 +733,15 @@ static int micron_temp_stats(int argc, char **argv, struct command *cmd, bool is_json = false; struct json_object *root; struct json_object *logPages; - int fd; + struct nvme_dev *dev; OPT_ARGS(opts) = { OPT_FMT("format", 'f', &cfg.fmt, fmt), OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) { printf("\nDevice not found \n");; return -1; } @@ -743,7 +749,7 @@ static int micron_temp_stats(int argc, char **argv, struct command *cmd, if (strcmp(cfg.fmt, "json") == 0) is_json = true; - err = nvme_get_log_smart(fd, 0xffffffff, false, &smart_log); + err = nvme_get_log_smart(dev_fd(dev), 0xffffffff, false, &smart_log); if (!err) { temperature = ((smart_log.temperature[1] << 8) | smart_log.temperature[0]); temperature = temperature ? temperature - 273 : 0; @@ -778,15 +784,16 @@ static int micron_temp_stats(int argc, char **argv, struct command *cmd, } } } - close(fd); + dev_close(dev); return err; } static int micron_pcie_stats(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - int i, fd, err = 0, bus = 0, domain = 0, device = 0, function = 0, ctrlIdx; + int i, err = 0, bus = 0, domain = 0, device = 0, function = 0, ctrlIdx; char strTempFile[1024], strTempFile2[1024], command[1024]; + struct nvme_dev *dev; char *businfo = NULL; char *devicename = NULL; char tdevice[NAME_MAX] = { 0 }; @@ -875,8 +882,8 @@ static int micron_pcie_stats(int argc, char **argv, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) { printf("\nDevice not found \n");; return -1; } @@ -896,7 +903,7 @@ static int micron_pcie_stats(int argc, char **argv, admin_cmd.addr = (__u64)(uintptr_t)&pcie_error_counters; admin_cmd.data_len = sizeof(pcie_error_counters); admin_cmd.cdw10 = 1; - err = nvme_submit_admin_passthru(fd, &admin_cmd, NULL); + err = nvme_submit_admin_passthru(dev_fd(dev), &admin_cmd, NULL); if (!err) { counters = true; correctable_errors = 10; @@ -1017,8 +1024,7 @@ print_stats: } out: - if (fd > 0) - close(fd); + dev_close(dev); return err; } @@ -1028,6 +1034,7 @@ static int micron_clear_pcie_correctable_errors(int argc, char **argv, { int err = -EINVAL, bus = 0, domain = 0, device = 0, function = 0; char strTempFile[1024], strTempFile2[1024], command[1024]; + struct nvme_dev *dev; char *businfo = NULL; char *devicename = NULL; char tdevice[PATH_MAX] = { 0 }; @@ -1035,7 +1042,6 @@ static int micron_clear_pcie_correctable_errors(int argc, char **argv, eDriveModel model = UNKNOWN_MODEL; struct nvme_passthru_cmd admin_cmd = { 0 }; char correctable[8] = { 0 }; - int fd = -1; FILE *fp; char *res; const char *desc = "Clear PCIe Device Correctable Errors"; @@ -1045,12 +1051,14 @@ static int micron_clear_pcie_correctable_errors(int argc, char **argv, OPT_END() }; - if ((fd = micron_parse_options(argc, argv, desc, opts, &model)) < 0) + err = micron_parse_options(&dev, argc, argv, desc, opts, &model); + if (err < 0) return err; /* For M51CX models, PCIe errors are cleared using 0xC3 feature */ if (model == M51CX) { - err = nvme_set_features_simple(fd, fid, 0, (1 << 31), false, &result); + err = nvme_set_features_simple(dev_fd(dev), fid, 0, (1 << 31), false, + &result); if (err == 0 && (err = (int)result) == 0) { printf("Device correctable errors are cleared!\n"); goto out; @@ -1059,7 +1067,7 @@ static int micron_clear_pcie_correctable_errors(int argc, char **argv, admin_cmd.opcode = 0xD6; admin_cmd.addr = 0; admin_cmd.cdw10 = 0; - err = nvme_submit_admin_passthru(fd, &admin_cmd, NULL); + err = nvme_submit_admin_passthru(dev_fd(dev), &admin_cmd, NULL); if (err == 0) { printf("Device correctable error counters are cleared!\n"); goto out; @@ -1134,7 +1142,7 @@ static int micron_clear_pcie_correctable_errors(int argc, char **argv, printf("Device correctable errors detected: %s\n", correctable); err = 0; out: - close(fd); + dev_close(dev); return err; } @@ -1490,7 +1498,8 @@ static int micron_nand_stats(int argc, char **argv, unsigned int logFB[FB_log_size/sizeof(int)] = { 0 }; eDriveModel eModel = UNKNOWN_MODEL; struct nvme_id_ctrl ctrl; - int fd, err, ctrlIdx; + struct nvme_dev *dev; + int err, ctrlIdx; __u8 nsze; bool has_d0_log = true; bool has_fb_log = false; @@ -1508,8 +1517,8 @@ static int micron_nand_stats(int argc, char **argv, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) { printf("\nDevice not found \n");; return -1; } @@ -1517,7 +1526,7 @@ static int micron_nand_stats(int argc, char **argv, if (strcmp(cfg.fmt, "normal") == 0) is_json = false; - err = nvme_identify_ctrl(fd, &ctrl); + err = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (err) { printf("Error %d retrieving controller identification data\n", err); goto out; @@ -1532,12 +1541,12 @@ static int micron_nand_stats(int argc, char **argv, goto out; } - err = nvme_get_log_simple(fd, 0xD0, D0_log_size, extSmartLog); + err = nvme_get_log_simple(dev_fd(dev), 0xD0, D0_log_size, extSmartLog); has_d0_log = (0 == err); /* should check for firmware version if this log is supported or not */ if (eModel == M5407 || eModel == M5410) { - err = nvme_get_log_simple(fd, 0xFB, FB_log_size, logFB); + err = nvme_get_log_simple(dev_fd(dev), 0xFB, FB_log_size, logFB); has_fb_log = (0 == err); } @@ -1555,7 +1564,7 @@ static int micron_nand_stats(int argc, char **argv, err = -ENOTTY; } out: - close(fd); + dev_close(dev); if (err > 0) nvme_show_status(err); @@ -1595,7 +1604,8 @@ static int micron_smart_ext_log(int argc, char **argv, const char *desc = "Retrieve extended SMART logs for the given device "; unsigned int extSmartLog[E1_log_size/sizeof(int)] = { 0 }; eDriveModel eModel = UNKNOWN_MODEL; - int fd = 0, err = 0, ctrlIdx = 0; + int err = 0, ctrlIdx = 0; + struct nvme_dev *dev; bool is_json = true; struct format { char *fmt; @@ -1609,8 +1619,8 @@ static int micron_smart_ext_log(int argc, char **argv, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) { printf("\nDevice not found \n");; return -1; } @@ -1623,13 +1633,13 @@ static int micron_smart_ext_log(int argc, char **argv, err = -1; goto out; } - err = nvme_get_log_simple(fd, 0xE1, E1_log_size, extSmartLog); + err = nvme_get_log_simple(dev_fd(dev), 0xE1, E1_log_size, extSmartLog); if (!err) { print_ext_smart_logs_e1((__u8 *)extSmartLog, is_json); } out: - close(fd); + dev_close(dev); if (err > 0) nvme_show_status(err); return err; @@ -2005,7 +2015,6 @@ static int micron_drive_info(int argc, char **argv, struct command *cmd, struct plugin *plugin) { const char *desc = "Get drive HW information"; - int fd, err = 0; struct nvme_id_ctrl ctrl = { 0 }; struct nvme_passthru_cmd admin_cmd = { 0 }; struct fb_drive_info { @@ -2018,9 +2027,11 @@ static int micron_drive_info(int argc, char **argv, struct command *cmd, eDriveModel model = UNKNOWN_MODEL; bool is_json = false; struct json_object *root, *driveInfo; + struct nvme_dev *dev; struct format { char *fmt; }; + int err = 0; const char *fmt = "output format normal"; struct format cfg = { @@ -2032,12 +2043,13 @@ static int micron_drive_info(int argc, char **argv, struct command *cmd, OPT_END() }; - if ((fd = micron_parse_options(argc, argv, desc, opts, &model)) < 0) + err = micron_parse_options(&dev, argc, argv, desc, opts, &model); + if (err < 0) return err; if (model == UNKNOWN_MODEL) { fprintf(stderr, "ERROR : Unsupported drive for vs-drive-info cmd"); - close(fd); + dev_close(dev); return -1; } @@ -2049,17 +2061,17 @@ static int micron_drive_info(int argc, char **argv, struct command *cmd, admin_cmd.addr = (__u64) (uintptr_t) &dinfo; admin_cmd.data_len = (__u32)sizeof(dinfo); admin_cmd.cdw12 = 3; - err = nvme_submit_admin_passthru(fd, &admin_cmd, NULL); + err = nvme_submit_admin_passthru(dev_fd(dev), &admin_cmd, NULL); if (err) { fprintf(stderr, "ERROR : drive-info opcode failed with 0x%x\n", err); - close(fd); + dev_close(dev); return -1; } } else { - err = nvme_identify_ctrl(fd, &ctrl); + err = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (err) { fprintf(stderr, "ERROR : identify_ctrl() failed with 0x%x\n", err); - close(fd); + dev_close(dev); return -1; } dinfo.hw_ver_major = ctrl.vs[820]; @@ -2103,7 +2115,7 @@ static int micron_drive_info(int argc, char **argv, struct command *cmd, } } - close(fd); + dev_close(dev); return 0; } @@ -2242,10 +2254,11 @@ static int micron_fw_activation_history(int argc, char **argv, struct command *c int count = 0; unsigned int logC2[C2_log_size/sizeof(int)] = { 0 }; eDriveModel eModel = UNKNOWN_MODEL; - int fd, err; + struct nvme_dev *dev; struct format { char *fmt; }; + int err; const char *fmt = "output format normal"; struct format cfg = { @@ -2257,13 +2270,13 @@ static int micron_fw_activation_history(int argc, char **argv, struct command *c OPT_END() }; - if ((fd = micron_parse_options(argc, argv, desc, opts, &eModel)) < 0) { + err = micron_parse_options(&dev, argc, argv, desc, opts, &eModel); + if (err < 0) return -1; - } if (strcmp(cfg.fmt, "normal") != 0) { fprintf (stderr, "only normal format is supported currently\n"); - close(fd); + dev_close(dev); return -1; } @@ -2274,7 +2287,7 @@ static int micron_fw_activation_history(int argc, char **argv, struct command *c goto out; } - err = nvme_get_log_simple(fd, 0xC2, C2_log_size, logC2); + err = nvme_get_log_simple(dev_fd(dev), 0xC2, C2_log_size, logC2); if (err) { fprintf(stderr, "Failed to retrieve fw activation history log, error: %x\n", err); goto out; @@ -2308,7 +2321,7 @@ static int micron_fw_activation_history(int argc, char **argv, struct command *c } } out: - close(fd); + dev_close(dev); return err; } @@ -2327,12 +2340,12 @@ static int micron_latency_stats_track(int argc, char **argv, struct command *cmd const char *thrtime = "The threshold value to use for latency monitoring in" " milliseconds, default is 800ms"; - int fd = 0; int fid = MICRON_FID_LATENCY_MONITOR; eDriveModel model = UNKNOWN_MODEL; uint32_t command_mask = 0x7; /* 1:read 2:write 4:trim 7:all */ uint32_t timing_mask = 0x08080800; /* R[31-24]:W[23:16]:T[15:8]:0 */ uint32_t enable = 2; + struct nvme_dev *dev; struct { char *option; char *command; @@ -2351,9 +2364,9 @@ static int micron_latency_stats_track(int argc, char **argv, struct command *cmd }; - if ((fd = micron_parse_options(argc, argv, desc, opts, &model)) < 0) { + err = micron_parse_options(&dev, argc, argv, desc, opts, &model); + if (err < 0) return -1; - } if (!strcmp(opt.option, "enable")) { enable = 1; @@ -2361,13 +2374,13 @@ static int micron_latency_stats_track(int argc, char **argv, struct command *cmd enable = 0; } else if (strcmp(opt.option, "status")) { printf("Invalid control option %s specified\n", opt.option); - close(fd); + dev_close(dev); return -1; } struct nvme_get_features_args g_args = { .args_size = sizeof(g_args), - .fd = fd, + .fd = dev_fd(dev), .fid = fid, .nsid = 0, .sel = 0, @@ -2382,7 +2395,7 @@ static int micron_latency_stats_track(int argc, char **argv, struct command *cmd err = nvme_get_features(&g_args); if (err != 0) { printf("Failed to retrieve latency monitoring feature status\n"); - close(fd); + dev_close(dev); return err; } @@ -2407,7 +2420,7 @@ static int micron_latency_stats_track(int argc, char **argv, struct command *cmd } else if (result == 0) { printf("\n"); } - close(fd); + dev_close(dev); return err; } @@ -2415,13 +2428,13 @@ static int micron_latency_stats_track(int argc, char **argv, struct command *cmd if (enable == 1) { if (opt.threshold > 2550) { printf("The maximum threshold value cannot be more than 2550 ms\n"); - close(fd); + dev_close(dev); return -1; } /* timing mask is in terms of 10ms units, so min allowed is 10ms */ else if ((opt.threshold % 10) != 0) { printf("The threshold value should be multiple of 10 ms\n"); - close(fd); + dev_close(dev); return -1; } opt.threshold /= 10; @@ -2440,13 +2453,13 @@ static int micron_latency_stats_track(int argc, char **argv, struct command *cmd } else if (strcmp(opt.command, "all")) { printf("Invalid command %s specified for option %s\n", opt.command, opt.option); - close(fd); + dev_close(dev); return -1; } struct nvme_set_features_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .fid = MICRON_FID_LATENCY_MONITOR, .nsid = 0, .cdw11 = enable, @@ -2469,7 +2482,7 @@ static int micron_latency_stats_track(int argc, char **argv, struct command *cmd opt.option, opt.command, opt.threshold == 0 ? 800 : opt.threshold * 10); } - close(fd); + dev_close(dev); return err; } @@ -2510,21 +2523,22 @@ static int micron_latency_stats_logs(int argc, char **argv, struct command *cmd, uint32_t rfu[6]; } log[LATENCY_LOG_ENTRIES]; eDriveModel model = UNKNOWN_MODEL; + struct nvme_dev *dev; int err = -1; - int fd = -1; const char *desc = "Display Latency tracking log information"; OPT_ARGS(opts) = { OPT_END() }; - if ((fd = micron_parse_options(argc, argv, desc, opts, &model)) < 0) + err = micron_parse_options(&dev, argc, argv, desc, opts, &model); + if (err) return err; memset(&log, 0, sizeof(log)); - err = nvme_get_log_simple(fd, 0xD1, sizeof(log), &log); + err = nvme_get_log_simple(dev_fd(dev), 0xD1, sizeof(log), &log); if (err) { if (err < 0) printf("Unable to retrieve latency stats log the drive\n"); - close(fd); + dev_close(dev); return err; } /* print header and each log entry */ @@ -2538,7 +2552,7 @@ static int micron_latency_stats_logs(int argc, char **argv, struct command *cmd, log[i].deac, log[i].prinfo, log[i].fua, log[i].lr); } printf("\n"); - close(fd); + dev_close(dev); return err; } @@ -2549,7 +2563,7 @@ static int micron_latency_stats_info(int argc, char **argv, struct command *cmd, const char *command = "command to display stats - all|read|write|trim" "default is all"; int err = 0; - int fd = -1; + struct nvme_dev *dev; eDriveModel model = UNKNOWN_MODEL; #define LATENCY_BUCKET_COUNT 32 #define LATENCY_BUCKET_RSVD 32 @@ -2592,7 +2606,8 @@ static int micron_latency_stats_info(int argc, char **argv, struct command *cmd, OPT_END() }; - if ((fd = micron_parse_options(argc, argv, desc, opts, &model)) < 0) + err = micron_parse_options(&dev, argc, argv, desc, opts, &model); + if (err < 0) return err; if (!strcmp(opt.command, "read")) { cmd_stats = &log.read_cmds[0]; @@ -2605,16 +2620,16 @@ static int micron_latency_stats_info(int argc, char **argv, struct command *cmd, cmd_str = "Trim"; } else if (strcmp(opt.command, "all")) { printf("Invalid command option %s to display latency stats\n", opt.command); - close(fd); + dev_close(dev); return -1; } memset(&log, 0, sizeof(log)); - err = nvme_get_log_simple(fd, 0xD0, sizeof(log), &log); + err = nvme_get_log_simple(dev_fd(dev), 0xD0, sizeof(log), &log); if (err) { if (err < 0) printf("Unable to retrieve latency stats log the drive\n"); - close(fd); + dev_close(dev); return err; } printf("Micron IO %s Command Latency Statistics\n" @@ -2636,7 +2651,7 @@ static int micron_latency_stats_info(int argc, char **argv, struct command *cmd, printf("%2d %8s %8s %8"PRIu64"\n", bucket, start, end, cmd_stats[b]); } - close(fd); + dev_close(dev); return err; } @@ -2648,7 +2663,7 @@ static int micron_ocp_smart_health_logs(int argc, char **argv, struct command *c unsigned int logFB[FB_log_size/sizeof(int)] = { 0 }; struct nvme_id_ctrl ctrl; eDriveModel eModel = UNKNOWN_MODEL; - int fd, err = 0; + struct nvme_dev *dev; bool is_json = true; struct format { char *fmt; @@ -2657,15 +2672,16 @@ static int micron_ocp_smart_health_logs(int argc, char **argv, struct command *c struct format cfg = { .fmt = "json", }; + int err = 0; OPT_ARGS(opts) = { OPT_FMT("format", 'f', &cfg.fmt, fmt), OPT_END() }; - if ((fd = micron_parse_options(argc, argv, desc, opts, &eModel)) < 0) { + err = micron_parse_options(&dev, argc, argv, desc, opts, &eModel); + if (err < 0) return -1; - } if (strcmp(cfg.fmt, "normal") == 0) is_json = false; @@ -2675,9 +2691,9 @@ static int micron_ocp_smart_health_logs(int argc, char **argv, struct command *c __u8 spec = (eModel == M5410) ? 0 : 1; __u8 nsze; - if ((err = nvme_identify_ctrl(fd, &ctrl)) == 0) - err = nvme_get_log_simple(fd, 0xFB, - FB_log_size, logFB); + if ((err = nvme_identify_ctrl(dev_fd(dev), &ctrl)) == 0) + err = nvme_get_log_simple(dev_fd(dev), 0xFB, + FB_log_size, logFB); if (err) { if (err < 0) printf("Unable to retrieve smart log 0xFB for the drive\n"); @@ -2698,14 +2714,14 @@ static int micron_ocp_smart_health_logs(int argc, char **argv, struct command *c goto out; } - err = nvme_get_log_simple(fd, 0xC0, C0_log_size, logC0); + err = nvme_get_log_simple(dev_fd(dev), 0xC0, C0_log_size, logC0); if (err == 0) { print_smart_cloud_health_log((__u8 *)logC0, is_json); } else if (err < 0) { printf("Unable to retrieve extended smart log 0xC0 for the drive\n"); } out: - close(fd); + dev_close(dev); if (err > 0) nvme_show_status(err); return err; @@ -2715,28 +2731,30 @@ static int micron_clr_fw_activation_history(int argc, char **argv, struct command *cmd, struct plugin *plugin) { const char *desc = "Clear FW activation history"; - int fd, err = 0; __u32 result = 0; __u8 fid = MICRON_FEATURE_CLEAR_FW_ACTIVATION_HISTORY; eDriveModel model = UNKNOWN_MODEL; + struct nvme_dev *dev; OPT_ARGS(opts) = { OPT_END() }; + int err = 0; - if ((fd = micron_parse_options(argc, argv, desc, opts, &model)) < 0) + err = micron_parse_options(&dev, argc, argv, desc, opts, &model); + if (err < 0) return err; if (model != M51CX) { printf ("This option is not supported for specified drive\n"); - close(fd); + dev_close(dev); return err; } - err = nvme_set_features_simple(fd, fid, 1 << 31, 0, 0, &result); + err = nvme_set_features_simple(dev_fd(dev), fid, 1 << 31, 0, 0, &result); if (err == 0) err = (int)result; else printf ("Failed to clear fw activation history, error = 0x%x\n", err); - close(fd); + dev_close(dev); return err; } @@ -2750,10 +2768,10 @@ static int micron_telemetry_cntrl_option(int argc, char **argv, const char *select = "select/save values: enable/disable options" "1 - save (persistent), 0 - non-persistent and for " "status options: 0 - current, 1 - default, 2-saved"; - int fd = 0; int fid = MICRON_FEATURE_TELEMETRY_CONTROL_OPTION; eDriveModel model = UNKNOWN_MODEL; struct nvme_id_ctrl ctrl = { 0 }; + struct nvme_dev *dev; struct { char *option; @@ -2769,21 +2787,21 @@ static int micron_telemetry_cntrl_option(int argc, char **argv, OPT_END() }; - if ((fd = micron_parse_options(argc, argv, desc, opts, &model)) < 0) { + err = micron_parse_options(&dev, argc, argv, desc, opts, &model); + if (err < 0) return -1; - } - err = nvme_identify_ctrl(fd, &ctrl); + err = nvme_identify_ctrl(dev_fd(dev), &ctrl); if ((ctrl.lpa & 0x8) != 0x8) { printf("drive doesn't support host/controller generated telemetry logs\n"); - close(fd); + dev_close(dev); return err; } if (!strcmp(opt.option, "enable")) { struct nvme_set_features_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .fid = fid, .nsid = 1, .cdw11 = 1, @@ -2805,7 +2823,7 @@ static int micron_telemetry_cntrl_option(int argc, char **argv, } else if (!strcmp(opt.option, "disable")) { struct nvme_set_features_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .fid = fid, .nsid = 1, .cdw11 = 0, @@ -2827,7 +2845,7 @@ static int micron_telemetry_cntrl_option(int argc, char **argv, } else if (!strcmp(opt.option, "status")) { struct nvme_get_features_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .fid = fid, .nsid = 1, .sel = opt.select & 0x3, @@ -2847,11 +2865,11 @@ static int micron_telemetry_cntrl_option(int argc, char **argv, } } else { printf("invalid option %s, valid values are enable,disable or status\n", opt.option); - close(fd); + dev_close(dev); return -1; } - close(fd); + dev_close(dev); return err; } @@ -2945,7 +2963,7 @@ static int get_common_log(int fd, uint8_t id, uint8_t **buf, int *size) if (hdr.log_size == sizeof(hdr)) { buffer = (uint8_t *)malloc(sizeof(hdr)); if (buffer == NULL) { - fprintf(stderr, "malloc of %lu bytes failed for log: 0x%X\n", + fprintf(stderr, "malloc of %zu bytes failed for log: 0x%X\n", sizeof(hdr), id); return -ENOMEM; } @@ -2953,7 +2971,7 @@ static int get_common_log(int fd, uint8_t id, uint8_t **buf, int *size) } else if (hdr.log_size < hdr.max_size) { buffer = (uint8_t *)malloc(sizeof(hdr) + hdr.log_size); if (buffer == NULL) { - fprintf(stderr, "malloc of %lu bytes failed for log: 0x%X\n", + fprintf(stderr, "malloc of %zu bytes failed for log: 0x%X\n", hdr.log_size + sizeof(hdr), id); return -ENOMEM; } @@ -2971,7 +2989,7 @@ static int get_common_log(int fd, uint8_t id, uint8_t **buf, int *size) */ buffer = (uint8_t *)malloc(hdr.max_size + sizeof(hdr)); if (buffer == NULL) { - fprintf(stderr, "malloc of %lu bytes failed for log: 0x%X\n", + fprintf(stderr, "malloc of %zu bytes failed for log: 0x%X\n", hdr.max_size + sizeof(hdr), id); return -ENOMEM; } @@ -3010,7 +3028,6 @@ static int micron_internal_logs(int argc, char **argv, struct command *cmd, struct plugin *plugin) { int err = -EINVAL; - int fd = 0; int ctrlIdx, telemetry_option = 0; char strOSDirName[1024]; char strCtrlDirName[1024]; @@ -3021,6 +3038,7 @@ static int micron_internal_logs(int argc, char **argv, struct command *cmd, char sn[20] = { 0 }; char msg[256] = { 0 }; int c_logs_index = 8; /* should be current size of aVendorLogs */ + struct nvme_dev *dev; struct { unsigned char ucLogPage; const char *strFileName; @@ -3104,10 +3122,9 @@ static int micron_internal_logs(int argc, char **argv, struct command *cmd, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; /* if telemetry type is specified, check for data area */ if (strlen(cfg.type) != 0) { @@ -3143,7 +3160,7 @@ static int micron_internal_logs(int argc, char **argv, struct command *cmd, goto out; } - err = nvme_identify_ctrl(fd, &ctrl); + err = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (err) goto out; @@ -3151,11 +3168,12 @@ static int micron_internal_logs(int argc, char **argv, struct command *cmd, if (telemetry_option) { if ((ctrl.lpa & 0x8) != 0x8) { printf("telemetry option is not supported for specified drive\n"); - close(fd); + dev_close(dev); goto out; } int logSize = 0; __u8 *buffer = NULL; const char *dir = "."; - err = micron_telemetry_log(fd, cfg.log, &buffer, &logSize, cfg.data_area); + err = micron_telemetry_log(dev_fd(dev), cfg.log, &buffer, &logSize, + cfg.data_area); if (err == 0 && logSize > 0 && buffer != NULL) { sprintf(msg, "telemetry log: 0x%X", cfg.log); WriteData(buffer, logSize, dir, cfg.package, msg); @@ -3184,16 +3202,16 @@ static int micron_internal_logs(int argc, char **argv, struct command *cmd, GetDriveInfo(strOSDirName, ctrlIdx, &ctrl); for (int i = 1; i <= ctrl.nn; i++) - GetNSIDDInfo(fd, strCtrlDirName, i); + GetNSIDDInfo(dev_fd(dev), strCtrlDirName, i); - GetSmartlogData(fd, strCtrlDirName); - GetErrorlogData(fd, ctrl.elpe, strCtrlDirName); - GetGenericLogs(fd, strCtrlDirName); + GetSmartlogData(dev_fd(dev), strCtrlDirName); + GetErrorlogData(dev_fd(dev), ctrl.elpe, strCtrlDirName); + GetGenericLogs(dev_fd(dev), strCtrlDirName); /* pull if telemetry log data is supported */ if ((ctrl.lpa & 0x8) == 0x8) - GetTelemetryData(fd, strCtrlDirName); + GetTelemetryData(dev_fd(dev), strCtrlDirName); - GetFeatureSettings(fd, strCtrlDirName); + GetFeatureSettings(dev_fd(dev), strCtrlDirName); if (eModel != M5410 && eModel != M5407) { memcpy(&aVendorLogs[c_logs_index], aM51XXLogs, sizeof(aM51XXLogs)); @@ -3221,15 +3239,18 @@ static int micron_internal_logs(int argc, char **argv, struct command *cmd, case 0xE4: case 0xE8: case 0xEA: - err = get_common_log(fd, aVendorLogs[i].ucLogPage, &dataBuffer, &bSize); + err = get_common_log(dev_fd(dev), aVendorLogs[i].ucLogPage, + &dataBuffer, &bSize); break; case 0xC1: case 0xC2: case 0xC4: - err = GetLogPageSize(fd, aVendorLogs[i].ucLogPage, &bSize); + err = GetLogPageSize(dev_fd(dev), aVendorLogs[i].ucLogPage, + &bSize); if (err == 0 && bSize > 0) - err = GetCommonLogPage(fd, aVendorLogs[i].ucLogPage, &dataBuffer, bSize); + err = GetCommonLogPage(dev_fd(dev), aVendorLogs[i].ucLogPage, + &dataBuffer, bSize); break; case 0xE6: @@ -3248,9 +3269,12 @@ static int micron_internal_logs(int argc, char **argv, struct command *cmd, if (bSize != 0 && (dataBuffer = (unsigned char *)malloc(bSize)) != NULL) { memset(dataBuffer, 0, bSize); if (eModel == M5410 || eModel == M5407) - err = NVMEGetLogPage(fd, aVendorLogs[i].ucLogPage, dataBuffer, bSize); + err = NVMEGetLogPage(dev_fd(dev), + aVendorLogs[i].ucLogPage, dataBuffer, + bSize); else - err = nvme_get_log_simple(fd, aVendorLogs[i].ucLogPage, + err = nvme_get_log_simple(dev_fd(dev), + aVendorLogs[i].ucLogPage, bSize, dataBuffer); } break; @@ -3260,7 +3284,7 @@ static int micron_internal_logs(int argc, char **argv, struct command *cmd, case 0xFC: case 0xFD: if (eModel == M51BX) { - (void)NVMEResetLog(fd, aVendorLogs[i].ucLogPage, + (void)NVMEResetLog(dev_fd(dev), aVendorLogs[i].ucLogPage, aVendorLogs[i].nLogSize, aVendorLogs[i].nMaxSize); } /* fallthrough */ @@ -3271,13 +3295,14 @@ static int micron_internal_logs(int argc, char **argv, struct command *cmd, break; } memset(dataBuffer, 0, bSize); - err = nvme_get_log_simple(fd, aVendorLogs[i].ucLogPage, + err = nvme_get_log_simple(dev_fd(dev), aVendorLogs[i].ucLogPage, bSize, dataBuffer); maxSize = aVendorLogs[i].nMaxSize - bSize; while (err == 0 && maxSize > 0 && ((unsigned int *)dataBuffer)[0] != 0xdeadbeef) { sprintf(msg, "log 0x%x", aVendorLogs[i].ucLogPage); WriteData(dataBuffer, bSize, strCtrlDirName, aVendorLogs[i].strFileName, msg); - err = nvme_get_log_simple(fd, aVendorLogs[i].ucLogPage, + err = nvme_get_log_simple(dev_fd(dev), + aVendorLogs[i].ucLogPage, bSize, dataBuffer); if (err || (((unsigned int *)dataBuffer)[0] == 0xdeadbeef)) break; @@ -3299,7 +3324,7 @@ static int micron_internal_logs(int argc, char **argv, struct command *cmd, err = ZipAndRemoveDir(strMainDirName, cfg.package); out: - close(fd); + dev_close(dev); return err; } @@ -3308,17 +3333,18 @@ static int micron_logpage_dir(int argc, char **argv, struct command *cmd, struct plugin *plugin) { int err = -1; - int fd = -1; const char *desc = "List the supported log pages"; eDriveModel model = UNKNOWN_MODEL; char logbuf[MIN_LOG_SIZE]; + struct nvme_dev *dev; int i; OPT_ARGS(opts) = { OPT_END() }; - if ((fd = micron_parse_options(argc, argv, desc, opts, &model)) < 0) + err = micron_parse_options(&dev, argc, argv, desc, opts, &model); + if (err < 0) return err; struct nvme_supported_logs { @@ -3359,7 +3385,7 @@ static int micron_logpage_dir(int argc, char **argv, struct command *cmd, printf("Supported log page list\nLog ID : Description\n"); for (i = 0; i < sizeof(log_list)/sizeof(log_list[0]); i++) { - err = nvme_get_log_simple(fd, log_list[i].log_id, + err = nvme_get_log_simple(dev_fd(dev), log_list[i].log_id, MIN_LOG_SIZE, &logbuf[0]); if (err) continue; printf("%02Xh : %s\n", log_list[i].log_id, log_list[i].desc); diff --git a/plugins/netapp/netapp-nvme.c b/plugins/netapp/netapp-nvme.c index b6bd3f6..f5cb073 100644 --- a/plugins/netapp/netapp-nvme.c +++ b/plugins/netapp/netapp-nvme.c @@ -22,7 +22,6 @@ #include #include #include -#include #include "common.h" #include "nvme.h" @@ -68,7 +67,7 @@ struct ontapdevice_info { unsigned nsid; struct nvme_id_ctrl ctrl; struct nvme_id_ns ns; - uuid_t uuid; + unsigned char uuid[NVME_UUID_LEN]; unsigned char log_data[ONTAP_C2_LOG_SIZE]; char dev[265]; }; @@ -334,7 +333,7 @@ static void netapp_ontapdevices_print(struct ontapdevice_info *devices, for (i = 0; i < count; i++) { netapp_get_ns_size(size, &lba, &devices[i].ns); - uuid_unparse_lower(devices[i].uuid, uuid_str); + nvme_uuid_to_string(devices[i].uuid, uuid_str); netapp_get_ontap_labels(vsname, nspath, devices[i].log_data); if (format == NJSON) { diff --git a/plugins/ocp/ocp-nvme.c b/plugins/ocp/ocp-nvme.c index 52c28a8..5cbf6cb 100644 --- a/plugins/ocp/ocp-nvme.c +++ b/plugins/ocp/ocp-nvme.c @@ -13,12 +13,14 @@ #include #include #include +#include #include "common.h" #include "nvme.h" #include "libnvme.h" #include "plugin.h" #include "linux/types.h" +#include "util/types.h" #include "nvme-print.h" #define CREATE_CMD @@ -122,18 +124,6 @@ struct __attribute__((__packed__)) ssd_latency_monitor_log { __u8 log_page_guid[0x10]; /* 0x1F0 */ }; -static long double int128_to_double(__u8 *data) -{ - int i; - long double result = 0; - - for (i = 0; i < 16; i++) { - result *= 256; - result += data[15 - i]; - } - return result; -} - static int convert_ts(time_t time, char *ts_buf) { struct tm gmTimeInfo; @@ -208,10 +198,10 @@ static void ocp_print_C0_log_normal(void *data) (uint64_t)le64_to_cpu(*(uint64_t *)&log_data[SCAO_SVN])); printf(" NUSE - Namespace utilization %"PRIu64"\n", (uint64_t)le64_to_cpu(*(uint64_t *)&log_data[SCAO_NUSE])); - printf(" PLP start count %.0Lf\n", - int128_to_double(&log_data[SCAO_PSC])); - printf(" Endurance estimate %.0Lf\n", - int128_to_double(&log_data[SCAO_EEST])); + printf(" PLP start count %s\n", + uint128_t_to_string(le128_to_cpu(&log_data[SCAO_PSC]))); + printf(" Endurance estimate %s\n", + uint128_t_to_string(le128_to_cpu(&log_data[SCAO_EEST]))); smart_log_ver = (uint16_t)le16_to_cpu(*(uint16_t *)&log_data[SCAO_LPV]); printf(" Log page version %"PRIu16"\n",smart_log_ver); printf(" Log page GUID 0x"); @@ -300,10 +290,10 @@ static void ocp_print_C0_log_json(void *data) (uint64_t)le64_to_cpu(*(uint64_t *)&log_data[SCAO_SVN])); json_object_add_value_uint64(root, "NUSE - Namespace utilization", (uint64_t)le64_to_cpu(*(uint64_t *)&log_data[SCAO_NUSE])); - json_object_add_value_uint(root, "PLP start count", - int128_to_double(&log_data[SCAO_PSC])); - json_object_add_value_uint64(root, "Endurance estimate", - int128_to_double(&log_data[SCAO_EEST])); + json_object_add_value_uint128(root, "PLP start count", + le128_to_cpu(&log_data[SCAO_PSC])); + json_object_add_value_uint128(root, "Endurance estimate", + le128_to_cpu(&log_data[SCAO_EEST])); smart_log_ver = (uint16_t)le16_to_cpu(*(uint16_t *)&log_data[SCAO_LPV]); json_object_add_value_uint(root, "Log page version", smart_log_ver); char guid[40]; @@ -401,7 +391,7 @@ static int ocp_smart_add_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { const char *desc = "Retrieve latency monitor log data."; - int fd; + struct nvme_dev *dev; int ret = 0; struct config { @@ -417,22 +407,23 @@ static int ocp_smart_add_log(int argc, char **argv, struct command *cmd, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; - ret = get_c0_log_page(fd, cfg.output_format); + ret = get_c0_log_page(dev_fd(dev), cfg.output_format); if (ret) fprintf(stderr, "ERROR : OCP : Failure reading the C0 Log Page, ret = %d\n", ret); - close(fd); + dev_close(dev); return ret; } -static int ocp_print_C3_log_normal(struct ssd_latency_monitor_log *log_data) +static int ocp_print_C3_log_normal(struct nvme_dev *dev, + struct ssd_latency_monitor_log *log_data) { printf("-Latency Monitor/C3 Log Page Data- \n"); - printf(" Controller : %s\n", devicename); + printf(" Controller : %s\n", dev->name); int i, j; int pos = 0; char ts_buf[128]; @@ -662,7 +653,7 @@ static void ocp_print_C3_log_json(struct ssd_latency_monitor_log *log_data) json_free_object(root); } -static int get_c3_log_page(int fd, char *format) +static int get_c3_log_page(struct nvme_dev *dev, char *format) { int ret = 0; int fmt = -1; @@ -682,8 +673,8 @@ static int get_c3_log_page(int fd, char *format) } memset(data, 0, sizeof (__u8) * C3_LATENCY_MON_LOG_BUF_LEN); - ret = nvme_get_log_simple(fd, C3_LATENCY_MON_OPCODE, - C3_LATENCY_MON_LOG_BUF_LEN, data); + ret = nvme_get_log_simple(dev_fd(dev), C3_LATENCY_MON_OPCODE, + C3_LATENCY_MON_LOG_BUF_LEN, data); if (strcmp(format, "json")) fprintf(stderr, @@ -725,7 +716,7 @@ static int get_c3_log_page(int fd, char *format) switch (fmt) { case NORMAL: - ocp_print_C3_log_normal(log_data); + ocp_print_C3_log_normal(dev, log_data); break; case JSON: ocp_print_C3_log_json(log_data); @@ -745,7 +736,7 @@ static int ocp_latency_monitor_log(int argc, char **argv, struct command *comman struct plugin *plugin) { const char *desc = "Retrieve latency monitor log data."; - int fd; + struct nvme_dev *dev; int ret = 0; struct config { @@ -762,15 +753,15 @@ static int ocp_latency_monitor_log(int argc, char **argv, struct command *comman OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; - ret = get_c3_log_page(fd, cfg.output_format); + ret = get_c3_log_page(dev, cfg.output_format); if (ret) fprintf(stderr, "ERROR : OCP : Failure reading the C3 Log Page, ret = %d\n", ret); - close(fd); + dev_close(dev); return ret; } diff --git a/plugins/scaleflux/sfx-nvme.c b/plugins/scaleflux/sfx-nvme.c index 0740e43..a776664 100644 --- a/plugins/scaleflux/sfx-nvme.c +++ b/plugins/scaleflux/sfx-nvme.c @@ -398,17 +398,18 @@ static void show_sfx_smart_log(struct nvme_additional_smart_log *smart, static int get_additional_smart_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { struct nvme_additional_smart_log smart_log; - int err, fd; char *desc = "Get ScaleFlux vendor specific additional smart log (optionally, "\ "for the specified namespace), and show it."; const char *namespace = "(optional) desired namespace"; const char *raw = "dump output in binary format"; const char *json= "Dump output in json format"; + struct nvme_dev *dev; struct config { __u32 namespace_id; bool raw_binary; bool json; }; + int err; struct config cfg = { .namespace_id = 0xffffffff, @@ -422,24 +423,25 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd, }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { - return fd; - } + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; - err = nvme_get_nsid_log(fd, false, 0xca, cfg.namespace_id, - sizeof(smart_log), (void *)&smart_log); + err = nvme_get_nsid_log(dev_fd(dev), false, 0xca, cfg.namespace_id, + sizeof(smart_log), (void *)&smart_log); if (!err) { if (cfg.json) - show_sfx_smart_log_jsn(&smart_log, cfg.namespace_id, devicename); + show_sfx_smart_log_jsn(&smart_log, cfg.namespace_id, + dev->name); else if (!cfg.raw_binary) - show_sfx_smart_log(&smart_log, cfg.namespace_id, devicename); + show_sfx_smart_log(&smart_log, cfg.namespace_id, + dev->name); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } else if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } @@ -609,22 +611,23 @@ static void show_lat_stats_myrtle(struct sfx_lat_stats_myrtle *stats, int write) for (i = 0; i < 64; i++) printf("Bucket %2d: %u\n", i, stats->bucket_19[i]); - printf("\nAverage latency statistics %lld\n", stats->average); + printf("\nAverage latency statistics %" PRIu64 "\n", + (uint64_t)stats->average); } static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { struct sfx_lat_stats stats; - int err, fd; - char *desc = "Get ScaleFlux Latency Statistics log and show it."; const char *raw = "dump output in binary format"; const char *write = "Get write statistics (read default)"; + struct nvme_dev *dev; struct config { bool raw_binary; bool write; }; + int err; struct config cfg = { }; @@ -635,12 +638,12 @@ static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { - return fd; - } + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; - err = nvme_get_log_simple(fd, cfg.write ? 0xc3 : 0xc1, sizeof(stats), (void *)&stats); + err = nvme_get_log_simple(dev_fd(dev), cfg.write ? 0xc3 : 0xc1, + sizeof(stats), (void *)&stats); if (!err) { if ((stats.ver.maj == VANDA_MAJOR_IDX) && (stats.ver.min == VANDA_MINOR_IDX)) { if (!cfg.raw_binary) { @@ -660,7 +663,7 @@ static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct } } else if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } @@ -764,9 +767,9 @@ static void bd_table_show(unsigned char *bd_table, __u64 table_size) */ static int sfx_get_bad_block(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - int fd; - unsigned char *data_buf; const __u64 buf_size = 256*4096*sizeof(unsigned char); + unsigned char *data_buf; + struct nvme_dev *dev; int err = 0; char *desc = "Get bad block table of sfx block device."; @@ -775,19 +778,18 @@ static int sfx_get_bad_block(int argc, char **argv, struct command *cmd, struct OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { - return fd; - } + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; data_buf = malloc(buf_size); if (!data_buf) { fprintf(stderr, "malloc fail, errno %d\r\n", errno); - close(fd); + dev_close(dev); return -1; } - err = get_bb_table(fd, 0xffffffff, data_buf, buf_size); + err = get_bb_table(dev_fd(dev), 0xffffffff, data_buf, buf_size); if (err < 0) { perror("get-bad-block"); } else if (err != 0) { @@ -798,7 +800,7 @@ static int sfx_get_bad_block(int argc, char **argv, struct command *cmd, struct } free(data_buf); - close(fd); + dev_close(dev); return 0; } @@ -819,25 +821,25 @@ static void show_cap_info(struct sfx_freespace_ctx *ctx) static int query_cap_info(int argc, char **argv, struct command *cmd, struct plugin *plugin) { struct sfx_freespace_ctx ctx = { 0 }; - int err = 0, fd; char *desc = "query current capacity info"; const char *raw = "dump output in binary format"; + struct nvme_dev *dev; struct config { bool raw_binary; }; struct config cfg; + int err = 0; OPT_ARGS(opts) = { OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw), OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { - return fd; - } + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; - if (nvme_query_cap(fd, 0xffffffff, sizeof(ctx), &ctx)) { + if (nvme_query_cap(dev_fd(dev), 0xffffffff, sizeof(ctx), &ctx)) { perror("sfx-query-cap"); err = -1; } @@ -849,7 +851,7 @@ static int query_cap_info(int argc, char **argv, struct command *cmd, struct plu d_raw((unsigned char *)&ctx, sizeof(ctx)); } } - close(fd); + dev_close(dev); return err; } @@ -939,14 +941,15 @@ static int sfx_confirm_change(const char *str) static int change_cap(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - int err = -1, fd; char *desc = "dynamic change capacity"; const char *cap_gb = "cap size in GB"; const char *cap_byte = "cap size in byte"; const char *force = "The \"I know what I'm doing\" flag, skip confirmation before sending command"; + struct nvme_dev *dev; __u64 cap_in_4k = 0; __u64 cap_in_sec = 0; int shrink = 0; + int err = -1; struct config { __u64 cap_in_byte; @@ -967,10 +970,9 @@ static int change_cap(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { - return fd; - } + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; cap_in_sec = IDEMA_CAP(cfg.capacity_in_gb); cap_in_4k = cap_in_sec >> 3; @@ -979,27 +981,27 @@ static int change_cap(int argc, char **argv, struct command *cmd, struct plugin printf("%dG %"PRIu64"B %"PRIu64" 4K\n", cfg.capacity_in_gb, (uint64_t)cfg.cap_in_byte, (uint64_t)cap_in_4k); - if (change_sanity_check(fd, cap_in_4k, &shrink)) { + if (change_sanity_check(dev_fd(dev), cap_in_4k, &shrink)) { printf("ScaleFlux change-capacity: fail\n"); - close(fd); + dev_close(dev); return err; } if (!cfg.force && shrink && !sfx_confirm_change("Changing Cap may irrevocably delete this device's data")) { - close(fd); + dev_close(dev); return 0; } - err = nvme_change_cap(fd, 0xffffffff, cap_in_4k); + err = nvme_change_cap(dev_fd(dev), 0xffffffff, cap_in_4k); if (err < 0) perror("sfx-change-cap"); else if (err != 0) nvme_show_status(err); else { printf("ScaleFlux change-capacity: success\n"); - ioctl(fd, BLKRRPART); + ioctl(dev_fd(dev), BLKRRPART); } - close(fd); + dev_close(dev); return err; } @@ -1051,7 +1053,6 @@ char *sfx_feature_to_string(int feature) static int sfx_set_feature(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - int err = 0, fd; char *desc = "ScaleFlux internal set features\n" "feature id 1: ATOMIC\n" "value 0: Disable atomic write\n" @@ -1060,8 +1061,9 @@ static int sfx_set_feature(int argc, char **argv, struct command *cmd, struct pl const char *feature_id = "hex feature name (required)"; const char *namespace_id = "desired namespace"; const char *force = "The \"I know what I'm doing\" flag, skip confirmation before sending command"; - + struct nvme_dev *dev; struct nvme_id_ns ns; + int err = 0; struct config { __u32 namespace_id; @@ -1084,37 +1086,37 @@ static int sfx_set_feature(int argc, char **argv, struct command *cmd, struct pl OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { - return fd; - } + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; if (!cfg.feature_id) { fprintf(stderr, "feature-id required param\n"); - close(fd); + dev_close(dev); return EINVAL; } if (cfg.feature_id == SFX_FEAT_CLR_CARD) { /*Warning for clean card*/ if (!cfg.force && !sfx_confirm_change("Going to clean device's data, confirm umount fs and try again")) { - close(fd); + dev_close(dev); return 0; } else { - return sfx_clean_card(fd); + return sfx_clean_card(dev_fd(dev)); } } if (cfg.feature_id == SFX_FEAT_ATOMIC && cfg.value != 0) { if (cfg.namespace_id != 0xffffffff) { - err = nvme_identify_ns(fd, cfg.namespace_id, &ns); + err = nvme_identify_ns(dev_fd(dev), cfg.namespace_id, + &ns); if (err) { if (err < 0) perror("identify-namespace"); else nvme_show_status(err); - close(fd); + dev_close(dev); return err; } /* @@ -1122,29 +1124,31 @@ static int sfx_set_feature(int argc, char **argv, struct command *cmd, struct pl */ if ((ns.flbas & 0xf) != 1) { printf("Please change-sector size to 4K, then retry\n"); - close(fd); + dev_close(dev); return EFAULT; } } } else if (cfg.feature_id == SFX_FEAT_UP_P_CAP) { if (cfg.value <= 0) { fprintf(stderr, "Invalid Param\n"); - close(fd); + dev_close(dev); return EINVAL; } /*Warning for change pacp by GB*/ if (!cfg.force && !sfx_confirm_change("Changing physical capacity may irrevocably delete this device's data")) { - close(fd); + dev_close(dev); return 0; } } - err = nvme_sfx_set_features(fd, cfg.namespace_id, cfg.feature_id, cfg.value); + err = nvme_sfx_set_features(dev_fd(dev), cfg.namespace_id, + cfg.feature_id, + cfg.value); if (err < 0) { perror("ScaleFlux-set-feature"); - close(fd); + dev_close(dev); return errno; } else if (!err) { printf("ScaleFlux set-feature:%#02x (%s), value:%d\n", cfg.feature_id, @@ -1152,18 +1156,19 @@ static int sfx_set_feature(int argc, char **argv, struct command *cmd, struct pl } else if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } static int sfx_get_feature(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - int err = 0, fd; char *desc = "ScaleFlux internal set features\n" "feature id 1: ATOMIC"; const char *feature_id = "hex feature name (required)"; const char *namespace_id = "desired namespace"; + struct nvme_dev *dev; __u32 result = 0; + int err = 0; struct config { __u32 namespace_id; @@ -1180,21 +1185,21 @@ static int sfx_get_feature(int argc, char **argv, struct command *cmd, struct pl OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { - return fd; - } + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; if (!cfg.feature_id) { fprintf(stderr, "feature-id required param\n"); - close(fd); + dev_close(dev); return EINVAL; } - err = nvme_sfx_get_features(fd, cfg.namespace_id, cfg.feature_id, &result); + err = nvme_sfx_get_features(dev_fd(dev), cfg.namespace_id, + cfg.feature_id, &result); if (err < 0) { perror("ScaleFlux-get-feature"); - close(fd); + dev_close(dev); return errno; } else if (!err) { printf("ScaleFlux get-feature:%02x (%s), value:%d\n", cfg.feature_id, @@ -1202,7 +1207,7 @@ static int sfx_get_feature(int argc, char **argv, struct command *cmd, struct pl } else if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } diff --git a/plugins/seagate/seagate-diag.h b/plugins/seagate/seagate-diag.h index 139901d..39f0d39 100644 --- a/plugins/seagate/seagate-diag.h +++ b/plugins/seagate/seagate-diag.h @@ -18,6 +18,8 @@ * * \file seagate-diag.h * \brief This file defines the functions and macros to make building a nvme-cli seagate plug-in. + * + * Author: Debabrata Bardhan */ @@ -25,19 +27,66 @@ #define SEAGATE_NVME_H #define SEAGATE_PLUGIN_VERSION_MAJOR 1 -#define SEAGATE_PLUGIN_VERSION_MINOR 1 +#define SEAGATE_PLUGIN_VERSION_MINOR 2 + +#define SEAGATE_OCP_PLUGIN_VERSION_MAJOR 1 +#define SEAGATE_OCP_PLUGIN_VERSION_MINOR 0 #define PERSIST_FILE_SIZE (2764800) #define ONE_MB (1048576) /* (1024 * 1024) */ #define PERSIST_CHUNK (65536) /* (1024 * 64) */ #define FOUR_KB (4096) +#define STX_NUM_LEGACY_DRV (123) + + +const char* stx_jag_pan_mn[STX_NUM_LEGACY_DRV] = {"ST1000KN0002", "ST1000KN0012", "ST2000KN0002", + "ST2000KN0012", "ST4000KN0002", "XP1600HE10002", + "XP1600HE10012", "XP1600HE30002", "XP1600HE30012", + "XP1920LE10002", "XP1920LE10012", "XP1920LE30002", + "XP1920LE30012", "XP3200HE10002", "XP3200HE10012", + "XP3840LE10002", "XP3840LE10012", "XP400HE30002", + "XP400HE30012", "XP400HE30022", "XP400HE30032", + "XP480LE30002", "XP480LE30012", "XP480LE30022", + "XP480LE30032", "XP800HE10002", "XP800HE10012", + "XP800HE30002", "XP800HE30012", "XP800HE30022", + "XP800HE30032", "XP960LE10002", "XP960LE10012", + "XP960LE30002", "XP960LE30012", "XP960LE30022", + "XP960LE30032", "XP256LE30011", "XP256LE30021", + "XP7680LE80002", "XP7680LE80003", "XP15360LE80003", + "XP30720LE80003", "XP7200-1A2048", "XP7200-1A4096", + "XP7201-2A2048", "XP7201-2A4096", "XP7200-1A8192", + "ST1000HM0021", "ST1000HM0031", "ST1000HM0061", + "ST1000HM0071", "ST1000HM0081", "ST1200HM0001", + "ST1600HM0031", "ST1800HM0001", "ST1800HM0011", + "ST2000HM0011", "ST2000HM0031", "ST400HM0061", + "ST400HM0071", "ST500HM0021", "ST500HM0031", + "ST500HM0061", "ST500HM0071", "ST500HM0081", + "ST800HM0061", "ST800HM0071", "ST1600HM0011", + "ST1600KN0001", "ST1600KN0011", "ST1920HM0001", + "ST1920KN0001", "ST1920KN0011", "ST400HM0021", + "ST400KN0001", "ST400KN0011", "ST480HM0001", + "ST480KN0001", "ST480KN0011", "ST800HM0021", + "ST800KN0001", "ST800KN0011", "ST960HM0001", + "ST960KN0001", "ST960KN0011", "XF1441-1AA251024", + "XF1441-1AA252048", "XF1441-1AA25512", "XF1441-1AB251024", + "XF1441-1AB252048", "XF1441-1AB25512", "XF1441-1BA251024", + "XF1441-1BA252048", "XF1441-1BA25512", "XF1441-1BB251024", + "XF1441-1BB252048", "XF1441-1BB25512", "ST400HM0031", + "ST400KN0021", "ST400KN0031", "ST480HM0011", + "ST480KN0021", "ST480KN0031", "ST800HM0031", + "ST800KN0021", "ST800KN0031", "ST960HM0011", + "ST960KN0021", "ST960KN0031", "XM1441-1AA111024", + "XM1441-1AA112048", "XM1441-1AA11512", "XM1441-1AA801024", + "XM1441-1AA80512", "XM1441-1AB111024", "XM1441-1AB112048", + "XM1441-1BA111024", "XM1441-1BA112048", "XM1441-1BA11512", + "XM1441-1BA801024", "XM1441-1BA80512", "XM1441-1BB112048"}; /*************************** *Supported Log-Pages from FW ***************************/ -typedef struct log_page_map_entry { +typedef struct __attribute__((__packed__)) log_page_map_entry { __u32 LogPageID; __u32 LogPageSignature; __u32 LogPageVersion; @@ -45,7 +94,7 @@ typedef struct log_page_map_entry { #define MAX_SUPPORTED_LOG_PAGE_ENTRIES ((4096 - sizeof(__u32)) / sizeof(log_page_map_entry)) -typedef struct log_page_map { +typedef struct __attribute__((__packed__)) log_page_map { __u32 NumLogPages; log_page_map_entry LogPageEntry[ MAX_SUPPORTED_LOG_PAGE_ENTRIES ]; } log_page_map; @@ -55,7 +104,6 @@ typedef struct log_page_map { /*************************** * Extended-SMART Information ***************************/ -#pragma pack(1) #define NUMBER_EXTENDED_SMART_ATTRIBUTES 42 typedef enum _EXTENDED_SMART_VERSION_ @@ -65,7 +113,7 @@ typedef enum _EXTENDED_SMART_VERSION_ EXTENDED_SMART_VERSION_VENDOR1, } EXTENDED_SMART_VERSION; -typedef struct _SmartVendorSpecific +typedef struct __attribute__((__packed__)) _SmartVendorSpecific { __u8 AttributeNumber; __u16 SmartStatus; @@ -75,22 +123,22 @@ typedef struct _SmartVendorSpecific __u8 RawHigh[3]; } SmartVendorSpecific; -typedef struct _EXTENDED_SMART_INFO_T +typedef struct __attribute__((__packed__)) _EXTENDED_SMART_INFO_T { __u16 Version; SmartVendorSpecific vendorData[NUMBER_EXTENDED_SMART_ATTRIBUTES]; __u8 vendor_specific_reserved[6]; } EXTENDED_SMART_INFO_T; -typedef struct vendor_smart_attribute_data +typedef struct __attribute__((__packed__)) vendor_smart_attribute_data { - __u8 AttributeNumber; /* 00 */ - __u8 Rsvd[3]; /* 01 -03 */ - __u32 LSDword; /* 04-07 */ - __u32 MSDword; /* 08 - 11 */ + __u8 AttributeNumber; + __u8 Rsvd[3]; + __u32 LSDword; + __u32 MSDword; } vendor_smart_attribute_data; -struct nvme_temetry_log_hdr +struct __attribute__((__packed__)) nvme_temetry_log_hdr { __u8 log_id; __u8 rsvd1[4]; @@ -104,38 +152,75 @@ struct nvme_temetry_log_hdr __u8 reason_identifier[128]; }; -typedef struct _U128 +typedef struct __attribute__((__packed__)) _U128 { __u64 LS__u64; __u64 MS__u64; } U128; -typedef struct _vendor_log_page_CF_Attr +typedef struct __attribute__((__packed__)) _vendor_log_page_CF_Attr { - __u16 SuperCapCurrentTemperature; /* 00-01 */ - __u16 SuperCapMaximumTemperature; /* 02-03 */ - __u8 SuperCapStatus; /* 04 */ - __u8 Reserved5to7[3]; /* 05-07 */ - U128 DataUnitsReadToDramNamespace; /* 08-23 */ - U128 DataUnitsWrittenToDramNamespace; /* 24-39 */ - __u64 DramCorrectableErrorCount; /* 40-47 */ - __u64 DramUncorrectableErrorCount; /* 48-55 */ -}vendor_log_page_CF_Attr; - -typedef struct _vendor_log_page_CF + __u16 SuperCapCurrentTemperature; + __u16 SuperCapMaximumTemperature; + __u8 SuperCapStatus; + __u8 Reserved5to7[3]; + U128 DataUnitsReadToDramNamespace; + U128 DataUnitsWrittenToDramNamespace; + __u64 DramCorrectableErrorCount; + __u64 DramUncorrectableErrorCount; +} vendor_log_page_CF_Attr; + +typedef struct __attribute__((__packed__)) _vendor_log_page_CF { vendor_log_page_CF_Attr AttrCF; __u8 Vendor_Specific_Reserved[ 456 ]; /* 56-511 */ -}vendor_log_page_CF; +} vendor_log_page_CF; + +typedef struct __attribute__((__packed__)) _STX_EXT_SMART_LOG_PAGE_C0 +{ + U128 phyMediaUnitsWrt; + U128 phyMediaUnitsRd; + __u64 badUsrNandBlocks; + __u64 badSysNandBlocks; + __u64 xorRecoveryCnt; + __u64 ucRdEc; + __u64 softEccEc; + __u64 etoeCrrCnt; + __u64 sysDataUsed : 8; + __u64 refreshCount : 56; + __u64 usrDataEraseCnt; + __u16 thermalThrottling; + __u8 dssdSpecVerErrata; + __u16 dssdSpecVerPoint; + __u16 dssdSpecVerMinor; + __u8 dssdSpecVerMajor; + __u64 pcieCorrEc; + __u32 incompleteShutdowns; + __u32 rsvd_116_119; + __u8 freeBlocks; + __u8 rsvd_121_127[7]; + __u16 capHealth; + __u8 nvmeErrataVer; + __u8 rsvd_131_135[5]; + __u64 unalignedIO; + __u64 secVerNum; + __u64 totalNUSE; + U128 plpStartCnt; + U128 enduranceEstimate; + __u64 pcieLinkRetCnt; + __u64 powStateChangeCnt; + __u8 rsvd_208_493[286]; + __u16 logPageVer; + U128 logPageGUID; +} STX_EXT_SMART_LOG_PAGE_C0; -#pragma pack() /* EOF Extended-SMART Information*/ /************************** * PCIE ERROR INFORMATION **************************/ -typedef struct pcie_error_log_page +typedef struct __attribute__((__packed__)) pcie_error_log_page { __u32 Version; __u32 BadDllpErrCnt; @@ -159,53 +244,86 @@ typedef struct pcie_error_log_page } pcie_error_log_page; /*EOF PCIE ERROR INFORMATION */ +/************************************** +* FW Activation History Log INFORMATION +***************************************/ + +typedef struct __attribute__((__packed__)) _stx_fw_activ_his_ele +{ + __u8 entryVerNum; + __u8 entryLen; + __u16 rev02_03; + __u16 fwActivCnt; + __u64 timeStamp; + __u64 rev14_21; + __u64 powCycleCnt; + __u8 previousFW[8]; + __u8 newFW[8]; + __u8 slotNum; + __u8 commitActionType; + __u16 result; + __u8 rev50_63[14]; +} stx_fw_activ_his_ele; + +typedef struct __attribute__((__packed__)) _stx_fw_activ_history_log_page +{ + __u8 logID; + __u8 rev01_03[3]; + __u32 numValidFwActHisEnt; + stx_fw_activ_his_ele fwActHisEnt[20]; + __u8 rev1288_4077[2790]; + __u16 logPageVer; + __u8 logPageGUID[16]; +} stx_fw_activ_history_log_page; + +/* FW Activation History Log INFORMATION */ + + typedef enum { - VS_ATTR_SOFT_READ_ERROR_RATE, /* 0 OFFSET : 02 -13 bytes */ - VS_ATTR_REALLOCATED_SECTOR_COUNT, /* 1 OFFSET : 14 -25 bytes */ - VS_ATTR_POWER_ON_HOURS, /* 2 OFFSET : 26 -37 bytes */ + VS_ATTR_SOFT_READ_ERROR_RATE, /* 0 OFFSET : 02 -13 bytes */ + VS_ATTR_REALLOCATED_SECTOR_COUNT, /* 1 OFFSET : 14 -25 bytes */ + VS_ATTR_POWER_ON_HOURS, /* 2 OFFSET : 26 -37 bytes */ VS_ATTR_POWER_FAIL_EVENT_COUNT, /* 3 OFFSET : 38 -49 bytes */ VS_ATTR_DEVICE_POWER_CYCLE_COUNT, /* 4 OFFSET : 50 -61 bytes */ - VS_ATTR_GB_ERASED, /* 5 OFFSET : 62 -73 bytes */ + VS_ATTR_GB_ERASED, /* 5 OFFSET : 62 -73 bytes */ VS_ATTR_LIFETIME_DEVSLEEP_EXIT_COUNT, /* 6 OFFSET : 74 -85 bytes */ - VS_ATTR_LIFETIME_ENTERING_PS4_COUNT, /* 7 OFFSET : 86 -97 bytes */ - VS_ATTR_LIFETIME_ENTERING_PS3_COUNT, /* 8 OFFSET : 98 -109 bytes */ - VS_ATTR_RETIRED_BLOCK_COUNT, /* 9 OFFSET : 110 -121 bytes */ - VS_ATTR_PROGRAM_FAILURE_COUNT, /* 10 OFFSET : 122 -133 bytes */ - VS_ATTR_ERASE_FAIL_COUNT, /* 11 OFFSET : 134 -145 bytes */ - VS_ATTR_AVG_ERASE_COUNT, /* 12 OFFSET : 146 -157 bytes */ - VS_ATTR_UNEXPECTED_POWER_LOSS_COUNT, /* 13 OFFSET : 158 -169 bytes */ - VS_ATTR_WEAR_RANGE_DELTA, /* 14 OFFSET : 170 -181 bytes */ - VS_ATTR_SATA_INTERFACE_DOWNSHIFT_COUNT, /* 15 OFFSET : 182 -193 bytes */ - VS_ATTR_END_TO_END_CRC_ERROR_COUNT, /* 16 OFFSET : 194 -205 bytes */ - VS_ATTR_MAX_LIFE_TEMPERATURE, /* 17 OFFSET : 206 -217 bytes */ - VS_ATTR_UNCORRECTABLE_RAISE_ERRORS, /* 18 OFFSET : 218 -229 bytes */ - VS_ATTR_DRIVE_LIFE_PROTECTION_STATUS, /* 19 OFFSET : 230 -241 bytes */ - VS_ATTR_REMAINING_SSD_LIFE, /* 20 OFFSET : 242 -253 bytes */ - VS_ATTR_LIFETIME_WRITES_TO_FLASH, /* 21 OFFSET : 254 -265 bytes */ - VS_ATTR_LIFETIME_WRITES_FROM_HOST, /* 22 OFFSET : 266 -277 bytes */ - VS_ATTR_LIFETIME_READS_TO_HOST, /* 23 OFFSET : 278 -289 bytes */ - VS_ATTR_FREE_SPACE, /* 24 OFFSET : 290 -301 bytes */ - VS_ATTR_TRIM_COUNT_LSB, /* 25 OFFSET : 302 -313 bytes */ - VS_ATTR_TRIM_COUNT_MSB, /* 26 OFFSET : 314 -325 bytes */ - VS_ATTR_OP_PERCENTAGE, /* 27 OFFSET : 326 -337 bytes */ - VS_ATTR_RAISE_ECC_CORRECTABLE_ERROR_COUNT, /* 28 OFFSET : 338 -349 bytes */ - VS_ATTR_UNCORRECTABLE_ECC_ERRORS , /* 29 OFFSET : 350 -361 bytes */ - VS_ATTR_LIFETIME_WRITES0_TO_FLASH, /* 30 362-372 */ - VS_ATTR_LIFETIME_WRITES1_TO_FLASH, /* 31 374-385 */ - VS_ATTR_LIFETIME_WRITES0_FROM_HOST, /* 32 386-397 */ - VS_ATTR_LIFETIME_WRITES1_FROM_HOST, /* 33 398-409 */ - VS_ATTR_LIFETIME_READ0_FROM_HOST, /* 34 410-421 */ - VS_ATTR_LIFETIME_READ1_FROM_HOST, /* 35 422-433 */ - VS_ATTR_PCIE_PHY_CRC_ERROR, /* 36 434-445 */ - VS_ATTR_BAD_BLOCK_COUNT_SYSTEM, /* 37 446-457 */ - VS_ATTR_BAD_BLOCK_COUNT_USER, /* 38 458-469 */ - VS_ATTR_THERMAL_THROTTLING_STATUS, /* 39 470-481 */ - VS_ATTR_POWER_CONSUMPTION, /* 40 482-493 */ - VS_ATTR_MAX_SOC_LIFE_TEMPERATURE, /* 41 494-505 */ - - VS_MAX_ATTR_NUMBER, - + VS_ATTR_LIFETIME_ENTERING_PS4_COUNT, /* 7 OFFSET : 86 -97 bytes */ + VS_ATTR_LIFETIME_ENTERING_PS3_COUNT, /* 8 OFFSET : 98 -109 bytes */ + VS_ATTR_RETIRED_BLOCK_COUNT, /* 9 OFFSET : 110 -121 bytes */ + VS_ATTR_PROGRAM_FAILURE_COUNT, /* 10 OFFSET : 122 -133 bytes */ + VS_ATTR_ERASE_FAIL_COUNT, /* 11 OFFSET : 134 -145 bytes */ + VS_ATTR_AVG_ERASE_COUNT, /* 12 OFFSET : 146 -157 bytes */ + VS_ATTR_UNEXPECTED_POWER_LOSS_COUNT, /* 13 OFFSET : 158 -169 bytes */ + VS_ATTR_WEAR_RANGE_DELTA, /* 14 OFFSET : 170 -181 bytes */ + VS_ATTR_SATA_INTERFACE_DOWNSHIFT_COUNT, /* 15 OFFSET : 182 -193 bytes */ + VS_ATTR_END_TO_END_CRC_ERROR_COUNT, /* 16 OFFSET : 194 -205 bytes */ + VS_ATTR_MAX_LIFE_TEMPERATURE, /* 17 OFFSET : 206 -217 bytes */ + VS_ATTR_UNCORRECTABLE_RAISE_ERRORS, /* 18 OFFSET : 218 -229 bytes */ + VS_ATTR_DRIVE_LIFE_PROTECTION_STATUS, /* 19 OFFSET : 230 -241 bytes */ + VS_ATTR_REMAINING_SSD_LIFE, /* 20 OFFSET : 242 -253 bytes */ + VS_ATTR_LIFETIME_WRITES_TO_FLASH, /* 21 OFFSET : 254 -265 bytes */ + VS_ATTR_LIFETIME_WRITES_FROM_HOST, /* 22 OFFSET : 266 -277 bytes */ + VS_ATTR_LIFETIME_READS_TO_HOST, /* 23 OFFSET : 278 -289 bytes */ + VS_ATTR_FREE_SPACE, /* 24 OFFSET : 290 -301 bytes */ + VS_ATTR_TRIM_COUNT_LSB, /* 25 OFFSET : 302 -313 bytes */ + VS_ATTR_TRIM_COUNT_MSB, /* 26 OFFSET : 314 -325 bytes */ + VS_ATTR_OP_PERCENTAGE, /* 27 OFFSET : 326 -337 bytes */ + VS_ATTR_RAISE_ECC_CORRECTABLE_ERROR_COUNT, /* 28 OFFSET : 338 -349 bytes */ + VS_ATTR_UNCORRECTABLE_ECC_ERRORS , /* 29 OFFSET : 350 -361 bytes */ + VS_ATTR_LIFETIME_WRITES0_TO_FLASH, /* 30 OFFSET : 362-372 bytes */ + VS_ATTR_LIFETIME_WRITES1_TO_FLASH, /* 31 OFFSET : 374-385 bytes */ + VS_ATTR_LIFETIME_WRITES0_FROM_HOST, /* 32 OFFSET : 386-397 bytes */ + VS_ATTR_LIFETIME_WRITES1_FROM_HOST, /* 33 OFFSET : 398-409 bytes */ + VS_ATTR_LIFETIME_READ0_FROM_HOST, /* 34 OFFSET : 410-421 bytes */ + VS_ATTR_LIFETIME_READ1_FROM_HOST, /* 35 OFFSET : 422-433 bytes */ + VS_ATTR_PCIE_PHY_CRC_ERROR, /* 36 OFFSET : 434-445 bytes */ + VS_ATTR_BAD_BLOCK_COUNT_SYSTEM, /* 37 OFFSET : 446-457 bytes */ + VS_ATTR_BAD_BLOCK_COUNT_USER, /* 38 OFFSET : 458-469 bytes */ + VS_ATTR_THERMAL_THROTTLING_STATUS, /* 39 OFFSET : 470-481 bytes */ + VS_ATTR_POWER_CONSUMPTION, /* 40 OFFSET : 482-493 bytes */ + VS_ATTR_MAX_SOC_LIFE_TEMPERATURE, /* 41 OFFSET : 494-505 bytes */ + VS_MAX_ATTR_NUMBER } extended_smart_attributes; /*Smart attribute IDs */ diff --git a/plugins/seagate/seagate-nvme.c b/plugins/seagate/seagate-nvme.c index a527c0f..1bd30a5 100644 --- a/plugins/seagate/seagate-nvme.c +++ b/plugins/seagate/seagate-nvme.c @@ -18,6 +18,8 @@ * * \file seagate-nvme.c * \brief This file defines the functions and macros to make building a nvme-cli seagate plug-in. + * + * Author: Debabrata Bardhan */ @@ -25,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +38,7 @@ #include "plugin.h" #include "linux/types.h" #include "nvme-print.h" +#include #define CREATE_CMD @@ -43,11 +47,11 @@ /*************************************** -*Command for "log-pages-supp" -***************************************/ + * Command for "log-pages-supp" + ***************************************/ static char *log_pages_supp_print(__u32 pageID) { - switch(pageID) { + switch (pageID) { case 0x01: return "ERROR_INFORMATION"; break; @@ -126,6 +130,20 @@ static char *log_pages_supp_print(__u32 pageID) } } +static int stx_is_jag_pan(char *devMN) +{ + int match_found = 1; /* found = 0, not_found = 1 */ + + for (int i = 0; i < STX_NUM_LEGACY_DRV; i++) { + match_found = strncmp(devMN, stx_jag_pan_mn[i], strlen(stx_jag_pan_mn[i])); + if (match_found == 0) { + break; + } + } + + return match_found; +} + static void json_log_pages_supp(log_page_map *logPageMap) { @@ -147,19 +165,18 @@ static void json_log_pages_supp(log_page_map *logPageMap) json_array_add_value_object(logPages, lbaf); } json_print_object(root, NULL); - printf("\n"); json_free_object(root); } static int log_pages_supp(int argc, char **argv, struct command *cmd, - struct plugin *plugin) + struct plugin *plugin) { int err = 0; - int fd = 0; __u32 i = 0; log_page_map logPageMap; const char *desc = "Retrieve Seagate Supported Log-Page information for the given device "; const char *output_format = "output in binary format"; + struct nvme_dev *dev; int fmt; struct config { @@ -175,35 +192,36 @@ static int log_pages_supp(int argc, char **argv, struct command *cmd, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; - err = nvme_get_log_simple(fd, 0xc5, sizeof(logPageMap), &logPageMap); + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; + err = nvme_get_log_simple(dev_fd(dev), 0xc5, + sizeof(logPageMap), &logPageMap); if (!err) { - if (strcmp(cfg.output_format,"json")) { + if (strcmp(cfg.output_format, "json")) { printf ("Seagate Supported Log-pages count :%d\n", le32_to_cpu(logPageMap.NumLogPages)); printf ("%-15s %-30s\n", "LogPage-Id", "LogPage-Name"); - for(fmt=0; fmt<45; fmt++) - printf ("-"); + for (fmt = 0; fmt < 45; fmt++) + printf("-"); printf("\n"); } else json_log_pages_supp(&logPageMap); - for (i = 0; i 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } @@ -215,7 +233,7 @@ static int log_pages_supp(int argc, char **argv, struct command *cmd, ***************************************/ static char *print_ext_smart_id(__u8 attrId) { - switch(attrId) { + switch (attrId) { case VS_ATTR_ID_SOFT_READ_ERROR_RATE: return "Soft ECC error count"; break; @@ -280,7 +298,7 @@ static char *print_ext_smart_id(__u8 attrId) return "LIFETIME_ENTERING_PS3_COUNT"; break; case VS_ATTR_ID_RETIRED_BLOCK_COUNT: - return "Retired block count"; /*VS_ATTR_ID_RETIRED_BLOCK_COUNT*/ + return "Retired block count"; break; case VS_ATTR_ID_PROGRAM_FAILURE_COUNT: return "Program fail count"; @@ -307,13 +325,13 @@ static char *print_ext_smart_id(__u8 attrId) return "Uncorrectable Read Error Count"; break; case VS_ATTR_ID_MAX_LIFE_TEMPERATURE: - return "Max lifetime temperature";/*VS_ATTR_ID_MAX_LIFE_TEMPERATURE for extended*/ + return "Max lifetime temperature"; break; case VS_ATTR_ID_RAISE_ECC_CORRECTABLE_ERROR_COUNT: return "RAIS_ECC_CORRECT_ERR_COUNT"; break; case VS_ATTR_ID_UNCORRECTABLE_RAISE_ERRORS: - return "Uncorrectable RAISE error count";/*VS_ATTR_ID_UNCORRECTABLE_RAISE_ERRORS*/ + return "Uncorrectable RAISE error count"; break; case VS_ATTR_ID_DRIVE_LIFE_PROTECTION_STATUS: return "DRIVE_LIFE_PROTECTION_STATUS"; @@ -356,7 +374,7 @@ static char *print_ext_smart_id(__u8 attrId) break; default: return "Un-Known"; - } + } } static __u64 smart_attribute_vs(__u16 verNo, SmartVendorSpecific attr) @@ -435,9 +453,8 @@ static void print_smart_log(__u16 verNo, SmartVendorSpecific attr, int lastAttr) if ((attr.AttributeNumber != 0) && (hideAttr != 1)) { printf("%-40s", print_ext_smart_id(attr.AttributeNumber)); - printf("%-15d", attr.AttributeNumber ); - printf(" 0x%016"PRIx64"", (uint64_t)smart_attribute_vs(verNo, attr)); - printf("\n"); + printf("%-15d", attr.AttributeNumber); + printf(" 0x%016"PRIx64"\n", (uint64_t)smart_attribute_vs(verNo, attr)); } if (lastAttr == 1) { @@ -448,8 +465,7 @@ static void print_smart_log(__u16 verNo, SmartVendorSpecific attr, int lastAttr) printf("%-15d", VS_ATTR_ID_GB_ERASED_MSB << 8 | VS_ATTR_ID_GB_ERASED_LSB); sprintf(buf, "0x%016"PRIx64"%016"PRIx64"", (uint64_t)msbGbErased, (uint64_t)lsbGbErased); - printf(" %s", buf); - printf("\n"); + printf(" %s\n", buf); sprintf(strBuf, "%s", (print_ext_smart_id(VS_ATTR_ID_LIFETIME_WRITES_TO_FLASH_LSB) + 7)); printf("%-40s", strBuf); @@ -457,8 +473,7 @@ static void print_smart_log(__u16 verNo, SmartVendorSpecific attr, int lastAttr) printf("%-15d", VS_ATTR_ID_LIFETIME_WRITES_TO_FLASH_MSB << 8 | VS_ATTR_ID_LIFETIME_WRITES_TO_FLASH_LSB); sprintf(buf, "0x%016"PRIx64"%016"PRIx64"", (uint64_t)msbLifWrtToFlash, (uint64_t)lsbLifWrtToFlash); - printf(" %s", buf); - printf("\n"); + printf(" %s\n", buf); sprintf(strBuf, "%s", (print_ext_smart_id(VS_ATTR_ID_LIFETIME_WRITES_FROM_HOST_LSB) + 7)); printf("%-40s", strBuf); @@ -466,8 +481,7 @@ static void print_smart_log(__u16 verNo, SmartVendorSpecific attr, int lastAttr) printf("%-15d", VS_ATTR_ID_LIFETIME_WRITES_FROM_HOST_MSB << 8 | VS_ATTR_ID_LIFETIME_WRITES_FROM_HOST_LSB); sprintf(buf, "0x%016"PRIx64"%016"PRIx64"", (uint64_t)msbLifWrtFrmHost, (uint64_t)lsbLifWrtFrmHost); - printf(" %s", buf); - printf("\n"); + printf(" %s\n", buf); sprintf(strBuf, "%s", (print_ext_smart_id(VS_ATTR_ID_LIFETIME_READS_TO_HOST_LSB) + 7)); printf("%-40s", strBuf); @@ -475,8 +489,7 @@ static void print_smart_log(__u16 verNo, SmartVendorSpecific attr, int lastAttr) printf("%-15d", VS_ATTR_ID_LIFETIME_READS_TO_HOST_MSB << 8 | VS_ATTR_ID_LIFETIME_READS_TO_HOST_LSB); sprintf(buf, "0x%016"PRIx64"%016"PRIx64"", (uint64_t)msbLifRdToHost, (uint64_t)lsbLifRdToHost); - printf(" %s", buf); - printf("\n"); + printf(" %s\n", buf); sprintf(strBuf, "%s", (print_ext_smart_id(VS_ATTR_ID_TRIM_COUNT_LSB) + 7)); printf("%-40s", strBuf); @@ -484,16 +497,13 @@ static void print_smart_log(__u16 verNo, SmartVendorSpecific attr, int lastAttr) printf("%-15d", VS_ATTR_ID_TRIM_COUNT_MSB << 8 | VS_ATTR_ID_TRIM_COUNT_LSB); sprintf(buf, "0x%016"PRIx64"%016"PRIx64"", (uint64_t)msbTrimCnt, (uint64_t)lsbTrimCnt); - printf(" %s", buf); - printf("\n"); + printf(" %s\n", buf); } } -static void json_print_smart_log(struct json_object *root, - EXTENDED_SMART_INFO_T *ExtdSMARTInfo ) +static void json_print_smart_log(struct json_object *root, EXTENDED_SMART_INFO_T *ExtdSMARTInfo) { - /*struct json_object *root; */ struct json_object *lbafs; int index = 0; @@ -501,46 +511,45 @@ static void json_print_smart_log(struct json_object *root, lsbLifWrtFrmHost = 0, msbLifWrtFrmHost = 0, lsbLifRdToHost = 0, msbLifRdToHost = 0, lsbTrimCnt = 0, msbTrimCnt = 0; char buf[40] = {0}; - /*root = json_create_object();*/ lbafs = json_create_array(); json_object_add_value_array(root, "Extended-SMART-Attributes", lbafs); - for (index =0; index < NUMBER_EXTENDED_SMART_ATTRIBUTES; index++) { + for (index = 0; index < NUMBER_EXTENDED_SMART_ATTRIBUTES; index++) { struct json_object *lbaf = json_create_object(); if (ExtdSMARTInfo->vendorData[index].AttributeNumber != 0) { json_object_add_value_string(lbaf, "attribute_name", print_ext_smart_id(ExtdSMARTInfo->vendorData[index].AttributeNumber)); - json_object_add_value_int(lbaf, "attribute_id",ExtdSMARTInfo->vendorData[index].AttributeNumber); + json_object_add_value_int(lbaf, "attribute_id", ExtdSMARTInfo->vendorData[index].AttributeNumber); json_object_add_value_int(lbaf, "attribute_value", smart_attribute_vs(ExtdSMARTInfo->Version, ExtdSMARTInfo->vendorData[index])); json_array_add_value_object(lbafs, lbaf); - if(ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_GB_ERASED_LSB) + if (ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_GB_ERASED_LSB) lsbGbErased = smart_attribute_vs(ExtdSMARTInfo->Version, ExtdSMARTInfo->vendorData[index]); - if(ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_GB_ERASED_MSB) + if (ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_GB_ERASED_MSB) msbGbErased = smart_attribute_vs(ExtdSMARTInfo->Version, ExtdSMARTInfo->vendorData[index]); - if(ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_LIFETIME_WRITES_TO_FLASH_LSB) + if (ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_LIFETIME_WRITES_TO_FLASH_LSB) lsbLifWrtToFlash = smart_attribute_vs(ExtdSMARTInfo->Version, ExtdSMARTInfo->vendorData[index]); - if(ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_LIFETIME_WRITES_TO_FLASH_MSB) + if (ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_LIFETIME_WRITES_TO_FLASH_MSB) msbLifWrtToFlash = smart_attribute_vs(ExtdSMARTInfo->Version, ExtdSMARTInfo->vendorData[index]); - if(ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_LIFETIME_WRITES_FROM_HOST_LSB) + if (ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_LIFETIME_WRITES_FROM_HOST_LSB) lsbLifWrtFrmHost = smart_attribute_vs(ExtdSMARTInfo->Version, ExtdSMARTInfo->vendorData[index]); - if(ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_LIFETIME_WRITES_FROM_HOST_MSB) + if (ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_LIFETIME_WRITES_FROM_HOST_MSB) msbLifWrtFrmHost = smart_attribute_vs(ExtdSMARTInfo->Version, ExtdSMARTInfo->vendorData[index]); - if(ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_LIFETIME_READS_TO_HOST_LSB) + if (ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_LIFETIME_READS_TO_HOST_LSB) lsbLifRdToHost = smart_attribute_vs(ExtdSMARTInfo->Version, ExtdSMARTInfo->vendorData[index]); - if(ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_LIFETIME_READS_TO_HOST_MSB) + if (ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_LIFETIME_READS_TO_HOST_MSB) msbLifRdToHost = smart_attribute_vs(ExtdSMARTInfo->Version, ExtdSMARTInfo->vendorData[index]); - if(ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_TRIM_COUNT_LSB) + if (ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_TRIM_COUNT_LSB) lsbTrimCnt = smart_attribute_vs(ExtdSMARTInfo->Version, ExtdSMARTInfo->vendorData[index]); - if(ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_TRIM_COUNT_MSB) + if (ExtdSMARTInfo->vendorData[index].AttributeNumber == VS_ATTR_ID_TRIM_COUNT_MSB) msbTrimCnt = smart_attribute_vs(ExtdSMARTInfo->Version, ExtdSMARTInfo->vendorData[index]); } } @@ -598,11 +607,6 @@ static void json_print_smart_log(struct json_object *root, sprintf(buf, "0x%016"PRIx64"%016"PRIx64"", (uint64_t)msbTrimCnt, (uint64_t)lsbTrimCnt); json_object_add_value_string(lbaf, "attribute_value", buf); json_array_add_value_object(lbafs, lbaf); - - /* - json_print_object(root, NULL); - printf("\n"); - */ } static void print_smart_log_CF(vendor_log_page_CF *pLogPageCF) @@ -613,63 +617,47 @@ static void print_smart_log_CF(vendor_log_page_CF *pLogPageCF) printf("%-40s", "Super-cap current temperature"); currentTemp = pLogPageCF->AttrCF.SuperCapCurrentTemperature; - /*currentTemp = currentTemp ? currentTemp - 273 : 0;*/ - printf(" 0x%016"PRIx64"", le64_to_cpu(currentTemp)); - printf("\n"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(currentTemp)); maxTemp = pLogPageCF->AttrCF.SuperCapMaximumTemperature; - /*maxTemp = maxTemp ? maxTemp - 273 : 0;*/ printf("%-40s", "Super-cap maximum temperature"); - printf(" 0x%016"PRIx64"", le64_to_cpu(maxTemp)); - printf("\n"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(maxTemp)); printf("%-40s", "Super-cap status"); - printf(" 0x%016"PRIx64"", le64_to_cpu(pLogPageCF->AttrCF.SuperCapStatus)); - printf("\n"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageCF->AttrCF.SuperCapStatus)); printf("%-40s", "Data units read to DRAM namespace"); - printf(" 0x%016"PRIx64"%016"PRIx64"", le64_to_cpu(pLogPageCF->AttrCF.DataUnitsReadToDramNamespace.MS__u64), - le64_to_cpu(pLogPageCF->AttrCF.DataUnitsReadToDramNamespace.LS__u64)); - printf("\n"); + printf(" 0x%016"PRIx64"%016"PRIx64"\n", le64_to_cpu(pLogPageCF->AttrCF.DataUnitsReadToDramNamespace.MS__u64), + le64_to_cpu(pLogPageCF->AttrCF.DataUnitsReadToDramNamespace.LS__u64)); printf("%-40s", "Data units written to DRAM namespace"); - printf(" 0x%016"PRIx64"%016"PRIx64"", le64_to_cpu(pLogPageCF->AttrCF.DataUnitsWrittenToDramNamespace.MS__u64), - le64_to_cpu(pLogPageCF->AttrCF.DataUnitsWrittenToDramNamespace.LS__u64)); - printf("\n"); + printf(" 0x%016"PRIx64"%016"PRIx64"\n", le64_to_cpu(pLogPageCF->AttrCF.DataUnitsWrittenToDramNamespace.MS__u64), + le64_to_cpu(pLogPageCF->AttrCF.DataUnitsWrittenToDramNamespace.LS__u64)); printf("%-40s", "DRAM correctable error count"); - printf(" 0x%016"PRIx64"", le64_to_cpu(pLogPageCF->AttrCF.DramCorrectableErrorCount)); - printf("\n"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageCF->AttrCF.DramCorrectableErrorCount)); printf("%-40s", "DRAM uncorrectable error count"); - printf(" 0x%016"PRIx64"", le64_to_cpu(pLogPageCF->AttrCF.DramUncorrectableErrorCount)); - printf("\n"); - + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageCF->AttrCF.DramUncorrectableErrorCount)); } -static void json_print_smart_log_CF(struct json_object *root, - vendor_log_page_CF *pLogPageCF) +static void json_print_smart_log_CF(struct json_object *root, vendor_log_page_CF *pLogPageCF) { - /*struct json_object *root;*/ struct json_object *logPages; unsigned int currentTemp, maxTemp; char buf[40]; - /*root = json_create_object(); */ - logPages = json_create_array(); json_object_add_value_array(root, "DRAM Supercap SMART Attributes", logPages); struct json_object *lbaf = json_create_object(); currentTemp = pLogPageCF->AttrCF.SuperCapCurrentTemperature; - /*currentTemp = currentTemp ? currentTemp - 273 : 0;*/ json_object_add_value_string(lbaf, "attribute_name", "Super-cap current temperature"); json_object_add_value_int(lbaf, "attribute_value", currentTemp); json_array_add_value_object(logPages, lbaf); lbaf = json_create_object(); maxTemp = pLogPageCF->AttrCF.SuperCapMaximumTemperature; - /*maxTemp = maxTemp ? maxTemp - 273 : 0;*/ json_object_add_value_string(lbaf, "attribute_name", "Super-cap maximum temperature"); json_object_add_value_int(lbaf, "attribute_value", maxTemp); json_array_add_value_object(logPages, lbaf); @@ -704,25 +692,285 @@ static void json_print_smart_log_CF(struct json_object *root, json_object_add_value_string(lbaf, "attribute_name", "DRAM uncorrectable error count"); json_object_add_value_int(lbaf, "attribute_value", pLogPageCF->AttrCF.DramUncorrectableErrorCount); json_array_add_value_object(logPages, lbaf); +} + + +static void print_stx_smart_log_C0(STX_EXT_SMART_LOG_PAGE_C0 *pLogPageC0) +{ + printf("\n\nSeagate SMART Health Attributes :\n"); + printf("%-39s %-19s \n", "Description", "Health Attributes"); + + printf("%-40s", "Physical Media Units Written"); + printf(" 0x%016"PRIx64"%016"PRIx64"\n", le64_to_cpu(pLogPageC0->phyMediaUnitsWrt.MS__u64), + le64_to_cpu(pLogPageC0->phyMediaUnitsWrt.LS__u64)); + + printf("%-40s", "Physical Media Units Read"); + printf(" 0x%016"PRIx64"%016"PRIx64"\n", le64_to_cpu(pLogPageC0->phyMediaUnitsRd.MS__u64), + le64_to_cpu(pLogPageC0->phyMediaUnitsRd.LS__u64)); + + printf("%-40s", "Bad User NAND Blocks"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageC0->badUsrNandBlocks)); + + printf("%-40s", "Bad System NAND Blocks"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageC0->badSysNandBlocks)); + + printf("%-40s", "XOR Recovery Count"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageC0->xorRecoveryCnt)); + + printf("%-40s", "Uncorrectable Read Error Count"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageC0->ucRdEc)); + + printf("%-40s", "Soft ECC Error Count"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageC0->softEccEc)); + + printf("%-40s", "End to End Correction Counts"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageC0->etoeCrrCnt)); + + printf("%-40s", "System Data Used in Parcent"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageC0->sysDataUsed)); + + printf("%-40s", "Refresh Counts"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageC0->refreshCount)); + + printf("%-40s", "User Data Erase Counts"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageC0->usrDataEraseCnt)); + + printf("%-40s", "Thermal Throttling Status and Count"); + printf(" 0x%04x\n", le16_to_cpu(pLogPageC0->thermalThrottling)); + + printf("%-40s", "DSSD Specification Version"); + printf(" %d.%d.%d.%d\n", pLogPageC0->dssdSpecVerMajor, + le16_to_cpu(pLogPageC0->dssdSpecVerMinor), + le16_to_cpu(pLogPageC0->dssdSpecVerPoint), + pLogPageC0->dssdSpecVerErrata); + + printf("%-40s", "PCIe Correctable Error Count"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageC0->pcieCorrEc)); + + printf("%-40s", "Incomplete Shutdowns"); + printf(" 0x%08x\n", le32_to_cpu(pLogPageC0->incompleteShutdowns)); + + printf("%-40s", "Free Blocks in Percent"); + printf(" %d\n", pLogPageC0->freeBlocks); + + printf("%-40s", "Capacitor Health"); + printf(" 0x%04x\n", le16_to_cpu(pLogPageC0->capHealth)); + + printf("%-40s", "NVMe Errata Version"); + printf(" %c\n", pLogPageC0->nvmeErrataVer); + + printf("%-40s", "Unaligned IO"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageC0->unalignedIO)); + + printf("%-40s", "Security Version Number"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageC0->secVerNum)); + + printf("%-40s", "Total Namespace Utilization"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageC0->totalNUSE)); + + printf("%-40s", "PLP Start Count"); + printf(" 0x%016"PRIx64"%016"PRIx64"\n", le64_to_cpu(pLogPageC0->plpStartCnt.MS__u64), + le64_to_cpu(pLogPageC0->plpStartCnt.LS__u64)); + + printf("%-40s", "Endurance Estimate"); + printf(" 0x%016"PRIx64"%016"PRIx64"\n", le64_to_cpu(pLogPageC0->enduranceEstimate.MS__u64), + le64_to_cpu(pLogPageC0->enduranceEstimate.LS__u64)); + + printf("%-40s", "PCIe Link Retraining Count"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageC0->pcieLinkRetCnt)); + + printf("%-40s", "Power State Change Count"); + printf(" 0x%016"PRIx64"\n", le64_to_cpu(pLogPageC0->powStateChangeCnt)); + + printf("%-40s", "Log Page Version"); + printf(" 0x%04x\n", le16_to_cpu(pLogPageC0->logPageVer)); + + printf("%-40s", "Log Page GUID"); + printf(" 0x%016"PRIx64"%016"PRIx64"\n", le64_to_cpu(pLogPageC0->logPageGUID.MS__u64), + le64_to_cpu(pLogPageC0->logPageGUID.LS__u64)); +} + +static void json_print_stx_smart_log_C0(struct json_object *root, STX_EXT_SMART_LOG_PAGE_C0 *pLogPageC0) +{ + struct json_object *logPages; + char buf[40]; + + logPages = json_create_array(); + json_object_add_value_array(root, "Seagate SMART Health Attributes", logPages); + + struct json_object *lbaf = json_create_object(); + + json_object_add_value_string(lbaf, "attribute_name", "Physical Media Units Written"); + memset(buf, 0, sizeof(buf)); + sprintf(buf, "0x%016"PRIx64"%016"PRIx64"", le64_to_cpu(pLogPageC0->phyMediaUnitsWrt.MS__u64), + le64_to_cpu(pLogPageC0->phyMediaUnitsWrt.LS__u64)); + json_object_add_value_string(lbaf, "attribute_value", buf); + json_array_add_value_object(logPages, lbaf); + + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Physical Media Units Read"); + memset(buf, 0, sizeof(buf)); + sprintf(buf, "0x%016"PRIx64"%016"PRIx64"", le64_to_cpu(pLogPageC0->phyMediaUnitsRd.MS__u64), + le64_to_cpu(pLogPageC0->phyMediaUnitsRd.LS__u64)); + json_object_add_value_string(lbaf, "attribute_value", buf); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Bad User NAND Blocks"); + json_object_add_value_int(lbaf, "attribute_value", le64_to_cpu(pLogPageC0->badUsrNandBlocks)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Bad System NAND Blocks"); + json_object_add_value_int(lbaf, "attribute_value", le64_to_cpu(pLogPageC0->badSysNandBlocks)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "XOR Recovery Count"); + json_object_add_value_int(lbaf, "attribute_value", le64_to_cpu(pLogPageC0->xorRecoveryCnt)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Uncorrectable Read Error Count"); + json_object_add_value_int(lbaf, "attribute_value", le64_to_cpu(pLogPageC0->ucRdEc)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Soft ECC Error Count"); + json_object_add_value_int(lbaf, "attribute_value", le64_to_cpu(pLogPageC0->softEccEc)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "End to End Correction Counts"); + json_object_add_value_int(lbaf, "attribute_value", le64_to_cpu(pLogPageC0->etoeCrrCnt)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "System Data Used in Parcent"); + json_object_add_value_int(lbaf, "attribute_value", le64_to_cpu(pLogPageC0->sysDataUsed)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Refresh Counts"); + json_object_add_value_int(lbaf, "attribute_value", le64_to_cpu(pLogPageC0->refreshCount)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "User Data Erase Counts"); + json_object_add_value_int(lbaf, "attribute_value", le64_to_cpu(pLogPageC0->usrDataEraseCnt)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Thermal Throttling Status and Count"); + json_object_add_value_int(lbaf, "attribute_value", le16_to_cpu(pLogPageC0->thermalThrottling)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "DSSD Specification Version"); + memset(buf, 0, sizeof(buf)); + sprintf(buf, "%d.%d.%d.%d", pLogPageC0->dssdSpecVerMajor, + le16_to_cpu(pLogPageC0->dssdSpecVerMinor), + le16_to_cpu(pLogPageC0->dssdSpecVerPoint), + pLogPageC0->dssdSpecVerErrata); + json_object_add_value_string(lbaf, "attribute_value", buf); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "PCIe Correctable Error Count"); + json_object_add_value_int(lbaf, "attribute_value", le64_to_cpu(pLogPageC0->pcieCorrEc)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Incomplete Shutdowns"); + json_object_add_value_int(lbaf, "attribute_value", le32_to_cpu(pLogPageC0->incompleteShutdowns)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Free Blocks in Percent"); + json_object_add_value_int(lbaf, "attribute_value", pLogPageC0->freeBlocks); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Capacitor Health"); + json_object_add_value_int(lbaf, "attribute_value", le16_to_cpu(pLogPageC0->capHealth)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "NVMe Errata Version"); + json_object_add_value_int(lbaf, "attribute_value", pLogPageC0->nvmeErrataVer); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Unaligned IO"); + json_object_add_value_int(lbaf, "attribute_value", le64_to_cpu(pLogPageC0->unalignedIO)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Security Version Number"); + json_object_add_value_int(lbaf, "attribute_value", le64_to_cpu(pLogPageC0->secVerNum)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Total Namespace Utilization"); + json_object_add_value_int(lbaf, "attribute_value", le64_to_cpu(pLogPageC0->totalNUSE)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "PLP Start Count"); + memset(buf, 0, sizeof(buf)); + sprintf(buf, "0x%016"PRIx64"%016"PRIx64"", le64_to_cpu(pLogPageC0->plpStartCnt.MS__u64), + le64_to_cpu(pLogPageC0->plpStartCnt.LS__u64)); + json_object_add_value_string(lbaf, "attribute_value", buf); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Endurance Estimate"); + memset(buf, 0, sizeof(buf)); + sprintf(buf, "0x%016"PRIx64"%016"PRIx64"", le64_to_cpu(pLogPageC0->enduranceEstimate.MS__u64), + le64_to_cpu(pLogPageC0->enduranceEstimate.LS__u64)); + json_object_add_value_string(lbaf, "attribute_value", buf); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "PCIe Link Retraining Count"); + json_object_add_value_int(lbaf, "attribute_value", le64_to_cpu(pLogPageC0->pcieLinkRetCnt)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Power State Change Count"); + json_object_add_value_int(lbaf, "attribute_value", le64_to_cpu(pLogPageC0->powStateChangeCnt)); + json_array_add_value_object(logPages, lbaf); + + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Log Page Version"); + json_object_add_value_int(lbaf, "attribute_value", le16_to_cpu(pLogPageC0->logPageVer)); + json_array_add_value_object(logPages, lbaf); - /* - json_print_object(root, NULL); - printf("\n"); - */ + lbaf = json_create_object(); + json_object_add_value_string(lbaf, "attribute_name", "Log Page GUID"); + memset(buf, 0, sizeof(buf)); + sprintf(buf, "0x%016"PRIx64"%016"PRIx64"", le64_to_cpu(pLogPageC0->logPageGUID.MS__u64), + le64_to_cpu(pLogPageC0->logPageGUID.LS__u64)); + json_object_add_value_string(lbaf, "attribute_value", buf); + json_array_add_value_object(logPages, lbaf); } static int vs_smart_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { + struct nvme_id_ctrl ctrl; + char modelNo[40]; + STX_EXT_SMART_LOG_PAGE_C0 ehExtSmart; EXTENDED_SMART_INFO_T ExtdSMARTInfo; vendor_log_page_CF logPageCF; - int fd; struct json_object *root = json_create_object(); struct json_object *lbafs = json_create_array(); struct json_object *lbafs_ExtSmart, *lbafs_DramSmart; - const char *desc = "Retrieve Seagate Extended SMART information for the given device "; + const char *desc = "Retrieve the Firmware Activation History for Seagate NVMe drives"; const char *output_format = "output in binary format"; - int err, index=0; + struct nvme_dev *dev; + int err, index = 0; struct config { char *output_format; }; @@ -736,23 +984,102 @@ static int vs_smart_log(int argc, char **argv, struct command *cmd, struct plugi OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) { printf ("\nDevice not found \n"); return -1; } - if (strcmp(cfg.output_format,"json")) + if (strcmp(cfg.output_format, "json")) printf("Seagate Extended SMART Information :\n"); - err = nvme_get_log_simple(fd, 0xC4, sizeof(ExtdSMARTInfo), &ExtdSMARTInfo); + + /** + * Here we should identify if the drive is a Panthor or Jaguar. + * Here we need to extract the model no from ctrl-id abd use it + * to deternine drive family. + */ + + err = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (!err) { - if (strcmp(cfg.output_format,"json")) { + memcpy(modelNo, ctrl.mn, sizeof(modelNo)); + } else { + nvme_show_status(err); + return err; + } + + if (stx_is_jag_pan(modelNo) == 0) { + + err = nvme_get_log_simple(dev_fd(dev), 0xC4, sizeof(ExtdSMARTInfo), &ExtdSMARTInfo); + if (!err) { + if (strcmp(cfg.output_format, "json")) { + printf("%-39s %-15s %-19s \n", "Description", "Ext-Smart-Id", "Ext-Smart-Value"); + for (index = 0; index < 80; index++) + printf("-"); + printf("\n"); + for (index = 0; index < NUMBER_EXTENDED_SMART_ATTRIBUTES; index++) + print_smart_log(ExtdSMARTInfo.Version, ExtdSMARTInfo.vendorData[index], index == (NUMBER_EXTENDED_SMART_ATTRIBUTES - 1)); + + } else { + lbafs_ExtSmart = json_create_object(); + json_print_smart_log(lbafs_ExtSmart, &ExtdSMARTInfo); + + json_object_add_value_array(root, "SMART-Attributes", lbafs); + json_array_add_value_object(lbafs, lbafs_ExtSmart); + } + + /** + * Next get Log Page 0xCF + */ + + err = nvme_get_log_simple(dev_fd(dev), 0xCF, sizeof(logPageCF), &logPageCF); + if (!err) { + if (strcmp(cfg.output_format, "json")) { + print_smart_log_CF(&logPageCF); + } else { + lbafs_DramSmart = json_create_object(); + json_print_smart_log_CF(lbafs_DramSmart, &logPageCF); + json_array_add_value_object(lbafs, lbafs_DramSmart); + json_print_object(root, NULL); + } + } else if (!strcmp(cfg.output_format, "json")) { + json_print_object(root, NULL); + json_free_object(root); + } + } else if (err > 0) + nvme_show_status(err); + } else { + err = nvme_get_log_simple(dev_fd(dev), 0xC0, sizeof(ehExtSmart), &ehExtSmart); + + if (!err) { + if (strcmp(cfg.output_format, "json")) { + print_stx_smart_log_C0(&ehExtSmart); + + } else { + lbafs_ExtSmart = json_create_object(); + json_print_stx_smart_log_C0(lbafs_ExtSmart, &ehExtSmart); + + json_object_add_value_array(root, "SMART-Attributes", lbafs); + json_array_add_value_object(lbafs, lbafs_ExtSmart); + + json_print_object(root, NULL); + json_free_object(root); + } + } + + if (err > 0) + nvme_show_status(err); + } + + err = nvme_get_log_simple(dev_fd(dev), 0xC4, + sizeof(ExtdSMARTInfo), &ExtdSMARTInfo); + if (!err) { + if (strcmp(cfg.output_format, "json")) { printf("%-39s %-15s %-19s \n", "Description", "Ext-Smart-Id", "Ext-Smart-Value"); - for(index=0; index<80; index++) + for (index = 0; index < 80; index++) printf("-"); printf("\n"); - for(index = 0; index < NUMBER_EXTENDED_SMART_ATTRIBUTES; index++) + for (index = 0; index < NUMBER_EXTENDED_SMART_ATTRIBUTES; index++) print_smart_log(ExtdSMARTInfo.Version, ExtdSMARTInfo.vendorData[index], index == (NUMBER_EXTENDED_SMART_ATTRIBUTES - 1)); } else { @@ -767,11 +1094,10 @@ static int vs_smart_log(int argc, char **argv, struct command *cmd, struct plugi * Next get Log Page 0xCF */ - err = nvme_get_log_simple(fd, 0xCF, sizeof(logPageCF), &logPageCF); + err = nvme_get_log_simple(dev_fd(dev), 0xCF, + sizeof(logPageCF), &logPageCF); if (!err) { - if(strcmp(cfg.output_format,"json")) { - /*printf("Seagate DRAM Supercap SMART Attributes :\n");*/ - + if (strcmp(cfg.output_format, "json")) { print_smart_log_CF(&logPageCF); } else { lbafs_DramSmart = json_create_object(); @@ -784,7 +1110,8 @@ static int vs_smart_log(int argc, char **argv, struct command *cmd, struct plugi } else if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); + return err; } @@ -794,7 +1121,7 @@ static int vs_smart_log(int argc, char **argv, struct command *cmd, struct plugi * Temperature-Stats information ***************************************/ static void json_temp_stats(__u32 temperature, __u32 PcbTemp, __u32 SocTemp, __u32 maxTemperature, - __u32 MaxSocTemp, __u32 cf_err, __u32 scCurrentTemp, __u32 scMaxTem) + __u32 MaxSocTemp, __u32 cf_err, __u32 scCurrentTemp, __u32 scMaxTem) { struct json_object *root; root = json_create_object(); @@ -804,28 +1131,27 @@ static void json_temp_stats(__u32 temperature, __u32 PcbTemp, __u32 SocTemp, __u json_object_add_value_int(root, "Current SOC temperature", SocTemp); json_object_add_value_int(root, "Highest temperature", maxTemperature); json_object_add_value_int(root, "Max SOC temperature", MaxSocTemp); - if(!cf_err) { + if (!cf_err) { json_object_add_value_int(root, "SuperCap Current temperature", scCurrentTemp); json_object_add_value_int(root, "SuperCap Max temperature", scMaxTem); } json_print_object(root, NULL); - printf("\n"); - } + static int temp_stats(int argc, char **argv, struct command *cmd, struct plugin *plugin) { struct nvme_smart_log smart_log; EXTENDED_SMART_INFO_T ExtdSMARTInfo; vendor_log_page_CF logPageCF; - int fd; int err, cf_err; int index; const char *desc = "Retrieve Seagate Temperature Stats information for the given device "; const char *output_format = "output in binary format"; unsigned int temperature = 0, PcbTemp = 0, SocTemp = 0, scCurrentTemp = 0, scMaxTemp = 0; unsigned long long maxTemperature = 0, MaxSocTemp = 0; + struct nvme_dev *dev; struct config { char *output_format; }; @@ -839,16 +1165,16 @@ static int temp_stats(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) { printf ("\nDevice not found \n");; return -1; } - if(strcmp(cfg.output_format,"json")) + if (strcmp(cfg.output_format, "json")) printf("Seagate Temperature Stats Information :\n"); /*STEP-1 : Get Current Temperature from SMART */ - err = nvme_get_log_smart(fd, 0xffffffff, false, &smart_log); + err = nvme_get_log_smart(dev_fd(dev), 0xffffffff, false, &smart_log); if (!err) { temperature = ((smart_log.temperature[1] << 8) | smart_log.temperature[0]); temperature = temperature ? temperature - 273 : 0; @@ -856,7 +1182,7 @@ static int temp_stats(int argc, char **argv, struct command *cmd, struct plugin PcbTemp = PcbTemp ? PcbTemp - 273 : 0; SocTemp = le16_to_cpu(smart_log.temp_sensor[1]); SocTemp = SocTemp ? SocTemp - 273 : 0; - if (strcmp(cfg.output_format,"json")) { + if (strcmp(cfg.output_format, "json")) { printf("%-20s : %u C\n", "Current Temperature", temperature); printf("%-20s : %u C\n", "Current PCB Temperature", PcbTemp); printf("%-20s : %u C\n", "Current SOC Temperature", SocTemp); @@ -864,30 +1190,33 @@ static int temp_stats(int argc, char **argv, struct command *cmd, struct plugin } /* STEP-2 : Get Max temperature form Ext SMART-id 194 */ - err = nvme_get_log_simple(fd, 0xC4, sizeof(ExtdSMARTInfo), &ExtdSMARTInfo); + err = nvme_get_log_simple(dev_fd(dev), 0xC4, + sizeof(ExtdSMARTInfo), &ExtdSMARTInfo); if (!err) { - for(index = 0; index < NUMBER_EXTENDED_SMART_ATTRIBUTES; index++) { + for (index = 0; index < NUMBER_EXTENDED_SMART_ATTRIBUTES; index++) { if (ExtdSMARTInfo.vendorData[index].AttributeNumber == VS_ATTR_ID_MAX_LIFE_TEMPERATURE) { maxTemperature = smart_attribute_vs(ExtdSMARTInfo.Version, ExtdSMARTInfo.vendorData[index]); maxTemperature = maxTemperature ? maxTemperature - 273 : 0; - if (strcmp(cfg.output_format,"json")) + if (strcmp(cfg.output_format, "json")) printf("%-20s : %d C\n", "Highest Temperature", (unsigned int)maxTemperature); } if (ExtdSMARTInfo.vendorData[index].AttributeNumber == VS_ATTR_ID_MAX_SOC_LIFE_TEMPERATURE) { MaxSocTemp = smart_attribute_vs(ExtdSMARTInfo.Version, ExtdSMARTInfo.vendorData[index]); MaxSocTemp = MaxSocTemp ? MaxSocTemp - 273 : 0; - if (strcmp(cfg.output_format,"json")) + if (strcmp(cfg.output_format, "json")) printf("%-20s : %d C\n", "Max SOC Temperature", (unsigned int)MaxSocTemp); } } + } else { + if (err > 0) + nvme_show_status(err); } - else if (err > 0) - nvme_show_status(err); - cf_err = nvme_get_log_simple(fd, 0xCF, sizeof(ExtdSMARTInfo), &logPageCF); + cf_err = nvme_get_log_simple(dev_fd(dev), 0xCF, + sizeof(ExtdSMARTInfo), &logPageCF); - if(!cf_err) { + if (!cf_err) { scCurrentTemp = logPageCF.AttrCF.SuperCapCurrentTemperature; scCurrentTemp = scCurrentTemp ? scCurrentTemp - 273 : 0; printf("%-20s : %d C\n", "Super-cap Current Temperature", scCurrentTemp); @@ -897,10 +1226,10 @@ static int temp_stats(int argc, char **argv, struct command *cmd, struct plugin printf("%-20s : %d C\n", "Super-cap Max Temperature", scMaxTemp); } - if(!strcmp(cfg.output_format,"json")) + if (!strcmp(cfg.output_format, "json")) json_temp_stats(temperature, PcbTemp, SocTemp, maxTemperature, MaxSocTemp, cf_err, scCurrentTemp, scMaxTemp); - close(fd); + dev_close(dev); return err; } /* EOF Temperature Stats information */ @@ -987,13 +1316,12 @@ static void json_vs_pcie_error_log(pcie_error_log_page pcieErrorLog) json_object_add_value_int(root, "Cpl TLP Poisoned Error Count", pcieErrorLog.CplTlpPoisonedErrCnt); json_object_add_value_int(root, "Request Completion Abort Error Count", pcieErrorLog.ReqCAErrCnt); json_print_object(root, NULL); - printf("\n"); } static int vs_pcie_error_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { pcie_error_log_page pcieErrorLog; - int fd; + struct nvme_dev *dev; const char *desc = "Retrieve Seagate PCIe error counters for the given device "; const char *output_format = "output in binary format"; @@ -1011,18 +1339,19 @@ static int vs_pcie_error_log(int argc, char **argv, struct command *cmd, struct OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) { printf ("\nDevice not found \n");; return -1; } - if(strcmp(cfg.output_format,"json")) + if (strcmp(cfg.output_format, "json")) printf("Seagate PCIe error counters Information :\n"); - err = nvme_get_log_simple(fd, 0xCB, sizeof(pcieErrorLog), &pcieErrorLog); + err = nvme_get_log_simple(dev_fd(dev), 0xCB, + sizeof(pcieErrorLog), &pcieErrorLog); if (!err) { - if(strcmp(cfg.output_format,"json")) { + if (strcmp(cfg.output_format, "json")) { print_vs_pcie_error_log(pcieErrorLog); } else json_vs_pcie_error_log(pcieErrorLog); @@ -1030,17 +1359,233 @@ static int vs_pcie_error_log(int argc, char **argv, struct command *cmd, struct } else if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } /* EOF PCIE error-log information */ + +/*************************************** + * FW Activation History log + ***************************************/ +static void print_stx_vs_fw_activate_history(stx_fw_activ_history_log_page fwActivHis) +{ + __u32 i; + char prev_fw[9] = {0}; + char new_fw[9] = {0}; + char buf[80]; + + if (fwActivHis.numValidFwActHisEnt > 0) { + printf("\n\nSeagate FW Activation Histry :\n"); + printf("%-9s %-21s %-7s %-13s %-9s %-5s %-15s %-9s\n", "Counter ", " Timestamp ", " PCC ", "Previous FW ", "New FW ", "Slot", "Commit Action", "Result"); + + for (i = 0; i < fwActivHis.numValidFwActHisEnt; i++) { + + printf(" %-4d ", fwActivHis.fwActHisEnt[i].fwActivCnt); + + time_t t = fwActivHis.fwActHisEnt[i].timeStamp / 1000; + struct tm ts; + ts = *localtime(&t); + strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &ts); + printf(" %-20s ", buf); + printf("%-5" PRId64 " ", + (uint64_t)fwActivHis.fwActHisEnt[i].powCycleCnt); + + memset(prev_fw, 0, sizeof(prev_fw)); + memcpy(prev_fw, fwActivHis.fwActHisEnt[i].previousFW, sizeof(fwActivHis.fwActHisEnt[i].previousFW)); + printf("%-8s ", prev_fw); + + memset(new_fw, 0, sizeof(new_fw)); + memcpy(new_fw, fwActivHis.fwActHisEnt[i].newFW, sizeof(fwActivHis.fwActHisEnt[i].newFW)); + printf("%-8s ", new_fw); + + printf(" %-2d ", fwActivHis.fwActHisEnt[i].slotNum); + printf(" 0x%02x ", fwActivHis.fwActHisEnt[i].commitActionType); + printf(" 0x%02x \n", fwActivHis.fwActHisEnt[i].result); + } + } else { + printf("%s\n", "Do not have valid FW Activation History"); + } +} + +static void json_stx_vs_fw_activate_history(stx_fw_activ_history_log_page fwActivHis) +{ + struct json_object *root; + root = json_create_object(); + __u32 i; + + char buf[80]; + + struct json_object *historyLogPage; + historyLogPage = json_create_array(); + json_object_add_value_array(root, "Seagate FW Activation History", historyLogPage); + + if (fwActivHis.numValidFwActHisEnt > 0) { + for (i = 0; i < fwActivHis.numValidFwActHisEnt; i++) { + struct json_object *lbaf = json_create_object(); + char prev_fw[8] = { 0 }; + char new_fw[8] = { 0 }; + + json_object_add_value_int(lbaf, "Counter", fwActivHis.fwActHisEnt[i].fwActivCnt); + + time_t t = fwActivHis.fwActHisEnt[i].timeStamp / 1000; + struct tm ts; + ts = *localtime(&t); + strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &ts); + printf(" %-20s ", buf); + json_object_add_value_string(lbaf, "Timestamp", buf); + + json_object_add_value_int(lbaf, "PCC", fwActivHis.fwActHisEnt[i].powCycleCnt); + sprintf(prev_fw, "%s", fwActivHis.fwActHisEnt[i].previousFW); + json_object_add_value_string(lbaf, "Previous_FW", prev_fw); + + sprintf(new_fw, "%s", fwActivHis.fwActHisEnt[i].newFW); + json_object_add_value_string(lbaf, "New_FW", new_fw); + + json_object_add_value_int(lbaf, "Slot", fwActivHis.fwActHisEnt[i].slotNum); + json_object_add_value_int(lbaf, "Commit_Action", fwActivHis.fwActHisEnt[i].commitActionType); + json_object_add_value_int(lbaf, "Result", fwActivHis.fwActHisEnt[i].result); + + json_array_add_value_object(historyLogPage, lbaf); + } + } else { + printf("%s\n", "Do not have valid FW Activation History"); + } + + json_print_object(root, NULL); + json_free_object(root); +} + +static int stx_vs_fw_activate_history(int argc, char **argv, struct command *cmd, struct plugin *plugin) +{ + stx_fw_activ_history_log_page fwActivHis; + struct nvme_dev *dev; + + const char *desc = "Retrieve FW Activate History for Seagate device "; + const char *output_format = "output in binary format"; + int err; + struct config { + char *output_format; + }; + + struct config cfg = { + .output_format = "normal", + }; + + OPT_ARGS(opts) = { + OPT_FMT("output-format", 'o', &cfg.output_format, output_format), + OPT_END() + }; + + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err < 0) { + printf ("\nDevice not found \n");; + return -1; + } + + if (strcmp(cfg.output_format, "json")) + printf("Seagate FW Activation Histry Information :\n"); + + err = nvme_get_log_simple(dev_fd(dev), 0xC2, sizeof(fwActivHis), &fwActivHis); + if (!err) { + if (strcmp(cfg.output_format, "json")) { + print_stx_vs_fw_activate_history(fwActivHis); + } else + json_stx_vs_fw_activate_history(fwActivHis); + + } else if (err > 0) + nvme_show_status(err); + + dev_close(dev); + return err; +} +/* EOF FW Activation History log information */ + + +static int clear_fw_activate_history(int argc, char **argv, struct command *cmd, struct plugin *plugin) +{ + const char *desc = "Clear FW Activation History for the given Seagate device "; + const char *save = "specifies that the controller shall save the attribute"; + int err; + struct nvme_dev *dev; + struct nvme_id_ctrl ctrl; + char modelNo[40]; + __u32 result; + + struct config { + bool save; + }; + + struct config cfg = { + .save = 0, + }; + + OPT_ARGS(opts) = { + OPT_FLAG("save", 's', &cfg.save, save), + OPT_END() + }; + + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err < 0) { + printf ("\nDevice not found \n"); + return -1; + } + + err = nvme_identify_ctrl(dev_fd(dev), &ctrl); + if (!err) { + memcpy(modelNo, ctrl.mn, sizeof(modelNo)); + } else { + nvme_show_status(err); + return err; + } + + if (stx_is_jag_pan(modelNo) == 0) { + printf ("\nDevice does not support Clear FW Activation History \n"); + } else { + + struct nvme_set_features_args args = { + .args_size = sizeof(args), + .fd = dev_fd(dev), + .fid = 0xC1, + .nsid = 0, + .cdw11 = 0x80000000, + .cdw12 = 0, + .save = 0, + .uuidx = 0, + .cdw15 = 0, + .data_len = 0, + .data = NULL, + .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, + .result = &result, + }; + err = nvme_set_features(&args); + if (err) + fprintf(stderr, "%s: couldn't clear PCIe correctable errors \n", + __func__); + } + + if (err < 0) { + perror("set-feature"); + return errno; + } + + dev_close(dev); + return err; +} + + static int vs_clr_pcie_correctable_errs(int argc, char **argv, struct command *cmd, struct plugin *plugin) { const char *desc = "Clear Seagate PCIe Correctable counters for the given device "; const char *save = "specifies that the controller shall save the attribute"; - int err, fd; + + struct nvme_id_ctrl ctrl; + char modelNo[40]; + + struct nvme_dev *dev; + __u32 result; + int err; struct config { bool save; @@ -1055,21 +1600,53 @@ static int vs_clr_pcie_correctable_errs(int argc, char **argv, struct command *c OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) { printf ("\nDevice not found \n");; return -1; } - err = nvme_set_features_simple(fd, 0xE1, 0, 0xCB, cfg.save, &result); + + err = nvme_identify_ctrl(dev_fd(dev), &ctrl); + if (!err) { + memcpy(modelNo, ctrl.mn, sizeof(modelNo)); + } else { + nvme_show_status(err); + return err; + } + + if (stx_is_jag_pan(modelNo) == 0) { + err = nvme_set_features_simple(dev_fd(dev), 0xE1, 0, 0xCB, cfg.save, &result); + } else { + struct nvme_set_features_args args = { + .args_size = sizeof(args), + .fd = dev_fd(dev), + .fid = 0xC3, + .nsid = 0, + .cdw11 = 0x80000000, + .cdw12 = 0, + .save = 0, + .uuidx = 0, + .cdw15 = 0, + .data_len = 0, + .data = NULL, + .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, + .result = &result, + }; + err = nvme_set_features(&args); + if (err) + fprintf(stderr, "%s: couldn't clear PCIe correctable errors \n", __func__); + } + + err = nvme_set_features_simple(dev_fd(dev), 0xE1, 0, 0xCB, cfg.save, &result); if (err < 0) { perror("set-feature"); + return errno; } - close(fd); + dev_close(dev); return err; - } static int get_host_tele(int argc, char **argv, struct command *cmd, struct plugin *plugin) @@ -1081,11 +1658,12 @@ static int get_host_tele(int argc, char **argv, struct command *cmd, struct plug "state of the controller at the time the command is processed. " \ "0 - controller shall not update the Telemetry Host Initiated Data."; const char *raw = "output in raw format"; - int err, fd, dump_fd; struct nvme_temetry_log_hdr tele_log; - __le64 offset = 0; int blkCnt, maxBlk = 0, blksToGet; + struct nvme_dev *dev; unsigned char *log; + __le64 offset = 0; + int err, dump_fd; struct config { __u32 namespace_id; @@ -1105,24 +1683,25 @@ static int get_host_tele(int argc, char **argv, struct command *cmd, struct plug OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; dump_fd = STDOUT_FILENO; cfg.log_id = (cfg.log_id << 8) | 0x07; - err = nvme_get_nsid_log(fd, false, cfg.log_id, cfg.namespace_id, - sizeof(tele_log), (void *)(&tele_log)); + err = nvme_get_nsid_log(dev_fd(dev), false, cfg.log_id, + cfg.namespace_id, + sizeof(tele_log), (void *)(&tele_log)); if (!err) { maxBlk = tele_log.tele_data_area3; offset += 512; if (!cfg.raw_binary) { printf("Device:%s log-id:%d namespace-id:%#x\n", - devicename, cfg.log_id, - cfg.namespace_id); + dev->name, cfg.log_id, + cfg.namespace_id); printf("Data Block 1 Last Block:%d Data Block 2 Last Block:%d Data Block 3 Last Block:%d\n", - tele_log.tele_data_area1, tele_log.tele_data_area2, tele_log.tele_data_area3); + tele_log.tele_data_area1, tele_log.tele_data_area2, tele_log.tele_data_area3); d((unsigned char *)(&tele_log), sizeof(tele_log), 16, 1); } else @@ -1134,13 +1713,13 @@ static int get_host_tele(int argc, char **argv, struct command *cmd, struct plug blkCnt = 0; - while(blkCnt < maxBlk) { + while (blkCnt < maxBlk) { unsigned long long bytesToGet; blksToGet = ((maxBlk - blkCnt) >= TELEMETRY_BLOCKS_TO_READ) ? TELEMETRY_BLOCKS_TO_READ : (maxBlk - blkCnt); - if(blksToGet == 0) { - close(fd); + if (blksToGet == 0) { + dev_close(dev); return err; } @@ -1149,28 +1728,28 @@ static int get_host_tele(int argc, char **argv, struct command *cmd, struct plug if (!log) { fprintf(stderr, "could not alloc buffer for log\n"); - close(fd); + dev_close(dev); return EINVAL; } memset(log, 0, bytesToGet); struct nvme_get_log_args args = { - .args_size = sizeof(args), - .fd = fd, - .lid = cfg.log_id, - .nsid = cfg.namespace_id, - .lpo = offset, - .lsp = 0, - .lsi = 0, - .rae = true, - .uuidx = 0, - .csi = NVME_CSI_NVM, - .ot = false, - .len = bytesToGet, - .log = (void *)log, - .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, - .result = NULL, + .args_size = sizeof(args), + .fd = dev_fd(dev), + .lid = cfg.log_id, + .nsid = cfg.namespace_id, + .lpo = offset, + .lsp = 0, + .lsi = 0, + .rae = true, + .uuidx = 0, + .csi = NVME_CSI_NVM, + .ot = false, + .len = bytesToGet, + .log = (void *)log, + .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, + .result = NULL, }; err = nvme_get_log(&args); if (!err) { @@ -1192,17 +1771,18 @@ static int get_host_tele(int argc, char **argv, struct command *cmd, struct plug free(log); } - close(fd); + dev_close(dev); return err; } static int get_ctrl_tele(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - const char *desc = "Capture the Telemetry Controller-Initiated Data in either " \ + const char *desc = "Capture the Telemetry Controller-Initiated Data in either " \ "hex-dump (default) or binary format"; const char *namespace_id = "desired namespace"; const char *raw = "output in raw format"; - int err, fd, dump_fd; + struct nvme_dev *dev; + int err, dump_fd; struct nvme_temetry_log_hdr tele_log; __le64 offset = 0; __u16 log_id; @@ -1224,24 +1804,24 @@ static int get_ctrl_tele(int argc, char **argv, struct command *cmd, struct plug OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; dump_fd = STDOUT_FILENO; log_id = 0x08; - err = nvme_get_nsid_log(fd, false, log_id, cfg.namespace_id, - sizeof(tele_log), (void *)(&tele_log)); + err = nvme_get_nsid_log(dev_fd(dev), false, log_id, cfg.namespace_id, + sizeof(tele_log), (void *)(&tele_log)); if (!err) { maxBlk = tele_log.tele_data_area3; offset += 512; if (!cfg.raw_binary) { printf("Device:%s namespace-id:%#x\n", - devicename, cfg.namespace_id); + dev->name, cfg.namespace_id); printf("Data Block 1 Last Block:%d Data Block 2 Last Block:%d Data Block 3 Last Block:%d\n", - tele_log.tele_data_area1, tele_log.tele_data_area2, tele_log.tele_data_area3); + tele_log.tele_data_area1, tele_log.tele_data_area2, tele_log.tele_data_area3); d((unsigned char *)(&tele_log), sizeof(tele_log), 16, 1); } else @@ -1253,12 +1833,12 @@ static int get_ctrl_tele(int argc, char **argv, struct command *cmd, struct plug blkCnt = 0; - while(blkCnt < maxBlk) { + while (blkCnt < maxBlk) { unsigned long long bytesToGet; blksToGet = ((maxBlk - blkCnt) >= TELEMETRY_BLOCKS_TO_READ) ? TELEMETRY_BLOCKS_TO_READ : (maxBlk - blkCnt); - if(blksToGet == 0) + if (blksToGet == 0) return err; bytesToGet = (unsigned long long)blksToGet * 512; @@ -1272,21 +1852,21 @@ static int get_ctrl_tele(int argc, char **argv, struct command *cmd, struct plug memset(log, 0, bytesToGet); struct nvme_get_log_args args = { - .args_size = sizeof(args), - .fd = fd, - .lid = log_id, - .nsid = cfg.namespace_id, - .lpo = offset, - .lsp = 0, - .lsi = 0, - .rae = true, - .uuidx = 0, - .csi = NVME_CSI_NVM, - .ot = false, - .len = bytesToGet, - .log = (void *)log, - .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, - .result = NULL, + .args_size = sizeof(args), + .fd = dev_fd(dev), + .lid = log_id, + .nsid = cfg.namespace_id, + .lpo = offset, + .lsp = 0, + .lsi = 0, + .rae = true, + .uuidx = 0, + .csi = NVME_CSI_NVM, + .ot = false, + .len = bytesToGet, + .log = (void *)log, + .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, + .result = NULL, }; err = nvme_get_log(&args); if (!err) { @@ -1308,21 +1888,14 @@ static int get_ctrl_tele(int argc, char **argv, struct command *cmd, struct plug free(log); } - close(fd); + dev_close(dev); return err; } void seaget_d_raw(unsigned char *buf, int len, int fd) { - /********************* - int i; - fflush(stdout); - for (i = 0; i < len; i++) - putchar(*(buf+i)); - *********************/ - if (write(fd, (void *)buf, len) <= 0) - printf("%s: Write Failed\n",__FUNCTION__); + printf("%s: Write Failed\n", __FUNCTION__); } @@ -1333,9 +1906,10 @@ static int vs_internal_log(int argc, char **argv, struct command *cmd, struct pl const char *namespace_id = "desired namespace"; const char *file = "dump file"; - int err, fd, dump_fd; + struct nvme_dev *dev; + int err, dump_fd; int flags = O_WRONLY | O_CREAT; - int mode = S_IRUSR | S_IWUSR |S_IRGRP | S_IWGRP| S_IROTH; + int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH; struct nvme_temetry_log_hdr tele_log; __le64 offset = 0; __u16 log_id; @@ -1358,31 +1932,27 @@ static int vs_internal_log(int argc, char **argv, struct command *cmd, struct pl OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; dump_fd = STDOUT_FILENO; - if(strlen(cfg.file)) { + if (strlen(cfg.file)) { dump_fd = open(cfg.file, flags, mode); if (dump_fd < 0) { perror(cfg.file); - close(fd); + dev_close(dev); return EINVAL; } } log_id = 0x08; - err = nvme_get_nsid_log(fd, false, log_id, cfg.namespace_id, - sizeof(tele_log), (void *)(&tele_log)); + err = nvme_get_nsid_log(dev_fd(dev), false, log_id, cfg.namespace_id, + sizeof(tele_log), (void *)(&tele_log)); if (!err) { maxBlk = tele_log.tele_data_area3; offset += 512; - /* - printf("Data Block 1 Last Block:%d Data Block 2 Last Block:%d Data Block 3 Last Block:%d\n", - tele_log.tele_data_area1, tele_log.tele_data_area2, tele_log.tele_data_area3); - */ seaget_d_raw((unsigned char *)(&tele_log), sizeof(tele_log), dump_fd); } else if (err > 0) nvme_show_status(err); @@ -1391,12 +1961,12 @@ static int vs_internal_log(int argc, char **argv, struct command *cmd, struct pl blkCnt = 0; - while(blkCnt < maxBlk) { + while (blkCnt < maxBlk) { unsigned long long bytesToGet; blksToGet = ((maxBlk - blkCnt) >= TELEMETRY_BLOCKS_TO_READ) ? TELEMETRY_BLOCKS_TO_READ : (maxBlk - blkCnt); - if(blksToGet == 0) { + if (blksToGet == 0) { goto out; } @@ -1412,21 +1982,21 @@ static int vs_internal_log(int argc, char **argv, struct command *cmd, struct pl memset(log, 0, bytesToGet); struct nvme_get_log_args args = { - .args_size = sizeof(args), - .fd = fd, - .lid = log_id, - .nsid = cfg.namespace_id, - .lpo = offset, - .lsp = 0, - .lsi = 0, - .rae = true, - .uuidx = 0, - .csi = NVME_CSI_NVM, - .ot = false, - .len = bytesToGet, - .log = (void *)log, - .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, - .result = NULL, + .args_size = sizeof(args), + .fd = dev_fd(dev), + .lid = log_id, + .nsid = cfg.namespace_id, + .lpo = offset, + .lsp = 0, + .lsi = 0, + .rae = true, + .uuidx = 0, + .csi = NVME_CSI_NVM, + .ot = false, + .len = bytesToGet, + .log = (void *)log, + .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, + .result = NULL, }; err = nvme_get_log(&args); if (!err) { @@ -1444,20 +2014,29 @@ static int vs_internal_log(int argc, char **argv, struct command *cmd, struct pl free(log); } out: - if(strlen(cfg.file)) + if (strlen(cfg.file)) close(dump_fd); - close(fd); + dev_close(dev); return err; } /*SEAGATE-PLUGIN Version */ -static int seagate_plugin_version(int argc, char **argv, struct command *cmd, - struct plugin *plugin) +static int seagate_plugin_version(int argc, char **argv, struct command *cmd, struct plugin *plugin) { printf("Seagate-Plugin version : %d.%d \n", - SEAGATE_PLUGIN_VERSION_MAJOR, - SEAGATE_PLUGIN_VERSION_MINOR); + SEAGATE_PLUGIN_VERSION_MAJOR, + SEAGATE_PLUGIN_VERSION_MINOR); return 0; } /*EOF SEAGATE-PLUGIN Version */ + +/*OCP SEAGATE-PLUGIN Version */ +static int stx_ocp_plugin_version(int argc, char **argv, struct command *cmd, struct plugin *plugin) +{ + printf("Seagate-OCP-Plugin version : %d.%d \n", + SEAGATE_OCP_PLUGIN_VERSION_MAJOR, + SEAGATE_OCP_PLUGIN_VERSION_MINOR); + return 0; +} +/*EOF OCP SEAGATE-PLUGIN Version */ diff --git a/plugins/seagate/seagate-nvme.h b/plugins/seagate/seagate-nvme.h index 6df1331..99f6327 100644 --- a/plugins/seagate/seagate-nvme.h +++ b/plugins/seagate/seagate-nvme.h @@ -18,6 +18,8 @@ * * \file seagate-nvme.h * \brief This file defines the functions and macros to make building a nvme-cli seagate plug-in. + * + * Author: Debabrata Bardhan */ #undef CMD_INC_FILE @@ -30,15 +32,18 @@ PLUGIN(NAME("seagate", "Seagate vendor specific extensions", NVME_VERSION), COMMAND_LIST( - ENTRY("vs-temperature-stats", "Retrieve Seagate temperature statistics ", temp_stats) - ENTRY("vs-log-page-sup", "Retrieve Seagate Supported Log-pages Information ", log_pages_supp) - ENTRY("vs-smart-add-log", "Retrieve Seagate extended-SMART Information ", vs_smart_log) - ENTRY("vs-pcie-stats", "Retrieve Seagate PCIe error statistics ", vs_pcie_error_log) - ENTRY("clear-pcie-correctable-errors", "Clear Seagate PCIe error statistics ", vs_clr_pcie_correctable_errs) - ENTRY("get-host-tele", "Retrieve Seagate Host-Initiated Telemetry ", get_host_tele) - ENTRY("get-ctrl-tele", "Retrieve Seagate Controller-Initiated Telemetry ", get_ctrl_tele) - ENTRY("vs-internal-log", "Retrieve Seagate Controller-Initiated Telemetry in binary format", vs_internal_log) - ENTRY("plugin-version", "Shows Seagate plugin's version information ", seagate_plugin_version) + ENTRY("vs-temperature-stats", "Retrieve Seagate temperature statistics ", temp_stats) + ENTRY("vs-log-page-sup", "Retrieve Seagate Supported Log-pages Information ", log_pages_supp) + ENTRY("vs-smart-add-log", "Retrieve Seagate extended-SMART Information ", vs_smart_log) + ENTRY("vs-pcie-stats", "Retrieve Seagate PCIe error statistics ", vs_pcie_error_log) + ENTRY("clear-pcie-correctable-errors", "Clear Seagate PCIe error statistics ", vs_clr_pcie_correctable_errs) + ENTRY("get-host-tele", "Retrieve Seagate Host-Initiated Telemetry ", get_host_tele) + ENTRY("get-ctrl-tele", "Retrieve Seagate Controller-Initiated Telemetry ", get_ctrl_tele) + ENTRY("vs-internal-log", "Retrieve Seagate Controller-Initiated Telemetry in binary format", vs_internal_log) + ENTRY("vs-fw-activate-history", "Retrieve the Firmware Activation History", stx_vs_fw_activate_history) + ENTRY("clear-fw-activate-history", "Clear Firmware Activation History", clear_fw_activate_history) + ENTRY("plugin-version", "Shows Seagate plugin's version information ", seagate_plugin_version) + ENTRY("cloud-SSD-plugin-version", "Shows OCP Seagate plugin's version information ", stx_ocp_plugin_version) ) ); diff --git a/plugins/shannon/shannon-nvme.c b/plugins/shannon/shannon-nvme.c index 220638f..424b3f7 100644 --- a/plugins/shannon/shannon-nvme.c +++ b/plugins/shannon/shannon-nvme.c @@ -117,15 +117,16 @@ static void show_shannon_smart_log(struct nvme_shannon_smart_log *smart, static int get_additional_smart_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { struct nvme_shannon_smart_log smart_log; - int err, fd; char *desc = "Get Shannon vendor specific additional smart log (optionally, "\ "for the specified namespace), and show it."; const char *namespace = "(optional) desired namespace"; const char *raw = "dump output in binary format"; + struct nvme_dev *dev; struct config { __u32 namespace_id; bool raw_binary; }; + int err; struct config cfg = { .namespace_id = NVME_NSID_ALL, @@ -137,20 +138,21 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; - err = nvme_get_nsid_log(fd, false, 0xca, cfg.namespace_id, - sizeof(smart_log), &smart_log); + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; + err = nvme_get_nsid_log(dev_fd(dev), false, 0xca, cfg.namespace_id, + sizeof(smart_log), &smart_log); if (!err) { if (!cfg.raw_binary) - show_shannon_smart_log(&smart_log, cfg.namespace_id, devicename); + show_shannon_smart_log(&smart_log, cfg.namespace_id, + dev->name); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } else if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } @@ -174,9 +176,10 @@ static int get_additional_feature(int argc, char **argv, struct command *cmd, st const char *data_len = "buffer len (if) data is returned"; const char *cdw11 = "dword 11 for interrupt vector config"; const char *human_readable = "show infos in readable format"; - int err, fd; - __u32 result; + struct nvme_dev *dev; void *buf = NULL; + __u32 result; + int err; struct config { __u32 namespace_id; @@ -207,24 +210,24 @@ static int get_additional_feature(int argc, char **argv, struct command *cmd, st OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; if (cfg.sel > 7) { fprintf(stderr, "invalid 'select' param:%d\n", cfg.sel); - close(fd); + dev_close(dev); return EINVAL; } if (!cfg.feature_id) { fprintf(stderr, "feature-id required param\n"); - close(fd); + dev_close(dev); return EINVAL; } if (cfg.data_len) { if (posix_memalign(&buf, getpagesize(), cfg.data_len)) { - close(fd); + dev_close(dev); exit(ENOMEM); } memset(buf, 0, cfg.data_len); @@ -232,7 +235,7 @@ static int get_additional_feature(int argc, char **argv, struct command *cmd, st struct nvme_get_features_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .fid = cfg.feature_id, .nsid = cfg.namespace_id, .sel = cfg.sel, @@ -286,10 +289,11 @@ static int set_additional_feature(int argc, char **argv, struct command *cmd, st const char *data = "optional file for feature data (default stdin)"; const char *value = "new value of feature (required)"; const char *save = "specifies that the controller shall save the attribute"; - int err, fd; - __u32 result; - void *buf = NULL; int ffd = STDIN_FILENO; + struct nvme_dev *dev; + void *buf = NULL; + __u32 result; + int err; struct config { char *file; @@ -319,20 +323,20 @@ static int set_additional_feature(int argc, char **argv, struct command *cmd, st OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; if (!cfg.feature_id) { fprintf(stderr, "feature-id required param\n"); - close(fd); + dev_close(dev); return EINVAL; } if (cfg.data_len) { if (posix_memalign(&buf, getpagesize(), cfg.data_len)){ fprintf(stderr, "can not allocate feature payload\n"); - close(fd); + dev_close(dev); return ENOMEM; } memset(buf, 0, cfg.data_len); @@ -357,7 +361,7 @@ static int set_additional_feature(int argc, char **argv, struct command *cmd, st struct nvme_set_features_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .fid = cfg.feature_id, .nsid = cfg.namespace_id, .cdw11 = cfg.value, diff --git a/plugins/solidigm/meson.build b/plugins/solidigm/meson.build index fb0f6a9..bca13bb 100644 --- a/plugins/solidigm/meson.build +++ b/plugins/solidigm/meson.build @@ -2,4 +2,6 @@ sources += [ 'plugins/solidigm/solidigm-smart.c', 'plugins/solidigm/solidigm-garbage-collection.c', 'plugins/solidigm/solidigm-latency-tracking.c', + 'plugins/solidigm/solidigm-telemetry.c', ] +subdir('solidigm-telemetry') diff --git a/plugins/solidigm/solidigm-garbage-collection.c b/plugins/solidigm/solidigm-garbage-collection.c index 415722b..8e2eccc 100644 --- a/plugins/solidigm/solidigm-garbage-collection.c +++ b/plugins/solidigm/solidigm-garbage-collection.c @@ -56,13 +56,15 @@ static void vu_gc_log_show(garbage_control_collection_log_t *payload, const char for (int i = 0; i < VU_GC_MAX_ITEMS; i++) { gc_item_t item = payload->item[i]; - printf("%-13lu %d\n",le64_to_cpu(item.timestamp), le32_to_cpu(item.timer_type)); + printf("%-13" PRIu64 " %d\n", le64_to_cpu(item.timestamp), le32_to_cpu(item.timer_type)); } } int solidigm_get_garbage_collection_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { const char *desc = "Get and parse Solidigm vendor specific garbage collection event log."; + struct nvme_dev *dev; + int err; struct config { char *output_format; @@ -77,35 +79,37 @@ int solidigm_get_garbage_collection_log(int argc, char **argv, struct command *c OPT_END() }; - int fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { - return fd; - } + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; enum nvme_print_flags flags = validate_output_format(cfg.output_format); if (flags == -EINVAL) { fprintf(stderr, "Invalid output format '%s'\n", cfg.output_format); - close(fd); - return flags; + dev_close(dev); + return EINVAL; } garbage_control_collection_log_t gc_log; const int solidigm_vu_gc_log_id = 0xfd; - int err = nvme_get_log_simple(fd, solidigm_vu_gc_log_id, sizeof(gc_log), &gc_log); + err = nvme_get_log_simple(dev_fd(dev), solidigm_vu_gc_log_id, + sizeof(gc_log), &gc_log); if (!err) { if (flags & BINARY) { d_raw((unsigned char *)&gc_log, sizeof(gc_log)); } else if (flags & JSON) { - vu_gc_log_show_json(&gc_log, devicename); + vu_gc_log_show_json(&gc_log, dev->name); } else { - vu_gc_log_show(&gc_log, devicename); + vu_gc_log_show(&gc_log, dev->name); } } else if (err > 0) { nvme_show_status(err); } - - close(fd); + + /* Redundant close() to make static code analysis happy */ + close(dev->direct.fd); + dev_close(dev); return err; } diff --git a/plugins/solidigm/solidigm-latency-tracking.c b/plugins/solidigm/solidigm-latency-tracking.c index 0bfd611..1013ae8 100644 --- a/plugins/solidigm/solidigm-latency-tracking.c +++ b/plugins/solidigm/solidigm-latency-tracking.c @@ -216,7 +216,7 @@ static void latency_tracker_pre_parse(struct latency_tracker *lt) printf("Major Revision: %u\nMinor Revision: %u\n", le16_to_cpu(lt->stats.version_major), le16_to_cpu(lt->stats.version_minor)); if (lt->has_average_latency_field) { - printf("Average Latency: %lu\n", le64_to_cpu(lt->stats.average_latency)); + printf("Average Latency: %" PRIu64 "\n", le64_to_cpu(lt->stats.average_latency)); } print_dash_separator(); printf("%-12s%-12s%-12s%-20s\n", "Bucket", "Start", "End", "Value"); @@ -385,6 +385,7 @@ int solidigm_get_latency_tracking_log(int argc, char **argv, struct command *cmd struct plugin *plugin) { const char *desc = "Get and Parse Solidigm Latency Tracking Statistics log."; + struct nvme_dev *dev; __u32 enabled; int err; @@ -407,43 +408,45 @@ int solidigm_get_latency_tracking_log(int argc, char **argv, struct command *cmd OPT_END() }; - lt.fd = parse_and_open(argc, argv, desc, opts); - if (lt.fd < 0) - return lt.fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; + + lt.fd = dev_fd(dev); lt.print_flags = validate_output_format(lt.cfg.output_format); if (lt.print_flags == -EINVAL) { fprintf(stderr, "Invalid output format '%s'\n", lt.cfg.output_format); - close(lt.fd); + dev_close(dev); return EINVAL; } if (lt.cfg.type > 0xf) { fprintf(stderr, "Invalid Log type value '%d'\n", lt.cfg.type); - close(lt.fd); + dev_close(dev); return EINVAL; } if (lt.cfg.type && !(lt.cfg.read || lt.cfg.write)) { fprintf(stderr, "Log type option valid only when retrieving statistics\n"); - close(lt.fd); + dev_close(dev); return EINVAL; } err = latency_tracking_enable(<); if (err){ - close(lt.fd); + dev_close(dev); return err; } err = latency_tracker_get_log(<); if (err){ - close(lt.fd); + dev_close(dev); return err; } if ((lt.cfg.read || lt.cfg.write || lt.cfg.enable || lt.cfg.disable)) { - close(lt.fd); + dev_close(dev); return 0; } @@ -465,6 +468,8 @@ int solidigm_get_latency_tracking_log(int argc, char **argv, struct command *cmd } else { fprintf(stderr, "Could not read feature id 0xE2.\n"); } - close(lt.fd); + /* Redundant close() to make static code analysis happy */ + close(dev->direct.fd); + dev_close(dev); return err; } diff --git a/plugins/solidigm/solidigm-nvme.c b/plugins/solidigm/solidigm-nvme.c index 3eb3cc9..684648a 100644 --- a/plugins/solidigm/solidigm-nvme.c +++ b/plugins/solidigm/solidigm-nvme.c @@ -13,6 +13,7 @@ #include "solidigm-smart.h" #include "solidigm-garbage-collection.h" #include "solidigm-latency-tracking.h" +#include "solidigm-telemetry.h" static int get_additional_smart_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { @@ -27,4 +28,9 @@ static int get_garbage_collection_log(int argc, char **argv, struct command *cmd static int get_latency_tracking_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { return solidigm_get_latency_tracking_log(argc, argv, cmd, plugin); +} + +static int get_telemetry_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) +{ + return solidigm_get_telemetry_log(argc, argv, cmd, plugin); } \ No newline at end of file diff --git a/plugins/solidigm/solidigm-nvme.h b/plugins/solidigm/solidigm-nvme.h index 9fc8b45..ed48400 100644 --- a/plugins/solidigm/solidigm-nvme.h +++ b/plugins/solidigm/solidigm-nvme.h @@ -13,13 +13,14 @@ #include "cmd.h" -#define SOLIDIGM_PLUGIN_VERSION "0.4" +#define SOLIDIGM_PLUGIN_VERSION "0.6" PLUGIN(NAME("solidigm", "Solidigm vendor specific extensions", SOLIDIGM_PLUGIN_VERSION), COMMAND_LIST( ENTRY("smart-log-add", "Retrieve Solidigm SMART Log", get_additional_smart_log) ENTRY("garbage-collect-log", "Retrieve Garbage Collection Log", get_garbage_collection_log) ENTRY("latency-tracking-log", "Enable/Retrieve Latency tracking Log", get_latency_tracking_log) + ENTRY("parse-telemetry-log", "Parse Telemetry Log binary", get_telemetry_log) ) ); diff --git a/plugins/solidigm/solidigm-smart.c b/plugins/solidigm/solidigm-smart.c index 77a2210..77c26ac 100644 --- a/plugins/solidigm/solidigm-smart.c +++ b/plugins/solidigm/solidigm-smart.c @@ -10,8 +10,6 @@ #include #include #include -#include -#include #include "common.h" #include "nvme.h" @@ -201,7 +199,8 @@ int solidigm_get_additional_smart_log(int argc, char **argv, struct command *cmd const int solidigm_vu_smart_log_id = 0xCA; vu_smart_log_t smart_log_payload; enum nvme_print_flags flags; - int fd, err; + struct nvme_dev *dev; + int err; struct config { __u32 namespace_id; @@ -219,32 +218,36 @@ int solidigm_get_additional_smart_log(int argc, char **argv, struct command *cmd OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { - return fd; - } + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; flags = validate_output_format(cfg.output_format); if (flags == -EINVAL) { fprintf(stderr, "Invalid output format '%s'\n", cfg.output_format); - close(fd); + dev_close(dev); return flags; } - err = nvme_get_log_simple(fd, solidigm_vu_smart_log_id, sizeof(smart_log_payload), &smart_log_payload); + err = nvme_get_log_simple(dev_fd(dev), solidigm_vu_smart_log_id, + sizeof(smart_log_payload), &smart_log_payload); if (!err) { if (flags & JSON) { - vu_smart_log_show_json(&smart_log_payload, cfg.namespace_id, devicename); + vu_smart_log_show_json(&smart_log_payload, + cfg.namespace_id, dev->name); } else if (flags & BINARY) { d_raw((unsigned char *)&smart_log_payload, sizeof(smart_log_payload)); } else { - vu_smart_log_show(&smart_log_payload, cfg.namespace_id, devicename); + vu_smart_log_show(&smart_log_payload, cfg.namespace_id, + dev->name); } } else if (err > 0) { nvme_show_status(err); } - close(fd); + /* Redundant close() to make static code analysis happy */ + close(dev->direct.fd); + dev_close(dev); return err; } diff --git a/plugins/solidigm/solidigm-telemetry.c b/plugins/solidigm/solidigm-telemetry.c new file mode 100644 index 0000000..84a4e2a --- /dev/null +++ b/plugins/solidigm/solidigm-telemetry.c @@ -0,0 +1,183 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2022 Solidigm. + * + * Author: leonardo.da.cunha@solidigm.com + */ + +#include +#include +#include +#include +#include + +#include "common.h" +#include "nvme.h" +#include "libnvme.h" +#include "plugin.h" +#include "nvme-print.h" +#include "solidigm-telemetry.h" +#include "solidigm-telemetry/telemetry-log.h" +#include "solidigm-telemetry/cod.h" +#include "solidigm-telemetry/header.h" +#include "solidigm-telemetry/config.h" +#include "solidigm-telemetry/data-area.h" + +static int read_file2buffer(char *file_name, char **buffer, size_t *length) +{ + FILE *fd = fopen(file_name, "rb"); + + if (!fd) + return errno; + + fseek(fd, 0, SEEK_END); + size_t length_bytes = ftell(fd); + + fseek(fd, 0, SEEK_SET); + + *buffer = malloc(length_bytes); + if (!*buffer) { + fclose(fd); + return errno; + } + *length = fread(*buffer, 1, length_bytes, fd); + fclose(fd); + return 0; +} + +struct config { + __u32 host_gen; + bool ctrl_init; + int data_area; + char *cfg_file; + bool is_input_file; +}; + +int solidigm_get_telemetry_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) +{ + const char *desc = "Parse Solidigm Telemetry log"; + const char *hgen = "Controls when to generate new host initiated report. Default value '1' generates new host initiated report, value '0' causes retrieval of existing log."; + const char *cgen = "Gather report generated by the controller."; + const char *dgen = "Pick which telemetry data area to report. Default is 3 to fetch areas 1-3. Valid options are 1, 2, 3, 4."; + const char *cfile = "JSON configuration file"; + const char *sfile = "data source is binary file containing log dump instead of block or character device"; + struct nvme_dev *dev; + + struct telemetry_log tl = { + .root = json_create_object(), + .log = NULL, + }; + + struct config cfg = { + .host_gen = 1, + .ctrl_init = false, + .data_area = 3, + .cfg_file = NULL, + .is_input_file = false, + }; + + OPT_ARGS(opts) = { + OPT_UINT("host-generate", 'g', &cfg.host_gen, hgen), + OPT_FLAG("controller-init", 'c', &cfg.ctrl_init, cgen), + OPT_UINT("data-area", 'd', &cfg.data_area, dgen), + OPT_FILE("config-file", 'j', &cfg.cfg_file, cfile), + OPT_FLAG("source-file", 's', &cfg.is_input_file, sfile), + OPT_END() + }; + + int err = argconfig_parse(argc, argv, desc, opts); + + if (err) + goto ret; + + if (cfg.is_input_file) { + if (optind >= argc) { + err = errno = EINVAL; + perror(argv[0]); + goto ret; + } + char *binary_file_name = argv[optind]; + + err = read_file2buffer(binary_file_name, (char **)&tl.log, &tl.log_size); + } else { + err = parse_and_open(&dev, argc, argv, desc, opts); + } + if (err) + goto ret; + + if (cfg.host_gen > 1) { + SOLIDIGM_LOG_WARNING("Invalid host-generate value '%d'", cfg.host_gen); + err = EINVAL; + goto close_fd; + } + + if (cfg.cfg_file) { + char *conf_str = 0; + size_t length = 0; + + err = read_file2buffer(cfg.cfg_file, &conf_str, &length); + if (err) { + SOLIDIGM_LOG_WARNING("Failed to open JSON configuration file %s: %s!", + cfg.cfg_file, strerror(err)); + goto close_fd; + } + json_tokener * jstok = json_tokener_new(); + + tl.configuration = json_tokener_parse_ex(jstok, conf_str, length); + if (jstok->err != json_tokener_success) { + SOLIDIGM_LOG_WARNING("Parsing error on JSON configuration file %s: %s (at offset %d)", + cfg.cfg_file, + json_tokener_error_desc(jstok->err), + jstok->char_offset); + json_tokener_free(jstok); + err = EINVAL; + goto close_fd; + } + json_tokener_free(jstok); + } + + if (!cfg.is_input_file) { + if (cfg.ctrl_init) + err = nvme_get_ctrl_telemetry(dev_fd(dev), true, + &tl.log, cfg.data_area, + &tl.log_size); + else if (cfg.host_gen) + err = nvme_get_new_host_telemetry(dev_fd(dev), &tl.log, + cfg.data_area, + &tl.log_size); + else + err = nvme_get_host_telemetry(dev_fd(dev), &tl.log, + cfg.data_area, + &tl.log_size); + + if (err < 0) { + SOLIDIGM_LOG_WARNING("get-telemetry-log: %s", + nvme_strerror(errno)); + goto close_fd; + } else if (err > 0) { + nvme_show_status(err); + SOLIDIGM_LOG_WARNING("Failed to acquire telemetry log %d!", err); + goto close_fd; + } + } + solidigm_telemetry_log_header_parse(&tl); + if (cfg.cfg_file) + solidigm_telemetry_log_data_areas_parse(&tl, cfg.data_area); + else + solidigm_telemetry_log_cod_parse(&tl); + + json_print_object(tl.root, NULL); + json_free_object(tl.root); + printf("\n"); + +close_fd: + if (!cfg.is_input_file) { + /* Redundant close() to make static code analysis happy */ + close(dev->direct.fd); + dev_close(dev); + } +ret: + json_free_object(tl.configuration); + free(tl.log); + return err; +} diff --git a/plugins/solidigm/solidigm-telemetry.h b/plugins/solidigm/solidigm-telemetry.h new file mode 100644 index 0000000..971ee2a --- /dev/null +++ b/plugins/solidigm/solidigm-telemetry.h @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2022 Solidigm. + * + * Author: leonardo.da.cunha@solidigm.com + */ + +int solidigm_get_telemetry_log(int argc, char **argv, struct command *cmd, struct plugin *plugin); diff --git a/plugins/solidigm/solidigm-telemetry/cod.c b/plugins/solidigm/solidigm-telemetry/cod.c new file mode 100644 index 0000000..be5685b --- /dev/null +++ b/plugins/solidigm/solidigm-telemetry/cod.c @@ -0,0 +1,194 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2022 Solidigm. + * + * Author: leonardo.da.cunha@solidigm.com + */ +#include "common.h" +#include "cod.h" + +const char *oemDataMapDesc[] = { + "Media Read Count", //Uid 0x00 + "Host Read count", //Uid 0x01 + "Media Write Count", //Uid 0x02 + "Host Write Count", //Uid 0x03 + "Device Model", // 0x04 + "Serial Number", // 0x05 + "Firmware Revision", // 0x06 + "Drive Status", // 0x07 + "Minimum Temperature", // 0x08 + "Maximum Temperature", // 0x09 + "Power Loss Protection Status", // 0x0a + "Lifetime Unsafe Shutdown Count", // 0x0b + "Lifetime Power Cycle Count", // 0x0c + "Minimum Read Latency", // 0x0d + "Maximum Read Latency", // 0x0e + "Average Read Latency", // 0x0f + "Minimum Write Latency", // 0x10 + "Maximum Write Latency", // 0x11 + "Average Write Latency", // 0x12 + "Grown Defects Count", // 0x13 + "DQS Recovery Count", // 0x14 + "Program Fail Count", // 0x15 + "Erase Fail Count", // 0x16 + "Defrag Writes in Progress Count", // 0x17 + "Total Defrag Writes Count", // 0x18 + "Max Die Offline Number", // 0x19 + "Current Die Offline Number", // 0x1A + "XOR Enable Status", // 0x1B + "Media Life Used", // 0x1C + "Uncorrectable Error Count", // 0x1D + "Current Wear Range Delta", // 0x1E + "Read Errors Corrected by XOR", // 0x1F + "Background Data Refresh", // 0x20 + "Pmic Vin History Data 1 Min", // 0x21 + "Pmic Vin History Data 1 Max", // 0x22 + "Pmic Vin History Data 1 Avg", // 0x23 + "Pmic Vin History Data 2 Min", // 0x24 + "Pmic Vin History Data 2 Max", // 0x25 + "Pmic Vin History Data 2 Avg", // 0x26 + "Pmic Vin History Data Total Readings", // 0x27 + "All Time Current Max Wear Level", // 0x28 + "Media Wear Remaining", // 0x29 + "Total Non-Defrag Writes", // 0x2A + "Number of sectors relocated in reaction to an error" //Uid 0x2B = 43 +}; + +static const char * getOemDataMapDescription(__u32 id) +{ + if (id < (sizeof(oemDataMapDesc) / sizeof(oemDataMapDesc[0]))) { + return oemDataMapDesc[id]; + } + return "unknown"; +} + +#define OEMSIGNATURE 0x504D4443 + +#pragma pack(push, cod, 1) +struct cod_header +{ + uint32_t versionMajor; + uint32_t versionMinor; + uint32_t Signature; //!Fixed signature value (0x504D4443) for identification and validation + uint32_t MapSizeInBytes; //!Total size of the map data structure in bytes + uint32_t EntryCount; //!Total number of entries in the entry list + uint8_t Reserved[12]; +}; + +struct cod_item +{ + uint32_t DataFieldMapUid; //!The data field unique identifier value + uint32_t reserved1 : 8; + uint32_t dataFieldType : 8; + uint32_t issigned : 1; + uint32_t bigEndian : 1; + uint32_t dataInvalid : 1; + uint32_t reserved2 : 13; + uint32_t DataFieldSizeInBytes; + uint8_t Reserved1[4]; + uint64_t DataFieldOffset; + uint8_t Reserved2[8]; +}; + +struct cod_map +{ + struct cod_header header; + struct cod_item items[]; +}; + +#pragma pack(pop, cod) + +void solidigm_telemetry_log_cod_parse(struct telemetry_log *tl) +{ + enum cod_field_type + { + INTEGER, + FLOAT, + STRING, + TWO_BYTE_ASCII, + FOUR_BYTE_ASCII, + + UNKNOWN = 0xFF, + }; + json_object *telemetry_header = NULL; + json_object *COD_offset = NULL; + json_object *reason_id = NULL; + + if (!json_object_object_get_ex(tl->root, "telemetryHeader", &telemetry_header)) + return; + if (!json_object_object_get_ex(telemetry_header, "reasonIdentifier", &reason_id)) + return; + if (!json_object_object_get_ex(reason_id, "OemDataMapOffset", &COD_offset)) + return; + + __u64 offset = json_object_get_int(COD_offset); + + if (offset == 0) { + return; + } + + if ((offset + sizeof(struct cod_header)) > tl->log_size) { + SOLIDIGM_LOG_WARNING("Warning: COD map header out of bounds."); + return; + } + + const struct cod_map *data = (struct cod_map *) (((__u8 *)tl->log ) + offset); + + uint32_t signature = be32_to_cpu(data->header.Signature); + if ( signature != OEMSIGNATURE){ + SOLIDIGM_LOG_WARNING("Warning: Unsupported COD data signature %x!", signature); + return; + } + if ((offset + data->header.MapSizeInBytes) > tl->log_size){ + SOLIDIGM_LOG_WARNING("Warning: COD map data out of bounds."); + return; + } + + json_object *cod = json_create_object(); + json_object_object_add(tl->root, "cod", cod); + + for (int i =0 ; i < data->header.EntryCount; i++) { + if ((offset + sizeof(struct cod_header) + (i + 1) * sizeof(struct cod_item)) > + tl->log_size){ + SOLIDIGM_LOG_WARNING("Warning: COD data out of bounds at item %d!", i); + return; + } + struct cod_item item = data->items[i]; + if (item.DataFieldOffset + item.DataFieldOffset > tl->log_size) { + continue; + } + if (item.dataInvalid) { + continue; + } + uint8_t *val = ((uint8_t *)tl->log )+ item.DataFieldOffset; + const char *key = getOemDataMapDescription(item.DataFieldMapUid); + switch(item.dataFieldType){ + case(INTEGER): + if (item.issigned) { + json_object_object_add(cod, key, + json_object_new_int64(le64_to_cpu(*(uint64_t *)val))); + } else { + json_object_add_value_uint64(cod, key, le64_to_cpu(*(uint64_t *)val)); + } + break; + case(FLOAT): + json_object_add_value_float(cod, key, *(float *) val); + break; + case(STRING): + json_object_object_add(cod, key, + json_object_new_string_len((const char *)val, item.DataFieldSizeInBytes)); + break; + case(TWO_BYTE_ASCII): + json_object_object_add(cod, key, + json_object_new_string_len((const char *)val,2)); + break; + case(FOUR_BYTE_ASCII): + json_object_object_add(cod, key, + json_object_new_string_len((const char *)val, 4)); + break; + default: + SOLIDIGM_LOG_WARNING("Warning: Unknown COD field type (%d)", item.DataFieldMapUid); + + } + } +} diff --git a/plugins/solidigm/solidigm-telemetry/cod.h b/plugins/solidigm/solidigm-telemetry/cod.h new file mode 100644 index 0000000..032ccdc --- /dev/null +++ b/plugins/solidigm/solidigm-telemetry/cod.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright (c) 2022 Solidigm. + * + * Author: leonardo.da.cunha@solidigm.com + */ + +#include "telemetry-log.h" +void solidigm_telemetry_log_cod_parse(struct telemetry_log *tl); diff --git a/plugins/solidigm/solidigm-telemetry/config.c b/plugins/solidigm/solidigm-telemetry/config.c new file mode 100644 index 0000000..781d786 --- /dev/null +++ b/plugins/solidigm/solidigm-telemetry/config.c @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2022 Solidigm. + * + * Author: leonardo.da.cunha@solidigm.com + */ +#include +#include "util/json.h" +#include + +// max 16 bit unsigned integer nummber 65535 +#define MAX_16BIT_NUM_AS_STRING_SIZE 6 + +static bool config_get_by_version(const json_object *obj, int version_major, + int version_minor, json_object **value) +{ + char str_key[MAX_16BIT_NUM_AS_STRING_SIZE]; + char str_subkey[MAX_16BIT_NUM_AS_STRING_SIZE]; + + snprintf(str_key, sizeof(str_key), "%d", version_major); + snprintf(str_subkey, sizeof(str_subkey), "%d", version_minor); + json_object *major_obj = NULL; + + if (!json_object_object_get_ex(obj, str_key, &major_obj)) + return false; + if (!json_object_object_get_ex(major_obj, str_subkey, value)) + return false; + return value != NULL; +} + +bool solidigm_config_get_by_token_version(const json_object *obj, int token_id, + int version_major, int version_minor, + json_object **value) +{ + json_object *token_obj = NULL; + char str_key[MAX_16BIT_NUM_AS_STRING_SIZE]; + + snprintf(str_key, sizeof(str_key), "%d", token_id); + if (!json_object_object_get_ex(obj, str_key, &token_obj)) + return false; + if (!config_get_by_version(token_obj, version_major, version_minor, value)) + return false; + return value != NULL; +} diff --git a/plugins/solidigm/solidigm-telemetry/config.h b/plugins/solidigm/solidigm-telemetry/config.h new file mode 100644 index 0000000..bea84fb --- /dev/null +++ b/plugins/solidigm/solidigm-telemetry/config.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright (c) 2022 Solidigm. + * + * Author: leonardo.da.cunha@solidigm.com + */ +#include +#include "util/json.h" + +bool solidigm_config_get_by_token_version(const json_object *obj, int key, int subkey, int subsubkey, json_object **value); diff --git a/plugins/solidigm/solidigm-telemetry/data-area.c b/plugins/solidigm/solidigm-telemetry/data-area.c new file mode 100644 index 0000000..7233e8f --- /dev/null +++ b/plugins/solidigm/solidigm-telemetry/data-area.c @@ -0,0 +1,424 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2022 Solidigm. + * + * Author: leonardo.da.cunha@solidigm.com + */ + +#include "common.h" +#include "data-area.h" +#include "config.h" +#include + +#define SIGNED_INT_PREFIX "int" +#define BITS_IN_BYTE 8 + +#define MAX_WARNING_SIZE 1024 + +static bool telemetry_log_get_value(const struct telemetry_log *tl, + uint32_t offset_bit, uint32_t size_bit, + bool is_signed, json_object **val_obj) +{ + uint32_t offset_bit_from_byte; + uint32_t additional_size_byte; + uint32_t offset_byte; + uint32_t val; + + if (size_bit == 0) { + char err_msg[MAX_WARNING_SIZE]; + + snprintf(err_msg, MAX_WARNING_SIZE, + "Value with size_bit=0 not supported."); + *val_obj = json_object_new_string(err_msg); + + return false; + } + additional_size_byte = (size_bit - 1) ? (size_bit - 1) / BITS_IN_BYTE : 0; + offset_byte = offset_bit / BITS_IN_BYTE; + + if (offset_byte > (tl->log_size - additional_size_byte)) { + char err_msg[MAX_WARNING_SIZE]; + + snprintf(err_msg, MAX_WARNING_SIZE, + "Value offset greater than binary size (%u > %zu).", + offset_byte, tl->log_size); + *val_obj = json_object_new_string(err_msg); + + return false; + } + + offset_bit_from_byte = offset_bit - (offset_byte * BITS_IN_BYTE); + + if ((size_bit + offset_bit_from_byte) > (sizeof(uint64_t) * BITS_IN_BYTE)) { + char err_msg[MAX_WARNING_SIZE]; + + snprintf(err_msg, MAX_WARNING_SIZE, + "Value crossing 64 bit, byte aligned bounday, " + "not supported. size_bit=%u, offset_bit_from_byte=%u.", + size_bit, offset_bit_from_byte); + *val_obj = json_object_new_string(err_msg); + + return false; + } + + val = *(uint64_t *)(((char *)tl->log) + offset_byte); + val >>= offset_bit_from_byte; + if (size_bit < 64) + val &= (1ULL << size_bit) - 1; + if (is_signed) { + if (val >> (size_bit - 1)) + val |= -1ULL << size_bit; + *val_obj = json_object_new_int64(val); + } else { + *val_obj = json_object_new_uint64(val); + } + + return true; +} + +static int telemetry_log_structure_parse(const struct telemetry_log *tl, + json_object *struct_def, + size_t parent_offset_bit, + json_object *output, + json_object *metadata) +{ + json_object *obj_arraySizeArray = NULL; + json_object *obj = NULL; + json_object *obj_memberList; + json_object *major_dimension; + json_object *sub_output; + bool is_enumeration = false; + bool has_member_list; + const char *type = ""; + const char *name; + size_t array_rank; + size_t offset_bit; + size_t size_bit; + uint32_t linear_array_pos_bit; + + if (!json_object_object_get_ex(struct_def, "name", &obj)) { + SOLIDIGM_LOG_WARNING("Warning: Structure definition missing property 'name': %s", + json_object_to_json_string(struct_def)); + return -1; + } + + name = json_object_get_string(obj); + + if (metadata) { + json_object_get(obj); + json_object_object_add(metadata, "objName", obj); + } + + if (json_object_object_get_ex(struct_def, "type", &obj)) + type = json_object_get_string(obj); + + if (!json_object_object_get_ex(struct_def, "offsetBit", &obj)) { + SOLIDIGM_LOG_WARNING("Warning: Structure definition missing " + "property 'offsetBit': %s", + json_object_to_json_string(struct_def)); + return -1; + } + + offset_bit = json_object_get_uint64(obj); + + if (!json_object_object_get_ex(struct_def, "sizeBit", &obj)) { + SOLIDIGM_LOG_WARNING("Warning: Structure definition missing " + "property 'sizeBit': %s", + json_object_to_json_string(struct_def)); + return -1; + } + + size_bit = json_object_get_uint64(obj); + + if (json_object_object_get_ex(struct_def, "enum", &obj)) + is_enumeration = json_object_get_boolean(obj); + + has_member_list = json_object_object_get_ex(struct_def, + "memberList", + &obj_memberList); + + if (!json_object_object_get_ex(struct_def, "arraySize", + &obj_arraySizeArray)) { + SOLIDIGM_LOG_WARNING("Warning: Structure definition missing " + "property 'arraySize': %s", + json_object_to_json_string(struct_def)); + return -1; + } + + array_rank = json_object_array_length(obj_arraySizeArray); + if (array_rank == 0) { + SOLIDIGM_LOG_WARNING("Warning: Structure property 'arraySize' " + "don't support flexible array: %s", + json_object_to_json_string(struct_def)); + return -1; + } + uint32_t array_size_dimension[array_rank]; + + for (size_t i = 0; i < array_rank; i++) { + json_object *dimension = json_object_array_get_idx(obj_arraySizeArray, i); + + array_size_dimension[i] = json_object_get_uint64(dimension); + major_dimension = dimension; + } + if (array_rank > 1) { + uint32_t linear_pos_per_index = array_size_dimension[0]; + uint32_t prev_index_offset_bit = 0; + json_object *dimension_output; + + for (int i = 1; i < (array_rank - 1); i++) + linear_pos_per_index *= array_size_dimension[i]; + + dimension_output = json_create_array(); + if (json_object_get_type(output) == json_type_array) + json_object_array_add(output, dimension_output); + else + json_object_add_value_array(output, name, dimension_output); + + /* + * Make sure major_dimension object will not be + * deleted from memory when deleted from array + */ + json_object_get(major_dimension); + json_object_array_del_idx(obj_arraySizeArray, array_rank - 1, 1); + + for (int i = 0 ; i < array_size_dimension[0]; i++) { + json_object *sub_array = json_create_array(); + size_t offset; + + offset = parent_offset_bit + prev_index_offset_bit; + + json_object_array_add(dimension_output, sub_array); + telemetry_log_structure_parse(tl, struct_def, + offset, sub_array, NULL); + prev_index_offset_bit += linear_pos_per_index * size_bit; + } + + json_object_array_put_idx(obj_arraySizeArray, array_rank - 1, + major_dimension); + + return 0; + } + + linear_array_pos_bit = 0; + sub_output = output; + + if (array_size_dimension[0] > 1) { + sub_output = json_create_array(); + if (json_object_get_type(output) == json_type_array) + json_object_array_add(output, sub_output); + else + json_object_add_value_array(output, name, sub_output); + } + + for (uint32_t j = 0; j < array_size_dimension[0]; j++) { + if (is_enumeration || !has_member_list) { + bool is_signed = !strncmp(type, SIGNED_INT_PREFIX, sizeof(SIGNED_INT_PREFIX)-1); + json_object *val_obj; + size_t offset; + + offset = parent_offset_bit + offset_bit + linear_array_pos_bit; + if (telemetry_log_get_value(tl, offset, size_bit, is_signed, &val_obj)) { + if (array_size_dimension[0] > 1) + json_object_array_put_idx(sub_output, j, val_obj); + else + json_object_object_add(sub_output, name, val_obj); + } else { + SOLIDIGM_LOG_WARNING("Warning: %s From property '%s', " + "array index %u, structure definition: %s", + json_object_get_string(val_obj), + name, j, json_object_to_json_string(struct_def)); + json_free_object(val_obj); + } + } else { + json_object *sub_sub_output = json_object_new_object(); + int num_members; + + if (array_size_dimension[0] > 1) + json_object_array_put_idx(sub_output, j, sub_sub_output); + else + json_object_add_value_object(sub_output, name, sub_sub_output); + + num_members = json_object_array_length(obj_memberList); + for (int k = 0; k < num_members; k++) { + json_object *member = json_object_array_get_idx(obj_memberList, k); + size_t offset; + + offset = parent_offset_bit + offset_bit + linear_array_pos_bit; + telemetry_log_structure_parse(tl, member, offset, + sub_sub_output, NULL); + } + } + linear_array_pos_bit += size_bit; + } + return 0; +} + +static int telemetry_log_data_area_get_offset(const struct telemetry_log *tl, + enum nvme_telemetry_da da, + uint32_t *offset, uint32_t *size) +{ + uint32_t offset_blocks = 1; + uint32_t last_block = tl->log->dalb1; + uint32_t last; + + switch (da) { + case NVME_TELEMETRY_DA_1: + offset_blocks = 1; + last_block = tl->log->dalb1; + break; + case NVME_TELEMETRY_DA_2: + offset_blocks = tl->log->dalb1 + 1; + last_block = tl->log->dalb2; + break; + case NVME_TELEMETRY_DA_3: + offset_blocks = tl->log->dalb2 + 1; + last_block = tl->log->dalb3; + break; + case NVME_TELEMETRY_DA_4: + offset_blocks = tl->log->dalb3 + 1; + last_block = tl->log->dalb4; + break; + default: + return -1; + } + + *offset = offset_blocks * NVME_LOG_TELEM_BLOCK_SIZE; + last = (last_block + 1) * NVME_LOG_TELEM_BLOCK_SIZE; + *size = last - *offset; + if ((*offset > tl->log_size) || (last > tl->log_size) || (last <= *offset)) { + SOLIDIGM_LOG_WARNING("Warning: Data Area %d don't fit this Telemetry log.", da); + return -1; + } + + return 0; +} + +struct toc_item { + uint32_t OffsetBytes; + uint32_t ContentSizeBytes; +}; + +struct data_area_header { + uint8_t versionMajor; + uint8_t versionMinor; + uint16_t TableOfContentsCount; + uint32_t DataAreaSize; + uint8_t Reserved[8]; +}; + +struct table_of_contents { + struct data_area_header header; + struct toc_item items[]; +}; + +struct telemetry_object_header { + uint16_t versionMajor; + uint16_t versionMinor; + uint32_t Token; + uint8_t CoreId; + uint8_t Reserved[3]; +}; + + +static void telemetry_log_data_area_toc_parse(const struct telemetry_log *tl, + enum nvme_telemetry_da da, + json_object *toc_array, + json_object *tele_obj_array) +{ + + const struct telemetry_object_header *header; + const struct table_of_contents *toc; + char *payload; + uint32_t da_offset; + uint32_t da_size; + + if (telemetry_log_data_area_get_offset(tl, da, &da_offset, &da_size)) + return; + + toc = (struct table_of_contents *)(((char *)tl->log) + da_offset); + payload = (char *) tl->log; + + for (int i = 0; i < toc->header.TableOfContentsCount; i++) { + json_object *structure_definition = NULL; + json_object *toc_item; + uint32_t obj_offset; + bool has_struct; + + if ((char *)&toc->items[i] > (((char *)toc) + da_size - sizeof(const struct toc_item))) { + SOLIDIGM_LOG_WARNING("Warning: Data Area %d, " + "Table of Contents item %d " + "crossed Data Area size.", da, i); + return; + } + + obj_offset = toc->items[i].OffsetBytes; + if ((obj_offset + sizeof(const struct telemetry_object_header)) > da_size) { + SOLIDIGM_LOG_WARNING("Warning: Data Area %d, item %d " + "data, crossed Data Area size.", da, i); + continue; + } + + toc_item = json_create_object(); + json_object_array_add(toc_array, toc_item); + json_object_add_value_uint(toc_item, "dataArea", da); + json_object_add_value_uint(toc_item, "dataAreaIndex", i); + json_object_add_value_uint(toc_item, "dataAreaOffset", obj_offset); + json_object_add_value_uint(toc_item, "fileOffset", obj_offset + da_offset); + json_object_add_value_uint(toc_item, "size", toc->items[i].ContentSizeBytes); + + header = (const struct telemetry_object_header *) (payload + da_offset + obj_offset); + json_object_add_value_uint(toc_item, "telemMajor", header->versionMajor); + json_object_add_value_uint(toc_item, "telemMinor", header->versionMinor); + json_object_add_value_uint(toc_item, "objectId", header->Token); + json_object_add_value_uint(toc_item, "mediaBankId", header->CoreId); + + has_struct = solidigm_config_get_by_token_version(tl->configuration, + header->Token, + header->versionMajor, + header->versionMinor, + &structure_definition); + + if (has_struct) { + json_object *tele_obj_item = json_create_object(); + + json_object_array_add(tele_obj_array, tele_obj_item); + json_object_get(toc_item); + json_object_add_value_object(tele_obj_item, "metadata", toc_item); + json_object *parsed_struct = json_object_new_object(); + + json_object_add_value_object(tele_obj_item, "objectData", parsed_struct); + json_object *obj_hasTelemObjHdr = NULL; + uint32_t header_offset = sizeof(const struct telemetry_object_header); + uint32_t file_offset; + + if (json_object_object_get_ex(structure_definition, + "hasTelemObjHdr", + &obj_hasTelemObjHdr)) { + bool hasHeader = json_object_get_boolean(obj_hasTelemObjHdr); + + if (hasHeader) + header_offset = 0; + } + + file_offset = da_offset + obj_offset + header_offset; + telemetry_log_structure_parse(tl, structure_definition, + BITS_IN_BYTE * file_offset, + parsed_struct, toc_item); + } + } +} + +int solidigm_telemetry_log_data_areas_parse(const struct telemetry_log *tl, + enum nvme_telemetry_da last_da) +{ + json_object *tele_obj_array = json_create_array(); + json_object *toc_array = json_create_array(); + + json_object_add_value_array(tl->root, "tableOfContents", toc_array); + json_object_add_value_array(tl->root, "telemetryObjects", tele_obj_array); + + for (enum nvme_telemetry_da da = NVME_TELEMETRY_DA_1; da <= last_da; da++) + telemetry_log_data_area_toc_parse(tl, da, toc_array, tele_obj_array); + + return 0; +} diff --git a/plugins/solidigm/solidigm-telemetry/data-area.h b/plugins/solidigm/solidigm-telemetry/data-area.h new file mode 100644 index 0000000..095eb64 --- /dev/null +++ b/plugins/solidigm/solidigm-telemetry/data-area.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright (c) 2022 Solidigm. + * + * Author: leonardo.da.cunha@solidigm.com + */ +#include "common.h" +#include "telemetry-log.h" + +int solidigm_telemetry_log_data_areas_parse(const struct telemetry_log *tl, + enum nvme_telemetry_da last_da); diff --git a/plugins/solidigm/solidigm-telemetry/header.c b/plugins/solidigm/solidigm-telemetry/header.c new file mode 100644 index 0000000..72b2d97 --- /dev/null +++ b/plugins/solidigm/solidigm-telemetry/header.c @@ -0,0 +1,199 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2022 Solidigm. + * + * Author: leonardo.da.cunha@solidigm.com + */ + +#include "common.h" +#include "header.h" + +#pragma pack(push, reason_indentifier, 1) +struct reason_indentifier_1_0 +{ + uint16_t versionMajor; + uint16_t versionMinor; + uint32_t reasonCode; //! 0 denotes no issue. All other values denote a potential issue. + char DriveStatus[20]; //! Drive Status String (for example: "Healthy", "*BAD_CONTEXT_2020") + char FirmwareVersion[12]; //! Similar to IdentifyController.FR + char BootloaderVersion[12]; //! Bootloader version string + char SerialNumber[20]; //! Device serial number + uint8_t Reserved[56]; //! Reserved for future usage +}; +static_assert(sizeof(const struct reason_indentifier_1_0) == + MEMBER_SIZE(struct nvme_telemetry_log, rsnident), + "Size mismatch for reason_indentifier_1_0"); + +struct reason_indentifier_1_1 +{ + uint16_t versionMajor; + uint16_t versionMinor; + uint32_t reasonCode; //! 0 denotes no issue. All other values denote a potential issue. + char DriveStatus[20]; //! Drive Status String (for example: "Healthy", "*BAD_CONTEXT_2020") + char FirmwareVersion[12]; //! Similar to IdentifyController.FR + char BootloaderVersion[12]; //! Bootloader version string + char SerialNumber[20]; //! Device serial number + uint64_t OemDataMapOffset; //! Customer Data Map Object Log Offset + uint8_t TelemetryMajorVersion; //! Shadow of version in TOC + uint8_t TelemetryMinorVersion; //! Shadow of version in TOC + uint8_t Reserved[46]; //! Reserved for future usage +}; +static_assert(sizeof(const struct reason_indentifier_1_1) == + MEMBER_SIZE(struct nvme_telemetry_log, rsnident), + "Size mismatch for reason_indentifier_1_1"); + +struct reason_indentifier_1_2 +{ + uint16_t versionMajor; + uint16_t versionMinor; + uint32_t reasonCode; //! 0 denotes no issue. All other values denote a potential issue. + char DriveStatus[20]; //! Drive Status String (for example: "Healthy", "*BAD_CONTEXT_2020") + uint8_t Reserved1[24]; //! pad over Fields removed from version 1.1 + char SerialNumber[20]; //! Device serial number + uint64_t OemDataMapOffset; //! Customer Data Map Object Log Offset + uint8_t TelemetryMajorVersion; //! Shadow of version in TOC + uint8_t TelemetryMinorVersion; //! Shadow of version in TOC + uint8_t ProductFamilyId; + uint8_t Reserved2[5]; //! Reserved for future usage + uint8_t DualPortReserved[40]; //! Reserved for dual port +}; +static_assert(sizeof(const struct reason_indentifier_1_2) == + MEMBER_SIZE(struct nvme_telemetry_log, rsnident), + "Size mismatch for reason_indentifier_1_2"); +#pragma pack(pop, reason_indentifier) + +static void telemetry_log_reason_id_parse1_0_ext(const struct telemetry_log *tl, + json_object *reason_id) +{ + const struct reason_indentifier_1_0 *ri; + json_object *reserved; + + ri = (struct reason_indentifier_1_0 *) tl->log->rsnident; + json_object_object_add(reason_id, "FirmwareVersion", json_object_new_string_len(ri->FirmwareVersion, sizeof(ri->FirmwareVersion))); + json_object_object_add(reason_id, "BootloaderVersion", json_object_new_string_len(ri->BootloaderVersion, sizeof(ri->BootloaderVersion))); + json_object_object_add(reason_id, "SerialNumber", json_object_new_string_len(ri->SerialNumber, sizeof(ri->SerialNumber))); + + reserved = json_create_array(); + json_object_add_value_array(reason_id, "Reserved", reserved); + for ( int i=0; i < sizeof(ri->Reserved); i++) { + json_object *val = json_object_new_int(ri->Reserved[i]); + json_object_array_add(reserved, val); + } +} + +static void telemetry_log_reason_id_parse1_1_ext(const struct telemetry_log *tl, + json_object *reason_id) +{ + const struct reason_indentifier_1_1 *ri; + json_object *reserved; + + ri = (struct reason_indentifier_1_1 *) tl->log->rsnident; + json_object_object_add(reason_id, "FirmwareVersion", json_object_new_string_len(ri->FirmwareVersion, sizeof(ri->FirmwareVersion))); + json_object_object_add(reason_id, "BootloaderVersion", json_object_new_string_len(ri->BootloaderVersion, sizeof(ri->BootloaderVersion))); + json_object_object_add(reason_id, "SerialNumber", json_object_new_string_len(ri->SerialNumber, sizeof(ri->SerialNumber))); + json_object_add_value_uint64(reason_id, "OemDataMapOffset", le64_to_cpu(ri->OemDataMapOffset)); + json_object_add_value_uint(reason_id, "TelemetryMajorVersion", le16_to_cpu(ri->TelemetryMajorVersion)); + json_object_add_value_uint(reason_id, "TelemetryMinorVersion", le16_to_cpu(ri->TelemetryMinorVersion)); + + reserved = json_create_array(); + json_object_add_value_array(reason_id, "Reserved", reserved); + for (int i = 0; i < sizeof(ri->Reserved); i++) { + json_object *val = json_object_new_int(ri->Reserved[i]); + json_object_array_add(reserved, val); + } +} + +static void telemetry_log_reason_id_parse1_2_ext(const struct telemetry_log *tl, + json_object *reason_id) +{ + const struct reason_indentifier_1_2 *ri; + json_object *dp_reserved; + json_object *reserved; + + ri = (struct reason_indentifier_1_2 *) tl->log->rsnident; + + json_object_object_add(reason_id, "SerialNumber", json_object_new_string_len(ri->SerialNumber, sizeof(ri->SerialNumber))); + json_object_add_value_uint64(reason_id, "OemDataMapOffset", le64_to_cpu(ri->OemDataMapOffset)); + json_object_add_value_uint(reason_id, "TelemetryMajorVersion", le16_to_cpu(ri->TelemetryMajorVersion)); + json_object_add_value_uint(reason_id, "TelemetryMinorVersion", le16_to_cpu(ri->TelemetryMinorVersion)); + json_object_add_value_uint(reason_id, "ProductFamilyId", ri->ProductFamilyId); + + reserved = json_create_array(); + json_object_add_value_array(reason_id, "Reserved2", reserved); + for (int i = 0; i < sizeof(ri->Reserved2); i++) { + json_object *val = json_object_new_int(ri->Reserved2[i]); + json_object_array_add(reserved, val); + } + + dp_reserved = json_create_array(); + json_object_add_value_array(reason_id, "DualPortReserved", dp_reserved); + for (int i = 0; i < sizeof(ri->DualPortReserved); i++) { + json_object *val = json_object_new_int(ri->DualPortReserved[i]); + json_object_array_add(dp_reserved, val); + } +} + +static void solidigm_telemetry_log_reason_id_parse(const struct telemetry_log *tl, json_object *reason_id) +{ + const struct reason_indentifier_1_0 *ri1_0 = + (struct reason_indentifier_1_0 *) tl->log->rsnident; + __u16 version_major = le16_to_cpu(ri1_0->versionMajor); + __u16 version_minor = le16_to_cpu(ri1_0->versionMinor); + + json_object_add_value_uint(reason_id, "versionMajor", version_major); + json_object_add_value_uint(reason_id, "versionMinor", version_minor); + json_object_add_value_uint(reason_id, "reasonCode", le32_to_cpu(ri1_0->reasonCode)); + json_object_add_value_object(reason_id, "DriveStatus", json_object_new_string_len(ri1_0->DriveStatus, sizeof(ri1_0->DriveStatus))); + if (version_major == 1) { + switch (version_minor) { + case 0: + telemetry_log_reason_id_parse1_0_ext(tl, reason_id); + break; + case 1: + telemetry_log_reason_id_parse1_1_ext(tl, reason_id); + break; + default: + telemetry_log_reason_id_parse1_2_ext(tl, reason_id); + } + } +} + +bool solidigm_telemetry_log_header_parse(const struct telemetry_log *tl) +{ + const struct nvme_telemetry_log *log; + json_object *ieee_oui_id; + json_object *reason_id; + json_object *header; + + if (tl->log_size < sizeof(const struct nvme_telemetry_log)) { + SOLIDIGM_LOG_WARNING("Telemetry log too short."); + return false; + } + + header = json_create_object(); + + json_object_object_add(tl->root, "telemetryHeader", header); + log = tl->log; + + json_object_add_value_uint(header, "logIdentifier", log->lpi); + ieee_oui_id = json_create_array(); + + json_object_object_add(header, "ieeeOuiIdentifier", ieee_oui_id); + for (int i = 0; i < sizeof(log->ieee); i++) { + json_object *val = json_object_new_int(log->ieee[i]); + + json_object_array_add(ieee_oui_id, val); + } + json_object_add_value_uint(header, "dataArea1LastBlock", log->dalb1); + json_object_add_value_uint(header, "dataArea2LastBlock", log->dalb2); + json_object_add_value_uint(header, "dataArea3LastBlock", log->dalb3); + json_object_add_value_uint(header, "hostInitiatedDataGeneration", log->hostdgn); + json_object_add_value_uint(header, "controllerInitiatedDataAvailable", log->ctrlavail); + json_object_add_value_uint(header, "controllerInitiatedDataGeneration", log->ctrldgn); + + reason_id = json_create_object(); + json_object_add_value_object(header, "reasonIdentifier", reason_id); + solidigm_telemetry_log_reason_id_parse(tl, reason_id); + + return true; +} diff --git a/plugins/solidigm/solidigm-telemetry/header.h b/plugins/solidigm/solidigm-telemetry/header.h new file mode 100644 index 0000000..027af55 --- /dev/null +++ b/plugins/solidigm/solidigm-telemetry/header.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright (c) 2022 Solidigm. + * + * Author: leonardo.da.cunha@solidigm.com + */ + +#include "telemetry-log.h" +bool solidigm_telemetry_log_header_parse(const struct telemetry_log *tl); diff --git a/plugins/solidigm/solidigm-telemetry/meson.build b/plugins/solidigm/solidigm-telemetry/meson.build new file mode 100644 index 0000000..53ab452 --- /dev/null +++ b/plugins/solidigm/solidigm-telemetry/meson.build @@ -0,0 +1,6 @@ +sources += [ + 'plugins/solidigm/solidigm-telemetry/cod.c', + 'plugins/solidigm/solidigm-telemetry/header.c', + 'plugins/solidigm/solidigm-telemetry/config.c', + 'plugins/solidigm/solidigm-telemetry/data-area.c', +] diff --git a/plugins/solidigm/solidigm-telemetry/telemetry-log.h b/plugins/solidigm/solidigm-telemetry/telemetry-log.h new file mode 100644 index 0000000..ef4ec5d --- /dev/null +++ b/plugins/solidigm/solidigm-telemetry/telemetry-log.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright (c) 2022 Solidigm. + * + * Author: leonardo.da.cunha@solidigm.com + */ + +#ifndef _SOLIDIGM_TELEMETRY_LOG_H +#define _SOLIDIGM_TELEMETRY_LOG_H + +#include "libnvme.h" +#include "util/json.h" +#include + +#if !defined __cplusplus +#define static_assert _Static_assert +#endif + +#define VA_ARGS(...), ##__VA_ARGS__ +#define SOLIDIGM_LOG_WARNING(format, ...) fprintf(stderr, format"\n" VA_ARGS(__VA_ARGS__)) + +#define MEMBER_SIZE(type, member) sizeof(((type *)0)->member) + +struct telemetry_log { + struct nvme_telemetry_log *log; + size_t log_size; + json_object *root; + json_object *configuration; +}; + +#endif /* _SOLIDIGM_TELEMETRY_LOG_H */ \ No newline at end of file diff --git a/plugins/toshiba/toshiba-nvme.c b/plugins/toshiba/toshiba-nvme.c index cf19352..5540fea 100644 --- a/plugins/toshiba/toshiba-nvme.c +++ b/plugins/toshiba/toshiba-nvme.c @@ -361,11 +361,11 @@ struct nvme_xdn_smart_log_c0 { __u8 resv[512 - NR_SMART_ITEMS_C0]; }; -static void default_show_vendor_log_c0(int fd, __u32 nsid, const char *devname, +static void default_show_vendor_log_c0(struct nvme_dev *dev, __u32 nsid, struct nvme_xdn_smart_log_c0 *smart) { printf("Vendor Log Page Directory 0xC0 for NVME device:%s namespace-id:%x\n", - devname, nsid); + dev->name, nsid); printf("Error Log : %u \n", smart->items[ERROR_LOG_C0]); printf("SMART Health Log : %u \n", smart->items[SMART_HEALTH_LOG_C0]); printf("Firmware Slot Info : %u \n", smart->items[FIRMWARE_SLOT_INFO_C0]); @@ -375,8 +375,8 @@ static void default_show_vendor_log_c0(int fd, __u32 nsid, const char *devname, printf("SMART Attributes : %u \n", smart->items[SMART_ATTRIBUTES_C0]); } -static int nvme_get_vendor_log(int fd, __u32 namespace_id, int log_page, - const char* const filename) +static int nvme_get_vendor_log(struct nvme_dev *dev, __u32 namespace_id, + int log_page, const char* const filename) { int err; void* log = NULL; @@ -388,11 +388,12 @@ static int nvme_get_vendor_log(int fd, __u32 namespace_id, int log_page, } /* Check device supported */ - err = nvme_get_sct_status(fd, MASK_0 | MASK_1); + err = nvme_get_sct_status(dev_fd(dev), MASK_0 | MASK_1); if (err) { goto end; } - err = nvme_get_nsid_log(fd, false, log_page, namespace_id, log_len, log); + err = nvme_get_nsid_log(dev_fd(dev), false, log_page, namespace_id, + log_len, log); if (err) { fprintf(stderr, "%s: couldn't get log 0x%x\n", __func__, log_page); @@ -419,8 +420,7 @@ static int nvme_get_vendor_log(int fd, __u32 namespace_id, int log_page, } } else { if (log_page == 0xc0) - default_show_vendor_log_c0(fd, namespace_id, devicename, - (struct nvme_xdn_smart_log_c0 *)log); + default_show_vendor_log_c0(dev, namespace_id, log); else d(log, log_len,16,1); } @@ -433,11 +433,12 @@ end: static int vendor_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - int err, fd; char *desc = "Get extended SMART information and show it."; const char *namespace = "(optional) desired namespace"; const char *output_file = "(optional) binary output filename"; const char *log = "(optional) log ID (0xC0, or 0xCA), default 0xCA"; + struct nvme_dev *dev; + int err; struct config { __u32 namespace_id; @@ -458,8 +459,8 @@ static int vendor_log(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) { fprintf(stderr,"%s: failed to parse arguments\n", __func__); return EINVAL; } @@ -470,22 +471,24 @@ static int vendor_log(int argc, char **argv, struct command *cmd, struct plugin goto end; } - err = nvme_get_vendor_log(fd, cfg.namespace_id, cfg.log, cfg.output_file); + err = nvme_get_vendor_log(dev, cfg.namespace_id, cfg.log, + cfg.output_file); if (err) fprintf(stderr, "%s: couldn't get vendor log 0x%x\n", __func__, cfg.log); end: if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } static int internal_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - int err, fd; char *desc = "Get internal status log and show it."; const char *output_file = "(optional) binary output filename"; const char *prev_log = "(optional) use previous log. Otherwise uses current log."; + struct nvme_dev *dev; + int err; struct config { const char* output_file; @@ -503,8 +506,8 @@ static int internal_log(int argc, char **argv, struct command *cmd, struct plugi OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) { fprintf(stderr,"%s: failed to parse arguments\n", __func__); return EINVAL; } @@ -514,46 +517,48 @@ static int internal_log(int argc, char **argv, struct command *cmd, struct plugi else printf("Getting current log\n"); - err = nvme_get_internal_log_file(fd, cfg.output_file, !cfg.prev_log); + err = nvme_get_internal_log_file(dev_fd(dev), cfg.output_file, + !cfg.prev_log); if (err < 0) fprintf(stderr, "%s: couldn't get fw log \n", __func__); if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } static int clear_correctable_errors(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - int err, fd; char *desc = "Clear PCIe correctable error count."; const __u32 namespace_id = 0xFFFFFFFF; const __u32 feature_id = 0xCA; const __u32 value = 1; /* Bit0 - reset clear PCIe correctable count */ const __u32 cdw12 = 0; const bool save = false; + struct nvme_dev *dev; __u32 result; + int err; OPT_ARGS(opts) = { OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) { fprintf(stderr,"%s: failed to parse arguments\n", __func__); return EINVAL; } /* Check device supported */ - err = nvme_get_sct_status(fd, MASK_0 | MASK_1); + err = nvme_get_sct_status(dev_fd(dev), MASK_0 | MASK_1); if (err) goto end; struct nvme_set_features_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .fid = feature_id, .nsid = namespace_id, .cdw11 = value, @@ -573,6 +578,6 @@ static int clear_correctable_errors(int argc, char **argv, struct command *cmd, end: if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } diff --git a/plugins/transcend/transcend-nvme.c b/plugins/transcend/transcend-nvme.c index a3b739d..024351f 100644 --- a/plugins/transcend/transcend-nvme.c +++ b/plugins/transcend/transcend-nvme.c @@ -21,20 +21,20 @@ static int getHealthValue(int argc, char **argv, struct command *cmd, struct plu { struct nvme_smart_log smart_log; char *desc = "Get nvme health percentage."; - int result=0, fd; int percent_used = 0, healthvalue=0; - + struct nvme_dev *dev; + int result; + OPT_ARGS(opts) = { OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - - if (fd < 0) { + result = parse_and_open(&dev, argc, argv, desc, opts); + if (result) { printf("\nDevice not found \n");; return -1; } - result = nvme_get_log_smart(fd, 0xffffffff, false, &smart_log); + result = nvme_get_log_smart(dev_fd(dev), 0xffffffff, false, &smart_log); if (!result) { printf("Transcend NVME heath value: "); percent_used =smart_log.percent_used; @@ -50,7 +50,7 @@ static int getHealthValue(int argc, char **argv, struct command *cmd, struct plu } } - close(fd); + dev_close(dev); return result; } @@ -59,15 +59,16 @@ static int getBadblock(int argc, char **argv, struct command *cmd, struct plugin { char *desc = "Get nvme bad block number."; - int result=0, fd; + struct nvme_dev *dev; + int result; OPT_ARGS(opts) = { OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { + result = parse_and_open(&dev, argc, argv, desc, opts); + if (result) { printf("\nDevice not found \n");; return -1; } @@ -79,11 +80,11 @@ static int getBadblock(int argc, char **argv, struct command *cmd, struct plugin nvmecmd.cdw12=DW12_BAD_BLOCK; nvmecmd.addr = (__u64)(uintptr_t)data; nvmecmd.data_len = 0x1; - result = nvme_submit_admin_passthru(fd, &nvmecmd, NULL); + result = nvme_submit_admin_passthru(dev_fd(dev), &nvmecmd, NULL); if(!result) { int badblock = data[0]; printf("Transcend NVME badblock count: %d\n",badblock); } - close(fd); + dev_close(dev); return result; } diff --git a/plugins/virtium/virtium-nvme.c b/plugins/virtium/virtium-nvme.c index b8cefe6..c8df126 100644 --- a/plugins/virtium/virtium-nvme.c +++ b/plugins/virtium/virtium-nvme.c @@ -14,6 +14,7 @@ #include "nvme.h" #include "libnvme.h" #include "plugin.h" +#include "util/types.h" #define CREATE_CMD #include "virtium-nvme.h" @@ -51,18 +52,6 @@ struct vtview_save_log_settings { const char* test_name; }; -static long double int128_to_double(__u8 *data) -{ - int i; - long double result = 0; - - for (i = 0; i < 16; i++) { - result *= 256; - result += data[15 - i]; - } - return result; -} - static void vt_initialize_header_buffer(struct vtview_log_header *pbuff) { memset(pbuff->path, 0, sizeof(pbuff->path)); @@ -151,25 +140,25 @@ static void vt_convert_smart_data_to_human_readable_format(struct vtview_smart_l strcat(text, tempbuff); snprintf(tempbuff, sizeof(tempbuff), "Percentage_Used;%u;", smart->raw_smart.percent_used); strcat(text, tempbuff); - snprintf(tempbuff, sizeof(tempbuff), "Data_Units_Read;%0.Lf;", int128_to_double(smart->raw_smart.data_units_read)); + snprintf(tempbuff, sizeof(tempbuff), "Data_Units_Read;%s;", uint128_t_to_string(le128_to_cpu(smart->raw_smart.data_units_read))); strcat(text, tempbuff); - snprintf(tempbuff, sizeof(tempbuff), "Data_Units_Written;%0.Lf;", int128_to_double(smart->raw_smart.data_units_written)); + snprintf(tempbuff, sizeof(tempbuff), "Data_Units_Written;%s;", uint128_t_to_string(le128_to_cpu(smart->raw_smart.data_units_written))); strcat(text, tempbuff); - snprintf(tempbuff, sizeof(tempbuff), "Host_Read_Commands;%0.Lf;", int128_to_double(smart->raw_smart.host_reads)); + snprintf(tempbuff, sizeof(tempbuff), "Host_Read_Commands;%s;", uint128_t_to_string(le128_to_cpu(smart->raw_smart.host_reads))); strcat(text, tempbuff); - snprintf(tempbuff, sizeof(tempbuff), "Host_Write_Commands;%0.Lf;", int128_to_double(smart->raw_smart.host_writes)); + snprintf(tempbuff, sizeof(tempbuff), "Host_Write_Commands;%s;", uint128_t_to_string(le128_to_cpu(smart->raw_smart.host_writes))); strcat(text, tempbuff); - snprintf(tempbuff, sizeof(tempbuff), "Controller_Busy_Time;%0.Lf;", int128_to_double(smart->raw_smart.ctrl_busy_time)); + snprintf(tempbuff, sizeof(tempbuff), "Controller_Busy_Time;%s;", uint128_t_to_string(le128_to_cpu(smart->raw_smart.ctrl_busy_time))); strcat(text, tempbuff); - snprintf(tempbuff, sizeof(tempbuff), "Power_Cycles;%0.Lf;", int128_to_double(smart->raw_smart.power_cycles)); + snprintf(tempbuff, sizeof(tempbuff), "Power_Cycles;%s;", uint128_t_to_string(le128_to_cpu(smart->raw_smart.power_cycles))); strcat(text, tempbuff); - snprintf(tempbuff, sizeof(tempbuff), "Power_On_Hours;%0.Lf;", int128_to_double(smart->raw_smart.power_on_hours)); + snprintf(tempbuff, sizeof(tempbuff), "Power_On_Hours;%s;", uint128_t_to_string(le128_to_cpu(smart->raw_smart.power_on_hours))); strcat(text, tempbuff); - snprintf(tempbuff, sizeof(tempbuff), "Unsafe_Shutdowns;%0.Lf;", int128_to_double(smart->raw_smart.unsafe_shutdowns)); + snprintf(tempbuff, sizeof(tempbuff), "Unsafe_Shutdowns;%s;", uint128_t_to_string(le128_to_cpu(smart->raw_smart.unsafe_shutdowns))); strcat(text, tempbuff); - snprintf(tempbuff, sizeof(tempbuff), "Media_Errors;%0.Lf;", int128_to_double(smart->raw_smart.media_errors)); + snprintf(tempbuff, sizeof(tempbuff), "Media_Errors;%s;", uint128_t_to_string(le128_to_cpu(smart->raw_smart.media_errors))); strcat(text, tempbuff); - snprintf(tempbuff, sizeof(tempbuff), "Num_Err_Log_Entries;%0.Lf;", int128_to_double(smart->raw_smart.num_err_log_entries)); + snprintf(tempbuff, sizeof(tempbuff), "Num_Err_Log_Entries;%s;", uint128_t_to_string(le128_to_cpu(smart->raw_smart.num_err_log_entries))); strcat(text, tempbuff); snprintf(tempbuff, sizeof(tempbuff), "Warning_Temperature_Time;%u;", le32_to_cpu(smart->raw_smart.warning_temp_time)); strcat(text, tempbuff); @@ -927,8 +916,7 @@ static void vt_parse_detail_identify(const struct nvme_id_ctrl *ctrl) static int vt_save_smart_to_vtview_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - int err = 0; - int fd, ret; + int ret, err = 0; long int total_time = 0; long int freq_time = 0; long int cur_time = 0; @@ -949,6 +937,7 @@ static int vt_save_smart_to_vtview_log(int argc, char **argv, struct command *cm const char *freq = "(optional) How often you want to log SMART data (0.25 = 15' , 0.5 = 30' , 1 = 1 hour, 2 = 2 hours, etc.). Default = 10 hours."; const char *output_file = "(optional) Name of the log file (give it a name that easy for you to remember what the test is). You can leave it blank too, we will take care it for you."; const char *test_name = "(optional) Name of the test you are doing. We use this as part of the name of the log file."; + struct nvme_dev *dev; struct vtview_save_log_settings cfg = { .run_time_hrs = 20, @@ -975,10 +964,10 @@ static int vt_save_smart_to_vtview_log(int argc, char **argv, struct command *cm strcpy(path, argv[1]); } - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { - printf("Error parse and open (fd = %d)\n", fd); - return (fd); + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) { + printf("Error parse and open (err = %d)\n", err); + return err; } printf("Running...\n"); @@ -986,10 +975,10 @@ static int vt_save_smart_to_vtview_log(int argc, char **argv, struct command *cm printf("Running for %lf hour(s)\n", cfg.run_time_hrs); printf("Logging SMART data for every %lf hour(s)\n", cfg.log_record_frequency_hrs); - ret = vt_update_vtview_log_header(fd, path, &cfg); + ret = vt_update_vtview_log_header(dev_fd(dev), path, &cfg); if (ret) { err = EINVAL; - close(fd); + dev_close(dev); return (err); } @@ -1009,7 +998,7 @@ static int vt_save_smart_to_vtview_log(int argc, char **argv, struct command *cm if(cur_time >= end_time) break; - ret = vt_add_entry_to_log(fd, path, &cfg); + ret = vt_add_entry_to_log(dev_fd(dev), path, &cfg); if (ret) { printf("Cannot update driver log\n"); break; @@ -1021,15 +1010,15 @@ static int vt_save_smart_to_vtview_log(int argc, char **argv, struct command *cm fflush(stdout); } - close (fd); + dev_close(dev); return (err); } static int vt_show_identify(int argc, char **argv, struct command *cmd, struct plugin *plugin) { - int err = 0; - int fd ,ret; + int ret, err = 0; struct nvme_id_ctrl ctrl; + struct nvme_dev *dev; char *desc = "Parse identify data to json format\n\n" "Typical usages:\n\n" "virtium show-identify /dev/yourDevice\n"; @@ -1038,16 +1027,16 @@ static int vt_show_identify(int argc, char **argv, struct command *cmd, struct p OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { - printf("Error parse and open (fd = %d)\n", fd); - return (fd); + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) { + printf("Error parse and open (err = %d)\n", err); + return err; } - ret = nvme_identify_ctrl(fd, &ctrl); + ret = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (ret) { printf("Cannot read identify device\n"); - close (fd); + dev_close(dev); return (-1); } @@ -1055,6 +1044,6 @@ static int vt_show_identify(int argc, char **argv, struct command *cmd, struct p vt_process_string(ctrl.mn, sizeof(ctrl.mn)); vt_parse_detail_identify(&ctrl); - close(fd); + dev_close(dev); return (err); } diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index 5f90c76..cf185be 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -36,6 +36,7 @@ #include "libnvme.h" #include "plugin.h" #include "linux/types.h" +#include "util/types.h" #include "nvme-print.h" #define CREATE_CMD @@ -77,11 +78,15 @@ #define WDC_NVME_SN650_DEV_ID_3 0x2720 #define WDC_NVME_SN650_DEV_ID_4 0x2721 #define WDC_NVME_SN655_DEV_ID 0x2722 +#define WDC_NVME_SN860_DEV_ID 0x2730 +#define WDC_NVME_SN660_DEV_ID 0x2704 + +/* This id's are no longer supported, delete ?? */ +#define WDC_NVME_SN550_DEV_ID 0x2708 #define WDC_NVME_SN560_DEV_ID_1 0x2712 #define WDC_NVME_SN560_DEV_ID_2 0x2713 #define WDC_NVME_SN560_DEV_ID_3 0x2714 -#define WDC_NVME_SN860_DEV_ID 0x2730 -#define WDC_NVME_SN550_DEV_ID 0x2708 + #define WDC_NVME_SXSLCL_DEV_ID 0x2001 #define WDC_NVME_SN520_DEV_ID 0x5003 #define WDC_NVME_SN520_DEV_ID_1 0x5004 @@ -89,8 +94,6 @@ #define WDC_NVME_SN530_DEV_ID 0x5009 #define WDC_NVME_SN720_DEV_ID 0x5002 #define WDC_NVME_SN730A_DEV_ID 0x5006 -#define WDC_NVME_SN730B_DEV_ID 0x3714 -#define WDC_NVME_SN730B_DEV_ID_1 0x3734 #define WDC_NVME_SN740_DEV_ID 0x5015 #define WDC_NVME_SN740_DEV_ID_1 0x5016 #define WDC_NVME_SN740_DEV_ID_2 0x5017 @@ -327,7 +330,7 @@ #define WDC_NVME_SMART_CLOUD_ATTR_LEN 0x200 /* C0 SMART Cloud Attributes Log Page*/ -#define WDC_NVME_GET_SMART_CLOUD_ATTR_LOG_OPCODE 0xC0 +#define WDC_NVME_GET_SMART_CLOUD_ATTR_LOG_ID 0xC0 /* CB - FW Activate History Log Page */ #define WDC_NVME_GET_FW_ACT_HISTORY_LOG_ID 0xCB @@ -341,7 +344,7 @@ /* C3 Latency Monitor Log Page */ #define WDC_LATENCY_MON_LOG_BUF_LEN 0x200 -#define WDC_LATENCY_MON_OPCODE 0xC3 +#define WDC_LATENCY_MON_LOG_ID 0xC3 #define WDC_LATENCY_MON_VERSION 0x0001 #define WDC_C3_GUID_LENGTH 16 @@ -792,17 +795,18 @@ static NVME_VU_DE_LOGPAGE_LIST deVULogPagesList[] = { NVME_DE_LOGPAGE_C0, 0xC0, 512, "0xc0"} }; -static int wdc_get_serial_name(int fd, char *file, size_t len, const char *suffix); +static int wdc_get_serial_name(struct nvme_dev *dev, char *file, size_t len, + const char *suffix); static int wdc_create_log_file(char *file, __u8 *drive_log_data, __u32 drive_log_length); -static int wdc_do_clear_dump(int fd, __u8 opcode, __u32 cdw12); -static int wdc_do_dump(int fd, __u32 opcode,__u32 data_len, +static int wdc_do_clear_dump(struct nvme_dev *dev, __u8 opcode, __u32 cdw12); +static int wdc_do_dump(struct nvme_dev *dev, __u32 opcode,__u32 data_len, __u32 cdw12, char *file, __u32 xfer_size); -static int wdc_do_crash_dump(int fd, char *file, int type); -static int wdc_crash_dump(int fd, char *file, int type); +static int wdc_do_crash_dump(struct nvme_dev *dev, char *file, int type); +static int wdc_crash_dump(struct nvme_dev *dev, char *file, int type); static int wdc_get_crash_dump(int argc, char **argv, struct command *command, struct plugin *plugin); -static int wdc_do_drive_log(int fd, char *file); +static int wdc_do_drive_log(struct nvme_dev *dev, char *file); static int wdc_drive_log(int argc, char **argv, struct command *command, struct plugin *plugin); static const char* wdc_purge_mon_status_to_string(__u32 status); @@ -810,10 +814,11 @@ static int wdc_purge(int argc, char **argv, struct command *command, struct plugin *plugin); static int wdc_purge_monitor(int argc, char **argv, struct command *command, struct plugin *plugin); -static bool wdc_nvme_check_supported_log_page(nvme_root_t r, int fd, __u8 log_id); +static bool wdc_nvme_check_supported_log_page(nvme_root_t r, + struct nvme_dev *dev, __u8 log_id); static int wdc_clear_pcie_correctable_errors(int argc, char **argv, struct command *command, struct plugin *plugin); -static int wdc_do_drive_essentials(nvme_root_t r, int fd, char *dir, char *key); +static int wdc_do_drive_essentials(nvme_root_t r, struct nvme_dev *dev, char *dir, char *key); static int wdc_drive_essentials(int argc, char **argv, struct command *command, struct plugin *plugin); static int wdc_drive_status(int argc, char **argv, struct command *command, @@ -822,27 +827,31 @@ static int wdc_clear_assert_dump(int argc, char **argv, struct command *command, struct plugin *plugin); static int wdc_drive_resize(int argc, char **argv, struct command *command, struct plugin *plugin); -static int wdc_do_drive_resize(int fd, uint64_t new_size); +static int wdc_do_drive_resize(struct nvme_dev *dev, uint64_t new_size); static int wdc_namespace_resize(int argc, char **argv, struct command *command, struct plugin *plugin); -static int wdc_do_namespace_resize(int fd, __u32 nsid, __u32 op_option); +static int wdc_do_namespace_resize(struct nvme_dev *dev, __u32 nsid, + __u32 op_option); static int wdc_reason_identifier(int argc, char **argv, struct command *command, struct plugin *plugin); -static int wdc_do_get_reason_id(int fd, char *file, int log_id); -static int wdc_save_reason_id(int fd, __u8 *rsn_ident, int size); -static int wdc_clear_reason_id(int fd); +static int wdc_do_get_reason_id(struct nvme_dev *dev, char *file, int log_id); +static int wdc_save_reason_id(struct nvme_dev *dev, __u8 *rsn_ident, int size); +static int wdc_clear_reason_id(struct nvme_dev *dev); static int wdc_log_page_directory(int argc, char **argv, struct command *command, struct plugin *plugin); -static int wdc_do_drive_info(int fd, __u32 *result); +static int wdc_do_drive_info(struct nvme_dev *dev, __u32 *result); static int wdc_vs_drive_info(int argc, char **argv, struct command *command, struct plugin *plugin); static int wdc_vs_temperature_stats(int argc, char **argv, struct command *command, struct plugin *plugin); -static __u64 wdc_get_enc_drive_capabilities(nvme_root_t r, int fd); -static int wdc_enc_get_nic_log(int fd, __u8 log_id, __u32 xfer_size, __u32 data_len, FILE *out); -static int wdc_enc_submit_move_data(int fd, char *cmd, int len, int xfer_size, FILE *out, int data_id, int cdw14, int cdw15); -static bool get_dev_mgment_cbs_data(nvme_root_t r, int fd, __u8 log_id, void **cbs_data); -static __u32 wdc_get_fw_cust_id(nvme_root_t r, int fd); +static __u64 wdc_get_enc_drive_capabilities(nvme_root_t r, struct nvme_dev *dev); +static int wdc_enc_get_nic_log(struct nvme_dev *dev, __u8 log_id, + __u32 xfer_size, __u32 data_len, FILE *out); +static int wdc_enc_submit_move_data(struct nvme_dev *dev, char *cmd, int len, + int xfer_size, FILE *out, int data_id, int cdw14, int cdw15); +static bool get_dev_mgment_cbs_data(nvme_root_t r, struct nvme_dev *dev, + __u8 log_id, void **cbs_data); +static __u32 wdc_get_fw_cust_id(nvme_root_t r, struct nvme_dev *dev); /* Drive log data size */ struct wdc_log_size { @@ -1084,7 +1093,8 @@ struct __attribute__((__packed__)) wdc_ssd_d0_smart_log { #define WDC_OCP_C1_GUID_LENGTH 16 #define WDC_ERROR_REC_LOG_BUF_LEN 512 #define WDC_ERROR_REC_LOG_ID 0xC1 -#define WDC_ERROR_REC_LOG_VERSION 0002 +#define WDC_ERROR_REC_LOG_VERSION1 0001 +#define WDC_ERROR_REC_LOG_VERSION2 0002 struct __attribute__((__packed__)) wdc_ocp_c1_error_recovery_log { __le16 panic_reset_wait_time; /* 000 - Panic Reset Wait Time */ @@ -1096,9 +1106,9 @@ struct __attribute__((__packed__)) wdc_ocp_c1_error_recovery_log { __u8 rsvd1[3]; /* 017 - 3 Reserved Bytes */ __le32 vs_cmd_cdw12; /* 020 - Vendor Specific Command CDW12 */ __le32 vs_cmd_cdw13; /* 024 - Vendor Specific Command CDW13 */ - __u8 vs_cmd_to; /* 028 - Vendor Specific Command Timeout */ - __u8 dev_recovery_action2; /* 029 - Device Recovery Action 2 */ - __u8 dev_recovery_action2_to; /* 030 - Device Recovery Action 2 Timeout */ + __u8 vs_cmd_to; /* 028 - Vendor Specific Command Timeout V2 */ + __u8 dev_recovery_action2; /* 029 - Device Recovery Action 2 V2 */ + __u8 dev_recovery_action2_to; /* 030 - Device Recovery Action 2 Timeout V2*/ __u8 rsvd2[463]; /* 031 - 463 Reserved Bytes */ __le16 log_page_version; /* 494 - Log Page Version */ __u8 log_page_guid[WDC_OCP_C1_GUID_LENGTH]; /* 496 - Log Page GUID */ @@ -1277,27 +1287,15 @@ static double calc_percent(uint64_t numerator, uint64_t denominator) (uint64_t)(((double)numerator / (double)denominator) * 100) : 0; } -static long double int128_to_double(__u8 *data) -{ - int i; - long double result = 0; - - for (i = 0; i < 16; i++) { - result *= 256; - result += data[15 - i]; - } - return result; -} - -static int wdc_get_pci_ids(nvme_root_t r, uint32_t *device_id, - uint32_t *vendor_id) +static int wdc_get_pci_ids(nvme_root_t r, struct nvme_dev *dev, + uint32_t *device_id, uint32_t *vendor_id) { char vid[256], did[256], id[32]; nvme_ctrl_t c = NULL; nvme_ns_t n = NULL; int fd, ret; - c = nvme_scan_ctrl(r, devicename); + c = nvme_scan_ctrl(r, dev->name); if (c) { snprintf(vid, sizeof(vid), "%s/device/vendor", nvme_ctrl_get_sysfs_dir(c)); @@ -1305,9 +1303,9 @@ static int wdc_get_pci_ids(nvme_root_t r, uint32_t *device_id, nvme_ctrl_get_sysfs_dir(c)); nvme_free_ctrl(c); } else { - n = nvme_scan_namespace(devicename); + n = nvme_scan_namespace(dev->name); if (!n) { - fprintf(stderr, "Unable to find %s\n", devicename); + fprintf(stderr, "Unable to find %s\n", dev->name); return -1; } @@ -1359,13 +1357,13 @@ static int wdc_get_pci_ids(nvme_root_t r, uint32_t *device_id, return 0; } -static int wdc_get_vendor_id(int fd, uint32_t *vendor_id) +static int wdc_get_vendor_id(struct nvme_dev *dev, uint32_t *vendor_id) { int ret; struct nvme_id_ctrl ctrl; memset(&ctrl, 0, sizeof(struct nvme_id_ctrl)); - ret = nvme_identify_ctrl(fd, &ctrl); + ret = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (ret) { fprintf(stderr, "ERROR : WDC : nvme_identify_ctrl() failed " "0x%x\n", ret); @@ -1382,13 +1380,13 @@ static bool wdc_check_power_of_2(int num) return (num && ( !(num & (num-1)))); } -static int wdc_get_model_number(int fd, char *model) +static int wdc_get_model_number(struct nvme_dev *dev, char *model) { int ret,i; struct nvme_id_ctrl ctrl; memset(&ctrl, 0, sizeof(struct nvme_id_ctrl)); - ret = nvme_identify_ctrl(fd, &ctrl); + ret = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (ret) { fprintf(stderr, "ERROR : WDC : nvme_identify_ctrl() failed " "0x%x\n", ret); @@ -1404,16 +1402,16 @@ static int wdc_get_model_number(int fd, char *model) return ret; } -static bool wdc_check_device(nvme_root_t r, int fd) +static bool wdc_check_device(nvme_root_t r, struct nvme_dev *dev) { int ret; bool supported; uint32_t read_device_id = -1, read_vendor_id = -1; - ret = wdc_get_pci_ids(r, &read_device_id, &read_vendor_id); + ret = wdc_get_pci_ids(r, dev, &read_device_id, &read_vendor_id); if (ret < 0) { /* Use the identify nvme command to get vendor id due to NVMeOF device. */ - if (wdc_get_vendor_id(fd, &read_vendor_id) < 0) + if (wdc_get_vendor_id(dev, &read_vendor_id) < 0) return false; } @@ -1430,13 +1428,13 @@ static bool wdc_check_device(nvme_root_t r, int fd) return supported; } -static bool wdc_enc_check_model(int fd) +static bool wdc_enc_check_model(struct nvme_dev *dev) { int ret; bool supported; char model[NVME_ID_CTRL_MODEL_NUMBER_SIZE+1]; - ret = wdc_get_model_number(fd, model); + ret = wdc_get_model_number(dev, model); if (ret < 0) return false; @@ -1450,23 +1448,24 @@ static bool wdc_enc_check_model(int fd) return supported; } -static __u64 wdc_get_drive_capabilities(nvme_root_t r, int fd) { +static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev) +{ int ret; uint32_t read_device_id = -1, read_vendor_id = -1; __u64 capabilities = 0; __u32 cust_id; - ret = wdc_get_pci_ids(r, &read_device_id, &read_vendor_id); + ret = wdc_get_pci_ids(r, dev, &read_device_id, &read_vendor_id); if (ret < 0) { - if (wdc_get_vendor_id(fd, &read_vendor_id) < 0) + if (wdc_get_vendor_id(dev, &read_vendor_id) < 0) return capabilities; } /* below check condition is added due in NVMeOF device we dont have device_id so we need to use only vendor_id*/ if (read_device_id == -1 && read_vendor_id != -1) { - capabilities = wdc_get_enc_drive_capabilities(r, fd); + capabilities = wdc_get_enc_drive_capabilities(r, dev); return capabilities; } @@ -1484,11 +1483,13 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, int fd) { WDC_DRIVE_CAP_PURGE); /* verify the 0xCA log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE) == true) + if (wdc_nvme_check_supported_log_page(r, dev, + WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE)) capabilities |= WDC_DRIVE_CAP_CA_LOG_PAGE; /* verify the 0xC1 log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_ADD_LOG_OPCODE) == true) + if (wdc_nvme_check_supported_log_page(r, dev, + WDC_NVME_ADD_LOG_OPCODE)) capabilities |= WDC_DRIVE_CAP_C1_LOG_PAGE; break; default: @@ -1504,11 +1505,14 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, int fd) { WDC_DRIVE_CAP_DRIVE_STATUS | WDC_DRIVE_CAP_CLEAR_ASSERT | WDC_DRIVE_CAP_RESIZE | WDC_DRIVE_CAP_CLEAR_PCIE); /* verify the 0xCA log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE) == true) + if (wdc_nvme_check_supported_log_page(r, dev, + WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE)) capabilities |= WDC_DRIVE_CAP_CA_LOG_PAGE; /* verify the 0xD0 log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_VU_SMART_LOG_OPCODE) == true) + if (wdc_nvme_check_supported_log_page(r, dev, + WDC_NVME_GET_VU_SMART_LOG_OPCODE) + == true) capabilities |= WDC_DRIVE_CAP_D0_LOG_PAGE; break; case WDC_NVME_SN640_DEV_ID: @@ -1524,8 +1528,12 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, int fd) { case WDC_NVME_SN560_DEV_ID_2: /* FALLTHRU */ case WDC_NVME_SN560_DEV_ID_3: + /* FALLTHRU */ + case WDC_NVME_SN660_DEV_ID: /* verify the 0xC0 log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_EOL_STATUS_LOG_OPCODE) == true) { + if (wdc_nvme_check_supported_log_page(r, dev, + WDC_NVME_GET_SMART_CLOUD_ATTR_LOG_ID) + == true) { capabilities |= WDC_DRIVE_CAP_C0_LOG_PAGE; } @@ -1536,30 +1544,36 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, int fd) { WDC_DRIVE_CAP_LOG_PAGE_DIR); /* verify the 0xC1 (OCP Error Recovery) log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_ERROR_REC_LOG_ID) == true) + if (wdc_nvme_check_supported_log_page(r, dev, + WDC_ERROR_REC_LOG_ID)) capabilities |= WDC_DRIVE_CAP_OCP_C1_LOG_PAGE; /* verify the 0xC3 (OCP Latency Monitor) log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_LATENCY_MON_OPCODE) == true) + if (wdc_nvme_check_supported_log_page(r, dev, + WDC_LATENCY_MON_LOG_ID)) capabilities |= WDC_DRIVE_CAP_C3_LOG_PAGE; /* verify the 0xC4 (OCP Device Capabilities) log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_DEV_CAP_LOG_ID) == true) + if (wdc_nvme_check_supported_log_page(r, dev, + WDC_DEV_CAP_LOG_ID)) capabilities |= WDC_DRIVE_CAP_OCP_C4_LOG_PAGE; /* verify the 0xC5 (OCP Unsupported Requirments) log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_UNSUPPORTED_REQS_LOG_ID) == true) + if (wdc_nvme_check_supported_log_page(r, dev, + WDC_UNSUPPORTED_REQS_LOG_ID)) capabilities |= WDC_DRIVE_CAP_OCP_C5_LOG_PAGE; /* verify the 0xCA log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE) == true) + if (wdc_nvme_check_supported_log_page(r, dev, + WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE)) capabilities |= WDC_DRIVE_CAP_CA_LOG_PAGE; /* verify the 0xD0 log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_VU_SMART_LOG_OPCODE) == true) + if (wdc_nvme_check_supported_log_page(r, dev, + WDC_NVME_GET_VU_SMART_LOG_OPCODE)) capabilities |= WDC_DRIVE_CAP_D0_LOG_PAGE; - cust_id = wdc_get_fw_cust_id(r, fd); + cust_id = wdc_get_fw_cust_id(r, dev); if (cust_id == WDC_INVALID_CUSTOMER_ID) { fprintf(stderr, "%s: ERROR : WDC : invalid customer id\n", __func__); return -1; @@ -1579,9 +1593,9 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, int fd) { /* FALLTHRU */ case WDC_NVME_SN860_DEV_ID: /* verify the 0xC0 log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_EOL_STATUS_LOG_OPCODE) == true) { + if (wdc_nvme_check_supported_log_page(r, dev, + WDC_NVME_GET_EOL_STATUS_LOG_OPCODE)) capabilities |= WDC_DRIVE_CAP_C0_LOG_PAGE; - } /* FALLTHRU */ case WDC_NVME_ZN540_DEV_ID: /* FALLTHRU */ @@ -1595,11 +1609,13 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, int fd) { WDC_DRIVE_CAP_LOG_PAGE_DIR ); /* verify the 0xCA log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE) == true) + if (wdc_nvme_check_supported_log_page(r, dev, + WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE)) capabilities |= WDC_DRIVE_CAP_CA_LOG_PAGE; /* verify the 0xD0 log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_VU_SMART_LOG_OPCODE) == true) + if (wdc_nvme_check_supported_log_page(r, dev, + WDC_NVME_GET_VU_SMART_LOG_OPCODE)) capabilities |= WDC_DRIVE_CAP_D0_LOG_PAGE; break; case WDC_NVME_SN650_DEV_ID: @@ -1610,23 +1626,45 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, int fd) { case WDC_NVME_SN655_DEV_ID: case WDC_NVME_SN550_DEV_ID: /* verify the 0xC0 log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_EOL_STATUS_LOG_OPCODE) == true) { + if (wdc_nvme_check_supported_log_page(r, dev, + WDC_NVME_GET_SMART_CLOUD_ATTR_LOG_ID)) capabilities |= WDC_DRIVE_CAP_C0_LOG_PAGE; - } + + /* verify the 0xC1 (OCP Error Recovery) log page is supported */ + if (wdc_nvme_check_supported_log_page(r, dev, WDC_ERROR_REC_LOG_ID)) + capabilities |= WDC_DRIVE_CAP_OCP_C1_LOG_PAGE; + + /* verify the 0xC3 (OCP Latency Monitor) log page is supported */ + if (wdc_nvme_check_supported_log_page(r, dev, WDC_LATENCY_MON_LOG_ID)) + capabilities |= WDC_DRIVE_CAP_C3_LOG_PAGE; + + /* verify the 0xC4 (OCP Device Capabilities) log page is supported */ + if (wdc_nvme_check_supported_log_page(r, dev, WDC_DEV_CAP_LOG_ID)) + capabilities |= WDC_DRIVE_CAP_OCP_C4_LOG_PAGE; + + /* verify the 0xC5 (OCP Unsupported Requirments) log page is supported */ + if (wdc_nvme_check_supported_log_page(r, dev, WDC_UNSUPPORTED_REQS_LOG_ID)) + capabilities |= WDC_DRIVE_CAP_OCP_C5_LOG_PAGE; capabilities |= (WDC_DRIVE_CAP_CAP_DIAG | WDC_DRIVE_CAP_INTERNAL_LOG | WDC_DRIVE_CAP_DRIVE_STATUS | WDC_DRIVE_CAP_CLEAR_ASSERT | - WDC_DRIVE_CAP_RESIZE | WDC_DRIVE_CAP_CLEAR_PCIE | - WDC_DRIVE_CAP_FW_ACTIVATE_HISTORY | WDC_DRIVE_CAP_CLEAR_FW_ACT_HISTORY | + WDC_DRIVE_CAP_RESIZE | WDC_DRIVE_CAP_FW_ACTIVATE_HISTORY | WDC_DRVIE_CAP_DISABLE_CTLR_TELE_LOG | WDC_DRIVE_CAP_REASON_ID | - WDC_DRIVE_CAP_LOG_PAGE_DIR | WDC_DRIVE_CAP_INFO | - WDC_DRIVE_CAP_CLOUD_SSD_VERSION); + WDC_DRIVE_CAP_LOG_PAGE_DIR); + + cust_id = wdc_get_fw_cust_id(r, dev); + if (cust_id == WDC_INVALID_CUSTOMER_ID) { + fprintf(stderr, "%s: ERROR : WDC : invalid customer id\n", __func__); + return -1; + } + + if ((cust_id == WDC_CUSTOMER_ID_0x1004) || (cust_id == WDC_CUSTOMER_ID_0x1008) || + (cust_id == WDC_CUSTOMER_ID_0x1005) || (cust_id == WDC_CUSTOMER_ID_0x1304)) + capabilities |= (WDC_DRIVE_CAP_VU_FID_CLEAR_FW_ACT_HISTORY | WDC_DRIVE_CAP_VU_FID_CLEAR_PCIE | + WDC_DRIVE_CAP_INFO | WDC_DRIVE_CAP_CLOUD_SSD_VERSION); + else + capabilities |= (WDC_DRIVE_CAP_CLEAR_FW_ACT_HISTORY | WDC_DRIVE_CAP_CLEAR_PCIE); - break; - case WDC_NVME_SN730B_DEV_ID: - /* FALLTHRU */ - case WDC_NVME_SN730B_DEV_ID_1: - capabilities = WDC_SN730B_CAP_VUC_LOG; break; default: capabilities = 0; @@ -1685,13 +1723,15 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, int fd) { return capabilities; } -static __u64 wdc_get_enc_drive_capabilities(nvme_root_t r, int fd) { +static __u64 wdc_get_enc_drive_capabilities(nvme_root_t r, + struct nvme_dev *dev) +{ int ret; uint32_t read_vendor_id; __u64 capabilities = 0; __u32 cust_id; - ret = wdc_get_vendor_id(fd, &read_vendor_id); + ret = wdc_get_vendor_id(dev, &read_vendor_id); if (ret < 0) return capabilities; @@ -1701,11 +1741,11 @@ static __u64 wdc_get_enc_drive_capabilities(nvme_root_t r, int fd) { WDC_DRIVE_CAP_DRIVE_LOG | WDC_DRIVE_CAP_CRASH_DUMP | WDC_DRIVE_CAP_PFAIL_DUMP); /* verify the 0xCA log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE) == true) + if (wdc_nvme_check_supported_log_page(r, dev, WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE) == true) capabilities |= WDC_DRIVE_CAP_CA_LOG_PAGE; /* verify the 0xC1 log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_ADD_LOG_OPCODE) == true) + if (wdc_nvme_check_supported_log_page(r, dev, WDC_NVME_ADD_LOG_OPCODE) == true) capabilities |= WDC_DRIVE_CAP_C1_LOG_PAGE; break; case WDC_NVME_VID_2: @@ -1714,22 +1754,22 @@ static __u64 wdc_get_enc_drive_capabilities(nvme_root_t r, int fd) { WDC_DRIVE_CAP_RESIZE); /* verify the 0xC3 log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_LATENCY_MON_OPCODE) == true) + if (wdc_nvme_check_supported_log_page(r, dev, WDC_LATENCY_MON_LOG_ID) == true) capabilities |= WDC_DRIVE_CAP_C3_LOG_PAGE; /* verify the 0xCB log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_FW_ACT_HISTORY_LOG_ID) == true) + if (wdc_nvme_check_supported_log_page(r, dev, WDC_NVME_GET_FW_ACT_HISTORY_LOG_ID) == true) capabilities |= WDC_DRIVE_CAP_FW_ACTIVATE_HISTORY; /* verify the 0xCA log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE) == true) + if (wdc_nvme_check_supported_log_page(r, dev, WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE) == true) capabilities |= WDC_DRIVE_CAP_CA_LOG_PAGE; /* verify the 0xD0 log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_VU_SMART_LOG_OPCODE) == true) + if (wdc_nvme_check_supported_log_page(r, dev, WDC_NVME_GET_VU_SMART_LOG_OPCODE) == true) capabilities |= WDC_DRIVE_CAP_D0_LOG_PAGE; - cust_id = wdc_get_fw_cust_id(r, fd); + cust_id = wdc_get_fw_cust_id(r, dev); if (cust_id == WDC_INVALID_CUSTOMER_ID) { fprintf(stderr, "%s: ERROR : WDC : invalid customer id\n", __func__); return -1; @@ -1752,7 +1792,8 @@ static __u64 wdc_get_enc_drive_capabilities(nvme_root_t r, int fd) { return capabilities; } -static int wdc_get_serial_name(int fd, char *file, size_t len, const char *suffix) +static int wdc_get_serial_name(struct nvme_dev *dev, char *file, size_t len, + const char *suffix) { int i; int ret; @@ -1765,7 +1806,7 @@ static int wdc_get_serial_name(int fd, char *file, size_t len, const char *suffi strncpy(orig, file, PATH_MAX - 1); memset(file, 0, len); memset(&ctrl, 0, sizeof (struct nvme_id_ctrl)); - ret = nvme_identify_ctrl(fd, &ctrl); + ret = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (ret) { fprintf(stderr, "ERROR : WDC : nvme_identify_ctrl() failed " "0x%x\n", ret); @@ -1927,7 +1968,8 @@ bool wdc_get_dev_mng_log_entry(__u32 log_length, return valid_log; } -static bool get_dev_mgment_cbs_data(nvme_root_t r, int fd, __u8 log_id, void **cbs_data) +static bool get_dev_mgment_cbs_data(nvme_root_t r, struct nvme_dev *dev, + __u8 log_id, void **cbs_data) { int ret = -1; void* data; @@ -1940,7 +1982,7 @@ static bool get_dev_mgment_cbs_data(nvme_root_t r, int fd, __u8 log_id, void **c *cbs_data = NULL; __u32 device_id, read_vendor_id; - ret = wdc_get_pci_ids(r, &device_id, &read_vendor_id); + ret = wdc_get_pci_ids(r, dev, &device_id, &read_vendor_id); if(device_id == WDC_NVME_ZN350_DEV_ID || device_id == WDC_NVME_ZN350_DEV_ID_1) { lid = WDC_NVME_GET_DEV_MGMNT_LOG_PAGE_OPCODE_C8; uuid_ix = 0; @@ -1956,7 +1998,7 @@ static bool get_dev_mgment_cbs_data(nvme_root_t r, int fd, __u8 log_id, void **c /* get the log page length */ struct nvme_get_log_args args_len = { .args_size = sizeof(args_len), - .fd = fd, + .fd = dev_fd(dev), .lid = lid, .nsid = 0xFFFFFFFF, .lpo = 0, @@ -1993,7 +2035,7 @@ static bool get_dev_mgment_cbs_data(nvme_root_t r, int fd, __u8 log_id, void **c /* get the log page data */ struct nvme_get_log_args args_data = { .args_size = sizeof(args_data), - .fd = fd, + .fd = dev_fd(dev), .lid = lid, .nsid = 0xFFFFFFFF, .lpo = 0, @@ -2034,7 +2076,7 @@ static bool get_dev_mgment_cbs_data(nvme_root_t r, int fd, __u8 log_id, void **c /* get the log page data */ struct nvme_get_log_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .lid = lid, .nsid = 0xFFFFFFFF, .lpo = 0, @@ -2072,13 +2114,15 @@ end: return found; } -static bool wdc_nvme_check_supported_log_page(nvme_root_t r, int fd, __u8 log_id) +static bool wdc_nvme_check_supported_log_page(nvme_root_t r, + struct nvme_dev *dev, + __u8 log_id) { int i; bool found = false; struct wdc_c2_cbs_data *cbs_data = NULL; - if (get_dev_mgment_cbs_data(r, fd, WDC_C2_LOG_PAGES_SUPPORTED_ID, (void *)&cbs_data)) { + if (get_dev_mgment_cbs_data(r, dev, WDC_C2_LOG_PAGES_SUPPORTED_ID, (void *)&cbs_data)) { if (cbs_data != NULL) { for (i = 0; i < le32_to_cpu(cbs_data->length); i++) { if (log_id == cbs_data->data[i]) { @@ -2104,12 +2148,14 @@ static bool wdc_nvme_check_supported_log_page(nvme_root_t r, int fd, __u8 log_id return found; } -static bool wdc_nvme_get_dev_status_log_data(nvme_root_t r, int fd, __le32 *ret_data, +static bool wdc_nvme_get_dev_status_log_data(nvme_root_t r, + struct nvme_dev *dev, + __le32 *ret_data, __u8 log_id) { __u32 *cbs_data = NULL; - if (get_dev_mgment_cbs_data(r, fd, log_id, (void *)&cbs_data)) { + if (get_dev_mgment_cbs_data(r, dev, log_id, (void *)&cbs_data)) { if (cbs_data != NULL) { memcpy((void *)ret_data, (void *)cbs_data, 4); free(cbs_data); @@ -2122,7 +2168,7 @@ static bool wdc_nvme_get_dev_status_log_data(nvme_root_t r, int fd, __le32 *ret_ return false; } -static int wdc_do_clear_dump(int fd, __u8 opcode, __u32 cdw12) +static int wdc_do_clear_dump(struct nvme_dev *dev, __u8 opcode, __u32 cdw12) { int ret; struct nvme_passthru_cmd admin_cmd; @@ -2130,7 +2176,7 @@ static int wdc_do_clear_dump(int fd, __u8 opcode, __u32 cdw12) memset(&admin_cmd, 0, sizeof (struct nvme_passthru_cmd)); admin_cmd.opcode = opcode; admin_cmd.cdw12 = cdw12; - ret = nvme_submit_admin_passthru(fd, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(dev_fd(dev), &admin_cmd, NULL); if (ret != 0) { fprintf(stdout, "ERROR : WDC : Crash dump erase failed\n"); } @@ -2248,7 +2294,7 @@ static __u32 wdc_dump_dui_data_v2(int fd, __u32 dataLen, __u64 offset, __u8 *dum return ret; } -static int wdc_do_dump(int fd, __u32 opcode,__u32 data_len, +static int wdc_do_dump(struct nvme_dev *dev, __u32 opcode,__u32 data_len, __u32 cdw12, char *file, __u32 xfer_size) { int ret = 0; @@ -2277,7 +2323,8 @@ static int wdc_do_dump(int fd, __u32 opcode,__u32 data_len, admin_cmd.cdw13 = curr_data_offset; while (curr_data_offset < data_len) { - ret = nvme_submit_admin_passthru(fd, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(dev_fd(dev), &admin_cmd, + NULL); if (ret != 0) { nvme_show_status(ret); fprintf(stderr, "%s: ERROR : WDC : Get chunk %d, size = 0x%x, offset = 0x%x, addr = 0x%lx\n", @@ -2370,7 +2417,8 @@ static int wdc_do_dump_e6(int fd, __u32 opcode,__u32 data_len, return ret; } -static int wdc_do_cap_telemetry_log(int fd, char *file, __u32 bs, int type, int data_area) +static int wdc_do_cap_telemetry_log(struct nvme_dev *dev, char *file, + __u32 bs, int type, int data_area) { struct nvme_telemetry_log *log; size_t full_size = 0; @@ -2386,7 +2434,7 @@ static int wdc_do_cap_telemetry_log(int fd, char *file, __u32 bs, int type, int nvme_root_t r; memset(&ctrl, 0, sizeof (struct nvme_id_ctrl)); - err = nvme_identify_ctrl(fd, &ctrl); + err = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (err) { fprintf(stderr, "ERROR : WDC : nvme_identify_ctrl() failed " "0x%x\n", err); @@ -2399,7 +2447,7 @@ static int wdc_do_cap_telemetry_log(int fd, char *file, __u32 bs, int type, int } r = nvme_scan(NULL); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if (type == WDC_TELEMETRY_TYPE_HOST) { host_gen = 1; @@ -2407,8 +2455,9 @@ static int wdc_do_cap_telemetry_log(int fd, char *file, __u32 bs, int type, int } else if (type == WDC_TELEMETRY_TYPE_CONTROLLER) { if ((capabilities & WDC_DRIVE_CAP_INTERNAL_LOG) == WDC_DRIVE_CAP_INTERNAL_LOG) { /* Verify the Controller Initiated Option is enabled */ - err = nvme_get_features_data(fd, WDC_VU_DISABLE_CNTLR_TELEMETRY_OPTION_FEATURE_ID, 0, - 4, buf, &result); + err = nvme_get_features_data(dev_fd(dev), + WDC_VU_DISABLE_CNTLR_TELEMETRY_OPTION_FEATURE_ID, + 0, 4, buf, &result); if (err == 0) { if (result == 0) { /* enabled */ @@ -2448,11 +2497,14 @@ static int wdc_do_cap_telemetry_log(int fd, char *file, __u32 bs, int type, int } if (ctrl_init) - err = nvme_get_ctrl_telemetry(fd, true, &log, data_area, &full_size); + err = nvme_get_ctrl_telemetry(dev_fd(dev), true, &log, + data_area, &full_size); else if (host_gen) - err = nvme_get_new_host_telemetry(fd, &log, data_area, &full_size); + err = nvme_get_new_host_telemetry(dev_fd(dev), &log, + data_area, &full_size); else - err = nvme_get_host_telemetry(fd, &log, data_area, &full_size); + err = nvme_get_host_telemetry(dev_fd(dev), &log, data_area, + &full_size); if (err < 0) { perror("get-telemetry-log"); @@ -2499,7 +2551,7 @@ close_output: return err; } -static int wdc_do_cap_diag(nvme_root_t r, int fd, char *file, +static int wdc_do_cap_diag(nvme_root_t r, struct nvme_dev *dev, char *file, __u32 xfer_size, int type, int data_area) { int ret = -1; @@ -2516,7 +2568,8 @@ static int wdc_do_cap_diag(nvme_root_t r, int fd, char *file, memset(log_hdr, 0, e6_log_hdr_size); if (type == WDC_TELEMETRY_TYPE_NONE) { - ret = wdc_dump_length_e6(fd, WDC_NVME_CAP_DIAG_OPCODE, + ret = wdc_dump_length_e6(dev_fd(dev), + WDC_NVME_CAP_DIAG_OPCODE, WDC_NVME_CAP_DIAG_HEADER_TOC_SIZE>>2, 0x00, log_hdr); @@ -2531,7 +2584,9 @@ static int wdc_do_cap_diag(nvme_root_t r, int fd, char *file, if (cap_diag_length == 0) { fprintf(stderr, "INFO : WDC : Capture Diagnostics log is empty\n"); } else { - ret = wdc_do_dump_e6(fd, WDC_NVME_CAP_DIAG_OPCODE, cap_diag_length, + ret = wdc_do_dump_e6(dev_fd(dev), + WDC_NVME_CAP_DIAG_OPCODE, + cap_diag_length, (WDC_NVME_CAP_DIAG_SUBCMD << WDC_NVME_SUBCMD_SHIFT) | WDC_NVME_CAP_DIAG_CMD, file, xfer_size, (__u8 *)log_hdr); @@ -2540,7 +2595,7 @@ static int wdc_do_cap_diag(nvme_root_t r, int fd, char *file, } else if ((type == WDC_TELEMETRY_TYPE_HOST) || (type == WDC_TELEMETRY_TYPE_CONTROLLER)) { /* Get the desired telemetry log page */ - ret = wdc_do_cap_telemetry_log(fd, file, xfer_size, type, data_area); + ret = wdc_do_cap_telemetry_log(dev, file, xfer_size, type, data_area); } else fprintf(stderr, "%s: ERROR : Invalid type : %d\n", __func__, type); @@ -2932,10 +2987,11 @@ static int wdc_cap_diag(int argc, char **argv, struct command *command, char *desc = "Capture Diagnostics Log."; char *file = "Output file pathname."; char *size = "Data retrieval transfer size."; + __u64 capabilities = 0; char f[PATH_MAX] = {0}; + struct nvme_dev *dev; __u32 xfer_size = 0; - int fd, ret = 0; - __u64 capabilities = 0; + int ret = 0; struct config { char *file; @@ -2953,9 +3009,9 @@ static int wdc_cap_diag(int argc, char **argv, struct command *command, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); @@ -2963,7 +3019,7 @@ static int wdc_cap_diag(int argc, char **argv, struct command *command, strncpy(f, cfg.file, PATH_MAX - 1); if (cfg.xfer_size != 0) xfer_size = cfg.xfer_size; - ret = wdc_get_serial_name(fd, f, PATH_MAX, "cap_diag"); + ret = wdc_get_serial_name(dev, f, PATH_MAX, "cap_diag"); if (ret) { fprintf(stderr, "ERROR : WDC: failed to generate file name\n"); goto out; @@ -2977,15 +3033,15 @@ static int wdc_cap_diag(int argc, char **argv, struct command *command, strcat(f, ".bin"); } - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_CAP_DIAG) == WDC_DRIVE_CAP_CAP_DIAG) - ret = wdc_do_cap_diag(r, fd, f, xfer_size, 0, 0); + ret = wdc_do_cap_diag(r, dev, f, xfer_size, 0, 0); else fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -3232,13 +3288,14 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *command char *verbose = "Display more debug messages."; char f[PATH_MAX] = {0}; char fileSuffix[PATH_MAX] = {0}; + struct nvme_dev *dev; nvme_root_t r; __u32 xfer_size = 0; - int fd, ret = -1; int telemetry_type = 0, telemetry_data_area = 0; UtilsTimeInfo timeInfo; __u8 timeStamp[MAX_PATH_LEN]; __u64 capabilities = 0; + int ret = -1; struct config { char *file; @@ -3271,12 +3328,12 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *command OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - if (!wdc_check_device(r, fd)) + if (!wdc_check_device(r, dev)) goto out; if (cfg.xfer_size != 0) @@ -3305,7 +3362,7 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *command timeInfo.hour, timeInfo.minute, timeInfo.second); snprintf(fileSuffix, PATH_MAX, "_internal_fw_log_%s", (char*)timeStamp); - ret = wdc_get_serial_name(fd, f, PATH_MAX, fileSuffix); + ret = wdc_get_serial_name(dev, f, PATH_MAX, fileSuffix); if (ret) { fprintf(stderr, "ERROR : WDC: failed to generate file name\n"); goto out; @@ -3349,12 +3406,12 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *command goto out; } - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_INTERNAL_LOG) == WDC_DRIVE_CAP_INTERNAL_LOG) { if (telemetry_data_area == 0) telemetry_data_area = 3; /* Set the default DA to 3 if not specified */ - ret = wdc_do_cap_diag(r, fd, f, xfer_size, + ret = wdc_do_cap_diag(r, dev, f, xfer_size, telemetry_type, telemetry_data_area); goto out; } @@ -3364,7 +3421,7 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *command if (telemetry_data_area == 0) telemetry_data_area = 3; /* Set the default DA to 3 if not specified */ /* Get the desired telemetry log page */ - ret = wdc_do_cap_telemetry_log(fd, f, xfer_size, + ret = wdc_do_cap_telemetry_log(dev, f, xfer_size, telemetry_type, telemetry_data_area); goto out; } else { @@ -3374,7 +3431,8 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *command /* FW requirement - xfer size must be 256k for data area 4 */ if (cfg.data_area >= 4) xfer_size = 0x40000; - ret = wdc_do_cap_dui(fd, f, xfer_size, cfg.data_area, + ret = wdc_do_cap_dui(dev_fd(dev), f, xfer_size, + cfg.data_area, cfg.verbose, cfg.file_size, cfg.offset); goto out; @@ -3386,29 +3444,29 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *command if (telemetry_data_area == 0) telemetry_data_area = 3; /* Set the default DA to 3 if not specified */ /* Get the desired telemetry log page */ - ret = wdc_do_cap_telemetry_log(fd, f, xfer_size, + ret = wdc_do_cap_telemetry_log(dev, f, xfer_size, telemetry_type, telemetry_data_area); goto out; } else { - ret = wdc_do_cap_dui(fd, f, xfer_size, + ret = wdc_do_cap_dui(dev_fd(dev), f, xfer_size, WDC_NVME_DUI_MAX_DATA_AREA, cfg.verbose, 0, 0); goto out; } } if ((capabilities & WDC_SN730B_CAP_VUC_LOG) == WDC_SN730B_CAP_VUC_LOG) - ret = wdc_do_sn730_get_and_tar(fd, f); + ret = wdc_do_sn730_get_and_tar(dev_fd(dev), f); else { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); ret = -1; } out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } -static int wdc_do_crash_dump(int fd, char *file, int type) +static int wdc_do_crash_dump(struct nvme_dev *dev, char *file, int type) { int ret; __u32 crash_dump_length; @@ -3445,11 +3503,11 @@ static int wdc_do_crash_dump(int fd, char *file, int type) WDC_NVME_CLEAR_CRASH_DUMP_CMD); } - ret = wdc_dump_length(fd, - opcode, - cdw10_size, - cdw12_size, - &crash_dump_length); + ret = wdc_dump_length(dev_fd(dev), + opcode, + cdw10_size, + cdw12_size, + &crash_dump_length); if (ret == -1) { if (type == WDC_NVME_PFAIL_DUMP_TYPE) @@ -3466,7 +3524,7 @@ static int wdc_do_crash_dump(int fd, char *file, int type) else fprintf(stderr, "INFO : WDC: Crash dump is empty\n"); } else { - ret = wdc_do_dump(fd, + ret = wdc_do_dump(dev, opcode, crash_dump_length, cdw12, @@ -3474,12 +3532,13 @@ static int wdc_do_crash_dump(int fd, char *file, int type) crash_dump_length); if (ret == 0) - ret = wdc_do_clear_dump(fd, WDC_NVME_CLEAR_DUMP_OPCODE, cdw12_clear); + ret = wdc_do_clear_dump(dev, WDC_NVME_CLEAR_DUMP_OPCODE, + cdw12_clear); } return ret; } -static int wdc_crash_dump(int fd, char *file, int type) +static int wdc_crash_dump(struct nvme_dev *dev, char *file, int type) { char f[PATH_MAX] = {0}; const char *dump_type; @@ -3494,26 +3553,26 @@ static int wdc_crash_dump(int fd, char *file, int type) else dump_type = "_crash_dump"; - ret = wdc_get_serial_name(fd, f, PATH_MAX, dump_type); + ret = wdc_get_serial_name(dev, f, PATH_MAX, dump_type); if (ret) fprintf(stderr, "ERROR : WDC : failed to generate file name\n"); else - ret = wdc_do_crash_dump(fd, f, type); + ret = wdc_do_crash_dump(dev, f, type); return ret; } -static int wdc_do_drive_log(int fd, char *file) +static int wdc_do_drive_log(struct nvme_dev *dev, char *file) { int ret; __u8 *drive_log_data; __u32 drive_log_length; struct nvme_passthru_cmd admin_cmd; - ret = wdc_dump_length(fd, WDC_NVME_DRIVE_LOG_SIZE_OPCODE, - WDC_NVME_DRIVE_LOG_SIZE_NDT, - (WDC_NVME_DRIVE_LOG_SIZE_SUBCMD << - WDC_NVME_SUBCMD_SHIFT | WDC_NVME_DRIVE_LOG_SIZE_CMD), - &drive_log_length); + ret = wdc_dump_length(dev_fd(dev), WDC_NVME_DRIVE_LOG_SIZE_OPCODE, + WDC_NVME_DRIVE_LOG_SIZE_NDT, + (WDC_NVME_DRIVE_LOG_SIZE_SUBCMD << + WDC_NVME_SUBCMD_SHIFT | WDC_NVME_DRIVE_LOG_SIZE_CMD), + &drive_log_length); if (ret == -1) { return -1; } @@ -3533,7 +3592,7 @@ static int wdc_do_drive_log(int fd, char *file) admin_cmd.cdw12 = ((WDC_NVME_DRIVE_LOG_SUBCMD << WDC_NVME_SUBCMD_SHIFT) | WDC_NVME_DRIVE_LOG_SIZE_CMD); - ret = nvme_submit_admin_passthru(fd, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(dev_fd(dev), &admin_cmd, NULL); nvme_show_status(ret); if (ret == 0) { ret = wdc_create_log_file(file, drive_log_data, drive_log_length); @@ -3548,7 +3607,7 @@ static int wdc_drive_log(int argc, char **argv, struct command *command, const char *desc = "Capture Drive Log."; const char *file = "Output file pathname."; char f[PATH_MAX] = {0}; - int fd; + struct nvme_dev *dev; int ret; nvme_root_t r; __u64 capabilities = 0; @@ -3565,18 +3624,18 @@ static int wdc_drive_log(int argc, char **argv, struct command *command, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - if (!wdc_check_device(r, fd)) { + if (!wdc_check_device(r, dev)) { nvme_free_tree(r); - close(fd); + dev_close(dev); return -1; } - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_DRIVE_LOG) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); @@ -3585,14 +3644,14 @@ static int wdc_drive_log(int argc, char **argv, struct command *command, if (cfg.file != NULL) { strncpy(f, cfg.file, PATH_MAX - 1); } - ret = wdc_get_serial_name(fd, f, PATH_MAX, "drive_log"); + ret = wdc_get_serial_name(dev, f, PATH_MAX, "drive_log"); if (ret) fprintf(stderr, "ERROR : WDC : failed to generate file name\n"); else - ret = wdc_do_drive_log(fd, f); + ret = wdc_do_drive_log(dev, f); } nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -3601,9 +3660,10 @@ static int wdc_get_crash_dump(int argc, char **argv, struct command *command, { const char *desc = "Get Crash Dump."; const char *file = "Output file pathname."; - int fd, ret; - nvme_root_t r; __u64 capabilities = 0; + struct nvme_dev *dev; + nvme_root_t r; + int ret; struct config { char *file; @@ -3618,32 +3678,32 @@ static int wdc_get_crash_dump(int argc, char **argv, struct command *command, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - if (!wdc_check_device(r, fd)) { + if (!wdc_check_device(r, dev)) { nvme_free_tree(r); - close(fd); + dev_close(dev); return -1; } - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_CRASH_DUMP) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); ret = -1; } else { - ret = wdc_crash_dump(fd, cfg.file, WDC_NVME_CRASH_DUMP_TYPE); + ret = wdc_crash_dump(dev, cfg.file, WDC_NVME_CRASH_DUMP_TYPE); if (ret != 0) { fprintf(stderr, "ERROR : WDC : failed to read crash dump\n"); } } nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -3652,13 +3712,13 @@ static int wdc_get_pfail_dump(int argc, char **argv, struct command *command, { char *desc = "Get Pfail Crash Dump."; char *file = "Output file pathname."; - int fd; - int ret; - nvme_root_t r; __u64 capabilities = 0; + struct nvme_dev *dev; struct config { char *file; }; + nvme_root_t r; + int ret; struct config cfg = { .file = NULL, @@ -3669,30 +3729,30 @@ static int wdc_get_pfail_dump(int argc, char **argv, struct command *command, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - if (!wdc_check_device(r, fd)) { + if (!wdc_check_device(r, dev)) { nvme_free_tree(r); - close(fd); + dev_close(dev); return -1; } - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_PFAIL_DUMP) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); ret = -1; } else { - ret = wdc_crash_dump(fd, cfg.file, WDC_NVME_PFAIL_DUMP_TYPE); + ret = wdc_crash_dump(dev, cfg.file, WDC_NVME_PFAIL_DUMP_TYPE); if (ret != 0) { fprintf(stderr, "ERROR : WDC : failed to read pfail crash dump\n"); } } nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -3748,29 +3808,30 @@ static int wdc_purge(int argc, char **argv, struct command *command, struct plugin *plugin) { const char *desc = "Send a Purge command."; - char *err_str; - int fd, ret; - nvme_root_t r; struct nvme_passthru_cmd admin_cmd; __u64 capabilities = 0; + struct nvme_dev *dev; + char *err_str; + nvme_root_t r; + int ret; OPT_ARGS(opts) = { OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - if (!wdc_check_device(r, fd)) { + if (!wdc_check_device(r, dev)) { nvme_free_tree(r); - close(fd); + dev_close(dev); return -1; } - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if((capabilities & WDC_DRIVE_CAP_PURGE) == 0) { ret = -1; fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); @@ -3779,7 +3840,8 @@ static int wdc_purge(int argc, char **argv, memset(&admin_cmd, 0, sizeof (admin_cmd)); admin_cmd.opcode = WDC_NVME_PURGE_CMD_OPCODE; - ret = nvme_submit_admin_passthru(fd, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(dev_fd(dev), &admin_cmd, + NULL); if (ret > 0) { switch (ret) { case WDC_NVME_PURGE_CMD_SEQ_ERR: @@ -3798,7 +3860,7 @@ static int wdc_purge(int argc, char **argv, nvme_show_status(ret); } nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -3806,30 +3868,31 @@ static int wdc_purge_monitor(int argc, char **argv, struct command *command, struct plugin *plugin) { const char *desc = "Send a Purge Monitor command."; - int fd, ret; - nvme_root_t r; __u8 output[WDC_NVME_PURGE_MONITOR_DATA_LEN]; double progress_percent; struct nvme_passthru_cmd admin_cmd; struct wdc_nvme_purge_monitor_data *mon; + struct nvme_dev *dev; __u64 capabilities; + nvme_root_t r; + int ret; OPT_ARGS(opts) = { OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - if (!wdc_check_device(r, fd)) { + if (!wdc_check_device(r, dev)) { nvme_free_tree(r); - close(fd); + dev_close(dev); return -1; } - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if((capabilities & WDC_DRIVE_CAP_PURGE) == 0) { ret = -1; fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); @@ -3842,7 +3905,8 @@ static int wdc_purge_monitor(int argc, char **argv, admin_cmd.cdw10 = WDC_NVME_PURGE_MONITOR_CMD_CDW10; admin_cmd.timeout_ms = WDC_NVME_PURGE_MONITOR_TIMEOUT; - ret = nvme_submit_admin_passthru(fd, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(dev_fd(dev), &admin_cmd, + NULL); if (ret == 0) { mon = (struct wdc_nvme_purge_monitor_data *) output; printf("Purge state = 0x%0x\n", admin_cmd.result); @@ -3858,7 +3922,7 @@ static int wdc_purge_monitor(int argc, char **argv, nvme_show_status(ret); } nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -4009,15 +4073,16 @@ static int wdc_convert_ts(time_t time, char *ts_buf) return 0; } -static int wdc_print_latency_monitor_log_normal(int fd, struct wdc_ssd_latency_monitor_log *log_data) +static int wdc_print_latency_monitor_log_normal(struct nvme_dev *dev, + struct wdc_ssd_latency_monitor_log *log_data) { printf("Latency Monitor/C3 Log Page Data \n"); - printf(" Controller : %s\n", devicename); + printf(" Controller : %s\n", dev->name); int err = -1, i, j; struct nvme_id_ctrl ctrl; char ts_buf[128]; - err = nvme_identify_ctrl(fd, &ctrl); + err = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (!err) printf(" Serial Number: %-.*s\n", (int)sizeof(ctrl.sn), ctrl.sn); else { @@ -4164,14 +4229,16 @@ static void wdc_print_error_rec_log_normal(struct wdc_ocp_c1_error_recovery_log printf(" Panic Reset Wait Time : 0x%x \n", le16_to_cpu(log_data->panic_reset_wait_time)); printf(" Panic Reset Action : 0x%x \n", log_data->panic_reset_action); printf(" Device Recovery Action 1 : 0x%x \n", log_data->dev_recovery_action1); - printf(" Panic ID : 0x%lx \n", le64_to_cpu(log_data->panic_id)); + printf(" Panic ID : 0x%" PRIu64 "\n", le64_to_cpu(log_data->panic_id)); printf(" Device Capabilities : 0x%x \n", le32_to_cpu(log_data->dev_capabilities)); printf(" Vendor Specific Recovery Opcode : 0x%x \n", log_data->vs_recovery_opc); printf(" Vendor Specific Command CDW12 : 0x%x \n", le32_to_cpu(log_data->vs_cmd_cdw12)); printf(" Vendor Specific Command CDW13 : 0x%x \n", le32_to_cpu(log_data->vs_cmd_cdw13)); - printf(" Vendor Specific Command Timeout : 0x%x \n", log_data->vs_cmd_to); - printf(" Device Recovery Action 2 : 0x%x \n", log_data->dev_recovery_action2); - printf(" Device Recovery Action 2 Timeout : 0x%x \n", log_data->dev_recovery_action2_to); + if (le16_to_cpu(log_data->log_page_version) == WDC_ERROR_REC_LOG_VERSION2) { + printf(" Vendor Specific Command Timeout : 0x%x \n", log_data->vs_cmd_to); + printf(" Device Recovery Action 2 : 0x%x \n", log_data->dev_recovery_action2); + printf(" Device Recovery Action 2 Timeout : 0x%x \n", log_data->dev_recovery_action2_to); + } printf(" Log Page Version : 0x%x \n", le16_to_cpu(log_data->log_page_version)); printf(" Log page GUID : 0x"); for (j = 0; j < WDC_OCP_C1_GUID_LENGTH; j++) { @@ -4193,9 +4260,11 @@ static void wdc_print_error_rec_log_json(struct wdc_ocp_c1_error_recovery_log *l json_object_add_value_int(root, "Vendor Specific Recovery Opcode", log_data->vs_recovery_opc); json_object_add_value_int(root, "Vendor Specific Command CDW12", le32_to_cpu(log_data->vs_cmd_cdw12)); json_object_add_value_int(root, "Vendor Specific Command CDW13", le32_to_cpu(log_data->vs_cmd_cdw13)); - json_object_add_value_int(root, "Vendor Specific Command Timeout", log_data->vs_cmd_to); - json_object_add_value_int(root, "Device Recovery Action 2", log_data->dev_recovery_action2); - json_object_add_value_int(root, "Device Recovery Action 2 Timeout", log_data->dev_recovery_action2_to); + if (le16_to_cpu(log_data->log_page_version) == WDC_ERROR_REC_LOG_VERSION2) { + json_object_add_value_int(root, "Vendor Specific Command Timeout", log_data->vs_cmd_to); + json_object_add_value_int(root, "Device Recovery Action 2", log_data->dev_recovery_action2); + json_object_add_value_int(root, "Device Recovery Action 2 Timeout", log_data->dev_recovery_action2_to); + } json_object_add_value_int(root, "Log Page Version", le16_to_cpu(log_data->log_page_version)); char guid[40]; @@ -4442,7 +4511,7 @@ static void wdc_print_fb_ca_log_json(struct wdc_ssd_ca_perf_stats *perf) json_free_object(root); } -static void wdc_print_bd_ca_log_normal(void *data) +static void wdc_print_bd_ca_log_normal(struct nvme_dev *dev, void *data) { struct wdc_bd_ca_log_format *bd_data = (struct wdc_bd_ca_log_format *)data; __u64 *raw; @@ -4453,7 +4522,7 @@ static void wdc_print_bd_ca_log_normal(void *data) if (bd_data->field_id == 0x00) { raw = (__u64*)&bd_data->raw_value[0]; printf("Additional Smart Log for NVME device:%s namespace-id:%x\n", - devicename, WDC_DE_GLOBAL_NSID); + dev->name, WDC_DE_GLOBAL_NSID); printf("key normalized raw\n"); printf("program_fail_count : %3"PRIu8"%% %"PRIu64"\n", bd_data->normalized_value, le64_to_cpu(*raw & 0x00FFFFFFFFFFFFFF)); @@ -5056,7 +5125,7 @@ static void wdc_print_fw_act_history_log_json(__u8 *data, int num_entries, __u32 root = json_create_object(); - if(data[0] == WDC_NVME_GET_FW_ACT_HISTORY_C2_LOG_ID) { + if (data[0] == WDC_NVME_GET_FW_ACT_HISTORY_C2_LOG_ID) { struct wdc_fw_act_history_log_format_c2 *fw_act_history_entry = (struct wdc_fw_act_history_log_format_c2 *)(data); oldestEntryIdx = WDC_MAX_NUM_ACT_HIST_ENTRIES; @@ -5100,7 +5169,7 @@ static void wdc_print_fw_act_history_log_json(__u8 *data, int num_entries, __u32 json_object_add_value_string(root, "Power on Hour", time_str); } else { uint64_t timestamp = (0x0000FFFFFFFFFFFF & le64_to_cpu(fw_act_history_entry->entry[entryIdx].timestamp)); - json_object_add_value_int(root, "Timestamp", timestamp); + json_object_add_value_uint64(root, "Timestamp", timestamp); } json_object_add_value_int(root, "Power Cycle Count", @@ -5122,6 +5191,9 @@ static void wdc_print_fw_act_history_log_json(__u8 *data, int num_entries, __u32 json_object_add_value_string(root, "Result", fail_str); } + json_print_object(root, NULL); + printf("\n"); + entryIdx++; if (entryIdx >= WDC_MAX_NUM_ACT_HIST_ENTRIES) entryIdx = 0; @@ -5179,15 +5251,15 @@ static void wdc_print_fw_act_history_log_json(__u8 *data, int num_entries, __u32 json_object_add_value_string(root, "Result", fail_str); } + json_print_object(root, NULL); + printf("\n"); + entryIdx++; if (entryIdx >= WDC_MAX_NUM_ACT_HIST_ENTRIES) entryIdx = 0; } } - json_print_object(root, NULL); - printf("\n"); - json_free_object(root); } @@ -5205,7 +5277,7 @@ static int nvme_get_ext_smart_cloud_log(int fd, __u8 **data, int uuid_index, __u struct nvme_get_log_args args = { .args_size = sizeof(args), .fd = fd, - .lid = WDC_NVME_GET_EOL_STATUS_LOG_OPCODE, + .lid = WDC_NVME_GET_SMART_CLOUD_ATTR_LOG_ID, .nsid = namespace_id, .lpo = 0, .lsp = NVME_LOG_LSP_NONE, @@ -5626,10 +5698,12 @@ static void wdc_print_ext_smart_cloud_log_normal(void *data, int mask) else printf(" SMART Cloud Attributes :- \n"); - printf(" Physical Media Units Written TLC (Bytes) : %'.0Lf\n", - int128_to_double(ext_smart_log_ptr->ext_smart_pmuwt)); - printf(" Physical Media Units Written SLC (Bytes) : %'.0Lf\n", - int128_to_double(ext_smart_log_ptr->ext_smart_pmuws)); + printf(" Physical Media Units Written TLC (Bytes) : %s\n", + uint128_t_to_string(le128_to_cpu( + ext_smart_log_ptr->ext_smart_pmuwt))); + printf(" Physical Media Units Written SLC (Bytes) : %s\n", + uint128_t_to_string(le128_to_cpu( + ext_smart_log_ptr->ext_smart_pmuws))); printf(" Bad User NAND Block Count (Normalized) (Int) : %d\n", le16_to_cpu(*(uint16_t *)ext_smart_log_ptr->ext_smart_bunbc)); printf(" Bad User NAND Block Count (Raw) (Int) : %"PRIu64"\n", @@ -5677,8 +5751,9 @@ static void wdc_print_ext_smart_cloud_log_normal(void *data, int mask) le64_to_cpu(ext_smart_log_ptr->ext_smart_svn)); printf(" %% Free Blocks (System) (Int) : %d %%\n", ext_smart_log_ptr->ext_smart_pfbs); - printf(" NVMe Stats (# Data Set Management/TRIM Commands Completed) (Int) : %'.0Lf\n", - int128_to_double(ext_smart_log_ptr->ext_smart_dcc)); + printf(" NVMe Stats (# Data Set Management/TRIM Commands Completed) (Int) : %s\n", + uint128_t_to_string(le128_to_cpu( + ext_smart_log_ptr->ext_smart_dcc))); printf(" Total Namespace Utilization (nvme0n1 NUSE) (Bytes) : %"PRIu64"\n", le64_to_cpu(ext_smart_log_ptr->ext_smart_tnu)); printf(" NVMe Stats (# NVMe Format Commands Completed) (Int) : %d\n", @@ -5696,16 +5771,18 @@ static void wdc_print_ext_smart_cloud_log_normal(void *data, int mask) le16_to_cpu(*(uint16_t *)ext_smart_log_ptr->ext_smart_bsnbc)); printf(" Bad System NAND Block Count (Raw) (Int) : %"PRIu64"\n", le64_to_cpu(*(uint64_t *)ext_smart_log_ptr->ext_smart_bsnbc & 0xFFFFFFFFFFFF0000)); - printf(" Endurance Estimate (Total Writable Lifetime Bytes) (Bytes) : %'.0Lf\n", - int128_to_double(ext_smart_log_ptr->ext_smart_eest)); + printf(" Endurance Estimate (Total Writable Lifetime Bytes) (Bytes) : %s\n", + uint128_t_to_string( + le128_to_cpu(ext_smart_log_ptr->ext_smart_eest))); if (mask == WDC_SCA_V1_ALL) { printf(" Thermal Throttling Status & Count (Number of thermal throttling events) (Int) : %d\n", le16_to_cpu(ext_smart_log_ptr->ext_smart_ttc)); printf(" Total # Unaligned I/O (Int) : %"PRIu64"\n", le64_to_cpu(ext_smart_log_ptr->ext_smart_uio)); } - printf(" Total Physical Media Units Read (Bytes) (Int) : %'.0Lf\n", - int128_to_double(ext_smart_log_ptr->ext_smart_pmur)); + printf(" Total Physical Media Units Read (Bytes) (Int) : %s\n", + uint128_t_to_string( + le128_to_cpu(ext_smart_log_ptr->ext_smart_pmur))); if (mask == WDC_SCA_V1_ALL) { printf(" Command Timeout (# of READ Commands > 5 Seconds) (Int) : %"PRIu32"\n", le32_to_cpu(ext_smart_log_ptr->ext_smart_rtoc)); @@ -5746,10 +5823,10 @@ static void wdc_print_ext_smart_cloud_log_json(void *data, int mask) struct json_object *root; root = json_create_object(); - json_object_add_value_double(root, "physical_media_units_bytes_tlc", - int128_to_double(ext_smart_log_ptr->ext_smart_pmuwt)); - json_object_add_value_double(root, "physical_media_units_bytes_slc", - int128_to_double(ext_smart_log_ptr->ext_smart_pmuws)); + json_object_add_value_uint128(root, "physical_media_units_bytes_tlc", + le128_to_cpu(ext_smart_log_ptr->ext_smart_pmuwt)); + json_object_add_value_uint128(root, "physical_media_units_bytes_slc", + le128_to_cpu(ext_smart_log_ptr->ext_smart_pmuws)); json_object_add_value_uint(root, "bad_user_blocks_normalized", le16_to_cpu(*(uint16_t *)ext_smart_log_ptr->ext_smart_bunbc)); json_object_add_value_uint64(root, "bad_user_blocks_raw", @@ -5797,8 +5874,8 @@ static void wdc_print_ext_smart_cloud_log_json(void *data, int mask) le64_to_cpu(ext_smart_log_ptr->ext_smart_svn)); json_object_add_value_uint(root, "pct_free_blocks_system", (__u8)ext_smart_log_ptr->ext_smart_pfbs); - json_object_add_value_double(root, "num_of_trim_commands", - int128_to_double(ext_smart_log_ptr->ext_smart_dcc)); + json_object_add_value_uint128(root, "num_of_trim_commands", + le128_to_cpu(ext_smart_log_ptr->ext_smart_dcc)); json_object_add_value_uint64(root, "total_nuse_bytes", le64_to_cpu(ext_smart_log_ptr->ext_smart_tnu)); json_object_add_value_uint(root, "num_of_format_commands", @@ -5816,16 +5893,16 @@ static void wdc_print_ext_smart_cloud_log_json(void *data, int mask) le16_to_cpu(*(uint16_t *)ext_smart_log_ptr->ext_smart_bsnbc)); json_object_add_value_uint64(root, "bad_system_block_raw", le64_to_cpu(*(uint64_t *)ext_smart_log_ptr->ext_smart_bsnbc & 0xFFFFFFFFFFFF0000)); - json_object_add_value_double(root, "endurance_est_bytes", - int128_to_double(ext_smart_log_ptr->ext_smart_eest)); + json_object_add_value_uint128(root, "endurance_est_bytes", + le128_to_cpu(ext_smart_log_ptr->ext_smart_eest)); if (mask == WDC_SCA_V1_ALL) { json_object_add_value_uint(root, "num_throttling_events", le16_to_cpu(ext_smart_log_ptr->ext_smart_ttc)); json_object_add_value_uint64(root, "total_unaligned_io", le64_to_cpu(ext_smart_log_ptr->ext_smart_uio)); } - json_object_add_value_double(root, "physical_media_units_read_bytes", - int128_to_double(ext_smart_log_ptr->ext_smart_pmur)); + json_object_add_value_uint128(root, "physical_media_units_read_bytes", + le128_to_cpu(ext_smart_log_ptr->ext_smart_pmur)); if (mask == WDC_SCA_V1_ALL) { json_object_add_value_uint(root, "num_read_timeouts", le32_to_cpu(ext_smart_log_ptr->ext_smart_rtoc)); @@ -5874,8 +5951,10 @@ static void wdc_print_smart_cloud_attr_C0_normal(void *data) printf(" SMART Cloud Attributes :- \n"); - printf(" Physical media units written : %'.0Lf\n", int128_to_double(&log_data[SCAO_PMUW])); - printf(" Physical media units read : %'.0Lf\n", int128_to_double(&log_data[SCAO_PMUR])); + printf(" Physical media units written : %s\n", + uint128_t_to_string(le128_to_cpu(&log_data[SCAO_PMUW]))); + printf(" Physical media units read : %s\n", + uint128_t_to_string(le128_to_cpu(&log_data[SCAO_PMUR]))); printf(" Bad user nand blocks Raw : %"PRIu64"\n", (uint64_t)le64_to_cpu(*(uint64_t *)&log_data[SCAO_BUNBR] & 0x0000FFFFFFFFFFFF)); printf(" Bad user nand blocks Normalized : %d\n", @@ -5916,8 +5995,10 @@ static void wdc_print_smart_cloud_attr_C0_normal(void *data) (uint64_t)le64_to_cpu(*(uint64_t *)&log_data[SCAO_SVN])); printf(" NUSE Namespace utilization : %"PRIu64"\n", (uint64_t)le64_to_cpu(*(uint64_t *)&log_data[SCAO_NUSE])); - printf(" PLP start count : %'.0Lf\n", int128_to_double(&log_data[SCAO_PSC])); - printf(" Endurance estimate : %'.0Lf\n", int128_to_double(&log_data[SCAO_EEST])); + printf(" PLP start count : %s\n", + uint128_t_to_string(le128_to_cpu(&log_data[SCAO_PSC]))); + printf(" Endurance estimate : %s\n", + uint128_t_to_string(le128_to_cpu(&log_data[SCAO_EEST]))); smart_log_ver = (uint16_t)le16_to_cpu(*(uint16_t *)&log_data[SCAO_LPV]); printf(" Log page version : %"PRIu16"\n",smart_log_ver); printf(" Log page GUID : 0x"); @@ -5951,10 +6032,10 @@ static void wdc_print_smart_cloud_attr_C0_json(void *data) uint16_t smart_log_ver = 0; root = json_create_object(); - json_object_add_value_double(root, "Physical media units written", - int128_to_double(&log_data[SCAO_PMUW])); - json_object_add_value_double(root, "Physical media units read", - int128_to_double(&log_data[SCAO_PMUR])); + json_object_add_value_uint128(root, "Physical media units written", + le128_to_cpu(&log_data[SCAO_PMUW])); + json_object_add_value_uint128(root, "Physical media units read", + le128_to_cpu(&log_data[SCAO_PMUR])); json_object_add_value_uint64(root, "Bad user nand blocks - Raw", (uint64_t)le64_to_cpu(*(uint64_t *)&log_data[SCAO_BUNBR] & 0x0000FFFFFFFFFFFF)); json_object_add_value_uint(root, "Bad user nand blocks - Normalized", @@ -5999,10 +6080,10 @@ static void wdc_print_smart_cloud_attr_C0_json(void *data) (uint64_t)le64_to_cpu(*(uint64_t *)&log_data[SCAO_SVN])); json_object_add_value_uint64(root, "NUSE - Namespace utilization", (uint64_t)le64_to_cpu(*(uint64_t *)&log_data[SCAO_NUSE])); - json_object_add_value_double(root, "PLP start count", - int128_to_double(&log_data[SCAO_PSC])); - json_object_add_value_double(root, "Endurance estimate", - int128_to_double(&log_data[SCAO_EEST])); + json_object_add_value_uint128(root, "PLP start count", + le128_to_cpu(&log_data[SCAO_PSC])); + json_object_add_value_uint128(root, "Endurance estimate", + le128_to_cpu(&log_data[SCAO_EEST])); smart_log_ver = (uint16_t)le16_to_cpu(*(uint16_t *)&log_data[SCAO_LPV]); json_object_add_value_uint(root, "Log page version", smart_log_ver); char guid[40]; @@ -6135,7 +6216,7 @@ static int wdc_print_c0_eol_log(void *data, int fmt) return 0; } -static int wdc_get_c0_log_page(nvme_root_t r, int fd, char *format, +static int wdc_get_c0_log_page(nvme_root_t r, struct nvme_dev *dev, char *format, int uuid_index, __u32 namespace_id) { int ret = 0; @@ -6145,7 +6226,7 @@ static int wdc_get_c0_log_page(nvme_root_t r, int fd, char *format, __u32 cust_id; uint32_t device_id, read_vendor_id; - if (!wdc_check_device(r, fd)) + if (!wdc_check_device(r, dev)) return -1; fmt = validate_output_format(format); if (fmt < 0) { @@ -6153,7 +6234,7 @@ static int wdc_get_c0_log_page(nvme_root_t r, int fd, char *format, return fmt; } - ret = wdc_get_pci_ids(r, &device_id, &read_vendor_id); + ret = wdc_get_pci_ids(r, dev, &device_id, &read_vendor_id); switch (device_id) { @@ -6173,7 +6254,8 @@ static int wdc_get_c0_log_page(nvme_root_t r, int fd, char *format, case WDC_NVME_SN560_DEV_ID_1: case WDC_NVME_SN560_DEV_ID_2: case WDC_NVME_SN560_DEV_ID_3: - cust_id = wdc_get_fw_cust_id(r, fd); + case WDC_NVME_SN550_DEV_ID: + cust_id = wdc_get_fw_cust_id(r, dev); if (cust_id == WDC_INVALID_CUSTOMER_ID) { fprintf(stderr, "%s: ERROR : WDC : invalid customer id\n", __func__); return -1; @@ -6189,7 +6271,8 @@ static int wdc_get_c0_log_page(nvme_root_t r, int fd, char *format, } if (namespace_id == NVME_NSID_ALL) { - ret = nvme_get_nsid(fd, &namespace_id); + ret = nvme_get_nsid(dev_fd(dev), + &namespace_id); if (ret < 0) { namespace_id = NVME_NSID_ALL; } @@ -6198,8 +6281,8 @@ static int wdc_get_c0_log_page(nvme_root_t r, int fd, char *format, /* Get the 0xC0 log data */ struct nvme_get_log_args args = { .args_size = sizeof(args), - .fd = fd, - .lid = WDC_NVME_GET_EOL_STATUS_LOG_OPCODE, + .fd = dev_fd(dev), + .lid = WDC_NVME_GET_SMART_CLOUD_ATTR_LOG_ID, .nsid = namespace_id, .lpo = 0, .lsp = NVME_LOG_LSP_NONE, @@ -6261,7 +6344,7 @@ static int wdc_get_c0_log_page(nvme_root_t r, int fd, char *format, /* Get the 0xC0 log data */ struct nvme_get_log_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .lid = WDC_NVME_GET_EOL_STATUS_LOG_OPCODE, .nsid = NVME_NSID_ALL, .lpo = 0, @@ -6302,8 +6385,10 @@ static int wdc_get_c0_log_page(nvme_root_t r, int fd, char *format, } /* Get the 0xC0 log data */ - ret = nvme_get_log_simple(fd, WDC_NVME_GET_EOL_STATUS_LOG_OPCODE, - WDC_NVME_EOL_STATUS_LOG_LEN, data); + ret = nvme_get_log_simple(dev_fd(dev), + WDC_NVME_GET_EOL_STATUS_LOG_OPCODE, + WDC_NVME_EOL_STATUS_LOG_LEN, + data); if (strcmp(format, "json")) nvme_show_status(ret); @@ -6328,8 +6413,9 @@ static int wdc_get_c0_log_page(nvme_root_t r, int fd, char *format, } /* Get the 0xC0 log data */ - ret = nvme_get_log_simple(fd, WDC_NVME_GET_SMART_CLOUD_ATTR_LOG_OPCODE, - WDC_NVME_SMART_CLOUD_ATTR_LEN, data); + ret = nvme_get_log_simple(dev_fd(dev), + WDC_NVME_GET_SMART_CLOUD_ATTR_LOG_ID, + WDC_NVME_SMART_CLOUD_ATTR_LEN, data); if (strcmp(format, "json")) nvme_show_status(ret); @@ -6348,7 +6434,8 @@ static int wdc_get_c0_log_page(nvme_root_t r, int fd, char *format, case WDC_NVME_SN820CL_DEV_ID: /* Get the 0xC0 Extended Smart Cloud Attribute log data */ data = NULL; - ret = nvme_get_ext_smart_cloud_log(fd, &data, uuid_index, namespace_id); + ret = nvme_get_ext_smart_cloud_log(dev_fd(dev), &data, + uuid_index, namespace_id); if (strcmp(format, "json")) nvme_show_status(ret); @@ -6375,7 +6462,9 @@ static int wdc_get_c0_log_page(nvme_root_t r, int fd, char *format, return ret; } -static int wdc_print_latency_monitor_log(int fd, struct wdc_ssd_latency_monitor_log *log_data, int fmt) +static int wdc_print_latency_monitor_log(struct nvme_dev *dev, + struct wdc_ssd_latency_monitor_log *log_data, + int fmt) { if (!log_data) { fprintf(stderr, "ERROR : WDC : Invalid C3 log data buffer\n"); @@ -6383,7 +6472,7 @@ static int wdc_print_latency_monitor_log(int fd, struct wdc_ssd_latency_monitor_ } switch (fmt) { case NORMAL: - wdc_print_latency_monitor_log_normal(fd, log_data); + wdc_print_latency_monitor_log_normal(dev, log_data); break; case JSON: wdc_print_latency_monitor_log_json(log_data); @@ -6460,7 +6549,7 @@ static int wdc_print_fb_ca_log(struct wdc_ssd_ca_perf_stats *perf, int fmt) return 0; } -static int wdc_print_bd_ca_log(void *bd_data, int fmt) +static int wdc_print_bd_ca_log(struct nvme_dev *dev, void *bd_data, int fmt) { if (!bd_data) { fprintf(stderr, "ERROR : WDC : Invalid buffer to read data\n"); @@ -6468,7 +6557,7 @@ static int wdc_print_bd_ca_log(void *bd_data, int fmt) } switch (fmt) { case NORMAL: - wdc_print_bd_ca_log_normal(bd_data); + wdc_print_bd_ca_log_normal(dev, bd_data); break; case JSON: wdc_print_bd_ca_log_json(bd_data); @@ -6515,7 +6604,7 @@ static int wdc_print_fw_act_history_log(__u8 *data, int num_entries, int fmt, __ return 0; } -static int wdc_get_ca_log_page(nvme_root_t r, int fd, char *format) +static int wdc_get_ca_log_page(nvme_root_t r, struct nvme_dev *dev, char *format) { int ret = 0; int fmt = -1; @@ -6524,7 +6613,7 @@ static int wdc_get_ca_log_page(nvme_root_t r, int fd, char *format) uint32_t read_device_id, read_vendor_id; __u32 cust_id; - if (!wdc_check_device(r, fd)) + if (!wdc_check_device(r, dev)) return -1; fmt = validate_output_format(format); if (fmt < 0) { @@ -6533,19 +6622,19 @@ static int wdc_get_ca_log_page(nvme_root_t r, int fd, char *format) } /* verify the 0xCA log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE) == false) { + if (wdc_nvme_check_supported_log_page(r, dev, WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE) == false) { fprintf(stderr, "ERROR : WDC : 0xCA Log Page not supported\n"); return -1; } /* get the FW customer id */ - cust_id = wdc_get_fw_cust_id(r, fd); + cust_id = wdc_get_fw_cust_id(r, dev); if (cust_id == WDC_INVALID_CUSTOMER_ID) { fprintf(stderr, "%s: ERROR : WDC : invalid customer id\n", __func__); return -1; } - ret = wdc_get_pci_ids(r, &read_device_id, &read_vendor_id); + ret = wdc_get_pci_ids(r, dev, &read_device_id, &read_vendor_id); switch (read_device_id) { @@ -6560,8 +6649,9 @@ static int wdc_get_ca_log_page(nvme_root_t r, int fd, char *format) memset(data, 0, sizeof (__u8) * WDC_FB_CA_LOG_BUF_LEN); - ret = nvme_get_log_simple(fd, WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE, - WDC_FB_CA_LOG_BUF_LEN, data); + ret = nvme_get_log_simple(dev_fd(dev), + WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE, + WDC_FB_CA_LOG_BUF_LEN, data); if (strcmp(format, "json")) nvme_show_status(ret); @@ -6596,8 +6686,9 @@ static int wdc_get_ca_log_page(nvme_root_t r, int fd, char *format) memset(data, 0, sizeof (__u8) * WDC_FB_CA_LOG_BUF_LEN); - ret = nvme_get_log_simple(fd, WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE, - WDC_FB_CA_LOG_BUF_LEN, data); + ret = nvme_get_log_simple(dev_fd(dev), + WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE, + WDC_FB_CA_LOG_BUF_LEN, data); if (strcmp(format, "json")) nvme_show_status(ret); @@ -6617,14 +6708,15 @@ static int wdc_get_ca_log_page(nvme_root_t r, int fd, char *format) } memset(data, 0, sizeof (__u8) * WDC_BD_CA_LOG_BUF_LEN); - ret = nvme_get_log_simple(fd, WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE, - WDC_BD_CA_LOG_BUF_LEN, data); + ret = nvme_get_log_simple(dev_fd(dev), + WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE, + WDC_BD_CA_LOG_BUF_LEN, data); if (strcmp(format, "json")) nvme_show_status(ret); if (ret == 0) { /* parse the data */ - ret = wdc_print_bd_ca_log(data, fmt); + ret = wdc_print_bd_ca_log(dev, data, fmt); } else { fprintf(stderr, "ERROR : WDC : Unable to read CA Log Page data\n"); ret = -1; @@ -6649,7 +6741,7 @@ static int wdc_get_ca_log_page(nvme_root_t r, int fd, char *format) return ret; } -static int wdc_get_c1_log_page(nvme_root_t r, int fd, +static int wdc_get_c1_log_page(nvme_root_t r, struct nvme_dev *dev, char *format, uint8_t interval) { int ret = 0; @@ -6663,7 +6755,7 @@ static int wdc_get_c1_log_page(nvme_root_t r, int fd, struct wdc_log_page_subpage_header *sph; struct wdc_ssd_perf_stats *perf; - if (!wdc_check_device(r, fd)) + if (!wdc_check_device(r, dev)) return -1; fmt = validate_output_format(format); if (fmt < 0) { @@ -6682,8 +6774,8 @@ static int wdc_get_c1_log_page(nvme_root_t r, int fd, } memset(data, 0, sizeof (__u8) * WDC_ADD_LOG_BUF_LEN); - ret = nvme_get_log_simple(fd, WDC_NVME_ADD_LOG_OPCODE, - WDC_ADD_LOG_BUF_LEN, data); + ret = nvme_get_log_simple(dev_fd(dev), WDC_NVME_ADD_LOG_OPCODE, + WDC_ADD_LOG_BUF_LEN, data); if (strcmp(format, "json")) nvme_show_status(ret); if (ret == 0) { @@ -6708,7 +6800,7 @@ static int wdc_get_c1_log_page(nvme_root_t r, int fd, return ret; } -static int wdc_get_c3_log_page(nvme_root_t r, int fd, char *format) +static int wdc_get_c3_log_page(nvme_root_t r, struct nvme_dev *dev, char *format) { int ret = 0; int fmt = -1; @@ -6716,7 +6808,7 @@ static int wdc_get_c3_log_page(nvme_root_t r, int fd, char *format) int i; struct wdc_ssd_latency_monitor_log *log_data; - if (!wdc_check_device(r, fd)) + if (!wdc_check_device(r, dev)) return -1; fmt = validate_output_format(format); if (fmt < 0) { @@ -6730,7 +6822,7 @@ static int wdc_get_c3_log_page(nvme_root_t r, int fd, char *format) } memset(data, 0, sizeof (__u8) * WDC_LATENCY_MON_LOG_BUF_LEN); - ret = nvme_get_log_simple(fd, WDC_LATENCY_MON_OPCODE, + ret = nvme_get_log_simple(dev_fd(dev), WDC_LATENCY_MON_LOG_ID, WDC_LATENCY_MON_LOG_BUF_LEN, data); if (strcmp(format, "json")) @@ -6768,7 +6860,7 @@ static int wdc_get_c3_log_page(nvme_root_t r, int fd, char *format) } /* parse the data */ - wdc_print_latency_monitor_log(fd, log_data, fmt); + wdc_print_latency_monitor_log(dev, log_data, fmt); } else { fprintf(stderr, "ERROR : WDC : Unable to read C3 data from buffer\n"); } @@ -6779,7 +6871,7 @@ out: } -static int wdc_get_ocp_c1_log_page(nvme_root_t r, int fd, char *format) +static int wdc_get_ocp_c1_log_page(nvme_root_t r, struct nvme_dev *dev, char *format) { int ret = 0; int fmt = -1; @@ -6787,7 +6879,7 @@ static int wdc_get_ocp_c1_log_page(nvme_root_t r, int fd, char *format) int i; struct wdc_ocp_c1_error_recovery_log *log_data; - if (!wdc_check_device(r, fd)) + if (!wdc_check_device(r, dev)) return -1; fmt = validate_output_format(format); if (fmt < 0) { @@ -6801,8 +6893,8 @@ static int wdc_get_ocp_c1_log_page(nvme_root_t r, int fd, char *format) } memset(data, 0, sizeof (__u8) * WDC_ERROR_REC_LOG_BUF_LEN); - ret = nvme_get_log_simple(fd, WDC_ERROR_REC_LOG_ID, - WDC_ERROR_REC_LOG_BUF_LEN, data); + ret = nvme_get_log_simple(dev_fd(dev), WDC_ERROR_REC_LOG_ID, + WDC_ERROR_REC_LOG_BUF_LEN, data); if (strcmp(format, "json")) fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(ret, false), ret); @@ -6811,7 +6903,8 @@ static int wdc_get_ocp_c1_log_page(nvme_root_t r, int fd, char *format) log_data = (struct wdc_ocp_c1_error_recovery_log *)data; /* check log page version */ - if (log_data->log_page_version != WDC_ERROR_REC_LOG_VERSION) { + if ((log_data->log_page_version != WDC_ERROR_REC_LOG_VERSION1) && + (log_data->log_page_version != WDC_ERROR_REC_LOG_VERSION2)) { fprintf(stderr, "ERROR : WDC : invalid error recovery log version - %d\n", log_data->log_page_version); ret = -1; goto out; @@ -6848,7 +6941,7 @@ out: return ret; } -static int wdc_get_ocp_c4_log_page(nvme_root_t r, int fd, char *format) +static int wdc_get_ocp_c4_log_page(nvme_root_t r, struct nvme_dev *dev, char *format) { int ret = 0; int fmt = -1; @@ -6856,7 +6949,7 @@ static int wdc_get_ocp_c4_log_page(nvme_root_t r, int fd, char *format) int i; struct wdc_ocp_C4_dev_cap_log *log_data; - if (!wdc_check_device(r, fd)) + if (!wdc_check_device(r, dev)) return -1; fmt = validate_output_format(format); if (fmt < 0) { @@ -6870,8 +6963,8 @@ static int wdc_get_ocp_c4_log_page(nvme_root_t r, int fd, char *format) } memset(data, 0, sizeof (__u8) * WDC_DEV_CAP_LOG_BUF_LEN); - ret = nvme_get_log_simple(fd, WDC_DEV_CAP_LOG_ID, - WDC_DEV_CAP_LOG_BUF_LEN, data); + ret = nvme_get_log_simple(dev_fd(dev), WDC_DEV_CAP_LOG_ID, + WDC_DEV_CAP_LOG_BUF_LEN, data); if (strcmp(format, "json")) fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(ret, false), ret); @@ -6893,7 +6986,7 @@ static int wdc_get_ocp_c4_log_page(nvme_root_t r, int fd, char *format) int j; fprintf(stderr, "ERROR : WDC : Expected GUID: 0x"); for (j = 0; j<16; j++) { - fprintf(stderr, "%x", wdc_ocp_c1_guid[j]); + fprintf(stderr, "%x", wdc_ocp_c4_guid[j]); } fprintf(stderr, "\nERROR : WDC : Actual GUID: 0x"); for (j = 0; j<16; j++) { @@ -6917,7 +7010,7 @@ out: return ret; } -static int wdc_get_ocp_c5_log_page(nvme_root_t r, int fd, char *format) +static int wdc_get_ocp_c5_log_page(nvme_root_t r, struct nvme_dev *dev, char *format) { int ret = 0; int fmt = -1; @@ -6925,7 +7018,7 @@ static int wdc_get_ocp_c5_log_page(nvme_root_t r, int fd, char *format) int i; struct wdc_ocp_C5_unsupported_reqs *log_data; - if (!wdc_check_device(r, fd)) + if (!wdc_check_device(r, dev)) return -1; fmt = validate_output_format(format); if (fmt < 0) { @@ -6939,8 +7032,8 @@ static int wdc_get_ocp_c5_log_page(nvme_root_t r, int fd, char *format) } memset(data, 0, sizeof (__u8) * WDC_UNSUPPORTED_REQS_LOG_BUF_LEN); - ret = nvme_get_log_simple(fd, WDC_UNSUPPORTED_REQS_LOG_ID, - WDC_UNSUPPORTED_REQS_LOG_BUF_LEN, data); + ret = nvme_get_log_simple(dev_fd(dev), WDC_UNSUPPORTED_REQS_LOG_ID, + WDC_UNSUPPORTED_REQS_LOG_BUF_LEN, data); if (strcmp(format, "json")) fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(ret, false), ret); @@ -6962,7 +7055,7 @@ static int wdc_get_ocp_c5_log_page(nvme_root_t r, int fd, char *format) int j; fprintf(stderr, "ERROR : WDC : Expected GUID: 0x"); for (j = 0; j<16; j++) { - fprintf(stderr, "%x", wdc_ocp_c1_guid[j]); + fprintf(stderr, "%x", wdc_ocp_c5_guid[j]); } fprintf(stderr, "\nERROR : WDC : Actual GUID: 0x"); for (j = 0; j<16; j++) { @@ -6986,14 +7079,14 @@ out: return ret; } -static int wdc_get_d0_log_page(nvme_root_t r, int fd, char *format) +static int wdc_get_d0_log_page(nvme_root_t r, struct nvme_dev *dev, char *format) { int ret = 0; int fmt = -1; __u8 *data; struct wdc_ssd_d0_smart_log *perf; - if (!wdc_check_device(r, fd)) + if (!wdc_check_device(r, dev)) return -1; fmt = validate_output_format(format); if (fmt < 0) { @@ -7002,7 +7095,7 @@ static int wdc_get_d0_log_page(nvme_root_t r, int fd, char *format) } /* verify the 0xD0 log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_VU_SMART_LOG_OPCODE) == false) { + if (wdc_nvme_check_supported_log_page(r, dev, WDC_NVME_GET_VU_SMART_LOG_OPCODE) == false) { fprintf(stderr, "ERROR : WDC : 0xD0 Log Page not supported\n"); return -1; } @@ -7013,8 +7106,9 @@ static int wdc_get_d0_log_page(nvme_root_t r, int fd, char *format) } memset(data, 0, sizeof (__u8) * WDC_NVME_VU_SMART_LOG_LEN); - ret = nvme_get_log_simple(fd, WDC_NVME_GET_VU_SMART_LOG_OPCODE, - WDC_NVME_VU_SMART_LOG_LEN, data); + ret = nvme_get_log_simple(dev_fd(dev), + WDC_NVME_GET_VU_SMART_LOG_OPCODE, + WDC_NVME_VU_SMART_LOG_LEN, data); if (strcmp(format, "json")) nvme_show_status(ret); @@ -7036,10 +7130,10 @@ static int wdc_vs_smart_add_log(int argc, char **argv, struct command *command, { const char *desc = "Retrieve additional performance statistics."; const char *interval = "Interval to read the statistics from [1, 15]."; - int fd; const char *log_page_version = "Log Page Version: 0 = vendor, 1 = WDC"; const char *log_page_mask = "Log Page Mask, comma separated list: 0xC0, 0xC1, 0xCA, 0xD0"; const char *namespace_id = "desired namespace id"; + struct nvme_dev *dev; nvme_root_t r; int ret = 0; int uuid_index = 0; @@ -7072,9 +7166,9 @@ static int wdc_vs_smart_add_log(int argc, char **argv, struct command *command, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); if (cfg.log_page_version == 0) { @@ -7121,7 +7215,7 @@ static int wdc_vs_smart_add_log(int argc, char **argv, struct command *command, fprintf(stderr, "ERROR : WDC: Unknown log page mask - %s\n", cfg.log_page_mask); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_SMART_LOG_MASK) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); @@ -7132,35 +7226,37 @@ static int wdc_vs_smart_add_log(int argc, char **argv, struct command *command, if (((capabilities & WDC_DRIVE_CAP_C0_LOG_PAGE) == WDC_DRIVE_CAP_C0_LOG_PAGE) && (page_mask & WDC_C0_PAGE_MASK)) { /* Get 0xC0 log page if possible. */ - ret = wdc_get_c0_log_page(r, fd, cfg.output_format, uuid_index, cfg.namespace_id); + ret = wdc_get_c0_log_page(r, dev, cfg.output_format, + uuid_index, cfg.namespace_id); if (ret) fprintf(stderr, "ERROR : WDC : Failure reading the C0 Log Page, ret = %d\n", ret); } if (((capabilities & (WDC_DRIVE_CAP_CA_LOG_PAGE)) == (WDC_DRIVE_CAP_CA_LOG_PAGE)) && (page_mask & WDC_CA_PAGE_MASK)) { /* Get the CA Log Page */ - ret = wdc_get_ca_log_page(r, fd, cfg.output_format); + ret = wdc_get_ca_log_page(r, dev, cfg.output_format); if (ret) fprintf(stderr, "ERROR : WDC : Failure reading the CA Log Page, ret = %d\n", ret); } if (((capabilities & WDC_DRIVE_CAP_C1_LOG_PAGE) == WDC_DRIVE_CAP_C1_LOG_PAGE) && (page_mask & WDC_C1_PAGE_MASK)) { /* Get the C1 Log Page */ - ret = wdc_get_c1_log_page(r, fd, cfg.output_format, cfg.interval); + ret = wdc_get_c1_log_page(r, dev, cfg.output_format, + cfg.interval); if (ret) fprintf(stderr, "ERROR : WDC : Failure reading the C1 Log Page, ret = %d\n", ret); } if (((capabilities & WDC_DRIVE_CAP_D0_LOG_PAGE) == WDC_DRIVE_CAP_D0_LOG_PAGE) && (page_mask & WDC_D0_PAGE_MASK)) { /* Get the D0 Log Page */ - ret = wdc_get_d0_log_page(r, fd, cfg.output_format); + ret = wdc_get_d0_log_page(r, dev, cfg.output_format); if (ret) fprintf(stderr, "ERROR : WDC : Failure reading the D0 Log Page, ret = %d\n", ret); } out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -7169,12 +7265,11 @@ static int wdc_vs_cloud_log(int argc, char **argv, struct command *command, { const char *desc = "Retrieve Cloud Log Smart/Health Information"; const char *namespace_id = "desired namespace id"; - int fd; - nvme_root_t r; - int ret = 0; __u64 capabilities = 0; + struct nvme_dev *dev; + int ret, fmt = -1; + nvme_root_t r; __u8 *data; - int fmt = -1; struct config { char *output_format; @@ -7192,13 +7287,13 @@ static int wdc_vs_cloud_log(int argc, char **argv, struct command *command, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_CLOUD_LOG_PAGE) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); @@ -7207,7 +7302,8 @@ static int wdc_vs_cloud_log(int argc, char **argv, struct command *command, } data = NULL; - ret = nvme_get_ext_smart_cloud_log(fd, &data, 0, cfg.namespace_id); + ret = nvme_get_ext_smart_cloud_log(dev_fd(dev), &data, 0, + cfg.namespace_id); if (strcmp(cfg.output_format, "json")) nvme_show_status(ret); @@ -7231,7 +7327,7 @@ static int wdc_vs_cloud_log(int argc, char **argv, struct command *command, out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -7240,12 +7336,11 @@ static int wdc_vs_hw_rev_log(int argc, char **argv, struct command *command, { const char *desc = "Retrieve Hardware Revision Log Information"; const char *namespace_id = "desired namespace id"; - int fd; - nvme_root_t r; - int ret = 0; __u64 capabilities = 0; + struct nvme_dev *dev; + int ret, fmt = -1; __u8 *data = NULL; - int fmt = -1; + nvme_root_t r; struct config { char *output_format; @@ -7263,13 +7358,13 @@ static int wdc_vs_hw_rev_log(int argc, char **argv, struct command *command, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_HW_REV_LOG_PAGE) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); @@ -7277,7 +7372,7 @@ static int wdc_vs_hw_rev_log(int argc, char **argv, struct command *command, goto out; } - ret = nvme_get_hw_rev_log(fd, &data, 0, cfg.namespace_id); + ret = nvme_get_hw_rev_log(dev_fd(dev), &data, 0, cfg.namespace_id); if (strcmp(cfg.output_format, "json")) nvme_show_status(ret); @@ -7314,7 +7409,7 @@ free_buf: out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -7324,8 +7419,8 @@ static int wdc_vs_device_waf(int argc, char **argv, struct command *command, const char *desc = "Retrieve Device Write Amplication Factor"; const char *namespace_id = "desired namespace id"; struct nvme_smart_log smart_log; + struct nvme_dev *dev; __u8 *data; - int fd; nvme_root_t r; int ret = 0; int fmt = -1; @@ -7354,13 +7449,13 @@ static int wdc_vs_device_waf(int argc, char **argv, struct command *command, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_DEVICE_WAF) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); @@ -7369,7 +7464,8 @@ static int wdc_vs_device_waf(int argc, char **argv, struct command *command, } /* get data units written from the smart log page */ - ret = nvme_get_log_smart(fd, cfg.namespace_id, false, &smart_log); + ret = nvme_get_log_smart(dev_fd(dev), cfg.namespace_id, false, + &smart_log); if (!ret) { data_units_written = int128_to_double(smart_log.data_units_written); } @@ -7385,7 +7481,8 @@ static int wdc_vs_device_waf(int argc, char **argv, struct command *command, /* get Physical Media Units Written from extended smart/C0 log page */ data = NULL; - ret = nvme_get_ext_smart_cloud_log(fd, &data, 0, cfg.namespace_id); + ret = nvme_get_ext_smart_cloud_log(dev_fd(dev), &data, 0, + cfg.namespace_id); if (ret == 0) { ext_smart_log_ptr = (wdc_nvme_ext_smart_log *)data; @@ -7438,7 +7535,7 @@ static int wdc_vs_device_waf(int argc, char **argv, struct command *command, out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -7446,10 +7543,10 @@ static int wdc_get_latency_monitor_log(int argc, char **argv, struct command *co struct plugin *plugin) { const char *desc = "Retrieve latency monitor log data."; + __u64 capabilities = 0; + struct nvme_dev *dev; nvme_root_t r; - int fd; int ret = 0; - __u64 capabilities = 0; struct config { char *output_format; @@ -7464,12 +7561,12 @@ static int wdc_get_latency_monitor_log(int argc, char **argv, struct command *co OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_C3_LOG_PAGE) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); @@ -7477,13 +7574,13 @@ static int wdc_get_latency_monitor_log(int argc, char **argv, struct command *co goto out; } - ret = wdc_get_c3_log_page(r, fd, cfg.output_format); + ret = wdc_get_c3_log_page(r, dev, cfg.output_format); if (ret) fprintf(stderr, "ERROR : WDC : Failure reading the Latency Monitor (C3) Log Page, ret = %d\n", ret); out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -7491,10 +7588,10 @@ static int wdc_get_error_recovery_log(int argc, char **argv, struct command *com struct plugin *plugin) { const char *desc = "Retrieve error recovery log data."; + __u64 capabilities = 0; + struct nvme_dev *dev; nvme_root_t r; - int fd; int ret = 0; - __u64 capabilities = 0; struct config { char *output_format; @@ -7509,12 +7606,12 @@ static int wdc_get_error_recovery_log(int argc, char **argv, struct command *com OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_OCP_C1_LOG_PAGE) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); @@ -7522,13 +7619,13 @@ static int wdc_get_error_recovery_log(int argc, char **argv, struct command *com goto out; } - ret = wdc_get_ocp_c1_log_page(r, fd, cfg.output_format); + ret = wdc_get_ocp_c1_log_page(r, dev, cfg.output_format); if (ret) fprintf(stderr, "ERROR : WDC : Failure reading the Error Recovery (C1) Log Page, ret = 0x%x\n", ret); out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -7536,10 +7633,10 @@ static int wdc_get_dev_capabilities_log(int argc, char **argv, struct command *c struct plugin *plugin) { const char *desc = "Retrieve device capabilities log data."; + __u64 capabilities = 0; + struct nvme_dev *dev; nvme_root_t r; - int fd; int ret = 0; - __u64 capabilities = 0; struct config { char *output_format; @@ -7554,12 +7651,12 @@ static int wdc_get_dev_capabilities_log(int argc, char **argv, struct command *c OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_OCP_C4_LOG_PAGE) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); @@ -7567,13 +7664,13 @@ static int wdc_get_dev_capabilities_log(int argc, char **argv, struct command *c goto out; } - ret = wdc_get_ocp_c4_log_page(r, fd, cfg.output_format); + ret = wdc_get_ocp_c4_log_page(r, dev, cfg.output_format); if (ret) fprintf(stderr, "ERROR : WDC : Failure reading the Device Capabilities (C4) Log Page, ret = 0x%x\n", ret); out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -7581,10 +7678,10 @@ static int wdc_get_unsupported_reqs_log(int argc, char **argv, struct command *c struct plugin *plugin) { const char *desc = "Retrieve unsupported requirements log data."; + __u64 capabilities = 0; + struct nvme_dev *dev; nvme_root_t r; - int fd; int ret = 0; - __u64 capabilities = 0; struct config { char *output_format; @@ -7599,12 +7696,12 @@ static int wdc_get_unsupported_reqs_log(int argc, char **argv, struct command *c OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_OCP_C5_LOG_PAGE) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); @@ -7612,13 +7709,13 @@ static int wdc_get_unsupported_reqs_log(int argc, char **argv, struct command *c goto out; } - ret = wdc_get_ocp_c5_log_page(r, fd, cfg.output_format); + ret = wdc_get_ocp_c5_log_page(r, dev, cfg.output_format); if (ret) fprintf(stderr, "ERROR : WDC : Failure reading the Unsupported Requirements (C5) Log Page, ret = 0x%x\n", ret); out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -7667,25 +7764,26 @@ static int wdc_clear_pcie_correctable_errors(int argc, char **argv, struct comma struct plugin *plugin) { char *desc = "Clear PCIE Correctable Errors."; - int fd, ret; - nvme_root_t r; __u64 capabilities = 0; + struct nvme_dev *dev; + nvme_root_t r; + int ret; OPT_ARGS(opts) = { OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - if (!wdc_check_device(r, fd)) { + if (!wdc_check_device(r, dev)) { ret = -1; goto out; } - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_CLEAR_PCIE_MASK) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); ret = -1; @@ -7693,18 +7791,18 @@ static int wdc_clear_pcie_correctable_errors(int argc, char **argv, struct comma } if (capabilities & WDC_DRIVE_CAP_CLEAR_PCIE) { - ret = wdc_do_clear_pcie_correctable_errors(fd); + ret = wdc_do_clear_pcie_correctable_errors(dev_fd(dev)); } else if (capabilities & WDC_DRIVE_CAP_VUC_CLEAR_PCIE) { - ret = wdc_do_clear_pcie_correctable_errors_vuc(fd); + ret = wdc_do_clear_pcie_correctable_errors_vuc(dev_fd(dev)); } else { - ret = wdc_do_clear_pcie_correctable_errors_fid(fd); + ret = wdc_do_clear_pcie_correctable_errors_fid(dev_fd(dev)); } out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -7712,7 +7810,7 @@ static int wdc_drive_status(int argc, char **argv, struct command *command, struct plugin *plugin) { char *desc = "Get Drive Status."; - int fd; + struct nvme_dev *dev; int ret = 0; nvme_root_t r; __le32 system_eol_state; @@ -7727,12 +7825,12 @@ static int wdc_drive_status(int argc, char **argv, struct command *command, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_DRIVE_STATUS) != WDC_DRIVE_CAP_DRIVE_STATUS) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); ret = -1; @@ -7740,41 +7838,42 @@ static int wdc_drive_status(int argc, char **argv, struct command *command, } /* verify the 0xC2 Device Manageability log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_DEV_MGMNT_LOG_PAGE_OPCODE) == false) { + if (wdc_nvme_check_supported_log_page(r, dev, + WDC_NVME_GET_DEV_MGMNT_LOG_PAGE_OPCODE) == false) { fprintf(stderr, "ERROR : WDC : 0xC2 Log Page not supported\n"); ret = -1; goto out; } /* Get the assert dump present status */ - if (!wdc_nvme_get_dev_status_log_data(r, fd, &assert_status, + if (!wdc_nvme_get_dev_status_log_data(r, dev, &assert_status, WDC_C2_ASSERT_DUMP_PRESENT_ID)) fprintf(stderr, "ERROR : WDC : Get Assert Status Failed\n"); /* Get the thermal throttling status */ - if (!wdc_nvme_get_dev_status_log_data(r, fd, &thermal_status, + if (!wdc_nvme_get_dev_status_log_data(r, dev, &thermal_status, WDC_C2_THERMAL_THROTTLE_STATUS_ID)) fprintf(stderr, "ERROR : WDC : Get Thermal Throttling Status Failed\n"); /* Get EOL status */ - if (!wdc_nvme_get_dev_status_log_data(r, fd, &eol_status, + if (!wdc_nvme_get_dev_status_log_data(r, dev, &eol_status, WDC_C2_USER_EOL_STATUS_ID)) { fprintf(stderr, "ERROR : WDC : Get User EOL Status Failed\n"); eol_status = cpu_to_le32(-1); } /* Get Customer EOL state */ - if (!wdc_nvme_get_dev_status_log_data(r, fd, &user_eol_state, + if (!wdc_nvme_get_dev_status_log_data(r, dev, &user_eol_state, WDC_C2_USER_EOL_STATE_ID)) fprintf(stderr, "ERROR : WDC : Get User EOL State Failed\n"); /* Get System EOL state*/ - if (!wdc_nvme_get_dev_status_log_data(r, fd, &system_eol_state, + if (!wdc_nvme_get_dev_status_log_data(r, dev, &system_eol_state, WDC_C2_SYSTEM_EOL_STATE_ID)) fprintf(stderr, "ERROR : WDC : Get System EOL State Failed\n"); /* Get format corrupt reason*/ - if (!wdc_nvme_get_dev_status_log_data(r, fd, &format_corrupt_reason, + if (!wdc_nvme_get_dev_status_log_data(r, dev, &format_corrupt_reason, WDC_C2_FORMAT_CORRUPT_REASON_ID)) fprintf(stderr, "ERROR : WDC : Get Format Corrupt Reason Failed\n"); @@ -7822,7 +7921,7 @@ static int wdc_drive_status(int argc, char **argv, struct command *command, out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -7830,7 +7929,7 @@ static int wdc_clear_assert_dump(int argc, char **argv, struct command *command, struct plugin *plugin) { char *desc = "Clear Assert Dump Present Status."; - int fd; + struct nvme_dev *dev; int ret = -1; nvme_root_t r; __le32 assert_status = cpu_to_le32(0xFFFFFFFF); @@ -7841,18 +7940,18 @@ static int wdc_clear_assert_dump(int argc, char **argv, struct command *command, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_CLEAR_ASSERT) != WDC_DRIVE_CAP_CLEAR_ASSERT) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); ret = -1; goto out; } - if (!wdc_nvme_get_dev_status_log_data(r, fd, &assert_status, + if (!wdc_nvme_get_dev_status_log_data(r, dev, &assert_status, WDC_C2_ASSERT_DUMP_PRESENT_ID)) { fprintf(stderr, "ERROR : WDC : Get Assert Status Failed\n"); ret = -1; @@ -7866,25 +7965,27 @@ static int wdc_clear_assert_dump(int argc, char **argv, struct command *command, admin_cmd.cdw12 = ((WDC_NVME_CLEAR_ASSERT_DUMP_SUBCMD << WDC_NVME_SUBCMD_SHIFT) | WDC_NVME_CLEAR_ASSERT_DUMP_CMD); - ret = nvme_submit_admin_passthru(fd, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(dev_fd(dev), &admin_cmd, + NULL); nvme_show_status(ret); } else fprintf(stderr, "INFO : WDC : No Assert Dump Present\n"); out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } -static int wdc_get_fw_act_history(nvme_root_t r, int fd, char *format) +static int wdc_get_fw_act_history(nvme_root_t r, struct nvme_dev *dev, + char *format) { int ret = 0; int fmt = -1; __u8 *data; struct wdc_fw_act_history_log_hdr *fw_act_history_hdr; - if (!wdc_check_device(r, fd)) + if (!wdc_check_device(r, dev)) return -1; fmt = validate_output_format(format); @@ -7894,7 +7995,7 @@ static int wdc_get_fw_act_history(nvme_root_t r, int fd, char *format) } /* verify the FW Activate History log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, WDC_NVME_GET_FW_ACT_HISTORY_LOG_ID) == false) { + if (wdc_nvme_check_supported_log_page(r, dev, WDC_NVME_GET_FW_ACT_HISTORY_LOG_ID) == false) { fprintf(stderr, "ERROR : WDC : %d Log Page not supported\n", WDC_NVME_GET_FW_ACT_HISTORY_LOG_ID); return -1; } @@ -7906,8 +8007,9 @@ static int wdc_get_fw_act_history(nvme_root_t r, int fd, char *format) memset(data, 0, sizeof (__u8) * WDC_FW_ACT_HISTORY_LOG_BUF_LEN); - ret = nvme_get_log_simple(fd, WDC_NVME_GET_FW_ACT_HISTORY_LOG_ID, - WDC_FW_ACT_HISTORY_LOG_BUF_LEN, data); + ret = nvme_get_log_simple(dev_fd(dev), + WDC_NVME_GET_FW_ACT_HISTORY_LOG_ID, + WDC_FW_ACT_HISTORY_LOG_BUF_LEN, data); if (strcmp(format, "json")) nvme_show_status(ret); @@ -7935,13 +8037,13 @@ static int wdc_get_fw_act_history(nvme_root_t r, int fd, char *format) return ret; } -static __u32 wdc_get_fw_cust_id(nvme_root_t r, int fd) +static __u32 wdc_get_fw_cust_id(nvme_root_t r, struct nvme_dev *dev) { __u32 cust_id = WDC_INVALID_CUSTOMER_ID; __u32 *cust_id_ptr = NULL; - if (!(get_dev_mgment_cbs_data(r, fd, WDC_C2_CUSTOMER_ID_ID, (void*)&cust_id_ptr))) { + if (!(get_dev_mgment_cbs_data(r, dev, WDC_C2_CUSTOMER_ID_ID, (void*)&cust_id_ptr))) { fprintf(stderr, "%s: ERROR : WDC : 0xC2 Log Page entry ID 0x%x not found\n", __func__, WDC_C2_CUSTOMER_ID_ID); } else { cust_id = *cust_id_ptr; @@ -7951,7 +8053,8 @@ static __u32 wdc_get_fw_cust_id(nvme_root_t r, int fd) return cust_id; } -static int wdc_get_fw_act_history_C2(nvme_root_t r, int fd, char *format) +static int wdc_get_fw_act_history_C2(nvme_root_t r, struct nvme_dev *dev, + char *format) { int ret = 0; int fmt = -1; @@ -7961,7 +8064,7 @@ static int wdc_get_fw_act_history_C2(nvme_root_t r, int fd, char *format) __u32 tot_entries = 0, num_entries = 0; __u32 vendor_id = 0, device_id = 0; - if (!wdc_check_device(r, fd)) + if (!wdc_check_device(r, dev)) return -1; fmt = validate_output_format(format); @@ -7970,7 +8073,7 @@ static int wdc_get_fw_act_history_C2(nvme_root_t r, int fd, char *format) return fmt; } - ret = wdc_get_pci_ids(r, &device_id, &vendor_id); + ret = wdc_get_pci_ids(r, dev, &device_id, &vendor_id); if ((data = (__u8*) malloc(sizeof (__u8) * WDC_FW_ACT_HISTORY_C2_LOG_BUF_LEN)) == NULL) { fprintf(stderr, "ERROR : WDC : malloc : %s\n", strerror(errno)); @@ -7979,8 +8082,9 @@ static int wdc_get_fw_act_history_C2(nvme_root_t r, int fd, char *format) memset(data, 0, sizeof (__u8) * WDC_FW_ACT_HISTORY_C2_LOG_BUF_LEN); - ret = nvme_get_log_simple(fd, WDC_NVME_GET_FW_ACT_HISTORY_C2_LOG_ID, - WDC_FW_ACT_HISTORY_C2_LOG_BUF_LEN, data); + ret = nvme_get_log_simple(dev_fd(dev), + WDC_NVME_GET_FW_ACT_HISTORY_C2_LOG_ID, + WDC_FW_ACT_HISTORY_C2_LOG_BUF_LEN, data); if (strcmp(format, "json")) nvme_show_status(ret); @@ -7992,7 +8096,7 @@ static int wdc_get_fw_act_history_C2(nvme_root_t r, int fd, char *format) if (tot_entries > 0) { /* get the FW customer id */ - cust_id = wdc_get_fw_cust_id(r, fd); + cust_id = wdc_get_fw_cust_id(r, dev); if (cust_id == WDC_INVALID_CUSTOMER_ID) { fprintf(stderr, "%s: ERROR : WDC : invalid customer id\n", __func__); ret = -1; @@ -8018,12 +8122,11 @@ freeData: static int wdc_vs_fw_activate_history(int argc, char **argv, struct command *command, struct plugin *plugin) { - int fd; - int ret = 0; - nvme_root_t r; - __u64 capabilities = 0; const char *desc = "Retrieve FW activate history table."; - + __u64 capabilities = 0; + struct nvme_dev *dev; + nvme_root_t r; + int ret; struct config { char *output_format; @@ -8038,13 +8141,12 @@ static int wdc_vs_fw_activate_history(int argc, char **argv, struct command *com OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_FW_ACTIVATE_HISTORY_MASK) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); ret = -1; @@ -8068,8 +8170,8 @@ static int wdc_vs_fw_activate_history(int argc, char **argv, struct command *com /* Get the 0xC0 log data */ struct nvme_get_log_args args = { .args_size = sizeof(args), - .fd = fd, - .lid = WDC_NVME_GET_SMART_CLOUD_ATTR_LOG_OPCODE, + .fd = dev_fd(dev), + .lid = WDC_NVME_GET_SMART_CLOUD_ATTR_LOG_ID, .nsid = 0xFFFFFFFF, .lpo = 0, .lsp = NVME_LOG_LSP_NONE, @@ -8101,21 +8203,22 @@ static int wdc_vs_fw_activate_history(int argc, char **argv, struct command *com free(data); if (c0GuidMatch) { - ret = wdc_get_fw_act_history_C2(r, fd, + ret = wdc_get_fw_act_history_C2(r, dev, cfg.output_format); } else { - ret = wdc_get_fw_act_history(r, fd, cfg.output_format); + ret = wdc_get_fw_act_history(r, dev, + cfg.output_format); } } else { - ret = wdc_get_fw_act_history_C2(r, fd, cfg.output_format); + ret = wdc_get_fw_act_history_C2(r, dev, cfg.output_format); } if (ret) fprintf(stderr, "ERROR : WDC : Failure reading the FW Activate History, ret = %d\n", ret); out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -8152,21 +8255,21 @@ static int wdc_clear_fw_activate_history(int argc, char **argv, struct command * struct plugin *plugin) { char *desc = "Clear FW activate history table."; - int fd; - int ret = -1; - nvme_root_t r; __u64 capabilities = 0; + struct nvme_dev *dev; + nvme_root_t r; + int ret; OPT_ARGS(opts) = { OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_CLEAR_FW_ACT_HISTORY_MASK) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); ret = -1; @@ -8174,13 +8277,13 @@ static int wdc_clear_fw_activate_history(int argc, char **argv, struct command * } if (capabilities & WDC_DRIVE_CAP_CLEAR_FW_ACT_HISTORY) - ret = wdc_do_clear_fw_activate_history_vuc(fd); + ret = wdc_do_clear_fw_activate_history_vuc(dev_fd(dev)); else - ret = wdc_do_clear_fw_activate_history_fid(fd); + ret = wdc_do_clear_fw_activate_history_fid(dev_fd(dev)); out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -8191,11 +8294,11 @@ static int wdc_vs_telemetry_controller_option(int argc, char **argv, struct comm char *disable = "Disable controller option of the telemetry log page."; char *enable = "Enable controller option of the telemetry log page."; char *status = "Displays the current state of the controller initiated log page."; - int fd; - int ret = -1; - nvme_root_t r; __u64 capabilities = 0; + struct nvme_dev *dev; + nvme_root_t r; __u32 result; + int ret = -1; struct config { @@ -8217,12 +8320,12 @@ static int wdc_vs_telemetry_controller_option(int argc, char **argv, struct comm OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRVIE_CAP_DISABLE_CTLR_TELE_LOG) != WDC_DRVIE_CAP_DISABLE_CTLR_TELE_LOG) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); ret = -1; @@ -8238,19 +8341,22 @@ static int wdc_vs_telemetry_controller_option(int argc, char **argv, struct comm } if (cfg.disable) { - ret = nvme_set_features_simple(fd, WDC_VU_DISABLE_CNTLR_TELEMETRY_OPTION_FEATURE_ID, 0, 1, - false, &result); + ret = nvme_set_features_simple(dev_fd(dev), + WDC_VU_DISABLE_CNTLR_TELEMETRY_OPTION_FEATURE_ID, + 0, 1, false, &result); - wdc_clear_reason_id(fd); + wdc_clear_reason_id(dev); } else { if (cfg.enable) { - ret = nvme_set_features_simple(fd, WDC_VU_DISABLE_CNTLR_TELEMETRY_OPTION_FEATURE_ID, 0, 0, - false, &result); + ret = nvme_set_features_simple(dev_fd(dev), + WDC_VU_DISABLE_CNTLR_TELEMETRY_OPTION_FEATURE_ID, + 0, 0, false, &result); } else if (cfg.status) { - ret = nvme_get_features_simple(fd, WDC_VU_DISABLE_CNTLR_TELEMETRY_OPTION_FEATURE_ID, 0, - &result); + ret = nvme_get_features_simple(dev_fd(dev), + WDC_VU_DISABLE_CNTLR_TELEMETRY_OPTION_FEATURE_ID, + 0, &result); if (ret == 0) { if (result) fprintf(stderr, "Controller Option Telemetry Log Page State: Disabled\n"); @@ -8271,12 +8377,12 @@ static int wdc_vs_telemetry_controller_option(int argc, char **argv, struct comm out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } -static int wdc_get_serial_and_fw_rev(int fd, char *sn, char *fw_rev) +static int wdc_get_serial_and_fw_rev(struct nvme_dev *dev, char *sn, char *fw_rev) { int i; int ret; @@ -8286,7 +8392,7 @@ static int wdc_get_serial_and_fw_rev(int fd, char *sn, char *fw_rev) memset(sn, 0, WDC_SERIAL_NO_LEN); memset(fw_rev, 0, WDC_NVME_FIRMWARE_REV_LEN); memset(&ctrl, 0, sizeof (struct nvme_id_ctrl)); - ret = nvme_identify_ctrl(fd, &ctrl); + ret = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (ret) { fprintf(stderr, "ERROR : WDC : nvme_identify_ctrl() failed " "0x%x\n", ret); @@ -8303,7 +8409,7 @@ static int wdc_get_serial_and_fw_rev(int fd, char *sn, char *fw_rev) return 0; } -static int wdc_get_max_transfer_len(int fd, __u32 *maxTransferLen) +static int wdc_get_max_transfer_len(struct nvme_dev *dev, __u32 *maxTransferLen) { int ret = 0; struct nvme_id_ctrl ctrl; @@ -8311,7 +8417,7 @@ static int wdc_get_max_transfer_len(int fd, __u32 *maxTransferLen) __u32 maxTransferLenDevice = 0; memset(&ctrl, 0, sizeof (struct nvme_id_ctrl)); - ret = nvme_identify_ctrl(fd, &ctrl); + ret = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (ret) { fprintf(stderr, "ERROR : WDC : nvme_identify_ctrl() failed 0x%x\n", ret); return -1; @@ -8323,12 +8429,13 @@ static int wdc_get_max_transfer_len(int fd, __u32 *maxTransferLen) return ret; } -static int wdc_de_VU_read_size(int fd, __u32 fileId, __u16 spiDestn, __u32* logSize) +static int wdc_de_VU_read_size(struct nvme_dev *dev, __u32 fileId, + __u16 spiDestn, __u32* logSize) { int ret = WDC_STATUS_FAILURE; struct nvme_passthru_cmd cmd; - if(!fd || !logSize ) + if(!dev || !logSize ) { ret = WDC_STATUS_INVALID_PARAMETER; goto end; @@ -8340,7 +8447,7 @@ static int wdc_de_VU_read_size(int fd, __u32 fileId, __u16 spiDestn, __u32* logS cmd.cdw13 = fileId<<16; cmd.cdw14 = spiDestn; - ret = nvme_submit_admin_passthru(fd, &cmd, NULL); + ret = nvme_submit_admin_passthru(dev_fd(dev), &cmd, NULL); if (!ret && logSize) *logSize = cmd.result; @@ -8353,13 +8460,15 @@ static int wdc_de_VU_read_size(int fd, __u32 fileId, __u16 spiDestn, __u32* logS return ret; } -static int wdc_de_VU_read_buffer(int fd, __u32 fileId, __u16 spiDestn, __u32 offsetInDwords, __u8* dataBuffer, __u32* bufferSize) +static int wdc_de_VU_read_buffer(struct nvme_dev *dev, __u32 fileId, + __u16 spiDestn, __u32 offsetInDwords, + __u8* dataBuffer, __u32* bufferSize) { int ret = WDC_STATUS_FAILURE; struct nvme_passthru_cmd cmd; __u32 noOfDwordExpected = 0; - if(!fd || !dataBuffer || !bufferSize) + if(!dev || !dataBuffer || !bufferSize) { ret = WDC_STATUS_INVALID_PARAMETER; goto end; @@ -8377,7 +8486,7 @@ static int wdc_de_VU_read_buffer(int fd, __u32 fileId, __u16 spiDestn, __u32 off cmd.addr = (__u64)(__u64)(uintptr_t)dataBuffer; cmd.data_len = *bufferSize; - ret = nvme_submit_admin_passthru(fd, &cmd, NULL); + ret = nvme_submit_admin_passthru(dev_fd(dev), &cmd, NULL); if( ret != WDC_STATUS_SUCCESS) { fprintf(stderr, "ERROR : WDC : VUReadBuffer() failed, "); @@ -8388,7 +8497,7 @@ static int wdc_de_VU_read_buffer(int fd, __u32 fileId, __u16 spiDestn, __u32 off return ret; } -static int wdc_get_log_dir_max_entries(int fd, __u32* maxNumOfEntries) +static int wdc_get_log_dir_max_entries(struct nvme_dev *dev, __u32* maxNumOfEntries) { int ret = WDC_STATUS_FAILURE; __u32 headerPayloadSize = 0; @@ -8398,13 +8507,13 @@ static int wdc_get_log_dir_max_entries(int fd, __u32* maxNumOfEntries) __u16 fileOffset = 0; - if (!fd || !maxNumOfEntries) + if (!dev || !maxNumOfEntries) { ret = WDC_STATUS_INVALID_PARAMETER; return ret; } /* 1.Get log directory first four bytes */ - if (WDC_STATUS_SUCCESS != (ret = wdc_de_VU_read_size(fd, 0, 5, (__u32*)&headerPayloadSize))) + if (WDC_STATUS_SUCCESS != (ret = wdc_de_VU_read_size(dev, 0, 5, (__u32*)&headerPayloadSize))) { fprintf(stderr, "ERROR : WDC : %s: Failed to get headerPayloadSize from file directory 0x%x\n", __func__, ret); @@ -8415,7 +8524,7 @@ static int wdc_get_log_dir_max_entries(int fd, __u32* maxNumOfEntries) fileIdOffsetsBuffer = (__u8*)calloc(1, fileIdOffsetsBufferSize); /* 2.Read to get file offsets */ - if (WDC_STATUS_SUCCESS != (ret = wdc_de_VU_read_buffer(fd, 0, 5, 0, fileIdOffsetsBuffer, &fileIdOffsetsBufferSize))) + if (WDC_STATUS_SUCCESS != (ret = wdc_de_VU_read_buffer(dev, 0, 5, 0, fileIdOffsetsBuffer, &fileIdOffsetsBufferSize))) { fprintf(stderr, "ERROR : WDC : %s: Failed to get fileIdOffsets from file directory 0x%x\n", __func__, ret); @@ -8455,7 +8564,7 @@ static WDC_DRIVE_ESSENTIAL_TYPE wdc_get_essential_type(__u8 fileName[]) return essentialType; } -static int wdc_fetch_log_directory(int fd, PWDC_DE_VU_LOG_DIRECTORY directory) +static int wdc_fetch_log_directory(struct nvme_dev *dev, PWDC_DE_VU_LOG_DIRECTORY directory) { int ret = WDC_STATUS_FAILURE; __u8 *fileOffset = NULL; @@ -8466,12 +8575,12 @@ static int wdc_fetch_log_directory(int fd, PWDC_DE_VU_LOG_DIRECTORY directory) __u32 entryId = 0; __u32 fileDirectorySize = 0; - if (!fd || !directory) { + if (!dev || !directory) { ret = WDC_STATUS_INVALID_PARAMETER; goto end; } - ret = wdc_de_VU_read_size(fd, 0, 5, &fileDirectorySize); + ret = wdc_de_VU_read_size(dev, 0, 5, &fileDirectorySize); if (WDC_STATUS_SUCCESS != ret) { fprintf(stderr, "ERROR : WDC : %s: Failed to get filesystem directory size, ret = %d\n", @@ -8480,7 +8589,7 @@ static int wdc_fetch_log_directory(int fd, PWDC_DE_VU_LOG_DIRECTORY directory) } fileDirectory = (__u8*)calloc(1, fileDirectorySize); - ret = wdc_de_VU_read_buffer(fd, 0, 5, 0, fileDirectory, &fileDirectorySize); + ret = wdc_de_VU_read_buffer(dev, 0, 5, 0, fileDirectory, &fileDirectorySize); if (WDC_STATUS_SUCCESS != ret) { fprintf(stderr, "ERROR : WDC : %s: Failed to get filesystem directory, ret = %d\n", @@ -8533,7 +8642,8 @@ end: return ret; } -static int wdc_fetch_log_file_from_device(int fd, __u32 fileId, __u16 spiDestn, __u64 fileSize, __u8* dataBuffer) +static int wdc_fetch_log_file_from_device(struct nvme_dev *dev, __u32 fileId, + __u16 spiDestn, __u64 fileSize, __u8* dataBuffer) { int ret = WDC_STATUS_FAILURE; __u32 chunckSize = WDC_DE_VU_READ_BUFFER_STANDARD_OFFSET; @@ -8541,13 +8651,13 @@ static int wdc_fetch_log_file_from_device(int fd, __u32 fileId, __u16 spiDestn, __u32 buffSize = 0; __u64 offsetIdx = 0; - if (!fd || !dataBuffer || !fileSize) + if (!dev || !dataBuffer || !fileSize) { ret = WDC_STATUS_INVALID_PARAMETER; goto end; } - if (wdc_get_max_transfer_len(fd, &maximumTransferLength) < 0) { + if (wdc_get_max_transfer_len(dev, &maximumTransferLength) < 0) { ret = WDC_STATUS_FAILURE; goto end; } @@ -8565,7 +8675,7 @@ static int wdc_fetch_log_file_from_device(int fd, __u32 fileId, __u16 spiDestn, if (((offsetIdx * chunckSize) + buffSize) > fileSize) buffSize = (__u32)(fileSize - (offsetIdx * chunckSize)); /* Limitation in VU read buffer - offsetIdx and bufferSize are not greater than u32 */ - ret = wdc_de_VU_read_buffer(fd, fileId, spiDestn, + ret = wdc_de_VU_read_buffer(dev, fileId, spiDestn, (__u32)((offsetIdx * chunckSize) / sizeof(__u32)), dataBuffer + (offsetIdx * chunckSize), &buffSize); if (ret != WDC_STATUS_SUCCESS) { @@ -8576,7 +8686,7 @@ static int wdc_fetch_log_file_from_device(int fd, __u32 fileId, __u16 spiDestn, } } else { buffSize = (__u32)fileSize; - ret = wdc_de_VU_read_buffer(fd, fileId, spiDestn, + ret = wdc_de_VU_read_buffer(dev, fileId, spiDestn, (__u32)((offsetIdx * chunckSize) / sizeof(__u32)), dataBuffer, &buffSize); if (ret != WDC_STATUS_SUCCESS) { @@ -8589,7 +8699,7 @@ static int wdc_fetch_log_file_from_device(int fd, __u32 fileId, __u16 spiDestn, return ret; } -static int wdc_de_get_dump_trace(int fd, char * filePath, __u16 binFileNameLen, char *binFileName) +static int wdc_de_get_dump_trace(struct nvme_dev *dev, char * filePath, __u16 binFileNameLen, char *binFileName) { int ret = WDC_STATUS_FAILURE; __u8 *readBuffer = NULL; @@ -8604,19 +8714,19 @@ static int wdc_de_get_dump_trace(int fd, char * filePath, __u16 binFileNameLen, __u16 i = 0; __u32 maximumTransferLength = 0; - if (!fd || !binFileName || !filePath) + if (!dev || !binFileName || !filePath) { ret = WDC_STATUS_INVALID_PARAMETER; return ret; } - if (wdc_get_max_transfer_len(fd, &maximumTransferLength) < 0) + if (wdc_get_max_transfer_len(dev, &maximumTransferLength) < 0) return WDC_STATUS_FAILURE; do { /* Get dumptrace size */ - ret = wdc_de_VU_read_size(fd, 0, WDC_DE_DUMPTRACE_DESTINATION, &dumptraceSize); + ret = wdc_de_VU_read_size(dev, 0, WDC_DE_DUMPTRACE_DESTINATION, &dumptraceSize); if (ret != WDC_STATUS_SUCCESS) { fprintf(stderr, "ERROR : WDC : %s: wdc_de_VU_read_size failed with ret = %d\n", @@ -8665,7 +8775,7 @@ static int wdc_de_get_dump_trace(int fd, char * filePath, __u16 binFileNameLen, readBufferLen = lastPktReadBufferLen; } - ret = wdc_de_VU_read_buffer(fd, 0, WDC_DE_DUMPTRACE_DESTINATION, 0, readBuffer + offset, &readBufferLen); + ret = wdc_de_VU_read_buffer(dev, 0, WDC_DE_DUMPTRACE_DESTINATION, 0, readBuffer + offset, &readBufferLen); if (ret != WDC_STATUS_SUCCESS) { fprintf(stderr, "ERROR : WDC : %s: wdc_de_VU_read_buffer failed, ret = %d on offset 0x%x\n", @@ -8692,7 +8802,8 @@ static int wdc_de_get_dump_trace(int fd, char * filePath, __u16 binFileNameLen, return ret; } -static int wdc_do_drive_essentials(nvme_root_t r, int fd, char *dir, char *key) +static int wdc_do_drive_essentials(nvme_root_t r, struct nvme_dev *dev, + char *dir, char *key) { int ret = 0; void *retPtr; @@ -8732,7 +8843,7 @@ static int wdc_do_drive_essentials(nvme_root_t r, int fd, char *dir, char *key) memset(tarCmd,0,sizeof(tarCmd)); memset(&timeInfo,0,sizeof(timeInfo)); - if (wdc_get_serial_and_fw_rev(fd, (char *)idSerialNo, (char *)idFwRev)) + if (wdc_get_serial_and_fw_rev(dev, (char *)idSerialNo, (char *)idFwRev)) { fprintf(stderr, "ERROR : WDC : get serial # and fw revision failed\n"); return -1; @@ -8785,7 +8896,7 @@ static int wdc_do_drive_essentials(nvme_root_t r, int fd, char *dir, char *key) /* Get Identify Controller Data */ memset(&ctrl, 0, sizeof (struct nvme_id_ctrl)); - ret = nvme_identify_ctrl(fd, &ctrl); + ret = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (ret) { fprintf(stderr, "ERROR : WDC : nvme_identify_ctrl() failed, ret = %d\n", ret); return -1; @@ -8796,7 +8907,7 @@ static int wdc_do_drive_essentials(nvme_root_t r, int fd, char *dir, char *key) } memset(&ns, 0, sizeof (struct nvme_id_ns)); - ret = nvme_identify_ns(fd, 1, &ns); + ret = nvme_identify_ns(dev_fd(dev), 1, &ns); if (ret) { fprintf(stderr, "ERROR : WDC : nvme_identify_ns() failed, ret = %d\n", ret); } else { @@ -8811,7 +8922,8 @@ static int wdc_do_drive_essentials(nvme_root_t r, int fd, char *dir, char *key) dataBuffer = calloc(1, elogBufferSize); elogBuffer = (struct nvme_error_log_page *)dataBuffer; - ret = nvme_get_log_error(fd, elogNumEntries, false, elogBuffer); + ret = nvme_get_log_error(dev_fd(dev), elogNumEntries, false, + elogBuffer); if (ret) { fprintf(stderr, "ERROR : WDC : nvme_error_log() failed, ret = %d\n", ret); } else { @@ -8825,7 +8937,8 @@ static int wdc_do_drive_essentials(nvme_root_t r, int fd, char *dir, char *key) /* Get Smart log page */ memset(&smart_log, 0, sizeof (struct nvme_smart_log)); - ret = nvme_get_log_smart(fd, NVME_NSID_ALL, false, &smart_log); + ret = nvme_get_log_smart(dev_fd(dev), NVME_NSID_ALL, false, + &smart_log); if (ret) { fprintf(stderr, "ERROR : WDC : nvme_smart_log() failed, ret = %d\n", ret); } else { @@ -8836,7 +8949,7 @@ static int wdc_do_drive_essentials(nvme_root_t r, int fd, char *dir, char *key) /* Get FW Slot log page */ memset(&fw_log, 0, sizeof (struct nvme_firmware_slot)); - ret = nvme_get_log_fw_slot(fd, false, &fw_log); + ret = nvme_get_log_fw_slot(dev_fd(dev), false, &fw_log); if (ret) { fprintf(stderr, "ERROR : WDC : nvme_fw_log() failed, ret = %d\n", ret); } else { @@ -8856,8 +8969,9 @@ static int wdc_do_drive_essentials(nvme_root_t r, int fd, char *dir, char *key) dataBuffer = calloc(1, dataBufferSize); memset(dataBuffer, 0, dataBufferSize); - ret = nvme_get_log_simple(fd, deVULogPagesList[vuLogIdx].logPageId, - dataBufferSize, dataBuffer); + ret = nvme_get_log_simple(dev_fd(dev), + deVULogPagesList[vuLogIdx].logPageId, + dataBufferSize, dataBuffer); if (ret) { fprintf(stderr, "ERROR : WDC : nvme_get_log() for log page 0x%x failed, ret = %d\n", deVULogPagesList[vuLogIdx].logPageId, ret); @@ -8881,8 +8995,11 @@ static int wdc_do_drive_essentials(nvme_root_t r, int fd, char *dir, char *key) /* skipping LbaRangeType as it is an optional nvme command and not supported */ if (deFeatureIdList[listIdx].featureId == FID_LBA_RANGE_TYPE) continue; - ret = nvme_get_features_data(fd, deFeatureIdList[listIdx].featureId, WDC_DE_GLOBAL_NSID, - sizeof(featureIdBuff), &featureIdBuff, &result); + ret = nvme_get_features_data(dev_fd(dev), + (enum nvme_features_id)deFeatureIdList[listIdx].featureId, + WDC_DE_GLOBAL_NSID, + sizeof(featureIdBuff), + &featureIdBuff, &result); if (ret) { fprintf(stderr, "ERROR : WDC : nvme_get_feature id 0x%x failed, ret = %d\n", @@ -8896,7 +9013,7 @@ static int wdc_do_drive_essentials(nvme_root_t r, int fd, char *dir, char *key) } /* Read Debug Directory */ - ret = wdc_get_log_dir_max_entries(fd, &maxNumOfVUFiles); + ret = wdc_get_log_dir_max_entries(dev, &maxNumOfVUFiles); if (ret == WDC_STATUS_SUCCESS) { memset(&deEssentialsList, 0, sizeof(deEssentialsList)); @@ -8904,7 +9021,7 @@ static int wdc_do_drive_essentials(nvme_root_t r, int fd, char *dir, char *key) deEssentialsList.maxNumLogEntries = maxNumOfVUFiles; /* Fetch VU File Directory */ - ret = wdc_fetch_log_directory(fd, &deEssentialsList); + ret = wdc_fetch_log_directory(dev, &deEssentialsList); if (ret == WDC_STATUS_SUCCESS) { /* Get Debug Data Files */ @@ -8918,7 +9035,7 @@ static int wdc_do_drive_essentials(nvme_root_t r, int fd, char *dir, char *key) } else { /* Fetch Log File Data */ dataBuffer = (char *)calloc(1, (size_t)deEssentialsList.logEntry[listIdx].metaData.fileSize); - ret = wdc_fetch_log_file_from_device(fd, deEssentialsList.logEntry[listIdx].metaData.fileID, WDC_DE_DESTN_SPI, deEssentialsList.logEntry[listIdx].metaData.fileSize, + ret = wdc_fetch_log_file_from_device(dev, deEssentialsList.logEntry[listIdx].metaData.fileID, WDC_DE_DESTN_SPI, deEssentialsList.logEntry[listIdx].metaData.fileSize, (__u8 *)dataBuffer); /* Write databuffer to file */ @@ -8954,7 +9071,7 @@ static int wdc_do_drive_essentials(nvme_root_t r, int fd, char *dir, char *key) /* Get Dump Trace Data */ wdc_UtilsSnprintf(fileName, MAX_PATH_LEN, "%s%s%s_%s_%s.bin", (char*)bufferFolderPath, WDC_DE_PATH_SEPARATOR, "dumptrace", serialNo, timeString); - if (WDC_STATUS_SUCCESS != (ret = wdc_de_get_dump_trace(fd, (char*)bufferFolderPath, 0, fileName))) + if (WDC_STATUS_SUCCESS != (ret = wdc_de_get_dump_trace(dev, (char*)bufferFolderPath, 0, fileName))) { fprintf(stderr, "ERROR : WDC : wdc_de_get_dump_trace failed, ret = %d\n", ret); } @@ -8987,10 +9104,11 @@ static int wdc_drive_essentials(int argc, char **argv, struct command *command, char *dirName = "Output directory pathname."; char d[PATH_MAX] = {0}; char k[PATH_MAX] = {0}; - char *d_ptr; - int fd, ret; - nvme_root_t r; __u64 capabilities = 0; + struct nvme_dev *dev; + nvme_root_t r; + char *d_ptr; + int ret; struct config { char *dirName; @@ -9006,12 +9124,12 @@ static int wdc_drive_essentials(int argc, char **argv, struct command *command, }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_DRIVE_ESSENTIALS) != WDC_DRIVE_CAP_DRIVE_ESSENTIALS) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); ret = -1; @@ -9025,14 +9143,14 @@ static int wdc_drive_essentials(int argc, char **argv, struct command *command, d_ptr = NULL; } - ret = wdc_do_drive_essentials(r, fd, d_ptr, k); + ret = wdc_do_drive_essentials(r, dev, d_ptr, k); out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } -static int wdc_do_drive_resize(int fd, uint64_t new_size) +static int wdc_do_drive_resize(struct nvme_dev *dev, uint64_t new_size) { int ret; struct nvme_passthru_cmd admin_cmd; @@ -9043,11 +9161,11 @@ static int wdc_do_drive_resize(int fd, uint64_t new_size) WDC_NVME_DRIVE_RESIZE_CMD); admin_cmd.cdw13 = new_size; - ret = nvme_submit_admin_passthru(fd, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(dev_fd(dev), &admin_cmd, NULL); return ret; } -static int wdc_do_namespace_resize(int fd, __u32 nsid, __u32 op_option) +static int wdc_do_namespace_resize(struct nvme_dev *dev, __u32 nsid, __u32 op_option) { int ret; struct nvme_passthru_cmd admin_cmd; @@ -9057,11 +9175,11 @@ static int wdc_do_namespace_resize(int fd, __u32 nsid, __u32 op_option) admin_cmd.nsid = nsid; admin_cmd.cdw10 = op_option; - ret = nvme_submit_admin_passthru(fd, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(dev_fd(dev), &admin_cmd, NULL); return ret; } -static int wdc_do_drive_info(int fd, __u32 *result) +static int wdc_do_drive_info(struct nvme_dev *dev, __u32 *result) { int ret; struct nvme_passthru_cmd admin_cmd; @@ -9071,7 +9189,7 @@ static int wdc_do_drive_info(int fd, __u32 *result) admin_cmd.cdw12 = ((WDC_NVME_DRIVE_INFO_SUBCMD << WDC_NVME_SUBCMD_SHIFT) | WDC_NVME_DRIVE_INFO_CMD); - ret = nvme_submit_admin_passthru(fd, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(dev_fd(dev), &admin_cmd, NULL); if (!ret && result) *result = admin_cmd.result; @@ -9084,9 +9202,10 @@ static int wdc_drive_resize(int argc, char **argv, { const char *desc = "Send a Resize command."; const char *size = "The new size (in GB) to resize the drive to."; - nvme_root_t r; uint64_t capabilities = 0; - int fd, ret; + struct nvme_dev *dev; + nvme_root_t r; + int ret; struct config { uint64_t size; @@ -9101,15 +9220,15 @@ static int wdc_drive_resize(int argc, char **argv, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - wdc_check_device(r, fd); - capabilities = wdc_get_drive_capabilities(r, fd); + wdc_check_device(r, dev); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_RESIZE) == WDC_DRIVE_CAP_RESIZE) { - ret = wdc_do_drive_resize(fd, cfg.size); + ret = wdc_do_drive_resize(dev, cfg.size); } else { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); ret = -1; @@ -9120,7 +9239,7 @@ static int wdc_drive_resize(int argc, char **argv, nvme_show_status(ret); nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -9130,9 +9249,10 @@ static int wdc_namespace_resize(int argc, char **argv, const char *desc = "Send a Namespace Resize command."; const char *namespace_id = "The namespace id to resize."; const char *op_option = "The over provisioning option to set for namespace."; - nvme_root_t r; uint64_t capabilities = 0; - int fd, ret; + struct nvme_dev *dev; + nvme_root_t r; + int ret; struct config { __u32 namespace_id; @@ -9150,9 +9270,9 @@ static int wdc_namespace_resize(int argc, char **argv, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; if ((cfg.op_option != 0x1) && (cfg.op_option != 0x2) && @@ -9160,15 +9280,16 @@ static int wdc_namespace_resize(int argc, char **argv, (cfg.op_option != 0xF)) { fprintf(stderr, "ERROR : WDC: unsupported OP option parameter\n"); - close(fd); + dev_close(dev); return -1; } r = nvme_scan(NULL); - wdc_check_device(r, fd); - capabilities = wdc_get_drive_capabilities(r, fd); + wdc_check_device(r, dev); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_NS_RESIZE) == WDC_DRIVE_CAP_NS_RESIZE) { - ret = wdc_do_namespace_resize(fd, cfg.namespace_id, cfg.op_option); + ret = wdc_do_namespace_resize(dev, cfg.namespace_id, + cfg.op_option); if (ret != 0) printf("ERROR : WDC: Namespace Resize of namespace id 0x%x, op option 0x%x failed\n", cfg.namespace_id, cfg.op_option); @@ -9179,7 +9300,7 @@ static int wdc_namespace_resize(int argc, char **argv, nvme_show_status(ret); nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -9189,8 +9310,8 @@ static int wdc_reason_identifier(int argc, char **argv, const char *desc = "Retrieve telemetry log reason identifier."; const char *log_id = "Log ID to retrieve - host - 7 or controller - 8"; const char *fname = "File name to save raw binary identifier"; + struct nvme_dev *dev; nvme_root_t r; - int fd; int ret; uint64_t capabilities = 0; char f[PATH_MAX] = {0}; @@ -9214,10 +9335,10 @@ static int wdc_reason_identifier(int argc, char **argv, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); + ret = parse_and_open(&dev, argc, argv, desc, opts); - if (fd < 0) - return fd; + if (ret) + return ret; r = nvme_scan(NULL); @@ -9250,7 +9371,7 @@ static int wdc_reason_identifier(int argc, char **argv, else snprintf(fileSuffix, PATH_MAX, "_error_reason_identifier_host_%s", (char*)timeStamp); - if (wdc_get_serial_name(fd, f, PATH_MAX, fileSuffix) == -1) { + if (wdc_get_serial_name(dev, f, PATH_MAX, fileSuffix) == -1) { fprintf(stderr, "ERROR : WDC: failed to generate file name\n"); ret = -1; goto close_fd; @@ -9265,9 +9386,9 @@ static int wdc_reason_identifier(int argc, char **argv, fprintf(stderr, "%s: filename = %s\n", __func__, f); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_REASON_ID) == WDC_DRIVE_CAP_REASON_ID) { - ret = wdc_do_get_reason_id(fd, f, cfg.log_id); + ret = wdc_do_get_reason_id(dev, f, cfg.log_id); } else { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); ret = -1; @@ -9276,7 +9397,7 @@ static int wdc_reason_identifier(int argc, char **argv, nvme_show_status(ret); close_fd: - close(fd); + dev_close(dev); nvme_free_tree(r); return ret; } @@ -9328,7 +9449,7 @@ static int wdc_log_page_directory(int argc, char **argv, struct command *command struct plugin *plugin) { const char *desc = "Retrieve Log Page Directory."; - int fd; + struct nvme_dev *dev; int ret = 0; nvme_root_t r; __u64 capabilities = 0; @@ -9350,36 +9471,36 @@ static int wdc_log_page_directory(int argc, char **argv, struct command *command OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; ret = validate_output_format(cfg.output_format); if (ret < 0) { fprintf(stderr, "%s: ERROR : WDC : invalid output format\n", __func__); - close(fd); + dev_close(dev); return ret; } ret = 0; r = nvme_scan(NULL); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_LOG_PAGE_DIR) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); ret = -1; } else { - ret = wdc_get_pci_ids(r, &device_id, &read_vendor_id); + ret = wdc_get_pci_ids(r, dev, &device_id, &read_vendor_id); log_id = (device_id == WDC_NVME_ZN350_DEV_ID || device_id == WDC_NVME_ZN350_DEV_ID_1) ? WDC_NVME_GET_DEV_MGMNT_LOG_PAGE_OPCODE_C8 : WDC_NVME_GET_DEV_MGMNT_LOG_PAGE_OPCODE; /* verify the 0xC2 Device Manageability log page is supported */ - if (wdc_nvme_check_supported_log_page(r, fd, log_id) == false) { + if (wdc_nvme_check_supported_log_page(r, dev, log_id) == false) { fprintf(stderr, "%s: ERROR : WDC : 0x%x Log Page not supported\n", __func__, log_id); ret = -1; goto out; } - if (get_dev_mgment_cbs_data(r, fd, WDC_C2_LOG_PAGES_SUPPORTED_ID, (void *)&cbs_data)) { + if (get_dev_mgment_cbs_data(r, dev, WDC_C2_LOG_PAGES_SUPPORTED_ID, (void *)&cbs_data)) { if (cbs_data != NULL) { printf("Log Page Directory\n"); /* print the supported pages */ @@ -9416,11 +9537,11 @@ static int wdc_log_page_directory(int argc, char **argv, struct command *command out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } -static int wdc_get_drive_reason_id(int fd, char *drive_reason_id, size_t len) +static int wdc_get_drive_reason_id(struct nvme_dev *dev, char *drive_reason_id, size_t len) { int i, j; int ret; @@ -9432,7 +9553,7 @@ static int wdc_get_drive_reason_id(int fd, char *drive_reason_id, size_t len) j = sizeof (ctrl.mn) - 1; memset(drive_reason_id, 0, len); memset(&ctrl, 0, sizeof (struct nvme_id_ctrl)); - ret = nvme_identify_ctrl(fd, &ctrl); + ret = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (ret) { fprintf(stderr, "ERROR : WDC : nvme_identify_ctrl() failed " "0x%x\n", ret); @@ -9459,7 +9580,7 @@ static int wdc_get_drive_reason_id(int fd, char *drive_reason_id, size_t len) return 0; } -static int wdc_save_reason_id(int fd, __u8 *rsn_ident, int size) +static int wdc_save_reason_id(struct nvme_dev *dev, __u8 *rsn_ident, int size) { int ret = 0; char *reason_id_file; @@ -9467,7 +9588,7 @@ static int wdc_save_reason_id(int fd, __u8 *rsn_ident, int size) char reason_id_path[PATH_MAX] = WDC_REASON_ID_PATH_NAME; struct stat st = {0}; - if (wdc_get_drive_reason_id(fd, drive_reason_id, PATH_MAX) == -1) { + if (wdc_get_drive_reason_id(dev, drive_reason_id, PATH_MAX) == -1) { fprintf(stderr, "%s: ERROR : failed to get drive reason id\n", __func__); return -1; } @@ -9494,14 +9615,14 @@ static int wdc_save_reason_id(int fd, __u8 *rsn_ident, int size) return ret; } -static int wdc_clear_reason_id(int fd) +static int wdc_clear_reason_id(struct nvme_dev *dev) { int ret = -1; int verify_file; char *reason_id_file; char drive_reason_id[PATH_MAX] = {0}; - if (wdc_get_drive_reason_id(fd, drive_reason_id, PATH_MAX) == -1) { + if (wdc_get_drive_reason_id(dev, drive_reason_id, PATH_MAX) == -1) { fprintf(stderr, "%s: ERROR : failed to get drive reason id\n", __func__); return -1; } @@ -9527,14 +9648,15 @@ static int wdc_clear_reason_id(int fd) return ret; } -static int wdc_dump_telemetry_hdr(int fd, int log_id, struct nvme_telemetry_log *log_hdr) +static int wdc_dump_telemetry_hdr(struct nvme_dev *dev, int log_id, struct nvme_telemetry_log *log_hdr) { int ret = 0; if (log_id == NVME_LOG_LID_TELEMETRY_HOST) - ret = nvme_get_log_create_telemetry_host(fd, log_hdr); + ret = nvme_get_log_create_telemetry_host(dev_fd(dev), log_hdr); else - ret = nvme_get_log_telemetry_ctrl(fd, false, 0, 512, (void *)log_hdr); + ret = nvme_get_log_telemetry_ctrl(dev_fd(dev), false, 0, 512, + (void *)log_hdr); if (ret < 0) perror("get-telemetry-log"); @@ -9546,7 +9668,7 @@ static int wdc_dump_telemetry_hdr(int fd, int log_id, struct nvme_telemetry_log return ret; } -static int wdc_do_get_reason_id(int fd, char *file, int log_id) +static int wdc_do_get_reason_id(struct nvme_dev *dev, char *file, int log_id) { int ret; struct nvme_telemetry_log *log_hdr; @@ -9561,7 +9683,7 @@ static int wdc_do_get_reason_id(int fd, char *file, int log_id) } memset(log_hdr, 0, log_hdr_size); - ret = wdc_dump_telemetry_hdr(fd, log_id, log_hdr); + ret = wdc_dump_telemetry_hdr(dev, log_id, log_hdr); if (ret != 0) { fprintf(stderr, "%s: ERROR : get telemetry header failed, ret : %d\n", __func__, ret); ret = -1; @@ -9571,7 +9693,7 @@ static int wdc_do_get_reason_id(int fd, char *file, int log_id) reason_id_size = sizeof(log_hdr->rsnident); if (log_id == NVME_LOG_LID_TELEMETRY_CTRL) - wdc_save_reason_id(fd, log_hdr->rsnident, reason_id_size); + wdc_save_reason_id(dev, log_hdr->rsnident, reason_id_size); ret = wdc_create_log_file(file, (__u8 *)log_hdr->rsnident, reason_id_size); @@ -9592,10 +9714,12 @@ static void wdc_print_nand_stats_normal(__u16 version, void *data) { case 0: printf(" NAND Statistics :- \n"); - printf(" NAND Writes TLC (Bytes) %.0Lf\n", - int128_to_double(nand_stats->nand_write_tlc)); - printf(" NAND Writes SLC (Bytes) %.0Lf\n", - int128_to_double(nand_stats->nand_write_slc)); + printf(" NAND Writes TLC (Bytes) %s\n", + uint128_t_to_string( + le128_to_cpu(nand_stats->nand_write_tlc))); + printf(" NAND Writes SLC (Bytes) %s\n", + uint128_t_to_string( + le128_to_cpu(nand_stats->nand_write_slc))); printf(" NAND Program Failures %"PRIu32"\n", (uint32_t)le32_to_cpu(nand_stats->nand_prog_failure)); printf(" NAND Erase Failures %"PRIu32"\n", @@ -9613,10 +9737,12 @@ static void wdc_print_nand_stats_normal(__u16 version, void *data) break; case 3: printf(" NAND Statistics V3:- \n"); - printf(" TLC Units Written %.0Lf\n", - int128_to_double(nand_stats_v3->nand_write_tlc)); - printf(" SLC Units Written %.0Lf\n", - int128_to_double(nand_stats_v3->nand_write_slc)); + printf(" TLC Units Written %s\n", + uint128_t_to_string( + le128_to_cpu(nand_stats_v3->nand_write_tlc))); + printf(" SLC Units Written %s\n", + uint128_t_to_string( + le128_to_cpu(nand_stats_v3->nand_write_slc))); temp_ptr = (__u64 *)nand_stats_v3->bad_nand_block_count; temp_norm = (__u16)(*temp_ptr & 0x000000000000FFFF); temp_raw = ((*temp_ptr & 0xFFFFFFFFFFFF0000) >> 16); @@ -9666,8 +9792,9 @@ static void wdc_print_nand_stats_normal(__u16 version, void *data) le64_to_cpu(nand_stats_v3->security_version_number)); printf(" %% Free Blocks (System) %u\n", nand_stats_v3->percent_free_blocks_system); - printf(" Data Set Management Commands %.0Lf\n", - int128_to_double(nand_stats_v3->trim_completions)); + printf(" Data Set Management Commands %s\n", + uint128_t_to_string( + le128_to_cpu(nand_stats_v3->trim_completions))); printf(" Estimate of Incomplete Trim Data %"PRIu64"\n", le64_to_cpu(nand_stats_v3->trim_completions[16])); printf(" %% of completed trim %u\n", @@ -9685,16 +9812,18 @@ static void wdc_print_nand_stats_normal(__u16 version, void *data) le16_to_cpu(temp_norm)); printf(" Bad System Nand Block Count - Raw %"PRIu64"\n", le64_to_cpu(temp_raw)); - printf(" Endurance Estimate %.0Lf\n", - int128_to_double(nand_stats_v3->endurance_estimate)); + printf(" Endurance Estimate %s\n", + uint128_t_to_string( + le128_to_cpu(nand_stats_v3->endurance_estimate))); printf(" Thermal Throttling Count %u\n", nand_stats_v3->thermal_throttling_st_ct[0]); printf(" Thermal Throttling Status %u\n", nand_stats_v3->thermal_throttling_st_ct[1]); printf(" Unaligned I/O %"PRIu64"\n", le64_to_cpu(nand_stats_v3->unaligned_IO)); - printf(" Physical Media Units Read %.0Lf\n", - int128_to_double(nand_stats_v3->physical_media_units)); + printf(" Physical Media Units Read %s\n", + uint128_t_to_string( + le128_to_cpu(nand_stats_v3->physical_media_units))); printf(" log page version %"PRIu16"\n", le16_to_cpu(nand_stats_v3->log_page_version)); break; @@ -9721,10 +9850,10 @@ static void wdc_print_nand_stats_json(__u16 version, void *data) case 0: - json_object_add_value_double(root, "NAND Writes TLC (Bytes)", - int128_to_double(nand_stats->nand_write_tlc)); - json_object_add_value_double(root, "NAND Writes SLC (Bytes)", - int128_to_double(nand_stats->nand_write_slc)); + json_object_add_value_uint128(root, "NAND Writes TLC (Bytes)", + le128_to_cpu(nand_stats->nand_write_tlc)); + json_object_add_value_uint128(root, "NAND Writes SLC (Bytes)", + le128_to_cpu(nand_stats->nand_write_slc)); json_object_add_value_uint(root, "NAND Program Failures", le32_to_cpu(nand_stats->nand_prog_failure)); json_object_add_value_uint(root, "NAND Erase Failures", @@ -9744,10 +9873,10 @@ static void wdc_print_nand_stats_json(__u16 version, void *data) case 3: - json_object_add_value_double(root, "NAND Writes TLC (Bytes)", - int128_to_double(nand_stats_v3->nand_write_tlc)); - json_object_add_value_double(root, "NAND Writes SLC (Bytes)", - int128_to_double(nand_stats_v3->nand_write_slc)); + json_object_add_value_uint128(root, "NAND Writes TLC (Bytes)", + le128_to_cpu(nand_stats_v3->nand_write_tlc)); + json_object_add_value_uint128(root, "NAND Writes SLC (Bytes)", + le128_to_cpu(nand_stats_v3->nand_write_slc)); temp_ptr = (__u64 *)nand_stats_v3->bad_nand_block_count; temp_norm = (__u16)(*temp_ptr & 0x000000000000FFFF); temp_raw = ((*temp_ptr & 0xFFFFFFFFFFFF0000) >> 16); @@ -9797,8 +9926,8 @@ static void wdc_print_nand_stats_json(__u16 version, void *data) le64_to_cpu(nand_stats_v3->security_version_number)); json_object_add_value_uint(root, "% Free Blocks (System)", nand_stats_v3->percent_free_blocks_system); - json_object_add_value_double(root, "Data Set Management Commands", - int128_to_double(nand_stats_v3->trim_completions)); + json_object_add_value_uint128(root, "Data Set Management Commands", + le128_to_cpu(nand_stats_v3->trim_completions)); json_object_add_value_uint64(root, "Estimate of Incomplete Trim Data", le64_to_cpu(nand_stats_v3->trim_completions[16])); json_object_add_value_uint(root, "%% of completed trim", @@ -9816,16 +9945,16 @@ static void wdc_print_nand_stats_json(__u16 version, void *data) le16_to_cpu(temp_norm)); json_object_add_value_uint64(root, "Bad System Nand Block Count - Raw", le64_to_cpu(temp_raw)); - json_object_add_value_double(root, "Endurance Estimate", - int128_to_double(nand_stats_v3->endurance_estimate)); + json_object_add_value_uint128(root, "Endurance Estimate", + le128_to_cpu(nand_stats_v3->endurance_estimate)); json_object_add_value_uint(root, "Thermal Throttling Status", nand_stats_v3->thermal_throttling_st_ct[0]); json_object_add_value_uint(root, "Thermal Throttling Count", nand_stats_v3->thermal_throttling_st_ct[1]); json_object_add_value_uint64(root, "Unaligned I/O", le64_to_cpu(nand_stats_v3->unaligned_IO)); - json_object_add_value_double(root, "Physical Media Units Read", - int128_to_double(nand_stats_v3->physical_media_units)); + json_object_add_value_uint128(root, "Physical Media Units Read", + le128_to_cpu(nand_stats_v3->physical_media_units)); json_object_add_value_uint(root, "log page version", le16_to_cpu(nand_stats_v3->log_page_version)); @@ -9926,14 +10055,15 @@ static void wdc_print_pcie_stats_json(struct wdc_vs_pcie_stats *pcie_stats) json_free_object(root); } -static int wdc_do_vs_nand_stats_sn810_2(int fd, char *format) +static int wdc_do_vs_nand_stats_sn810_2(struct nvme_dev *dev, char *format) { int ret; int fmt = -1; uint8_t *data = NULL; data = NULL; - ret = nvme_get_ext_smart_cloud_log(fd, &data, 0, NVME_NSID_ALL); + ret = nvme_get_ext_smart_cloud_log(dev_fd(dev), &data, 0, + NVME_NSID_ALL); if (ret) { fprintf(stderr, "ERROR : WDC : %s : Failed to retreive NAND stats\n", __func__); @@ -9963,7 +10093,7 @@ out: return ret; } -static int wdc_do_vs_nand_stats(int fd, char *format) +static int wdc_do_vs_nand_stats(struct nvme_dev *dev, char *format) { int ret; int fmt = -1; @@ -9976,8 +10106,8 @@ static int wdc_do_vs_nand_stats(int fd, char *format) goto out; } - ret = nvme_get_log_simple(fd, WDC_NVME_NAND_STATS_LOG_ID, - WDC_NVME_NAND_STATS_SIZE, (void*)output); + ret = nvme_get_log_simple(dev_fd(dev), WDC_NVME_NAND_STATS_LOG_ID, + WDC_NVME_NAND_STATS_SIZE, (void*)output); if (ret) { fprintf(stderr, "ERROR : WDC : %s : Failed to retreive NAND stats\n", __func__); goto out; @@ -10011,12 +10141,11 @@ static int wdc_vs_nand_stats(int argc, char **argv, struct command *command, struct plugin *plugin) { const char *desc = "Retrieve NAND statistics."; - - int fd; - int ret = 0; + struct nvme_dev *dev; nvme_root_t r; __u64 capabilities = 0; uint32_t read_device_id = 0, read_vendor_id = 0; + int ret; struct config { char *output_format; @@ -10031,18 +10160,18 @@ static int wdc_vs_nand_stats(int argc, char **argv, struct command *command, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_NAND_STATS) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); ret = -1; } else { - ret = wdc_get_pci_ids(r, &read_device_id, &read_vendor_id); + ret = wdc_get_pci_ids(r, dev, &read_device_id, &read_vendor_id); if (ret < 0) { fprintf(stderr, "ERROR : WDC: %s: failure to get pci ids, ret = %d\n", __func__, ret); @@ -10051,10 +10180,11 @@ static int wdc_vs_nand_stats(int argc, char **argv, struct command *command, switch (read_device_id) { case WDC_NVME_SN820CL_DEV_ID: - ret = wdc_do_vs_nand_stats_sn810_2(fd, cfg.output_format); + ret = wdc_do_vs_nand_stats_sn810_2(dev, + cfg.output_format); break; default: - ret = wdc_do_vs_nand_stats(fd, cfg.output_format); + ret = wdc_do_vs_nand_stats(dev, cfg.output_format); break; } } @@ -10063,11 +10193,11 @@ static int wdc_vs_nand_stats(int argc, char **argv, struct command *command, fprintf(stderr, "ERROR : WDC : Failure reading NAND statistics, ret = %d\n", ret); nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } -static int wdc_do_vs_pcie_stats(int fd, +static int wdc_do_vs_pcie_stats(struct nvme_dev *dev, struct wdc_vs_pcie_stats *pcieStatsPtr) { int ret; @@ -10079,7 +10209,7 @@ static int wdc_do_vs_pcie_stats(int fd, admin_cmd.addr = (__u64)(uintptr_t)pcieStatsPtr; admin_cmd.data_len = pcie_stats_size; - ret = nvme_submit_admin_passthru(fd, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(dev_fd(dev), &admin_cmd, NULL); return ret; } @@ -10088,8 +10218,7 @@ static int wdc_vs_pcie_stats(int argc, char **argv, struct command *command, struct plugin *plugin) { const char *desc = "Retrieve PCIE statistics."; - - int fd; + struct nvme_dev *dev; int ret = 0; nvme_root_t r; __u64 capabilities = 0; @@ -10111,9 +10240,9 @@ static int wdc_vs_pcie_stats(int argc, char **argv, struct command *command, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); @@ -10133,13 +10262,13 @@ static int wdc_vs_pcie_stats(int argc, char **argv, struct command *command, memset((void *)pcieStatsPtr, 0, pcie_stats_size); - capabilities = wdc_get_drive_capabilities(r, fd); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_PCIE_STATS) == 0) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); ret = -1; } else { - ret = wdc_do_vs_pcie_stats(fd, pcieStatsPtr); + ret = wdc_do_vs_pcie_stats(dev, pcieStatsPtr); if (ret) fprintf(stderr, "ERROR : WDC : Failure reading PCIE statistics, ret = 0x%x\n", ret); else { @@ -10159,7 +10288,7 @@ static int wdc_vs_pcie_stats(int argc, char **argv, struct command *command, out: nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -10169,7 +10298,8 @@ static int wdc_vs_drive_info(int argc, char **argv, const char *desc = "Send a vs-drive-info command."; nvme_root_t r; uint64_t capabilities = 0; - int fd, ret; + struct nvme_dev *dev; + int ret; __le32 result; __u16 size; double rev; @@ -10199,31 +10329,31 @@ static int wdc_vs_drive_info(int argc, char **argv, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; fmt = validate_output_format(cfg.output_format); if (fmt < 0) { fprintf(stderr, "ERROR : WDC %s invalid output format\n", __func__); - close(fd); + dev_close(dev); return fmt; } /* get the id ctrl data used to fill in drive info below */ - ret = nvme_identify_ctrl(fd, &ctrl); + ret = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (ret) { fprintf(stderr, "ERROR : WDC %s: Identify Controller failed\n", __func__); - close(fd); + dev_close(dev); return ret; } r = nvme_scan(NULL); - wdc_check_device(r, fd); - capabilities = wdc_get_drive_capabilities(r, fd); + wdc_check_device(r, dev); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_INFO) == WDC_DRIVE_CAP_INFO) { - ret = wdc_get_pci_ids(r, &read_device_id, &read_vendor_id); + ret = wdc_get_pci_ids(r, dev, &read_device_id, &read_vendor_id); if (ret < 0) { fprintf(stderr, "ERROR : WDC: %s: failure to get pci ids, ret = %d\n", __func__, ret); @@ -10247,7 +10377,7 @@ static int wdc_vs_drive_info(int argc, char **argv, case WDC_NVME_SN550_DEV_ID: case WDC_NVME_ZN350_DEV_ID: case WDC_NVME_ZN350_DEV_ID_1: - ret = wdc_do_drive_info(fd, &result); + ret = wdc_do_drive_info(dev, &result); if (!ret) { size = (__u16)((cpu_to_le32(result) & 0xffff0000) >> 16); @@ -10299,7 +10429,8 @@ static int wdc_vs_drive_info(int argc, char **argv, break; case WDC_NVME_SN820CL_DEV_ID: /* Get the Drive HW Rev from the C6 Log page */ - ret = nvme_get_hw_rev_log(fd, &data, 0, NVME_NSID_ALL); + ret = nvme_get_hw_rev_log(dev_fd(dev), &data, 0, + NVME_NSID_ALL); if (ret == 0) { wdc_nvme_hw_rev_log *log_data = (wdc_nvme_hw_rev_log *)data; major_rev = log_data->hw_rev_gdr; @@ -10319,7 +10450,8 @@ static int wdc_vs_drive_info(int argc, char **argv, goto out; } - ret = nvme_get_ext_smart_cloud_log(fd, &data, 0, NVME_NSID_ALL); + ret = nvme_get_ext_smart_cloud_log(dev_fd(dev), &data, + 0, NVME_NSID_ALL); if (ret == 0) { ext_smart_log_ptr = (wdc_nvme_ext_smart_log *)data; @@ -10376,7 +10508,7 @@ static int wdc_vs_drive_info(int argc, char **argv, out: nvme_show_status(ret); nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -10386,12 +10518,12 @@ static int wdc_vs_temperature_stats(int argc, char **argv, const char *desc = "Send a vs-temperature-stats command."; struct nvme_smart_log smart_log; struct nvme_id_ctrl id_ctrl; + struct nvme_dev *dev; nvme_root_t r; uint64_t capabilities = 0; __u32 hctm_tmt; - int fd, ret; int temperature, temp_tmt1, temp_tmt2; - int fmt = -1; + int ret, fmt = -1; struct config { char *output_format; @@ -10406,9 +10538,9 @@ static int wdc_vs_temperature_stats(int argc, char **argv, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; r = nvme_scan(NULL); fmt = validate_output_format(cfg.output_format); @@ -10419,8 +10551,8 @@ static int wdc_vs_temperature_stats(int argc, char **argv, } /* check if command is supported */ - wdc_check_device(r, fd); - capabilities = wdc_get_drive_capabilities(r, fd); + wdc_check_device(r, dev); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_TEMP_STATS) != WDC_DRIVE_CAP_TEMP_STATS) { fprintf(stderr, "ERROR : WDC: unsupported device for this command\n"); ret = -1; @@ -10428,10 +10560,11 @@ static int wdc_vs_temperature_stats(int argc, char **argv, } /* get the temperature stats or report errors */ - ret = nvme_identify_ctrl(fd, &id_ctrl); + ret = nvme_identify_ctrl(dev_fd(dev), &id_ctrl); if (ret != 0) goto out; - ret = nvme_get_log_smart(fd, NVME_NSID_ALL, false, &smart_log); + ret = nvme_get_log_smart(dev_fd(dev), NVME_NSID_ALL, false, + &smart_log); if (ret != 0) goto out; @@ -10439,14 +10572,14 @@ static int wdc_vs_temperature_stats(int argc, char **argv, temperature = ((smart_log.temperature[1] << 8) | smart_log.temperature[0]) - 273; /* retrieve HCTM Thermal Management Temperatures */ - nvme_get_features_simple(fd, 0x10, 0, &hctm_tmt); + nvme_get_features_simple(dev_fd(dev), 0x10, 0, &hctm_tmt); temp_tmt1 = ((hctm_tmt >> 16) & 0xffff) ? ((hctm_tmt >> 16) & 0xffff) - 273 : 0; temp_tmt2 = (hctm_tmt & 0xffff) ? (hctm_tmt & 0xffff) - 273 : 0; if (fmt == NORMAL) { /* print the temperature stats */ printf("Temperature Stats for NVME device:%s namespace-id:%x\n", - devicename, WDC_DE_GLOBAL_NSID); + dev->name, WDC_DE_GLOBAL_NSID); printf("Current Composite Temperature : %d °C\n", temperature); printf("WCTEMP : %"PRIu16" °C\n", id_ctrl.wctemp - 273); @@ -10493,7 +10626,7 @@ static int wdc_vs_temperature_stats(int argc, char **argv, out: nvme_show_status(ret); nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -10501,26 +10634,27 @@ static int wdc_capabilities(int argc, char **argv, struct command *command, struct plugin *plugin) { const char *desc = "Send a capabilities command."; - nvme_root_t r; uint64_t capabilities = 0; - int fd; + struct nvme_dev *dev; + nvme_root_t r; + int ret; OPT_ARGS(opts) = { OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; /* get capabilities */ r = nvme_scan(NULL); - wdc_check_device(r, fd); - capabilities = wdc_get_drive_capabilities(r, fd); + wdc_check_device(r, dev); + capabilities = wdc_get_drive_capabilities(r, dev); /* print command and supported status */ - printf("WDC Plugin Capabilities for NVME device:%s\n", devicename); + printf("WDC Plugin Capabilities for NVME device:%s\n", dev->name); printf("cap-diag : %s\n", capabilities & WDC_DRIVE_CAP_CAP_DIAG ? "Supported" : "Not Supported"); printf("drive-log : %s\n", @@ -10598,7 +10732,7 @@ static int wdc_capabilities(int argc, char **argv, capabilities & WDC_DRIVE_CAP_DEVICE_WAF ? "Supported" : "Not Supported"); printf("capabilities : Supported\n"); nvme_free_tree(r); - close(fd); + dev_close(dev); return 0; } @@ -10606,22 +10740,23 @@ static int wdc_cloud_ssd_plugin_version(int argc, char **argv, struct command *command, struct plugin *plugin) { const char *desc = "Get Cloud SSD Plugin Version command."; - nvme_root_t r; uint64_t capabilities = 0; - int fd; + struct nvme_dev *dev; + nvme_root_t r; + int ret; OPT_ARGS(opts) = { OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; /* get capabilities */ r = nvme_scan(NULL); - wdc_check_device(r, fd); - capabilities = wdc_get_drive_capabilities(r, fd); + wdc_check_device(r, dev); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_CLOUD_SSD_VERSION) == WDC_DRIVE_CAP_CLOUD_SSD_VERSION) { /* print command and supported status */ @@ -10631,7 +10766,7 @@ static int wdc_cloud_ssd_plugin_version(int argc, char **argv, } nvme_free_tree(r); - close(fd); + dev_close(dev); return 0; } @@ -10642,7 +10777,8 @@ static int wdc_cloud_boot_SSD_version(int argc, char **argv, const char *namespace_id = "desired namespace id"; nvme_root_t r; uint64_t capabilities = 0; - int fd, ret = -1; + struct nvme_dev *dev; + int ret; int major = 0, minor = 0; __u8 *data = NULL; wdc_nvme_ext_smart_log *ext_smart_log_ptr = NULL; @@ -10660,18 +10796,19 @@ static int wdc_cloud_boot_SSD_version(int argc, char **argv, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + ret = parse_and_open(&dev, argc, argv, desc, opts); + if (ret) + return ret; /* get capabilities */ r = nvme_scan(NULL); - wdc_check_device(r, fd); - capabilities = wdc_get_drive_capabilities(r, fd); + wdc_check_device(r, dev); + capabilities = wdc_get_drive_capabilities(r, dev); if ((capabilities & WDC_DRIVE_CAP_CLOUD_BOOT_SSD_VERSION) == WDC_DRIVE_CAP_CLOUD_BOOT_SSD_VERSION) { /* Get the 0xC0 Smart Cloud Attribute V1 log data */ - ret = nvme_get_ext_smart_cloud_log(fd, &data, 0, cfg.namespace_id); + ret = nvme_get_ext_smart_cloud_log(dev_fd(dev), &data, 0, + cfg.namespace_id); ext_smart_log_ptr = (wdc_nvme_ext_smart_log *)data; if (ret == 0) { @@ -10693,7 +10830,7 @@ static int wdc_cloud_boot_SSD_version(int argc, char **argv, } nvme_free_tree(r); - close(fd); + dev_close(dev); return ret; } @@ -10704,9 +10841,9 @@ static int wdc_enc_get_log(int argc, char **argv, struct command *command, char *file = "Output file pathname."; char *size = "Data retrieval transfer size."; char *log = "Enclosure Log Page ID."; + struct nvme_dev *dev; FILE *output_fd; int xfer_size = 0; - int fd; int len; int err = 0; @@ -10729,12 +10866,11 @@ static int wdc_enc_get_log(int argc, char **argv, struct command *command, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; - } - if (!wdc_enc_check_model(fd)) { + if (!wdc_enc_check_model(dev)) { err = -EINVAL; goto closed_fd; } @@ -10770,10 +10906,15 @@ static int wdc_enc_get_log(int argc, char **argv, struct command *command, if (cfg.log_id == WDC_ENC_NIC_CRASH_DUMP_ID_SLOT_1 || cfg.log_id == WDC_ENC_NIC_CRASH_DUMP_ID_SLOT_2 || cfg.log_id == WDC_ENC_NIC_CRASH_DUMP_ID_SLOT_3 || cfg.log_id == WDC_ENC_NIC_CRASH_DUMP_ID_SLOT_4) { fprintf(stderr, "args - sz:%x logid:%x of:%s\n",xfer_size,cfg.log_id,cfg.file); - err = wdc_enc_get_nic_log(fd, cfg.log_id, xfer_size, WDC_NVME_ENC_NIC_LOG_SIZE, output_fd); + err = wdc_enc_get_nic_log(dev, cfg.log_id, + xfer_size, + WDC_NVME_ENC_NIC_LOG_SIZE, + output_fd); } else { fprintf(stderr, "args - sz:%x logid:%x of:%s\n",xfer_size,cfg.log_id,cfg.file); - err = wdc_enc_submit_move_data(fd, NULL, 0, xfer_size, output_fd, cfg.log_id, 0, 0); + err = wdc_enc_submit_move_data(dev, NULL, 0, + xfer_size, output_fd, + cfg.log_id, 0, 0); } if (err == WDC_RESULT_NOT_AVAILABLE) { @@ -10784,12 +10925,14 @@ static int wdc_enc_get_log(int argc, char **argv, struct command *command, } } closed_fd: - close(fd); + dev_close(dev); ret: return err; } -static int wdc_enc_submit_move_data(int fd, char *cmd, int len, int xfer_size, FILE *out, int log_id, int cdw14, int cdw15) +static int wdc_enc_submit_move_data(struct nvme_dev *dev, char *cmd, int len, + int xfer_size, FILE *out, int log_id, + int cdw14, int cdw15) { struct timespec time; uint32_t response_size, more; @@ -10840,8 +10983,8 @@ static int wdc_enc_submit_move_data(int fd, char *cmd, int len, int xfer_size, F d); #endif nvme_cmd.result = 0; - err = nvme_submit_admin_passthru(fd, &nvme_cmd, NULL); - if (err == NVME_SC_INTERNAL) { + err = nvme_submit_admin_passthru(dev_fd(dev), &nvme_cmd, NULL); + if (nvme_status_equals(err, NVME_STATUS_TYPE_NVME, NVME_SC_INTERNAL)) { fprintf(stderr, "%s: WARNING : WDC : No log ID:x%x available\n", __func__, log_id); } @@ -10868,7 +11011,8 @@ static int wdc_enc_submit_move_data(int fd, char *cmd, int len, int xfer_size, F nvme_cmd.cdw14 = cdw14; nvme_cmd.cdw15 = cdw15; nvme_cmd.result = 0; /* returned result !=0 indicates more data available */ - err = nvme_submit_admin_passthru(fd, &nvme_cmd, NULL); + err = nvme_submit_admin_passthru(dev_fd(dev), + &nvme_cmd, NULL); if (err != 0) { more = 0; fprintf(stderr, "%s: ERROR : WDC : NVMe Rcv Mgmt ", __func__); @@ -10890,7 +11034,7 @@ static int wdc_enc_submit_move_data(int fd, char *cmd, int len, int xfer_size, F return err; } -static int wdc_enc_get_nic_log(int fd, __u8 log_id, __u32 xfer_size, __u32 data_len, FILE *out) +static int wdc_enc_get_nic_log(struct nvme_dev *dev, __u8 log_id, __u32 xfer_size, __u32 data_len, FILE *out) { __u8 *dump_data; __u32 curr_data_offset, curr_data_len; @@ -10925,7 +11069,8 @@ static int wdc_enc_get_nic_log(int fd, __u8 log_id, __u32 xfer_size, __u32 data_ #ifdef WDC_NVME_CLI_DEBUG fprintf(stderr, "nsid 0x%08x addr 0x%08llx, data_len 0x%08x, cdw10 0x%08x, cdw11 0x%08x, cdw12 0x%08x, cdw13 0x%08x, cdw14 0x%08x \n", admin_cmd.nsid, admin_cmd.addr, admin_cmd.data_len, admin_cmd.cdw10, admin_cmd.cdw11, admin_cmd.cdw12, admin_cmd.cdw13, admin_cmd.cdw14); #endif - ret = nvme_submit_admin_passthru(fd, &admin_cmd, NULL); + ret = nvme_submit_admin_passthru(dev_fd(dev), &admin_cmd, + NULL); if (ret != 0) { nvme_show_status(ret); fprintf(stderr, "%s: ERROR : WDC : Get chunk %d, size = 0x%x, offset = 0x%x, addr = 0x%lx\n", diff --git a/plugins/wdc/wdc-nvme.h b/plugins/wdc/wdc-nvme.h index c7b7f4c..242cf9a 100644 --- a/plugins/wdc/wdc-nvme.h +++ b/plugins/wdc/wdc-nvme.h @@ -5,7 +5,7 @@ #if !defined(WDC_NVME) || defined(CMD_HEADER_MULTI_READ) #define WDC_NVME -#define WDC_PLUGIN_VERSION "2.0.3" +#define WDC_PLUGIN_VERSION "2.1.2" #include "cmd.h" PLUGIN(NAME("wdc", "Western Digital vendor specific extensions", WDC_PLUGIN_VERSION), diff --git a/plugins/ymtc/ymtc-nvme.c b/plugins/ymtc/ymtc-nvme.c index cfbf6a6..d04481c 100644 --- a/plugins/ymtc/ymtc-nvme.c +++ b/plugins/ymtc/ymtc-nvme.c @@ -21,8 +21,8 @@ static void get_ymtc_smart_info(struct nvme_ymtc_smart_log *smart, int index, u8 memcpy(raw_val, smart->itemArr[index].rawVal, RAW_SIZE); } -static int show_ymtc_smart_log(int fd, __u32 nsid, const char *devname, - struct nvme_ymtc_smart_log *smart) +static int show_ymtc_smart_log(struct nvme_dev *dev, __u32 nsid, + struct nvme_ymtc_smart_log *smart) { struct nvme_id_ctrl ctrl; char fw_ver[10]; @@ -40,7 +40,7 @@ static int show_ymtc_smart_log(int fd, __u32 nsid, const char *devname, free(nm); return -1; } - err = nvme_identify_ctrl(fd, &ctrl); + err = nvme_identify_ctrl(dev_fd(dev), &ctrl); if (err) { free(nm); free(raw); @@ -52,7 +52,8 @@ static int show_ymtc_smart_log(int fd, __u32 nsid, const char *devname, ctrl.fr[4], ctrl.fr[5], ctrl.fr[6]); /* Table Title */ - printf("Additional Smart Log for NVME device:%s namespace-id:%x\n", devname, nsid); + printf("Additional Smart Log for NVME device:%s namespace-id:%x\n", + dev->name, nsid); /* Clumn Name*/ printf("key normalized raw\n"); /* 00 SI_VD_PROGRAM_FAIL */ @@ -119,15 +120,16 @@ static int show_ymtc_smart_log(int fd, __u32 nsid, const char *devname, static int get_additional_smart_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { struct nvme_ymtc_smart_log smart_log; - int err, fd; char *desc = "Get Ymtc vendor specific additional smart log (optionally, "\ "for the specified namespace), and show it."; const char *namespace = "(optional) desired namespace"; const char *raw = "dump output in binary format"; + struct nvme_dev *dev; struct config { __u32 namespace_id; bool raw_binary; }; + int err; struct config cfg = { .namespace_id = NVME_NSID_ALL, @@ -139,21 +141,21 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd, OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) - return fd; + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; - err = nvme_get_nsid_log(fd, false, 0xca, cfg.namespace_id, + err = nvme_get_nsid_log(dev_fd(dev), false, 0xca, cfg.namespace_id, sizeof(smart_log), &smart_log); if (!err) { if (!cfg.raw_binary) - err = show_ymtc_smart_log(fd, cfg.namespace_id, devicename, &smart_log); + err = show_ymtc_smart_log(dev, cfg.namespace_id, &smart_log); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } if (err > 0) nvme_show_status(err); - close(fd); + dev_close(dev); return err; } diff --git a/plugins/zns/zns.c b/plugins/zns/zns.c index 0b96346..f8809ba 100644 --- a/plugins/zns/zns.c +++ b/plugins/zns/zns.c @@ -120,7 +120,8 @@ static int id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *pl enum nvme_print_flags flags; struct nvme_zns_id_ctrl ctrl; - int fd, err = -1; + struct nvme_dev *dev; + int err = -1; struct config { char *output_format; @@ -135,15 +136,15 @@ static int id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *pl OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) return errno; err = flags = validate_output_format(cfg.output_format); if (flags < 0) goto close_fd; - err = nvme_zns_identify_ctrl(fd, &ctrl); + err = nvme_zns_identify_ctrl(dev_fd(dev), &ctrl); if (!err) nvme_show_zns_id_ctrl(&ctrl, flags); else if (err > 0) @@ -151,7 +152,7 @@ static int id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *pl else perror("zns identify controller"); close_fd: - close(fd); + dev_close(dev); return err; } @@ -166,7 +167,8 @@ static int id_ns(int argc, char **argv, struct command *cmd, struct plugin *plug enum nvme_print_flags flags; struct nvme_zns_id_ns ns; struct nvme_id_ns id_ns; - int fd, err = -1; + struct nvme_dev *dev; + int err = -1; struct config { char *output_format; @@ -187,8 +189,8 @@ static int id_ns(int argc, char **argv, struct command *cmd, struct plugin *plug OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) return errno; flags = validate_output_format(cfg.output_format); @@ -200,20 +202,20 @@ static int id_ns(int argc, char **argv, struct command *cmd, struct plugin *plug flags |= VERBOSE; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); goto close_fd; } } - err = nvme_identify_ns(fd, cfg.namespace_id, &id_ns); + err = nvme_identify_ns(dev_fd(dev), cfg.namespace_id, &id_ns); if (err) { nvme_show_status(err); goto close_fd; } - err = nvme_zns_identify_ns(fd, cfg.namespace_id, &ns); + err = nvme_zns_identify_ns(dev_fd(dev), cfg.namespace_id, &ns); if (!err) nvme_show_zns_id_ns(&ns, &id_ns, flags); else if (err > 0) @@ -221,7 +223,7 @@ static int id_ns(int argc, char **argv, struct command *cmd, struct plugin *plug else perror("zns identify namespace"); close_fd: - close(fd); + dev_close(dev); return err; } @@ -231,8 +233,8 @@ static int zns_mgmt_send(int argc, char **argv, struct command *cmd, struct plug const char *zslba = "starting LBA of the zone for this command"; const char *select_all = "send command to all zones"; const char *timeout = "timeout value, in milliseconds"; - - int err, fd, zcapc = 0; + struct nvme_dev *dev; + int err, zcapc = 0; char *command; __u32 result; @@ -253,16 +255,16 @@ static int zns_mgmt_send(int argc, char **argv, struct command *cmd, struct plug OPT_END() }; - err = fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) goto ret; err = asprintf(&command, "%s-%s", plugin->name, cmd->name); if (err < 0) - goto close_fd; + goto close_dev; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); goto free; @@ -271,7 +273,7 @@ static int zns_mgmt_send(int argc, char **argv, struct command *cmd, struct plug struct nvme_zns_mgmt_send_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .slba = cfg.zslba, .zsa = zsa, @@ -297,8 +299,8 @@ static int zns_mgmt_send(int argc, char **argv, struct command *cmd, struct plug perror(desc); free: free(command); -close_fd: - close(fd); +close_dev: + dev_close(dev); ret: return err; } @@ -344,7 +346,8 @@ static int zone_mgmt_send(int argc, char **argv, struct command *cmd, struct plu const char *data = "optional file for data (default stdin)"; const char *timeout = "timeout value, in milliseconds"; - int fd, ffd = STDIN_FILENO, err = -1; + int ffd = STDIN_FILENO, err = -1; + struct nvme_dev *dev; void *buf = NULL; struct config { @@ -372,41 +375,42 @@ static int zone_mgmt_send(int argc, char **argv, struct command *cmd, struct plu OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) return errno; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); - goto close_fd; + goto close_dev; } } if (!cfg.zsa) { fprintf(stderr, "zone send action must be specified\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.zsa == NVME_ZNS_ZSA_SET_DESC_EXT) { if(!cfg.data_len) { - int data_len = get_zdes_bytes(fd, cfg.namespace_id); + int data_len = get_zdes_bytes(dev_fd(dev), + cfg.namespace_id); if (data_len == 0) { fprintf(stderr, "Zone Descriptor Extensions are not supported\n"); - goto close_fd; + goto close_dev; } else if (data_len < 0) { err = data_len; - goto close_fd; + goto close_dev; } cfg.data_len = data_len; } if (posix_memalign(&buf, getpagesize(), cfg.data_len)) { fprintf(stderr, "can not allocate feature payload\n"); - goto close_fd; + goto close_dev; } memset(buf, 0, cfg.data_len); @@ -428,13 +432,13 @@ static int zone_mgmt_send(int argc, char **argv, struct command *cmd, struct plu fprintf(stderr, "data, data_len only valid with set extended descriptor\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } } struct nvme_zns_mgmt_send_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .slba = cfg.zslba, .zsa = cfg.zsa, @@ -461,8 +465,8 @@ close_ffd: close(ffd); free: free(buf); -close_fd: - close(fd); +close_dev: + dev_close(dev); return err; } @@ -487,8 +491,8 @@ static int open_zone(int argc, char **argv, struct command *cmd, struct plugin * const char *zrwaa = "Allocate Zone Random Write Area to zone"; const char *select_all = "send command to all zones"; const char *timeout = "timeout value, in milliseconds"; - - int err, fd; + struct nvme_dev *dev; + int err; struct config { __u64 zslba; @@ -510,21 +514,21 @@ static int open_zone(int argc, char **argv, struct command *cmd, struct plugin * OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) return errno; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); - goto close_fd; + goto close_dev; } } struct nvme_zns_mgmt_send_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .slba = cfg.zslba, .zsa = NVME_ZNS_ZSA_OPEN, @@ -541,8 +545,8 @@ static int open_zone(int argc, char **argv, struct command *cmd, struct plugin * (uint64_t)cfg.zslba, cfg.namespace_id); else nvme_show_status(err); -close_fd: - close(fd); +close_dev: + dev_close(dev); return err; } @@ -568,7 +572,8 @@ static int set_zone_desc(int argc, char **argv, struct command *cmd, struct plug const char *data = "optional file for zone extention data (default stdin)"; const char *timeout = "timeout value, in milliseconds"; - int fd, ffd = STDIN_FILENO, err; + int ffd = STDIN_FILENO, err; + struct nvme_dev *dev; void *buf = NULL; int data_len; @@ -591,33 +596,33 @@ static int set_zone_desc(int argc, char **argv, struct command *cmd, struct plug OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) return errno; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); - goto close_fd; + goto close_dev; } } - data_len = get_zdes_bytes(fd, cfg.namespace_id); + data_len = get_zdes_bytes(dev_fd(dev), cfg.namespace_id); if (!data_len || data_len < 0) { fprintf(stderr, "zone format does not provide descriptor extention\n"); errno = EINVAL; err = -1; - goto close_fd; + goto close_dev; } buf = calloc(1, data_len); if (!buf) { perror("could not alloc memory for zone desc"); err = -ENOMEM; - goto close_fd; + goto close_dev; } if (cfg.file) { @@ -637,7 +642,7 @@ static int set_zone_desc(int argc, char **argv, struct command *cmd, struct plug struct nvme_zns_mgmt_send_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .slba = cfg.zslba, .zsa = NVME_ZNS_ZSA_SET_DESC_EXT, @@ -661,8 +666,8 @@ close_ffd: close(ffd); free: free(buf); -close_fd: - close(fd); +close_dev: + dev_close(dev); return err; } @@ -672,8 +677,8 @@ static int zrwa_flush_zone(int argc, char **argv, struct command *cmd, struct pl const char *desc = "Flush Explicit ZRWA Range"; const char *slba = "LBA to flush up to"; const char *timeout = "timeout value, in milliseconds"; - - int err, fd; + struct nvme_dev *dev; + int err; struct config { __u64 lba; @@ -690,21 +695,21 @@ static int zrwa_flush_zone(int argc, char **argv, struct command *cmd, struct pl OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) return errno; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); - goto close_fd; + goto close_dev; } } struct nvme_zns_mgmt_send_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .slba = cfg.lba, .zsa = NVME_ZNS_ZSA_ZRWA_FLUSH, @@ -721,8 +726,8 @@ static int zrwa_flush_zone(int argc, char **argv, struct command *cmd, struct pl (uint64_t)cfg.lba, cfg.namespace_id); else nvme_show_status(err); -close_fd: - close(fd); +close_dev: + dev_close(dev); return err; } @@ -736,8 +741,9 @@ static int zone_mgmt_recv(int argc, char **argv, struct command *cmd, struct plu const char *data_len = "length of data in bytes"; enum nvme_print_flags flags; - int fd, err = -1; + struct nvme_dev *dev; void *data = NULL; + int err = -1; struct config { char *output_format; @@ -764,39 +770,39 @@ static int zone_mgmt_recv(int argc, char **argv, struct command *cmd, struct plu OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) return errno; flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); - goto close_fd; + goto close_dev; } } if (cfg.zra == NVME_ZNS_ZRA_REPORT_ZONES && !cfg.data_len) { fprintf(stderr, "error: data len is needed for NVME_ZRA_ZONE_REPORT\n"); err = -EINVAL; - goto close_fd; + goto close_dev; } if (cfg.data_len) { data = calloc(1, cfg.data_len); if (!data) { perror("could not alloc memory for zone mgmt receive data"); err = -ENOMEM; - goto close_fd; + goto close_dev; } } struct nvme_zns_mgmt_recv_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .slba = cfg.zslba, .zra = cfg.zra, @@ -817,8 +823,8 @@ static int zone_mgmt_recv(int argc, char **argv, struct command *cmd, struct plu perror("zns zone-mgmt-recv"); free(data); -close_fd: - close(fd); +close_dev: + dev_close(dev); return err; } @@ -833,11 +839,11 @@ static int report_zones(int argc, char **argv, struct command *cmd, struct plugi const char *verbose = "show report zones verbosity"; enum nvme_print_flags flags; - int fd, zdes = 0, err = -1; + int zdes = 0, err = -1; + struct nvme_dev *dev; __u32 report_size; - void *report; bool huge = false; - struct nvme_zone_report *buff; + struct nvme_zone_report *report, *buff; unsigned int nr_zones_chunks = 1024, /* 1024 entries * 64 bytes per entry = 64k byte transfer */ nr_zones_retrieved = 0, @@ -879,39 +885,39 @@ static int report_zones(int argc, char **argv, struct command *cmd, struct plugi OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) return errno; flags = validate_output_format(cfg.output_format); if (flags < 0) - goto close_fd; + goto close_dev; if (cfg.verbose) flags |= VERBOSE; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); - goto close_fd; + goto close_dev; } } if (cfg.extended) { - zdes = get_zdes_bytes(fd, cfg.namespace_id); + zdes = get_zdes_bytes(dev_fd(dev), cfg.namespace_id); if (zdes < 0) { err = zdes; - goto close_fd; + goto close_dev; } } - err = nvme_identify_ns(fd, cfg.namespace_id, &id_ns); + err = nvme_identify_ns(dev_fd(dev), cfg.namespace_id, &id_ns); if (err) { nvme_show_status(err); - goto close_fd; + goto close_dev; } - err = nvme_zns_identify_ns(fd, cfg.namespace_id, &id_zns); + err = nvme_zns_identify_ns(dev_fd(dev), cfg.namespace_id, &id_zns); if (!err) { /* get zsze field from zns id ns data - needed for offset calculation */ nvme_id_ns_flbas_to_lbaf_inuse(id_ns.flbas, &lbaf); @@ -919,17 +925,17 @@ static int report_zones(int argc, char **argv, struct command *cmd, struct plugi } else { nvme_show_status(err); - goto close_fd; + goto close_dev; } log_len = sizeof(struct nvme_zone_report); buff = calloc(1, log_len); if (!buff) { err = -ENOMEM; - goto close_fd; + goto close_dev; } - err = nvme_zns_report_zones(fd, cfg.namespace_id, 0, + err = nvme_zns_report_zones(dev_fd(dev), cfg.namespace_id, 0, cfg.state, false, false, log_len, buff, NVME_DEFAULT_IOCTL_TIMEOUT, NULL); @@ -959,7 +965,7 @@ static int report_zones(int argc, char **argv, struct command *cmd, struct plugi if (!report) { perror("alloc"); err = -ENOMEM; - goto close_fd; + goto close_dev; } offset = cfg.zslba; @@ -977,7 +983,8 @@ static int report_zones(int argc, char **argv, struct command *cmd, struct plugi log_len = sizeof(struct nvme_zone_report) + ((sizeof(struct nvme_zns_desc) * nr_zones_chunks) + (nr_zones_chunks * zdes)); } - err = nvme_zns_report_zones(fd, cfg.namespace_id, offset, + err = nvme_zns_report_zones(dev_fd(dev), cfg.namespace_id, + offset, cfg.state, cfg.extended, cfg.partial, log_len, report, NVME_DEFAULT_IOCTL_TIMEOUT, NULL); @@ -991,7 +998,7 @@ static int report_zones(int argc, char **argv, struct command *cmd, struct plugi zdes, log_len, flags, zone_list); nr_zones_retrieved += nr_zones_chunks; - offset = (nr_zones_retrieved * zsze); + offset = le64_to_cpu(report->entries[nr_zones_chunks-1].zslba) + zsze; } if (flags & JSON) @@ -1001,8 +1008,8 @@ static int report_zones(int argc, char **argv, struct command *cmd, struct plugi free_buff: free(buff); -close_fd: - close(fd); +close_dev: + dev_close(dev); return err; } @@ -1025,10 +1032,11 @@ static int zone_append(int argc, char **argv, struct command *cmd, struct plugin const char *data_size = "size of data in bytes"; const char *latency = "output latency statistics"; - int err = -1, fd, dfd = STDIN_FILENO, mfd = STDIN_FILENO; + int err = -1, dfd = STDIN_FILENO, mfd = STDIN_FILENO; unsigned int lba_size, meta_size; void *buf = NULL, *mbuf = NULL; __u16 nblocks, control = 0; + struct nvme_dev *dev; __u64 result; __u8 lba_index; struct timeval start_time, end_time; @@ -1072,28 +1080,28 @@ static int zone_append(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) return errno; if (!cfg.data_size) { fprintf(stderr, "Append size not provided\n"); errno = EINVAL; - goto close_fd; + goto close_dev; } if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); - goto close_fd; + goto close_dev; } } - err = nvme_identify_ns(fd, cfg.namespace_id, &ns); + err = nvme_identify_ns(dev_fd(dev), cfg.namespace_id, &ns); if (err) { nvme_show_status(err); - goto close_fd; + goto close_dev; } nvme_id_ns_flbas_to_lbaf_inuse(ns.flbas, &lba_index); @@ -1103,7 +1111,7 @@ static int zone_append(int argc, char **argv, struct command *cmd, struct plugin "Data size:%#"PRIx64" not aligned to lba size:%#x\n", (uint64_t)cfg.data_size, lba_size); errno = EINVAL; - goto close_fd; + goto close_dev; } meta_size = ns.lbaf[lba_index].ms; @@ -1113,20 +1121,20 @@ static int zone_append(int argc, char **argv, struct command *cmd, struct plugin "Metadata size:%#"PRIx64" not aligned to metadata size:%#x\n", (uint64_t)cfg.metadata_size, meta_size); errno = EINVAL; - goto close_fd; + goto close_dev; } if (cfg.prinfo > 0xf) { fprintf(stderr, "Invalid value for prinfo:%#x\n", cfg.prinfo); errno = EINVAL; - goto close_fd; + goto close_dev; } if (cfg.data) { dfd = open(cfg.data, O_RDONLY); if (dfd < 0) { perror(cfg.data); - goto close_fd; + goto close_dev; } } @@ -1179,7 +1187,7 @@ static int zone_append(int argc, char **argv, struct command *cmd, struct plugin struct nvme_zns_append_args args = { .args_size = sizeof(args), - .fd = fd, + .fd = dev_fd(dev), .nsid = cfg.namespace_id, .zslba = cfg.zslba, .nlb = nblocks, @@ -1219,8 +1227,8 @@ free_data: close_dfd: if (cfg.data) close(dfd); -close_fd: - close(fd); +close_dev: + dev_close(dev); return err; } @@ -1231,7 +1239,8 @@ static int changed_zone_list(int argc, char **argv, struct command *cmd, struct struct nvme_zns_changed_zone_log log; enum nvme_print_flags flags; - int fd, err = -1; + struct nvme_dev *dev; + int err = -1; struct config { char *output_format; @@ -1250,8 +1259,8 @@ static int changed_zone_list(int argc, char **argv, struct command *cmd, struct OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) return errno; flags = validate_output_format(cfg.output_format); @@ -1259,14 +1268,15 @@ static int changed_zone_list(int argc, char **argv, struct command *cmd, struct goto close_fd; if (!cfg.namespace_id) { - err = nvme_get_nsid(fd, &cfg.namespace_id); + err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); goto close_fd; } } - err = nvme_get_log_zns_changed_zones(fd, cfg.namespace_id, cfg.rae, &log); + err = nvme_get_log_zns_changed_zones(dev_fd(dev), cfg.namespace_id, + cfg.rae, &log); if (!err) nvme_show_zns_changed(&log, flags); else if (err > 0) @@ -1275,6 +1285,6 @@ static int changed_zone_list(int argc, char **argv, struct command *cmd, struct perror("zns changed-zone-list"); close_fd: - close(fd); + dev_close(dev); return err; } diff --git a/subprojects/json-c.wrap b/subprojects/json-c.wrap index 5084932..ce9ff51 100644 --- a/subprojects/json-c.wrap +++ b/subprojects/json-c.wrap @@ -3,11 +3,10 @@ directory = json-c-0.16 source_url = https://s3.amazonaws.com/json-c_releases/releases/json-c-0.16.tar.gz source_filename = json-c-0.16.tar.gz source_hash = 8e45ac8f96ec7791eaf3bb7ee50e9c2100bbbc87b8d0f1d030c5ba8a0288d96b -patch_filename = json-c_0.16-1_patch.zip -patch_url = https://wrapdb.mesonbuild.com/v2/json-c_0.16-1/get_patch -patch_hash = 69db1e0c391c6a00c42d05c0d845bd551d92db10171f4a40d0b070f29f918101 -wrapdb_version = 0.16-1 +patch_filename = json-c_0.16-3_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/json-c_0.16-3/get_patch +patch_hash = 6e712826ba1e6e1b6d21c6157a764984fedc6b594c9f92443498b972b6377a94 +wrapdb_version = 0.16-3 [provide] json-c = json_c_dep - diff --git a/subprojects/libnvme.wrap b/subprojects/libnvme.wrap index 5bbc79d..a4f55dc 100644 --- a/subprojects/libnvme.wrap +++ b/subprojects/libnvme.wrap @@ -1,6 +1,7 @@ [wrap-git] url = https://github.com/linux-nvme/libnvme.git -revision = 47e3562a7d9b4bb871f374058c52c654fb4735e9 +revision = b25dc6102bc000ff4c8061e6448cfb4c034eaed6 [provide] libnvme = libnvme_dep +libnvme-mi = libnvme_mi_dep diff --git a/subprojects/uuid.wrap b/subprojects/uuid.wrap deleted file mode 100644 index 0692c4e..0000000 --- a/subprojects/uuid.wrap +++ /dev/null @@ -1,6 +0,0 @@ -[wrap-git] -url = https://github.com/util-linux/util-linux.git -revision = eefff5aac7bce6979c950e3931a578efe03acbac - -[provide] -dependency_names = uuid \ No newline at end of file diff --git a/subprojects/zlib.wrap b/subprojects/zlib.wrap index 3c7b575..0482386 100644 --- a/subprojects/zlib.wrap +++ b/subprojects/zlib.wrap @@ -1,12 +1,12 @@ [wrap-file] -directory = zlib-1.2.12 -source_url = http://zlib.net/fossils/zlib-1.2.12.tar.gz -source_filename = zlib-1.2.12.tar.gz -source_hash = 91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9 -patch_filename = zlib_1.2.12-1_patch.zip -patch_url = https://wrapdb.mesonbuild.com/v2/zlib_1.2.12-1/get_patch -patch_hash = 8ec8344f3fe7b06ad4be768fd416694bc56cb4545ce78b0f1c18b3e72b3ec936 +directory = zlib-1.2.13 +source_url = http://zlib.net/fossils/zlib-1.2.13.tar.gz +source_filename = zlib-1.2.13.tar.gz +source_hash = b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30 +patch_filename = zlib_1.2.13-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/zlib_1.2.13-1/get_patch +patch_hash = 73a0103df54133b10f8774f92e23da048bd22554523e2b833cdb72b2702c0628 +wrapdb_version = 1.2.13-1 [provide] zlib = zlib_dep - diff --git a/tests/meson.build b/tests/meson.build index bc49d05..6f17137 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -32,6 +32,12 @@ tests = [ runtests = find_program('nose2', required : false) +if meson.version().version_compare('>= 0.56') + nvmecli_path = meson.project_build_root() +else + nvmecli_path = meson.build_root() +endif + if runtests.found() foreach file : infra + tests configure_file( @@ -43,12 +49,21 @@ if runtests.found() foreach t : tests t_name = t.split('.')[0] test(t_name, runtests, - args: ['--verbose', '--start-dir', meson.build_root() + '/tests', t_name], - env: ['PATH=' + meson.build_root() + ':/usr/bin:/usr/sbin'], + args: ['--verbose', '--start-dir', meson.current_build_dir(), t_name], + env: ['PATH=' + nvmecli_path + ':/usr/bin:/usr/sbin'], timeout: 500) endforeach endif +test_uint128 = executable( + 'test-uint128', + ['test-uint128.c', '../util/types.c'], + include_directories: [incdir, '..'], + dependencies: [libnvme_dep], +) + +test('uint128', test_uint128) + python_module = import('python') python = python_module.find_installation('python3') diff --git a/tests/nvme_copy_test.py b/tests/nvme_copy_test.py index 12676ea..d84a6d2 100644 --- a/tests/nvme_copy_test.py +++ b/tests/nvme_copy_test.py @@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0-only +# SPDX-License-Identifier: GPL-2.0-or-later # # This file is part of nvme-cli # diff --git a/tests/nvme_dsm_test.py b/tests/nvme_dsm_test.py index 7d5e477..d92bf58 100644 --- a/tests/nvme_dsm_test.py +++ b/tests/nvme_dsm_test.py @@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0-only +# SPDX-License-Identifier: GPL-2.0-or-later # # This file is part of nvme-cli # diff --git a/tests/nvme_get_lba_status_test.py b/tests/nvme_get_lba_status_test.py index 924a7ce..539c493 100644 --- a/tests/nvme_get_lba_status_test.py +++ b/tests/nvme_get_lba_status_test.py @@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0-only +# SPDX-License-Identifier: GPL-2.0-or-later # # This file is part of nvme-cli # diff --git a/tests/nvme_lba_status_log_test.py b/tests/nvme_lba_status_log_test.py index 90bfe91..c91d1e5 100644 --- a/tests/nvme_lba_status_log_test.py +++ b/tests/nvme_lba_status_log_test.py @@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0-only +# SPDX-License-Identifier: GPL-2.0-or-later # # This file is part of nvme-cli # diff --git a/tests/nvme_verify_test.py b/tests/nvme_verify_test.py index 68e5165..7c30828 100644 --- a/tests/nvme_verify_test.py +++ b/tests/nvme_verify_test.py @@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0-only +# SPDX-License-Identifier: GPL-2.0-or-later # # This file is part of nvme-cli # diff --git a/tests/test-uint128.c b/tests/test-uint128.c new file mode 100644 index 0000000..6301a38 --- /dev/null +++ b/tests/test-uint128.c @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include + +#include "../util/types.h" + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) + +/* create a uint128_t from four uint32_ts. w0 is the most significant value, + * w2 the least */ +#define U128(w0, w1, w2, w3) { .words = { w0, w1, w2, w3 } } + +static int test_rc; + +static void check_str(nvme_uint128_t val, const char *exp, const char *res) +{ + if (!strcmp(res, exp)) + return; + + printf("ERROR: printing {%08x.%08x.%08x.%08x}, got '%s', expected '%s'\n", + val.words[3], val.words[2], val.words[1], val.words[0], + res, exp); + + test_rc = 1; +} + +struct tostr_test { + nvme_uint128_t val; + const char *exp; +}; + +static struct tostr_test tostr_tests[] = { + { U128(0, 0, 0, 0), "0" }, + { U128(0, 0, 0, 1), "1" }, + { U128(0, 0, 0, 10), "10" }, + { U128(4, 3, 2, 1), "316912650112397582603894390785" }, + { + U128(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), + "340282366920938463463374607431768211455" + }, +}; + +void tostr_test(struct tostr_test *test) +{ + char *str; + str = uint128_t_to_string(test->val); + check_str(test->val, test->exp, str); +} + +int main(void) +{ + unsigned int i; + + test_rc = 0; + + for (i = 0; i < ARRAY_SIZE(tostr_tests); i++) + tostr_test(&tostr_tests[i]); + + return test_rc ? EXIT_FAILURE : EXIT_SUCCESS; +} diff --git a/util/argconfig.c b/util/argconfig.c index d09ba9d..2c328ff 100644 --- a/util/argconfig.c +++ b/util/argconfig.c @@ -488,6 +488,51 @@ int argconfig_parse_comma_sep_array(char *string, int *val, } } +int argconfig_parse_comma_sep_array_short(char *string, unsigned short *val, + unsigned max_length) +{ + int ret = 0; + unsigned long v; + char *tmp; + char *p; + + if (!string || !strlen(string)) + return 0; + + tmp = strtok(string, ","); + if (!tmp) + return 0; + + v = strtoul(tmp, &p, 0); + if (*p != 0) + return -1; + if (v > UINT16_MAX) { + fprintf(stderr, "%s out of range\n", tmp); + return -1; + } + val[ret] = v; + ret++; + + while (1) { + tmp = strtok(NULL, ","); + if (tmp == NULL) + return ret; + + if (ret >= max_length) + return -1; + + v = strtoul(tmp, &p, 0); + if (*p != 0) + return -1; + if (v > UINT16_MAX) { + fprintf(stderr, "%s out of range\n", tmp); + return -1; + } + val[ret] = v; + ret++; + } +} + int argconfig_parse_comma_sep_array_long(char *string, unsigned long long *val, unsigned max_length) diff --git a/util/argconfig.h b/util/argconfig.h index de715b1..b66706a 100644 --- a/util/argconfig.h +++ b/util/argconfig.h @@ -126,6 +126,8 @@ int argconfig_parse_subopt_string(char *string, char **options, size_t max_options); int argconfig_parse_comma_sep_array(char *string, int *ret, unsigned max_length); +int argconfig_parse_comma_sep_array_short(char *string, unsigned short *ret, + unsigned max_length); int argconfig_parse_comma_sep_array_long(char *string, unsigned long long *ret, unsigned max_length); diff --git a/util/json.c b/util/json.c index fd52861..84d43e5 100644 --- a/util/json.c +++ b/util/json.c @@ -1,7 +1,9 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include #include "json.h" +#include "types.h" struct json_object *util_json_object_new_double(long double d) { @@ -17,3 +19,42 @@ struct json_object *util_json_object_new_double(long double d) return obj; } + +struct json_object *util_json_object_new_uint64(uint64_t i) +{ + struct json_object *obj; + char *str; + + if (asprintf(&str, "%" PRIu64, i) < 0) + return NULL; + + obj = json_object_new_string(str); + + free(str); + return obj; + +} + +struct json_object *util_json_object_new_uint128(nvme_uint128_t val) +{ + struct json_object *obj; + obj = json_object_new_string(uint128_t_to_string(val)); + return obj; +} + +uint64_t util_json_object_get_uint64(struct json_object *obj) +{ + uint64_t val = 0; + + if (json_object_is_type(obj, json_type_string)) { + char *end = NULL; + const char *buf; + + buf = json_object_get_string(obj); + val = strtoull(buf, &end, 10); + if ((val == 0 && errno != 0) || (end == buf)) + return 0; + } + + return val; +} diff --git a/util/json.h b/util/json.h index 2b8022a..1312cb8 100644 --- a/util/json.h +++ b/util/json.h @@ -3,6 +3,7 @@ #define __JSON__H #include +#include "util/types.h" /* Wrappers around json-c's API */ @@ -14,17 +15,14 @@ json_object_object_add(o, k, json_object_new_int(v)) #define json_object_add_value_int(o, k, v) \ json_object_object_add(o, k, json_object_new_int(v)) -#ifdef CONFIG_JSONC_14 +#ifndef CONFIG_JSONC_14 +#define json_object_new_uint64(v) util_json_object_new_uint64(v) +#define json_object_get_uint64(v) util_json_object_get_uint64(v) +#endif #define json_object_add_value_uint64(o, k, v) \ json_object_object_add(o, k, json_object_new_uint64(v)) -#else -#define json_object_add_value_uint64(o, k, v) \ - if ((v) > UINT_MAX) { \ - fprintf(stderr, "Value overflow in %s", k); \ - json_object_object_add(o, k, json_object_new_int(-1)); \ - } else \ - json_object_object_add(o, k, json_object_new_int(v)) -#endif +#define json_object_add_value_uint128(o, k, v) \ + json_object_object_add(o, k, util_json_object_new_uint128(v)) #define json_object_add_value_double(o, k, v) \ json_object_object_add(o, k, util_json_object_new_double(v)) #define json_object_add_value_float(o, k, v) \ @@ -45,5 +43,9 @@ JSON_C_TO_STRING_NOSLASHESCAPE)) struct json_object *util_json_object_new_double(long double d); +struct json_object *util_json_object_new_uint64(uint64_t i); +struct json_object *util_json_object_new_uint128(nvme_uint128_t val); +struct json_object *util_json_object_new_uint128(nvme_uint128_t val); +uint64_t util_json_object_get_uint64(struct json_object *obj); #endif diff --git a/util/meson.build b/util/meson.build index a999b80..349c70c 100644 --- a/util/meson.build +++ b/util/meson.build @@ -6,4 +6,5 @@ sources += [ 'util/json.c', 'util/suffix.c', 'util/base64.c', + 'util/types.c', ] diff --git a/util/types.c b/util/types.c new file mode 100644 index 0000000..06bb8d4 --- /dev/null +++ b/util/types.c @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include + +#include + +#include "types.h" + +nvme_uint128_t le128_to_cpu(__u8 *data) +{ + nvme_uint128_t u; + nvme_uint128_t tmp; + memcpy(tmp.bytes, data, 16); + u.words[0] = le32_to_cpu(tmp.words[3]); + u.words[1] = le32_to_cpu(tmp.words[2]); + u.words[2] = le32_to_cpu(tmp.words[1]); + u.words[3] = le32_to_cpu(tmp.words[0]); + return u; +} + +long double int128_to_double(__u8 *data) +{ + int i; + long double result = 0; + + for (i = 0; i < 16; i++) { + result *= 256; + result += data[15 - i]; + } + return result; +} + +uint64_t int48_to_long(__u8 *data) +{ + int i; + uint64_t result = 0; + + for (i = 0; i < 6; i++) { + result *= 256; + result += data[5 - i]; + } + return result; +} + +char *uint128_t_to_string(nvme_uint128_t val) +{ + static char str[40]; + int idx = 40; + __u64 div, rem; + + /* terminate at the end, and build up from the ones */ + str[--idx] = '\0'; + + do { + rem = val.words[0]; + + div = rem / 10; + rem = ((rem - div * 10) << 32) + val.words[1]; + val.words[0] = div; + + div = rem / 10; + rem = ((rem - div * 10) << 32) + val.words[2]; + val.words[1] = div; + + div = rem / 10; + rem = ((rem - div * 10) << 32) + val.words[3]; + val.words[2] = div; + + div = rem / 10; + rem = rem - div * 10; + val.words[3] = div; + + str[--idx] = '0' + rem; + } while (val.words[0] || val.words[1] || val.words[2] || val.words[3]); + + return str + idx; +} + +const char *util_uuid_to_string(unsigned char uuid[NVME_UUID_LEN]) +{ + static char uuid_str[NVME_UUID_LEN_STRING]; + + nvme_uuid_to_string(uuid, uuid_str); + + return uuid_str; +} + +const char *util_fw_to_string(char *c) +{ + static char ret[9]; + int i; + + for (i = 0; i < 8; i++) + ret[i] = c[i] >= '!' && c[i] <= '~' ? c[i] : '.'; + ret[i] = '\0'; + return ret; +} diff --git a/util/types.h b/util/types.h new file mode 100644 index 0000000..6d45108 --- /dev/null +++ b/util/types.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef _MISC_H +#define _MISC_H + +/* type conversion helpers */ + +#include +#include + +#include + +#define ABSOLUTE_ZERO_CELSIUS -273 + +static inline long kelvin_to_celsius(long t) +{ + return t + ABSOLUTE_ZERO_CELSIUS; +} + +/* uint128_t is not always available, define our own. */ +union nvme_uint128 { + __u8 bytes[16]; + __u32 words[4]; /* [0] is most significant word */ +}; + +typedef union nvme_uint128 nvme_uint128_t; + +nvme_uint128_t le128_to_cpu(__u8 *data); +long double int128_to_double(__u8 *data); +uint64_t int48_to_long(__u8 *data); + +char *uint128_t_to_string(nvme_uint128_t val); +const char *util_uuid_to_string(unsigned char uuid[NVME_UUID_LEN]); +const char *util_fw_to_string(char *c); + +#endif /* _MISC_H */ diff --git a/wrapper.c b/wrapper.c deleted file mode 100644 index 2ba5b32..0000000 --- a/wrapper.c +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * This file is part of nvme-cli - * - * Copyright (c) 2022 Daniel Wagner, SUSE - */ - -#include - -#include - -#define PROTO(args...) args -#define ARGS(args...) args - -#define VOID_FN(name, proto, args) \ -void __attribute__((weak)) name(proto) \ -{ \ - void (*fn)(proto); \ - fn = dlsym(RTLD_NEXT, #name); \ - if (fn) \ - fn(args); \ -} - -#define FN(name, rtype, proto, args, fallback) \ -rtype __attribute__((weak)) name(proto) \ -{ \ - rtype (*fn)(proto); \ - fn = dlsym(RTLD_NEXT, #name); \ - if (fn) \ - return fn(args); \ - return fallback; \ -} - -FN(nvme_get_version, - const char *, PROTO(enum nvme_version type), - ARGS(type), "n/a") - -VOID_FN(nvme_init_copy_range_f1, - PROTO(struct nvme_copy_range_f1 *copy, __u16 *nlbs, - __u64 *slbas, __u64 *eilbrts, __u32 *elbatms, - __u32 *elbats, __u16 nr), - ARGS(copy, nlbs, slbas, eilbrts, elbatms, elbats, nr)) -- cgit v1.2.3