Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion nvme-print-binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,14 @@ static void binary_power_meas_log(struct nvme_power_meas_log *log, __u32 size)
d_raw((unsigned char *)log, size);
}

static void binary_feature_show(enum nvme_features_id fid, int sel,
unsigned int result, void *buf, __u32 data_len)
{
if (buf) {
d_raw(buf, data_len);
}
}

static struct print_ops binary_print_ops = {
/* libnvme types.h print functions */
.ana_log = binary_ana_log,
Expand Down Expand Up @@ -410,7 +418,7 @@ static struct print_ops binary_print_ops = {
.zns_id_ctrl = binary_zns_id_ctrl,
.zns_id_ns = binary_zns_id_ns,
.zns_report_zones = binary_zns_report_zones,
.show_feature = NULL,
.show_feature = binary_feature_show,
.show_feature_fields = NULL,
.id_ctrl_rpmbs = NULL,
.lba_range = NULL,
Expand Down
8 changes: 7 additions & 1 deletion nvme-print-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -4178,7 +4178,8 @@ static void json_feature_show_fields_power_meas(struct json_object *r,
obj_add_uint(r, "Stop Measurement Time (SMT)", smt);
}

static void json_feature_show(enum nvme_features_id fid, int sel, unsigned int result)
static void json_feature_show(enum nvme_features_id fid, int sel,
unsigned int result, void *buf, __u32 data_len)
{
struct json_object *r;
char json_str[STR_LEN];
Expand All @@ -4192,6 +4193,11 @@ static void json_feature_show(enum nvme_features_id fid, int sel, unsigned int r
obj_add_str(r, nvme_select_to_string(sel), json_str);

obj_print(r);

if (NVME_CHECK(sel, GET_FEATURES_SEL, SUPPORTED))
json_select_result(fid, result);
else
json_feature_show_fields(fid, result, buf);
}

static void json_feature_show_fields(enum nvme_features_id fid, unsigned int result,
Expand Down
10 changes: 9 additions & 1 deletion nvme-print-stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -5227,10 +5227,18 @@ static void stdout_feat_host_id(unsigned int result, unsigned char *hostid)
le64_to_cpu(*(__le64 *)hostid));
}

static void stdout_feature_show(enum nvme_features_id fid, int sel, unsigned int result)
static void stdout_feature_show(enum nvme_features_id fid, int sel,
unsigned int result, void *buf, __u32 data_len)
{
printf("get-feature:%#0*x (%s), %s value:%#0*x\n", fid ? 4 : 2, fid,
nvme_feature_to_string(fid), nvme_select_to_string(sel), result ? 10 : 8, result);

if (NVME_CHECK(sel, GET_FEATURES_SEL, SUPPORTED))
stdout_select_result(fid, result);
else if (stdout_print_ops.flags & VERBOSE)
stdout_feature_show_fields(fid, result, buf);
else if (buf)
d(buf, data_len, 16, 1);
}

static void stdout_feature_show_fields(enum nvme_features_id fid,
Expand Down
5 changes: 3 additions & 2 deletions nvme-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -1608,9 +1608,10 @@ const char *nvme_ipmsr_srs_to_string(__u8 srs)
}
}

void nvme_feature_show(enum nvme_features_id fid, int sel, unsigned int result)
void nvme_show_feature(enum nvme_features_id fid, int sel, unsigned int result,
void *buf, __u32 data_len, nvme_print_flags_t flags)
{
nvme_print(show_feature, NORMAL, fid, sel, result);
nvme_print(show_feature, flags, fid, sel, result, buf, data_len);
}

void nvme_feature_show_fields(enum nvme_features_id fid, unsigned int result, unsigned char *buf)
Expand Down
6 changes: 4 additions & 2 deletions nvme-print.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ struct print_ops {
void (*zns_id_ctrl)(struct nvme_zns_id_ctrl *ctrl);
void (*zns_id_ns)(struct nvme_zns_id_ns *ns, struct nvme_id_ns *id_ns);
void (*zns_report_zones)(void *report, __u32 descs, __u8 ext_size, __u32 report_size, struct json_object *zone_list);
void (*show_feature)(enum nvme_features_id fid, int sel, unsigned int result);
void (*show_feature)(enum nvme_features_id fid, int sel,
unsigned int result, void *buf, __u32 data_len);
void (*show_feature_fields)(enum nvme_features_id fid, unsigned int result, unsigned char *buf);
void (*id_ctrl_rpmbs)(__le32 ctrl_rpmbs);
void (*lba_range)(struct nvme_lba_range_type *lbrt, int nr_ranges);
Expand Down Expand Up @@ -263,7 +264,8 @@ void nvme_show_topology(struct libnvme_global_ctx *ctx,
nvme_print_flags_t flags);
void nvme_show_topology_tabular(struct libnvme_global_ctx *ctx, nvme_print_flags_t flags);

void nvme_feature_show(enum nvme_features_id fid, int sel, unsigned int result);
void nvme_show_feature(enum nvme_features_id fid, int sel, unsigned int result,
void *buf, __u32 data_len, nvme_print_flags_t flags);
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, __u64 result,
void *buf, __u32 len, nvme_print_flags_t flags);
Expand Down
30 changes: 10 additions & 20 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -4838,29 +4838,19 @@ static int filter_out_flags(int status)
static void get_feature_id_print(struct feat_cfg cfg, int err, __u64 result,
void *buf, nvme_print_flags_t flags)
{
int status = filter_out_flags(err);
int verbose = flags & VERBOSE;
int status = err > 0 ? filter_out_flags(err) : err;
enum nvme_status_type type = NVME_STATUS_TYPE_NVME;

if (!err) {
if (!cfg.raw_binary || !buf) {
nvme_feature_show(cfg.feature_id, cfg.sel, result);
if (NVME_CHECK(cfg.sel, GET_FEATURES_SEL, SUPPORTED))
nvme_show_select_result(cfg.feature_id, result);
else if (verbose || !strcmp(nvme_args.output_format, "json"))
nvme_feature_show_fields(cfg.feature_id, result, buf);
else if (buf)
d(buf, cfg.data_len, 16, 1);
} else if (buf) {
d_raw(buf, cfg.data_len);
}
} else if (err > 0) {
if (!nvme_status_equals(status, type, NVME_SC_INVALID_FIELD) &&
!nvme_status_equals(status, type, NVME_SC_INVALID_NS))
nvme_show_status(err);
} else {
nvme_show_error("get-feature: %s", libnvme_strerror(err));
if (err) {
if (nvme_status_equals(status, type, NVME_SC_INVALID_FIELD) ||
nvme_status_equals(status, type, NVME_SC_INVALID_NS))
return;
nvme_show_err(err, "get-feature");
Comment thread
igaw marked this conversation as resolved.
return;
}

nvme_show_feature(cfg.feature_id, cfg.sel, result, buf, cfg.data_len,
flags);
}

static bool is_get_feature_result_set(enum nvme_features_id feature_id)
Expand Down
6 changes: 1 addition & 5 deletions plugins/feat/feat-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ static int feat_get_nsid(struct libnvme_transport_handle *hdl, __u32 nsid,

nvme_show_init();

nvme_feature_show(fid, sel, result);
if (NVME_CHECK(sel, GET_FEATURES_SEL, SUPPORTED))
nvme_show_select_result(fid, result);
else
nvme_feature_show_fields(fid, result, buf);
nvme_show_feature(fid, sel, result, buf, len, NORMAL);

nvme_show_finish();

Expand Down
Loading