Skip to content

Commit

Permalink
nvme-print: add feature fields struct definition to print feild values
Browse files Browse the repository at this point in the history
Add arbitration, power management, LBA range type and temperature
threshold features definitions at first so still remained features.

Signed-off-by: Tokunori Ikegami <[email protected]>
  • Loading branch information
ikegami-t committed Jul 25, 2024
1 parent fa02967 commit 40aa96c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 18 deletions.
36 changes: 18 additions & 18 deletions nvme-print-stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -4427,40 +4427,40 @@ static void stdout_feature_show_fields(enum nvme_features_id fid,
unsigned int result,
unsigned char *buf)
{
__u8 field;
uint64_t ull;
struct feature_fields *fields = (struct feature_fields *)&result;

switch (fid) {
case NVME_FEAT_FID_ARBITRATION:
printf("\tHigh Priority Weight (HPW): %u\n", ((result & 0xff000000) >> 24) + 1);
printf("\tMedium Priority Weight (MPW): %u\n", ((result & 0x00ff0000) >> 16) + 1);
printf("\tLow Priority Weight (LPW): %u\n", ((result & 0x0000ff00) >> 8) + 1);
printf("\tHigh Priority Weight (HPW): %u\n", fields->arbitration.hpw + 1);
printf("\tMedium Priority Weight (MPW): %u\n", fields->arbitration.mpw + 1);
printf("\tLow Priority Weight (LPW): %u\n", fields->arbitration.lpw + 1);
printf("\tArbitration Burst (AB): ");
if ((result & 0x00000007) == 7)
if (fields->arbitration.ab == 7)
printf("No limit\n");
else
printf("%u\n", 1 << (result & 0x00000007));
printf("%u\n", 1 << fields->arbitration.ab);
break;
case NVME_FEAT_FID_POWER_MGMT:
field = (result & 0x000000E0) >> 5;
printf("\tWorkload Hint (WH): %u - %s\n", field, nvme_feature_wl_hints_to_string(field));
printf("\tPower State (PS): %u\n", result & 0x0000001f);
printf("\tWorkload Hint (WH): %u - %s\n", fields->power_management.wh,
nvme_feature_wl_hints_to_string(fields->power_management.wh));
printf("\tPower State (PS): %u\n", fields->power_management.ps);
break;
case NVME_FEAT_FID_LBA_RANGE:
field = result & 0x0000003f;
printf("\tNumber of LBA Ranges (NUM): %u\n", field + 1);
printf("\tNumber of LBA Ranges (NUM): %u\n", fields->lba_range_type.num + 1);
if (buf)
stdout_lba_range((struct nvme_lba_range_type *)buf, field);
stdout_lba_range((struct nvme_lba_range_type *)buf,
fields->lba_range_type.num);
break;
case NVME_FEAT_FID_TEMP_THRESH:
field = (result & 0x00300000) >> 20;
printf("\tThreshold Type Select (THSEL): %u - %s\n", field,
nvme_feature_temp_type_to_string(field));
field = (result & 0x000f0000) >> 16;
printf("\tThreshold Type Select (THSEL): %u - %s\n",
fields->temp_thresh.thsel,
nvme_feature_temp_type_to_string(fields->temp_thresh.thsel));
printf("\tThreshold Temperature Select (TMPSEL): %u - %s\n",
field, nvme_feature_temp_sel_to_string(field));
fields->temp_thresh.tmpsel,
nvme_feature_temp_sel_to_string(fields->temp_thresh.tmpsel));
printf("\tTemperature Threshold (TMPTH): %s (%u K)\n",
nvme_degrees_string(result & 0x0000ffff), result & 0x0000ffff);
nvme_degrees_string(fields->temp_thresh.tmpth), fields->temp_thresh.tmpth);
break;
case NVME_FEAT_FID_ERR_RECOVERY:
printf("\tDeallocated or Unwritten Logical Block Error Enable (DULBE): %s\n",
Expand Down
27 changes: 27 additions & 0 deletions nvme-print.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,33 @@ struct nvme_bar_cap {
__u8 rsvd61:3;
};

struct feature_fields {
union {
struct {
__u32 ab:3;
__u32 rsvd3:5;
__u32 lpw:8;
__u32 mpw:8;
__u32 hpw:8;
} arbitration;
struct {
__u32 ps:5;
__u32 wh:3;
__u32 rsvd8:24;
} power_management;
struct {
__u32 num:6;
__u32 rsvd6:26;
} lba_range_type;
struct {
__u32 tmpth:16;
__u32 tmpsel:4;
__u32 thsel:2;
__u32 rsvd22:10;
} temp_thresh;
};
};

#ifdef CONFIG_JSONC

struct print_ops *nvme_get_json_print_ops(nvme_print_flags_t flags);
Expand Down

0 comments on commit 40aa96c

Please sign in to comment.