public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Chaitanya Kulkarni <kch@nvidia.com>
Cc: hare@suse.de, linux-nvme@lists.infradead.org, hch@lst.de,
	sagi@grimberg.me
Subject: Re: [PATCH 3/3] nvme-fabrics: factor out common for auth
Date: Tue, 23 May 2023 09:00:36 +0200	[thread overview]
Message-ID: <20230523070036.GA8599@lst.de> (raw)
In-Reply-To: <20230522130408.105328-4-kch@nvidia.com>

On Mon, May 22, 2023 at 06:04:08AM -0700, Chaitanya Kulkarni wrote:
> nvmf_connect_admin_queue and nvmf_connect_io_queue() shares common code
> for post connect command authentication processing that includes,
> returning appropriate NVMe authentication status based on the
> command result, authentication negotiation per qid, waiting on
> negotiation per qid.
> 
> Add a common helper function to reduce the code duplication with
> necessary aruments of qid and result of connect command.
> 
> No functional changes in this patch.
> 
> Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
> ---
>  drivers/nvme/host/fabrics.c | 81 ++++++++++++++++---------------------
>  1 file changed, 35 insertions(+), 46 deletions(-)
> 
> diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
> index 9d3df63eb49a..1d48c0b77cd0 100644
> --- a/drivers/nvme/host/fabrics.c
> +++ b/drivers/nvme/host/fabrics.c
> @@ -433,6 +433,39 @@ static void nvmf_connect_cmd_prep(struct nvme_ctrl *ctrl, u16 qid,
>  		cmd->connect.cattr |= NVME_CONNECT_DISABLE_SQFLOW;
>  }
>  
> +static u16 nvmf_auth_post_queue_connect(struct nvme_ctrl *ctrl, u16 qid,
> +					u32 result)
> +{
> +	int ret;
> +
> +	if (!(result & (NVME_CONNECT_AUTHREQ_ATR | NVME_CONNECT_AUTHREQ_ASCR)))
> +		return NVME_SC_SUCCESS;

While it's a minor duplication, I'd prepfer to keep this check in the
callers.  That makes it very explicit we are only calling into the helper
when authentication is required.

> +	ret = nvme_auth_wait(ctrl, qid);
> +	if (ret) {
> +		dev_warn(ctrl->device, "qid %u: authentication failed\n", qid);
> +		return ret;
> +	}
> +	if (!ret && qid == 0)

ret must be 0 at this point bsed on the check above.


  reply	other threads:[~2023-05-23  7:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22 13:04 [PATCH 0/3] nvme-fabrics: auth fixes and cleanup Chaitanya Kulkarni
2023-05-22 13:04 ` [PATCH 1/3] nvme-fabrics: fix qid in error message Chaitanya Kulkarni
2023-05-23  6:58   ` Christoph Hellwig
2023-05-22 13:04 ` [PATCH 2/3] nvme-fabrics: error out when connect I/O fails Chaitanya Kulkarni
2023-05-23  6:58   ` Christoph Hellwig
2023-05-22 13:04 ` [PATCH 3/3] nvme-fabrics: factor out common for auth Chaitanya Kulkarni
2023-05-23  7:00   ` Christoph Hellwig [this message]
2023-05-23  8:31     ` Chaitanya Kulkarni

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=20230523070036.GA8599@lst.de \
    --to=hch@lst.de \
    --cc=hare@suse.de \
    --cc=kch@nvidia.com \
    --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