* [PATCH] nvme-core: choose PIF from QPIF if QPIFS supports and PIF is QTYPE
[not found] <CGME20240715063116epcas5p1d5653ed4b1f71c1a4542f9315a62b6db@epcas5p1.samsung.com>
@ 2024-07-15 1:01 ` francis.p
2024-07-16 4:32 ` Christoph Hellwig
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: francis.p @ 2024-07-15 1:01 UTC (permalink / raw)
To: kbusch, axboe, hch, sagi
Cc: linux-nvme, anshul, jg123.choi, prakash.bv, d.palani, sathya.m,
Francis Pravin
From: Francis Pravin <francis.p@samsung.com>
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>
---
drivers/nvme/host/core.c | 8 +++++++-
include/linux/nvme.h | 9 +++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 782090ce0bc1..205174d45fac 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1844,12 +1844,18 @@ static void nvme_configure_pi_elbas(struct nvme_ns_head *head,
struct nvme_id_ns *id, struct nvme_id_ns_nvm *nvm)
{
u32 elbaf = le32_to_cpu(nvm->elbaf[nvme_lbaf_index(id->flbas)]);
+ u8 guard_type;
/* no support for storage tag formats right now */
if (nvme_elbaf_sts(elbaf))
return;
- head->guard_type = nvme_elbaf_guard_type(elbaf);
+ guard_type = nvme_elbaf_guard_type(elbaf);
+ if ((nvm->pic & NVME_ID_NS_NVM_QPIFS) &&
+ guard_type == NVME_NVM_NS_QTYPE_GUARD)
+ guard_type = nvme_elbaf_qualified_guard_type(elbaf);
+
+ head->guard_type = guard_type;
switch (head->guard_type) {
case NVME_NVM_NS_64B_GUARD:
head->pi_size = sizeof(struct crc64_pi_tuple);
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index c693ac344ec0..857fde303c36 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -482,6 +482,9 @@ enum {
NVME_ID_NS_NVM_STS_MASK = 0x7f,
NVME_ID_NS_NVM_GUARD_SHIFT = 7,
NVME_ID_NS_NVM_GUARD_MASK = 0x3,
+ NVME_ID_NS_NVM_QPIF_SHIFT = 9,
+ NVME_ID_NS_NVM_QPIF_MASK = 0xf,
+ NVME_ID_NS_NVM_QPIFS = 1 << 3,
};
static inline __u8 nvme_elbaf_sts(__u32 elbaf)
@@ -494,6 +497,11 @@ static inline __u8 nvme_elbaf_guard_type(__u32 elbaf)
return (elbaf >> NVME_ID_NS_NVM_GUARD_SHIFT) & NVME_ID_NS_NVM_GUARD_MASK;
}
+static inline __u8 nvme_elbaf_qualified_guard_type(__u32 elbaf)
+{
+ return (elbaf >> NVME_ID_NS_NVM_QPIF_SHIFT) & NVME_ID_NS_NVM_QPIF_MASK;
+}
+
struct nvme_id_ctrl_nvm {
__u8 vsl;
__u8 wzsl;
@@ -573,6 +581,7 @@ enum {
NVME_NVM_NS_16B_GUARD = 0,
NVME_NVM_NS_32B_GUARD = 1,
NVME_NVM_NS_64B_GUARD = 2,
+ NVME_NVM_NS_QTYPE_GUARD = 3,
};
static inline __u8 nvme_lbaf_index(__u8 flbas)
--
2.43.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme-core: choose PIF from QPIF if QPIFS supports and PIF is QTYPE
2024-07-15 1:01 ` [PATCH] nvme-core: choose PIF from QPIF if QPIFS supports and PIF is QTYPE francis.p
@ 2024-07-16 4:32 ` Christoph Hellwig
2024-07-16 6:28 ` Sagi Grimberg
2024-07-16 14:56 ` Keith Busch
2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2024-07-16 4:32 UTC (permalink / raw)
To: francis.p
Cc: kbusch, axboe, hch, sagi, linux-nvme, anshul, jg123.choi,
prakash.bv, d.palani, sathya.m
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme-core: choose PIF from QPIF if QPIFS supports and PIF is QTYPE
2024-07-15 1:01 ` [PATCH] nvme-core: choose PIF from QPIF if QPIFS supports and PIF is QTYPE francis.p
2024-07-16 4:32 ` Christoph Hellwig
@ 2024-07-16 6:28 ` Sagi Grimberg
2024-07-16 14:56 ` Keith Busch
2 siblings, 0 replies; 4+ messages in thread
From: Sagi Grimberg @ 2024-07-16 6:28 UTC (permalink / raw)
To: francis.p, kbusch, axboe, hch
Cc: linux-nvme, anshul, jg123.choi, prakash.bv, d.palani, sathya.m
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme-core: choose PIF from QPIF if QPIFS supports and PIF is QTYPE
2024-07-15 1:01 ` [PATCH] nvme-core: choose PIF from QPIF if QPIFS supports and PIF is QTYPE francis.p
2024-07-16 4:32 ` Christoph Hellwig
2024-07-16 6:28 ` Sagi Grimberg
@ 2024-07-16 14:56 ` Keith Busch
2 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2024-07-16 14:56 UTC (permalink / raw)
To: francis.p
Cc: axboe, hch, sagi, linux-nvme, anshul, jg123.choi, prakash.bv,
d.palani, sathya.m
On Mon, Jul 15, 2024 at 06:31:57AM +0530, francis.p@samsung.com wrote:
> From: Francis Pravin <francis.p@samsung.com>
>
> 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.
Thanks, applied to nvme-6.11.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-07-16 14:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20240715063116epcas5p1d5653ed4b1f71c1a4542f9315a62b6db@epcas5p1.samsung.com>
2024-07-15 1:01 ` [PATCH] nvme-core: choose PIF from QPIF if QPIFS supports and PIF is QTYPE francis.p
2024-07-16 4:32 ` Christoph Hellwig
2024-07-16 6:28 ` Sagi Grimberg
2024-07-16 14:56 ` Keith Busch
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.