linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <kch@nvidia.com>
To: <hare@suse.de>
Cc: <hch@lst.de>, <sagi@grimberg.me>,
	<linux-nvme@lists.infradead.org>, <kbusch@kernel.org>,
	Chaitanya Kulkarni <kch@nvidia.com>
Subject: [PATCH V2 3/4] nvmet-auth: use helper for auth send/recv cmd prep
Date: Sun, 4 Jun 2023 23:44:33 -0700	[thread overview]
Message-ID: <20230605064434.45233-4-kch@nvidia.com> (raw)
In-Reply-To: <20230605064434.45233-1-kch@nvidia.com>

Add a common helper to factor out secp/spsp values check and transfer
buffer allocation in nvmet_execute_auth_send() and
nvmet_execute_auth_receive().

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/nvme/target/fabrics-cmd-auth.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/nvme/target/fabrics-cmd-auth.c b/drivers/nvme/target/fabrics-cmd-auth.c
index 778961e231a3..d331c22ed26e 100644
--- a/drivers/nvme/target/fabrics-cmd-auth.c
+++ b/drivers/nvme/target/fabrics-cmd-auth.c
@@ -41,6 +41,15 @@ static u16 nvmet_auth_alloc_transfer_buffer(struct nvmet_req *req, void **buf,
 	return *buf ? NVME_SC_SUCCESS : NVME_SC_INTERNAL;
 }
 
+static u16 nvmet_auth_common_prep(struct nvmet_req *req, void **buf, u32 *len)
+{
+	u16 status = nvmet_auth_check_secp_spsp(req);
+
+	if (status)
+		return status;
+	return nvmet_auth_alloc_transfer_buffer(req, buf, len);
+}
+
 static void nvmet_auth_expired_work(struct work_struct *work)
 {
 	struct nvmet_sq *sq = container_of(to_delayed_work(work),
@@ -216,10 +225,7 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
 	u32 tl;
 	u16 status;
 
-	status = nvmet_auth_check_secp_spsp(req);
-	if (status)
-		goto done;
-	status = nvmet_auth_alloc_transfer_buffer(req, &d, &tl);
+	status = nvmet_auth_common_prep(req, &d, &tl);
 	if (status)
 		goto done;
 
@@ -440,10 +446,7 @@ void nvmet_execute_auth_receive(struct nvmet_req *req)
 	u32 al;
 	u16 status;
 
-	status = nvmet_auth_check_secp_spsp(req);
-	if (status)
-		goto done;
-	status = nvmet_auth_alloc_transfer_buffer(req, &d, &al);
+	status = nvmet_auth_common_prep(req, &d, &al);
 	if (status)
 		goto done;
 	if (!nvmet_check_transfer_len(req, al)) {
-- 
2.40.0



  parent reply	other threads:[~2023-06-05  6:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-05  6:44 [PATCH V2 0/4] nvmet-auth: auth send / receive cleanup Chaitanya Kulkarni
2023-06-05  6:44 ` [PATCH V2 1/4] nvmet-auth: use common helper to check secp/spsp Chaitanya Kulkarni
2023-06-05  7:42   ` Hannes Reinecke
2023-06-05  6:44 ` [PATCH V2 2/4] nvmet_auth: use common helper for buffer alloc Chaitanya Kulkarni
2023-06-05  7:45   ` Hannes Reinecke
2023-06-05  6:44 ` Chaitanya Kulkarni [this message]
2023-06-05  7:46   ` [PATCH V2 3/4] nvmet-auth: use helper for auth send/recv cmd prep Hannes Reinecke
2023-06-05  8:41     ` Chaitanya Kulkarni
2023-06-07  4:57   ` Christoph Hellwig
2023-06-05  6:44 ` [PATCH V2 4/4] nvmet-auth: use correct type for status variable Chaitanya Kulkarni
2023-06-05  7:49   ` Hannes Reinecke
2023-06-07  4:58   ` Christoph Hellwig

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=20230605064434.45233-4-kch@nvidia.com \
    --to=kch@nvidia.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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;
as well as URLs for NNTP newsgroup(s).