Skip to content

Commit c7b24c0

Browse files
ikegami-tigaw
authored andcommitted
nvme-print-json: add performance characteristic feature output
The feature supported by NVM command set specification revision 1.1. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 5110bff commit c7b24c0

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

nvme-print-json.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3712,6 +3712,72 @@ static void json_feature_show_fields_power_loss_signal(struct json_object *r, un
37123712
nvme_pls_mode_to_string(NVME_GET(result, FEAT_PLS_MODE)));
37133713
}
37143714

3715+
static void json_feat_perfc_std(struct json_object *r, struct nvme_std_perf_attr *data)
3716+
{
3717+
obj_add_str(r, "random 4 kib average read latency",
3718+
nvme_feature_perfc_r4karl_to_string(data->r4karl));
3719+
obj_add_uint_02x(r, "R4KARL", data->r4karl);
3720+
}
3721+
3722+
static void json_feat_perfc_id_list(struct json_object *r, struct nvme_perf_attr_id_list *data)
3723+
{
3724+
int i;
3725+
int attri_vs;
3726+
char json_str[STR_LEN];
3727+
struct json_object *paida = json_create_array();
3728+
struct json_object *paide;
3729+
3730+
obj_add_str(r, "attribute type", nvme_feature_perfc_attrtyp_to_string(data->attrtyp));
3731+
obj_add_uint_02x(r, "ATTRTYP", data->attrtyp);
3732+
obj_add_int(r, "maximum saveable vendor specific performance attributes (MSVSPA)",
3733+
data->msvspa);
3734+
obj_add_int(r, "unused saveable vendor specific performance attributes (USVSPA)",
3735+
data->usvspa);
3736+
3737+
obj_add_array(r, "performance attribute identifier list", paida);
3738+
for (i = 0; i < ARRAY_SIZE(data->id_list); i++) {
3739+
paide = json_create_object();
3740+
array_add_obj(paida, paide);
3741+
attri_vs = i + NVME_FEAT_PERFC_ATTRI_VS_MIN;
3742+
sprintf(json_str, "performance attribute %02xh identifier (PA%02XHI)", attri_vs,
3743+
attri_vs);
3744+
obj_add_str(paide, json_str, util_uuid_to_string(data->id_list[i].id));
3745+
}
3746+
}
3747+
3748+
static void json_feat_perfc_vs(struct json_object *r, struct nvme_vs_perf_attr *data)
3749+
{
3750+
obj_add_str(r, "performance attribute identifier (PAID)", util_uuid_to_string(data->paid));
3751+
obj_add_uint(r, "attribute length (ATTRL)", data->attrl);
3752+
obj_d(r, "vendor specific (VS)", (unsigned char *)data->vs, data->attrl, 16, 1);
3753+
}
3754+
3755+
static void json_feat_perfc(struct json_object *r, enum nvme_features_id fid, unsigned int result,
3756+
struct nvme_perf_characteristics *data)
3757+
{
3758+
__u8 attri;
3759+
bool rvspa;
3760+
3761+
nvme_feature_decode_perf_characteristics(result, &attri, &rvspa);
3762+
3763+
obj_add_str(r, "attribute index", nvme_feature_perfc_attri_to_string(attri));
3764+
obj_add_uint_02x(r, "ATTRI", attri);
3765+
3766+
switch (attri) {
3767+
case NVME_FEAT_PERFC_ATTRI_STD:
3768+
json_feat_perfc_std(r, data->std_perf);
3769+
break;
3770+
case NVME_FEAT_PERFC_ATTRI_ID_LIST:
3771+
json_feat_perfc_id_list(r, data->id_list);
3772+
break;
3773+
case NVME_FEAT_PERFC_ATTRI_VS_MIN ... NVME_FEAT_PERFC_ATTRI_VS_MAX:
3774+
json_feat_perfc_vs(r, data->vs_perf);
3775+
break;
3776+
default:
3777+
break;
3778+
}
3779+
}
3780+
37153781
static void json_host_metadata(struct json_object *r, enum nvme_features_id fid,
37163782
struct nvme_host_metadata *data)
37173783
{
@@ -3925,6 +3991,9 @@ static void json_feature_show_fields(enum nvme_features_id fid, unsigned int res
39253991
case NVME_FEAT_FID_POWER_LOSS_SIGNAL:
39263992
json_feature_show_fields_power_loss_signal(r, result);
39273993
break;
3994+
case NVME_FEAT_FID_PERF_CHARACTERISTICS:
3995+
json_feat_perfc(r, fid, result, (struct nvme_perf_characteristics *)buf);
3996+
break;
39283997
case NVME_FEAT_FID_ENH_CTRL_METADATA:
39293998
case NVME_FEAT_FID_CTRL_METADATA:
39303999
case NVME_FEAT_FID_NS_METADATA:

0 commit comments

Comments
 (0)