From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 506F56EB4E for ; Thu, 25 Apr 2024 18:47:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714070836; cv=none; b=FMn16oMZjzYiKmOW1RyoWK6EFE9EhGLR/Om448/0QPftcgW+BFJbz9srG04S6dDw91mlOBGFT7bUgszjBobmlKBglk+Xpq2ErmhxKnlmu0NGer6VAtgDNLGBXP5yfcj3+6bxggNUCTntZB9rz66+IaDsBwn+ssh/uTZ/ykz/OQs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714070836; c=relaxed/simple; bh=yjhSZQBWHu+9ooXnHDKChNMvyIgMGhUXB9T+UWulfH0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=jK+WQzQVekfsQxyczgyctMrWj9QqmCp+jhcndk/1rpUgY16RcOMjeo9J2+t7uaPxMgUjauLMIOpZt4FrE3VCqwuwQHY0Fwr60BjE12dPSqYIvX2f7PwVQ7wLk0CwsWd9DkWeNA9K09gej/KYGKf2Cmz2zbkAeN1iF+dXbAKn99U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=VtYVIxFg; arc=none smtp.client-ip=203.254.224.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="VtYVIxFg" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240425184712epoutp0234fc012b4b2d3bb73d8e897a19785c45~Jmlc3_sfT2801828018epoutp020 for ; Thu, 25 Apr 2024 18:47:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240425184712epoutp0234fc012b4b2d3bb73d8e897a19785c45~Jmlc3_sfT2801828018epoutp020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1714070832; bh=GpaNMWMqzUtQKOveThTCzAl0+LvJX9/CNL8Eg2zqipA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VtYVIxFgkXgDu7QRDS2Uc6QnTjsq3ywg+ckiPPZN5/cJtsXLA7yE3sJHBoECbQoXn xr/9CQyd84Ru2wgpLRm3A4ozyAkLQBeGGusV+oZTmFwdroR4l6ST2rJ3cB0ud0fdC0 ewGpLf9Xqj5Ut1Jho1Iq9JOa1QcO3jp9NsQiKNHw= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240425184711epcas5p2ff167da86ca6a3e26396a9b47387ce8b~JmlcTLqnC1621116211epcas5p2Y; Thu, 25 Apr 2024 18:47:11 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.177]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4VQPwZ5lFvz4x9Pv; Thu, 25 Apr 2024 18:47:10 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 7D.E6.19431.E25AA266; Fri, 26 Apr 2024 03:47:10 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240425184710epcas5p2968bbc40ed10d1f0184bb511af054fcb~Jmla3wUSC1896318963epcas5p2H; Thu, 25 Apr 2024 18:47:10 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240425184710epsmtrp2407dc1e395edbb139ed2fd6ca97458fa~Jmla3B_-P0377403774epsmtrp2G; Thu, 25 Apr 2024 18:47:10 +0000 (GMT) X-AuditID: b6c32a50-ccbff70000004be7-d8-662aa52ef286 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 0D.F0.07541.E25AA266; Fri, 26 Apr 2024 03:47:10 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240425184708epsmtip15a805bc42cf84a83e5c58dc63dbc8ef4~JmlZIg4mQ3266832668epsmtip17; Thu, 25 Apr 2024 18:47:08 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, martin.petersen@oracle.com, kbusch@kernel.org, hch@lst.de, brauner@kernel.org Cc: asml.silence@gmail.com, dw@davidwei.uk, io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Kanchan Joshi Subject: [PATCH 10/10] nvme: add separate handling for user integrity buffer Date: Fri, 26 Apr 2024 00:09:43 +0530 Message-Id: <20240425183943.6319-11-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240425183943.6319-1-joshi.k@samsung.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrLJsWRmVeSWpSXmKPExsWy7bCmpq7eUq00g/2ztSzmrNrGaLH6bj+b xevDnxgtXs1Yy2Zx88BOJouVq48yWbxrPcdicfT/WzaLSYeuMVrsvaVtMX/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75r3dS0BW9s/OQtfrq1VclNiKc5INNRiLipOBADpcb0jAwMAAA== X-CMS-MailID: 20240425184710epcas5p2968bbc40ed10d1f0184bb511af054fcb X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240425184710epcas5p2968bbc40ed10d1f0184bb511af054fcb References: <20240425183943.6319-1-joshi.k@samsung.com> For user provided integrity buffer, convert bip flags (guard/reftag/apptag checks) to protocol specific flags. Also pass apptag and reftag down. Signed-off-by: Kanchan Joshi --- drivers/nvme/host/core.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 27281a9a8951..3b719be4eedb 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -886,6 +886,13 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req, return BLK_STS_OK; } +static void nvme_set_app_tag(struct nvme_command *cmnd, u16 apptag) +{ + cmnd->rw.apptag = cpu_to_le16(apptag); + /* use 0xfff as mask so that apptag is used in entirety*/ + cmnd->rw.appmask = cpu_to_le16(0xffff); +} + static void nvme_set_ref_tag(struct nvme_ns *ns, struct nvme_command *cmnd, struct request *req) { @@ -943,6 +950,25 @@ static inline blk_status_t nvme_setup_write_zeroes(struct nvme_ns *ns, return BLK_STS_OK; } +static inline void nvme_setup_user_integrity(struct nvme_ns *ns, + struct request *req, struct nvme_command *cmnd, + u16 *control) +{ + struct bio_integrity_payload *bip = bio_integrity(req->bio); + unsigned short bip_flags = bip->bip_flags; + + if (bip_flags & BIP_USER_CHK_GUARD) + *control |= NVME_RW_PRINFO_PRCHK_GUARD; + if (bip_flags & BIP_USER_CHK_REFTAG) { + *control |= NVME_RW_PRINFO_PRCHK_REF; + nvme_set_ref_tag(ns, cmnd, req); + } + if (bip_flags & BIP_USER_CHK_APPTAG) { + *control |= NVME_RW_PRINFO_PRCHK_APP; + nvme_set_app_tag(cmnd, bip->apptag); + } +} + static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, struct request *req, struct nvme_command *cmnd, enum nvme_opcode op) @@ -983,6 +1009,14 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, if (WARN_ON_ONCE(!nvme_ns_has_pi(ns->head))) return BLK_STS_NOTSUPP; control |= NVME_RW_PRINFO_PRACT; + } else { + /* process user-created integrity */ + if (bio_integrity(req->bio)->bip_flags & + BIP_INTEGRITY_USER) { + nvme_setup_user_integrity(ns, req, cmnd, + &control); + goto out; + } } switch (ns->head->pi_type) { @@ -999,7 +1033,7 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, break; } } - +out: cmnd->rw.control = cpu_to_le16(control); cmnd->rw.dsmgmt = cpu_to_le32(dsmgmt); return 0; -- 2.25.1