Skip to content

Commit b691c91

Browse files
committed
nvme-print-json: add performance characteristics feature output
The feature identifier 1Ch added by NVMe 2.1. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent c16e914 commit b691c91

1 file changed

Lines changed: 68 additions & 3 deletions

File tree

nvme-print-json.c

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static const uint8_t zero_uuid[16] = { 0 };
4545
static struct print_ops json_print_ops;
4646
static struct json_object *json_r;
4747

48-
static void json_feature_show_fields(enum nvme_features_id fid, unsigned int result,
48+
static void json_feature_show_fields(enum nvme_features_id fid, __u32 cdw11, unsigned int result,
4949
unsigned char *buf);
5050

5151
static void d_json(unsigned char *buf, int len, int width, int group, struct json_object *array)
@@ -1751,7 +1751,7 @@ static void json_pel_set_feature(void *pevent_log_info, __u32 offset,
17511751

17521752
if (NVME_SET_FEAT_EVENT_MB_COUNT(set_feat_event->layout)) {
17531753
mem_buf = (unsigned char *)(set_feat_event + 4 + dword_cnt * 4);
1754-
json_feature_show_fields(fid, cdw11, mem_buf);
1754+
json_feature_show_fields(fid, cdw11, cdw11, mem_buf);
17551755
}
17561756
}
17571757

@@ -3589,6 +3589,69 @@ static void json_feature_show_fields_power_loss_signal(struct json_object *r, un
35893589
nvme_pls_mode_to_string(NVME_GET(result, FEAT_PLS_MODE)));
35903590
}
35913591

3592+
static void json_perfc_std_attr(struct json_object *r, struct nvme_std_perf_attr *std_perf)
3593+
{
3594+
obj_add_str(r, "Random 4 KiB average read latency (R4KARL)",
3595+
nvme_perf_lat_to_string(std_perf->r4karl));
3596+
}
3597+
3598+
static void json_perfc_attr_id_list(struct json_object *r, struct nvme_perf_attr_id_list *id_list)
3599+
{
3600+
int i;
3601+
char json_str[STR_LEN];
3602+
3603+
obj_add_str(r, "Attribute Type (ATTRTYP)",
3604+
nvme_perf_attr_type_to_string(NVME_GET(id_list->attrtyp, FEAT_PERFC_ATTRTYP)));
3605+
obj_add_uint(r, "Maximum Saveable Vendor Specific Performance Attributes (MSVSPA)",
3606+
id_list->msvspa);
3607+
obj_add_uint(r, "Unused Saveable Vendor Specific Performance Attributes (USVSPA)",
3608+
id_list->usvspa);
3609+
for (i = 0; i < ARRAY_SIZE(id_list->id_list); i++) {
3610+
sprintf(json_str, "Performance Attribute %Xh Identifier (PA%XHI)", i, i);
3611+
obj_add_str(r, json_str, util_uuid_to_string(id_list->id_list[i].id));
3612+
}
3613+
}
3614+
3615+
static void json_perfc_vs_attr(struct json_object *r, struct nvme_vs_perf_attr *vs_perf)
3616+
{
3617+
obj_add_str(r, "Performance Attribute Identifier (PAID)",
3618+
memcmp(vs_perf->paid.id, zero_uuid, sizeof(zero_uuid)) ?
3619+
util_uuid_to_string(vs_perf->paid.id) : "Unused");
3620+
obj_add_uint(r, "Attribute Length (ATTRL)", le16_to_cpu(vs_perf->attrl));
3621+
obj_d(r, "Vendor Specific (VS)", (unsigned char *)vs_perf->vs, le16_to_cpu(vs_perf->attrl),
3622+
16, 1);
3623+
}
3624+
3625+
static void json_perf_characteristics(struct json_object *r, __u32 cdw11, unsigned char *buf)
3626+
{
3627+
struct nvme_perf_characteristics *attr = (struct nvme_perf_characteristics *)buf;
3628+
__u8 attri;
3629+
bool rvspa;
3630+
3631+
nvme_feature_decode_perf_characteristics(cdw11, &attri, &rvspa);
3632+
3633+
obj_add_str(r, "Attribute Index (ATTRI)", nvme_attr_index_to_string(attri));
3634+
obj_add_str(r, "Revert Vendor Specific Performance Attribute (RVSPA)",
3635+
rvspa ? "Deleted" : "Not deleted");
3636+
3637+
if (!attr)
3638+
return;
3639+
3640+
switch (attri) {
3641+
case 0:
3642+
json_perfc_std_attr(r, attr->std_perf);
3643+
break;
3644+
case 0xc0:
3645+
json_perfc_attr_id_list(r, attr->id_list);
3646+
break;
3647+
case 0xc1 ... 0xff:
3648+
json_perfc_vs_attr(r, attr->vs_perf);
3649+
break;
3650+
default:
3651+
break;
3652+
}
3653+
}
3654+
35923655
static void json_host_metadata(struct json_object *r, enum nvme_features_id fid,
35933656
struct nvme_host_metadata *data)
35943657
{
@@ -3711,7 +3774,7 @@ static void json_feature_show(enum nvme_features_id fid, int sel, unsigned int r
37113774
obj_print(r);
37123775
}
37133776

3714-
static void json_feature_show_fields(enum nvme_features_id fid, unsigned int result,
3777+
static void json_feature_show_fields(enum nvme_features_id fid, __u32 cdw11, unsigned int result,
37153778
unsigned char *buf)
37163779
{
37173780
struct json_object *r;
@@ -3802,6 +3865,8 @@ static void json_feature_show_fields(enum nvme_features_id fid, unsigned int res
38023865
case NVME_FEAT_FID_POWER_LOSS_SIGNAL:
38033866
json_feature_show_fields_power_loss_signal(r, result);
38043867
break;
3868+
case NVME_FEAT_FID_PERF_CHARACTERISTICS:
3869+
json_perf_characteristics(r, cdw11, buf);
38053870
case NVME_FEAT_FID_ENH_CTRL_METADATA:
38063871
case NVME_FEAT_FID_CTRL_METADATA:
38073872
case NVME_FEAT_FID_NS_METADATA:

0 commit comments

Comments
 (0)