Merging upstream version 2.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
888be815c6
commit
e4376063b0
521 changed files with 21541 additions and 21644 deletions
|
@ -5,16 +5,12 @@
|
|||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "linux/nvme_ioctl.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "nvme.h"
|
||||
#include "nvme-print.h"
|
||||
#include "nvme-ioctl.h"
|
||||
#include "libnvme.h"
|
||||
#include "plugin.h"
|
||||
|
||||
#include "argconfig.h"
|
||||
#include "suffix.h"
|
||||
#include "linux/types.h"
|
||||
#include "nvme-print.h"
|
||||
|
||||
#define CREATE_CMD
|
||||
#include "shannon-nvme.h"
|
||||
|
@ -127,7 +123,7 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
|
|||
const char *raw = "dump output in binary format";
|
||||
struct config {
|
||||
__u32 namespace_id;
|
||||
int raw_binary;
|
||||
bool raw_binary;
|
||||
};
|
||||
|
||||
struct config cfg = {
|
||||
|
@ -141,8 +137,8 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
|
|||
};
|
||||
|
||||
fd = parse_and_open(argc, argv, desc, opts);
|
||||
err = nvme_get_log(fd, cfg.namespace_id, 0xca, false,
|
||||
NVME_NO_LOG_LSP, sizeof(smart_log), &smart_log);
|
||||
err = nvme_get_nsid_log(fd, 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);
|
||||
|
@ -150,8 +146,7 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
|
|||
d_raw((unsigned char *)&smart_log, sizeof(smart_log));
|
||||
}
|
||||
else if (err > 0)
|
||||
fprintf(stderr, "NVMe Status:%s(%x)\n",
|
||||
nvme_status_to_string(err), err);
|
||||
nvme_show_status(err);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -181,17 +176,17 @@ static int get_additional_feature(int argc, char **argv, struct command *cmd, st
|
|||
|
||||
struct config {
|
||||
__u32 namespace_id;
|
||||
enum nvme_feat feature_id;
|
||||
enum nvme_features_id feature_id;
|
||||
__u8 sel;
|
||||
__u32 cdw11;
|
||||
__u32 data_len;
|
||||
int raw_binary;
|
||||
int human_readable;
|
||||
bool raw_binary;
|
||||
bool human_readable;
|
||||
};
|
||||
|
||||
struct config cfg = {
|
||||
.namespace_id = 1,
|
||||
.feature_id = NVME_FEAT_NONE,
|
||||
.feature_id = 0,
|
||||
.sel = 0,
|
||||
.cdw11 = 0,
|
||||
.data_len = 0,
|
||||
|
@ -231,9 +226,22 @@ static int get_additional_feature(int argc, char **argv, struct command *cmd, st
|
|||
memset(buf, 0, cfg.data_len);
|
||||
}
|
||||
|
||||
err = nvme_get_feature(fd, cfg.namespace_id, cfg.feature_id, cfg.sel, cfg.cdw11, 0,
|
||||
cfg.data_len, buf, &result);
|
||||
struct nvme_get_features_args args = {
|
||||
.args_size = sizeof(args),
|
||||
.fd = fd,
|
||||
.fid = cfg.feature_id,
|
||||
.nsid = cfg.namespace_id,
|
||||
.sel = cfg.sel,
|
||||
.cdw11 = cfg.cdw11,
|
||||
.uuidx = 0,
|
||||
.data_len = cfg.data_len,
|
||||
.data = buf,
|
||||
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
|
||||
.result = &result,
|
||||
};
|
||||
err = nvme_get_features(&args);
|
||||
if (!err) {
|
||||
#if 0
|
||||
printf("get-feature:0x%02x (%s), %s value: %#08x\n", cfg.feature_id,
|
||||
nvme_feature_to_string(cfg.feature_id),
|
||||
nvme_select_to_string(cfg.sel), result);
|
||||
|
@ -247,9 +255,9 @@ static int get_additional_feature(int argc, char **argv, struct command *cmd, st
|
|||
d_raw(buf, cfg.data_len);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else if (err > 0)
|
||||
fprintf(stderr, "NVMe Status:%s(%x)\n",
|
||||
nvme_status_to_string(err), err);
|
||||
nvme_show_status(err);
|
||||
if (buf)
|
||||
free(buf);
|
||||
return err;
|
||||
|
@ -285,7 +293,7 @@ static int set_additional_feature(int argc, char **argv, struct command *cmd, st
|
|||
__u32 feature_id;
|
||||
__u32 value;
|
||||
__u32 data_len;
|
||||
int save;
|
||||
bool save;
|
||||
};
|
||||
|
||||
struct config cfg = {
|
||||
|
@ -343,20 +351,35 @@ static int set_additional_feature(int argc, char **argv, struct command *cmd, st
|
|||
}
|
||||
}
|
||||
|
||||
err = nvme_set_feature(fd, cfg.namespace_id, cfg.feature_id, cfg.value,
|
||||
0, cfg.save, 0, cfg.data_len, buf, &result);
|
||||
struct nvme_set_features_args args = {
|
||||
.args_size = sizeof(args),
|
||||
.fd = fd,
|
||||
.fid = cfg.feature_id,
|
||||
.nsid = cfg.namespace_id,
|
||||
.cdw11 = cfg.value,
|
||||
.cdw12 = 0,
|
||||
.save = cfg.save,
|
||||
.uuidx = 0,
|
||||
.cdw15 = 0,
|
||||
.data_len = cfg.data_len,
|
||||
.data = buf,
|
||||
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
|
||||
.result = &result,
|
||||
};
|
||||
err = nvme_set_features(&args);
|
||||
if (err < 0) {
|
||||
perror("set-feature");
|
||||
goto free;
|
||||
}
|
||||
if (!err) {
|
||||
#if 0
|
||||
printf("set-feature:%02x (%s), value:%#08x\n", cfg.feature_id,
|
||||
nvme_feature_to_string(cfg.feature_id), cfg.value);
|
||||
#endif
|
||||
if (buf)
|
||||
d(buf, cfg.data_len, 16, 1);
|
||||
} else if (err > 0)
|
||||
fprintf(stderr, "NVMe Status:%s(%x)\n",
|
||||
nvme_status_to_string(err), err);
|
||||
nvme_show_status(err);
|
||||
|
||||
free:
|
||||
if (buf)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue