From: Kanchan Joshi <joshi.k@samsung.com>
To: josef@toxicpanda.com, dsterba@suse.com, clm@fb.com,
axboe@kernel.dk, kbusch@kernel.org, hch@lst.de
Cc: linux-btrfs@vger.kernel.org, linux-nvme@lists.infradead.org,
linux-block@vger.kernel.org, gost.dev@samsung.com,
Kanchan Joshi <joshi.k@samsung.com>
Subject: [RFC 2/3] nvme: support integrity offload
Date: Wed, 29 Jan 2025 19:32:06 +0530 [thread overview]
Message-ID: <20250129140207.22718-3-joshi.k@samsung.com> (raw)
In-Reply-To: <20250129140207.22718-1-joshi.k@samsung.com>
Register the integrity offload with the block layer if it is supported
by the device.
Serve incoming offload requests by setting PRACT and GUARD check.
Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
---
drivers/nvme/host/core.c | 24 ++++++++++++++++++++++++
drivers/nvme/host/nvme.h | 1 +
2 files changed, 25 insertions(+)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index f4b8d6a0984a..1fae0a6a932e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -984,6 +984,7 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
{
u16 control = 0;
u32 dsmgmt = 0;
+ u8 type;
if (req->cmd_flags & REQ_FUA)
control |= NVME_RW_FUA;
@@ -1022,7 +1023,21 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
return BLK_STS_NOTSUPP;
control |= NVME_RW_PRINFO_PRACT;
}
+ if (req->cmd_flags & REQ_INTEGRITY_OFFLOAD) {
+ type = ns->head->pi_offload_type;
+ if (type == BLK_INTEGRITY_OFFLOAD_NONE ||
+ (type == BLK_INTEGRITY_OFFLOAD_BUF &&
+ !blk_integrity_rq(req))) {
+ WARN_ON_ONCE(1);
+ return BLK_STS_NOTSUPP;
+ }
+
+ control |= NVME_RW_PRINFO_PRACT |
+ NVME_RW_PRINFO_PRCHK_GUARD;
+ /* skip redundant processing for offload */
+ goto out;
+ }
if (bio_integrity_flagged(req->bio, BIP_CHECK_GUARD))
control |= NVME_RW_PRINFO_PRCHK_GUARD;
if (bio_integrity_flagged(req->bio, BIP_CHECK_REFTAG)) {
@@ -1037,6 +1052,7 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
}
}
+out:
cmnd->rw.control = cpu_to_le16(control);
cmnd->rw.dsmgmt = cpu_to_le32(dsmgmt);
return 0;
@@ -1846,6 +1862,14 @@ static bool nvme_init_integrity(struct nvme_ns_head *head,
bi->tuple_size = head->ms;
bi->pi_offset = info->pi_offset;
+ if (bi->csum_type != BLK_INTEGRITY_CSUM_NONE) {
+ if (head->ms == head->pi_size)
+ bi->offload_type = BLK_INTEGRITY_OFFLOAD_NO_BUF;
+ else
+ bi->offload_type = BLK_INTEGRITY_OFFLOAD_BUF;
+ head->pi_offload_type = bi->offload_type;
+ }
+
return true;
}
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 7be92d07430e..add04583b040 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -476,6 +476,7 @@ struct nvme_ns_head {
u16 pi_size;
u8 pi_type;
u8 guard_type;
+ u8 pi_offload_type;
struct list_head entry;
struct kref ref;
bool shared;
--
2.25.1
next prev parent reply other threads:[~2025-01-29 14:10 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20250129141039epcas5p11feb1be4124c0db3c5223325924183a3@epcas5p1.samsung.com>
2025-01-29 14:02 ` [RFC 0/3] Btrfs checksum offload Kanchan Joshi
2025-01-29 14:02 ` [RFC 1/3] block: add integrity offload Kanchan Joshi
2025-01-29 14:02 ` Kanchan Joshi [this message]
2025-01-29 14:02 ` [RFC 3/3] btrfs: add checksum offload Kanchan Joshi
2025-01-29 21:27 ` Qu Wenruo
2025-01-29 14:55 ` [RFC 0/3] Btrfs " Johannes Thumshirn
2025-01-31 10:19 ` Kanchan Joshi
2025-01-31 10:29 ` Johannes Thumshirn
2025-02-03 13:25 ` Kanchan Joshi
2025-02-03 13:40 ` Johannes Thumshirn
2025-02-03 14:03 ` Kanchan Joshi
2025-02-03 14:41 ` Johannes Thumshirn
2025-01-29 15:28 ` Keith Busch
2025-01-29 15:40 ` Christoph Hellwig
2025-01-29 18:03 ` Keith Busch
2025-01-30 12:54 ` Christoph Hellwig
2025-01-29 15:35 ` Christoph Hellwig
2025-01-30 9:22 ` Kanchan Joshi
2025-01-30 12:53 ` Christoph Hellwig
2025-01-31 10:29 ` Kanchan Joshi
2025-01-31 10:42 ` Christoph Hellwig
2025-01-29 15:55 ` Mark Harmstone
2025-01-29 19:02 ` Goffredo Baroncelli
2025-01-30 9:33 ` Daniel Vacek
2025-01-30 20:21 ` Martin K. Petersen
2025-01-31 7:44 ` Christoph Hellwig
2025-02-03 19:31 ` Martin K. Petersen
2025-02-04 5:12 ` Christoph Hellwig
2025-02-04 12:52 ` Martin K. Petersen
2025-02-04 13:49 ` Christoph Hellwig
2025-02-05 2:31 ` Martin K. Petersen
2025-02-03 13:24 ` Kanchan Joshi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250129140207.22718-3-joshi.k@samsung.com \
--to=joshi.k@samsung.com \
--cc=axboe@kernel.dk \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=gost.dev@samsung.com \
--cc=hch@lst.de \
--cc=josef@toxicpanda.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox