summaryrefslogtreecommitdiffstats
path: root/plugins/toshiba
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:23:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:23:26 +0000
commitfab3f41b7b3f080c215157a026ee6bc7efbfe968 (patch)
treef0fafb0805c3eb11eb2a278f9f8058376c8f0f2b /plugins/toshiba
parentAdding upstream version 2.1.2. (diff)
downloadnvme-cli-fab3f41b7b3f080c215157a026ee6bc7efbfe968.tar.xz
nvme-cli-fab3f41b7b3f080c215157a026ee6bc7efbfe968.zip
Adding upstream version 2.2.1.upstream/2.2.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plugins/toshiba')
-rw-r--r--plugins/toshiba/toshiba-nvme.c53
1 files changed, 29 insertions, 24 deletions
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;
}