Skip to content

Commit 81ad527

Browse files
francispravin5igaw
authored andcommitted
nvme-print: print the new fields added in TP4141a
Print the newly added fields in TP4141a. Also, fixed the stcrs bit mask value. Signed-off-by: Francis Pravin <francis.p@samsung.com> Reviewed-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
1 parent af5f508 commit 81ad527

File tree

2 files changed

+43
-14
lines changed

2 files changed

+43
-14
lines changed

nvme-print-json.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -3048,15 +3048,17 @@ static void json_nvme_nvm_id_ns(struct nvme_nvm_id_ns *nvm_ns,
30483048
obj_add_uint64(r, "lbstm", le64_to_cpu(nvm_ns->lbstm));
30493049

30503050
obj_add_int(r, "pic", nvm_ns->pic);
3051+
obj_add_int(r, "pifa", nvm_ns->pifa);
30513052

30523053
obj_add_array(r, "elbafs", elbafs);
30533054

3054-
for (i = 0; i <= ns->nlbaf; i++) {
3055+
for (i = 0; i <= ns->nlbaf + ns->nulbaf; i++) {
30553056
struct json_object *elbaf = json_create_object();
30563057
unsigned int elbaf_val = le32_to_cpu(nvm_ns->elbaf[i]);
30573058

30583059
obj_add_uint(elbaf, "sts", elbaf_val & 0x7F);
30593060
obj_add_uint(elbaf, "pif", (elbaf_val >> 7) & 0x3);
3061+
obj_add_uint(elbaf, "qpif", (elbaf_val >> 9) & 0xF);
30603062

30613063
array_add_obj(elbafs, elbaf);
30623064
}

nvme-print-stdout.c

+40-13
Original file line numberDiff line numberDiff line change
@@ -3041,22 +3041,40 @@ static void stdout_id_ctrl_nvm(struct nvme_id_ctrl_nvm *ctrl_nvm)
30413041

30423042
static void stdout_nvm_id_ns_pic(__u8 pic)
30433043
{
3044-
__u8 rsvd = (pic & 0xF8) >> 3;
3045-
__u8 stcrs = (pic & 0x3) >> 2;
3044+
__u8 rsvd = (pic & 0xF0) >> 4;
3045+
__u8 qpifs = (pic & 0x8) >> 3;
3046+
__u8 stcrs = (pic & 0x4) >> 2;
30463047
__u8 pic_16bpistm = (pic & 0x2) >> 1;
30473048
__u8 pic_16bpists = pic & 0x1;
30483049

30493050
if (rsvd)
3050-
printf(" [7:3] : %#x\tReserved\n", rsvd);
3051-
printf(" [2:2] : %#x\tStorage Tag Check Read Support\n", stcrs);
3051+
printf(" [7:4] : %#x\tReserved\n", rsvd);
3052+
printf(" [3:3] : %#x\tQualified Protection Information Format %sSupported\n",
3053+
qpifs, qpifs ? "" : "Not ");
3054+
printf(" [2:2] : %#x\tStorage Tag Check Read %sSupported\n",
3055+
stcrs, stcrs ? "" : "Not ");
30523056
printf(" [1:1] : %#x\t16b Guard Protection Information Storage Tag Mask\n",
30533057
pic_16bpistm);
3054-
printf(" [0:0] : %#x\t16b Guard Protection Information Storage Tag Support\n",
3055-
pic_16bpists);
3058+
printf(" [0:0] : %#x\t16b Guard Protection Information Storage Tag %sSupported\n",
3059+
pic_16bpists, pic_16bpists ? "" : "Not ");
3060+
printf("\n");
3061+
}
3062+
3063+
static void stdout_nvm_id_ns_pifa(__u8 pifa)
3064+
{
3065+
__u8 rsvd = (pifa & 0xF8) >> 3;
3066+
__u8 stmla = pifa & 0x7;
3067+
3068+
if (rsvd)
3069+
printf(" [7:3] : %#x\tReserved\n", rsvd);
3070+
printf(" [2:0] : %#x\tStorage Tag Masking Level Attribute : %s\n", stmla,
3071+
stmla == 0 ? "Bit Granularity Masking" :
3072+
stmla == 1 ? "Byte Granularity Masking" :
3073+
stmla == 2 ? "Masking Not Supported" : "Reserved");
30563074
printf("\n");
30573075
}
30583076

3059-
static char *pif_to_string(__u8 pif)
3077+
static char *pif_to_string(__u8 pif, bool qpifs, bool pif_field)
30603078
{
30613079
switch (pif) {
30623080
case NVME_NVM_PIF_16B_GUARD:
@@ -3065,6 +3083,9 @@ static char *pif_to_string(__u8 pif)
30653083
return "32b Guard";
30663084
case NVME_NVM_PIF_64B_GUARD:
30673085
return "64b Guard";
3086+
case NVME_NVM_PIF_QTYPE:
3087+
if (pif_field && qpifs)
3088+
return "Qualified Type";
30683089
default:
30693090
return "Reserved";
30703091
}
@@ -3075,9 +3096,10 @@ static void stdout_nvm_id_ns(struct nvme_nvm_id_ns *nvm_ns, unsigned int nsid,
30753096
bool cap_only)
30763097
{
30773098
int i, verbose = stdout_print_ops.flags & VERBOSE;
3099+
bool qpifs = (nvm_ns->pic & 0x8) >> 3;
30783100
__u32 elbaf;
30793101
__u8 lbaf;
3080-
int pif, sts;
3102+
int pif, sts, qpif;
30813103
char *in_use = "(in use)";
30823104

30833105
nvme_id_ns_flbas_to_lbaf_inuse(ns->flbas, &lbaf);
@@ -3092,18 +3114,23 @@ static void stdout_nvm_id_ns(struct nvme_nvm_id_ns *nvm_ns, unsigned int nsid,
30923114
printf("pic : %#x\n", nvm_ns->pic);
30933115
if (verbose)
30943116
stdout_nvm_id_ns_pic(nvm_ns->pic);
3117+
printf("pifa : %#x\n", nvm_ns->pifa);
3118+
if (verbose)
3119+
stdout_nvm_id_ns_pifa(nvm_ns->pifa);
30953120

30963121
for (i = 0; i <= ns->nlbaf + ns->nulbaf; i++) {
30973122
elbaf = le32_to_cpu(nvm_ns->elbaf[i]);
3123+
qpif = (elbaf >> 9) & 0xF;
30983124
pif = (elbaf >> 7) & 0x3;
30993125
sts = elbaf & 0x7f;
31003126
if (verbose)
3101-
printf("Extended LBA Format %2d : Protection Information Format: "
3102-
"%s(%d) - Storage Tag Size (MSB): %-2d %s\n",
3103-
i, pif_to_string(pif), pif, sts, i == lbaf ? in_use : "");
3127+
printf("Extended LBA Format %2d : Qualified Protection Information Format: "
3128+
"%s(%d) - Protection Information Format: %s(%d) - Storage Tag Size "
3129+
"(MSB): %-2d %s\n", i, pif_to_string(qpif, qpifs, false), qpif,
3130+
pif_to_string(pif, qpifs, true), pif, sts, i == lbaf ? in_use : "");
31043131
else
3105-
printf("elbaf %2d : pif:%d sts:%-2d %s\n", i,
3106-
pif, sts, i == lbaf ? in_use : "");
3132+
printf("elbaf %2d : qpif:%d pif:%d sts:%-2d %s\n", i,
3133+
qpif, pif, sts, i == lbaf ? in_use : "");
31073134
}
31083135
}
31093136

0 commit comments

Comments
 (0)