Skip to content

Commit 7f64b7d

Browse files
francispravin5igaw
authored andcommitted
nvme: choose PIF from QPIF if QPIFS supports and PIF is QTYPE
As per TP4141a: "If the Qualified Protection Information Format Support(QPIFS) bit is set to 1 and the Protection Information Format(PIF) field is set to 11b (i.e., Qualified Type), then the pif is as defined in the Qualified Protection Information Format (QPIF) field." So, choose PIF from QPIF if QPIFS supports and PIF is QTYPE. Signed-off-by: Francis Pravin <francis.p@samsung.com> Reviewed-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
1 parent 66c1f70 commit 7f64b7d

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

nvme.c

+20-9
Original file line numberDiff line numberDiff line change
@@ -6860,6 +6860,7 @@ static int write_zeroes(int argc, char **argv, struct command *cmd, struct plugi
68606860
_cleanup_free_ struct nvme_id_ns *ns = NULL;
68616861
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
68626862
__u8 lba_index, sts = 0, pif = 0;
6863+
__u32 elbaf = 0;
68636864
__u16 control = 0;
68646865
int err;
68656866

@@ -6971,8 +6972,11 @@ static int write_zeroes(int argc, char **argv, struct command *cmd, struct plugi
69716972
err = nvme_identify_ns_csi(dev_fd(dev), cfg.namespace_id, 0, NVME_CSI_NVM, nvm_ns);
69726973
if (!err) {
69736974
nvme_id_ns_flbas_to_lbaf_inuse(ns->flbas, &lba_index);
6974-
sts = nvm_ns->elbaf[lba_index] & NVME_NVM_ELBAF_STS_MASK;
6975-
pif = (nvm_ns->elbaf[lba_index] & NVME_NVM_ELBAF_PIF_MASK) >> 7;
6975+
elbaf = le32_to_cpu(nvm_ns->elbaf[lba_index]);
6976+
sts = elbaf & NVME_NVM_ELBAF_STS_MASK;
6977+
pif = (elbaf & NVME_NVM_ELBAF_PIF_MASK) >> 7;
6978+
if (pif == NVME_NVM_PIF_QTYPE && (nvm_ns->pic & 0x8))
6979+
pif = (elbaf & NVME_NVM_ELBAF_QPIF_MASK) >> 9;
69766980
}
69776981

69786982
if (invalid_tags(cfg.storage_tag, cfg.ref_tag, sts, pif))
@@ -7698,7 +7702,7 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char
76987702
int flags;
76997703
int mode = 0644;
77007704
__u16 control = 0, nblocks = 0;
7701-
__u32 dsmgmt = 0;
7705+
__u32 dsmgmt = 0, elbaf = 0;
77027706
unsigned int logical_block_size = 0;
77037707
unsigned long long buffer_size = 0, mbuffer_size = 0;
77047708
_cleanup_huge_ struct nvme_mem_huge mh = { 0, };
@@ -7929,8 +7933,11 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char
79297933
if (cfg.metadata_size) {
79307934
err = nvme_identify_ns_csi(dev_fd(dev), 1, 0, NVME_CSI_NVM, nvm_ns);
79317935
if (!err) {
7932-
sts = nvm_ns->elbaf[lba_index] & NVME_NVM_ELBAF_STS_MASK;
7933-
pif = (nvm_ns->elbaf[lba_index] & NVME_NVM_ELBAF_PIF_MASK) >> 7;
7936+
elbaf = le32_to_cpu(nvm_ns->elbaf[lba_index]);
7937+
sts = elbaf & NVME_NVM_ELBAF_STS_MASK;
7938+
pif = (elbaf & NVME_NVM_ELBAF_PIF_MASK) >> 7;
7939+
if (pif == NVME_NVM_PIF_QTYPE && (nvm_ns->pic & 0x8))
7940+
pif = (elbaf & NVME_NVM_ELBAF_QPIF_MASK) >> 9;
79347941
}
79357942

79367943
mbuffer_size = ((unsigned long long)cfg.block_count + 1) * ms;
@@ -8065,11 +8072,12 @@ static int write_cmd(int argc, char **argv, struct command *cmd, struct plugin *
80658072

80668073
static int verify_cmd(int argc, char **argv, struct command *cmd, struct plugin *plugin)
80678074
{
8068-
__u16 control = 0;
8069-
__u8 lba_index, sts = 0, pif = 0;
80708075
_cleanup_free_ struct nvme_nvm_id_ns *nvm_ns = NULL;
80718076
_cleanup_free_ struct nvme_id_ns *ns = NULL;
80728077
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
8078+
__u8 lba_index, sts = 0, pif = 0;
8079+
__u16 control = 0;
8080+
__u32 elbaf = 0;
80738081
int err;
80748082

80758083
const char *desc = "Verify specified logical blocks on the given device.";
@@ -8163,8 +8171,11 @@ static int verify_cmd(int argc, char **argv, struct command *cmd, struct plugin
81638171
NVME_CSI_NVM, nvm_ns);
81648172
if (!err) {
81658173
nvme_id_ns_flbas_to_lbaf_inuse(ns->flbas, &lba_index);
8166-
sts = nvm_ns->elbaf[lba_index] & NVME_NVM_ELBAF_STS_MASK;
8167-
pif = (nvm_ns->elbaf[lba_index] & NVME_NVM_ELBAF_PIF_MASK) >> 7;
8174+
elbaf = le32_to_cpu(nvm_ns->elbaf[lba_index]);
8175+
sts = elbaf & NVME_NVM_ELBAF_STS_MASK;
8176+
pif = (elbaf & NVME_NVM_ELBAF_PIF_MASK) >> 7;
8177+
if (pif == NVME_NVM_PIF_QTYPE && (nvm_ns->pic & 0x8))
8178+
pif = (elbaf & NVME_NVM_ELBAF_QPIF_MASK) >> 9;
81688179
}
81698180

81708181
if (invalid_tags(cfg.storage_tag, cfg.ref_tag, sts, pif))

0 commit comments

Comments
 (0)