linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Himanshu Madhani <himanshu.madhani@oracle.com>
To: James Smart <jsmart2021@gmail.com>, linux-nvme@lists.infradead.org
Cc: martin.petersen@oracle.com
Subject: Re: [PATCH 10/29] nvmefc: Use common definitions for LS names, formatting, and validation
Date: Thu, 26 Mar 2020 11:41:19 -0500	[thread overview]
Message-ID: <b51800ea-4e17-0468-29fa-2463cf494a0f@oracle.com> (raw)
In-Reply-To: <20200205183753.25959-11-jsmart2021@gmail.com>

On 2/5/2020 12:37 PM, James Smart wrote:
> Given that both host and target now generate and receive LS's create
> a single table definition for LS names. Each tranport half will have
> a local version of the table.
> 
> As Create Association LS is issued by both sides, and received by
> both sides, create common routines to format the LS and to validate
> the LS.
> 
> Convert the host side transport to use the new common Create
> Association LS formatting routine.
> 
> Convert the target side transport to use the new common Create
> Association LS validation routine.
> 
> Signed-off-by: James Smart <jsmart2021@gmail.com>
> ---
>   drivers/nvme/host/fc.c   | 25 ++-------------
>   drivers/nvme/host/fc.h   | 79 ++++++++++++++++++++++++++++++++++++++++++++++++
>   drivers/nvme/target/fc.c | 28 ++---------------
>   3 files changed, 83 insertions(+), 49 deletions(-)
> 
> diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
> index 1a58e3dc0399..8fed69504c38 100644
> --- a/drivers/nvme/host/fc.c
> +++ b/drivers/nvme/host/fc.c
> @@ -1421,29 +1421,8 @@ nvme_fc_xmt_disconnect_assoc(struct nvme_fc_ctrl *ctrl)
>   	else
>   		lsreq->private = NULL;
>   
> -	discon_rqst->w0.ls_cmd = FCNVME_LS_DISCONNECT_ASSOC;
> -	discon_rqst->desc_list_len = cpu_to_be32(
> -				sizeof(struct fcnvme_lsdesc_assoc_id) +
> -				sizeof(struct fcnvme_lsdesc_disconn_cmd));
> -
> -	discon_rqst->associd.desc_tag = cpu_to_be32(FCNVME_LSDESC_ASSOC_ID);
> -	discon_rqst->associd.desc_len =
> -			fcnvme_lsdesc_len(
> -				sizeof(struct fcnvme_lsdesc_assoc_id));
> -
> -	discon_rqst->associd.association_id = cpu_to_be64(ctrl->association_id);
> -
> -	discon_rqst->discon_cmd.desc_tag = cpu_to_be32(
> -						FCNVME_LSDESC_DISCONN_CMD);
> -	discon_rqst->discon_cmd.desc_len =
> -			fcnvme_lsdesc_len(
> -				sizeof(struct fcnvme_lsdesc_disconn_cmd));
> -
> -	lsreq->rqstaddr = discon_rqst;
> -	lsreq->rqstlen = sizeof(*discon_rqst);
> -	lsreq->rspaddr = discon_acc;
> -	lsreq->rsplen = sizeof(*discon_acc);
> -	lsreq->timeout = NVME_FC_LS_TIMEOUT_SEC;
> +	nvmefc_fmt_lsreq_discon_assoc(lsreq, discon_rqst, discon_acc,
> +				ctrl->association_id);
>   
>   	ret = nvme_fc_send_ls_req_async(ctrl->rport, lsop,
>   				nvme_fc_disconnect_assoc_done);
> diff --git a/drivers/nvme/host/fc.h b/drivers/nvme/host/fc.h
> index 08fa88381d45..05ce566f2caf 100644
> --- a/drivers/nvme/host/fc.h
> +++ b/drivers/nvme/host/fc.h
> @@ -17,6 +17,7 @@
>    */
>   
>   union nvmefc_ls_requests {
> +	struct fcnvme_ls_rqst_w0		w0;
>   	struct fcnvme_ls_cr_assoc_rqst		rq_cr_assoc;
>   	struct fcnvme_ls_cr_conn_rqst		rq_cr_conn;
>   	struct fcnvme_ls_disconnect_assoc_rqst	rq_dis_assoc;
> @@ -145,4 +146,82 @@ static char *validation_errors[] = {
>   	"Bad Disconnect ACC Length",
>   };
>   
> +#define NVME_FC_LAST_LS_CMD_VALUE	FCNVME_LS_DISCONNECT_CONN
> +
> +static char *nvmefc_ls_names[] = {
> +	"Reserved (0)",
> +	"RJT (1)",
> +	"ACC (2)",
> +	"Create Association",
> +	"Create Connection",
> +	"Disconnect Association",
> +	"Disconnect Connection",
> +};
> +
> +static inline void
> +nvmefc_fmt_lsreq_discon_assoc(struct nvmefc_ls_req *lsreq,
> +	struct fcnvme_ls_disconnect_assoc_rqst *discon_rqst,
> +	struct fcnvme_ls_disconnect_assoc_acc *discon_acc,
> +	u64 association_id)
> +{
> +	lsreq->rqstaddr = discon_rqst;
> +	lsreq->rqstlen = sizeof(*discon_rqst);
> +	lsreq->rspaddr = discon_acc;
> +	lsreq->rsplen = sizeof(*discon_acc);
> +	lsreq->timeout = NVME_FC_LS_TIMEOUT_SEC;
> +
> +	discon_rqst->w0.ls_cmd = FCNVME_LS_DISCONNECT_ASSOC;
> +	discon_rqst->desc_list_len = cpu_to_be32(
> +				sizeof(struct fcnvme_lsdesc_assoc_id) +
> +				sizeof(struct fcnvme_lsdesc_disconn_cmd));
> +
> +	discon_rqst->associd.desc_tag = cpu_to_be32(FCNVME_LSDESC_ASSOC_ID);
> +	discon_rqst->associd.desc_len =
> +			fcnvme_lsdesc_len(
> +				sizeof(struct fcnvme_lsdesc_assoc_id));
> +
> +	discon_rqst->associd.association_id = cpu_to_be64(association_id);
> +
> +	discon_rqst->discon_cmd.desc_tag = cpu_to_be32(
> +						FCNVME_LSDESC_DISCONN_CMD);
> +	discon_rqst->discon_cmd.desc_len =
> +			fcnvme_lsdesc_len(
> +				sizeof(struct fcnvme_lsdesc_disconn_cmd));
> +}
> +
> +static inline int
> +nvmefc_vldt_lsreq_discon_assoc(u32 rqstlen,
> +	struct fcnvme_ls_disconnect_assoc_rqst *rqst)
> +{
> +	int ret = 0;
> +
> +	if (rqstlen < sizeof(struct fcnvme_ls_disconnect_assoc_rqst))
> +		ret = VERR_DISCONN_LEN;
> +	else if (rqst->desc_list_len !=
> +			fcnvme_lsdesc_len(
> +				sizeof(struct fcnvme_ls_disconnect_assoc_rqst)))
> +		ret = VERR_DISCONN_RQST_LEN;
> +	else if (rqst->associd.desc_tag != cpu_to_be32(FCNVME_LSDESC_ASSOC_ID))
> +		ret = VERR_ASSOC_ID;
> +	else if (rqst->associd.desc_len !=
> +			fcnvme_lsdesc_len(
> +				sizeof(struct fcnvme_lsdesc_assoc_id)))
> +		ret = VERR_ASSOC_ID_LEN;
> +	else if (rqst->discon_cmd.desc_tag !=
> +			cpu_to_be32(FCNVME_LSDESC_DISCONN_CMD))
> +		ret = VERR_DISCONN_CMD;
> +	else if (rqst->discon_cmd.desc_len !=
> +			fcnvme_lsdesc_len(
> +				sizeof(struct fcnvme_lsdesc_disconn_cmd)))
> +		ret = VERR_DISCONN_CMD_LEN;
> +	/*
> +	 * As the standard changed on the LS, check if old format and scope
> +	 * something other than Association (e.g. 0).
> +	 */
> +	else if (rqst->discon_cmd.rsvd8[0])
> +		ret = VERR_DISCONN_SCOPE;
> +
> +	return ret;
> +}
> +
>   #endif /* _NVME_FC_TRANSPORT_H */
> diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
> index 66a60a218994..5739df7edc59 100644
> --- a/drivers/nvme/target/fc.c
> +++ b/drivers/nvme/target/fc.c
> @@ -1442,32 +1442,8 @@ nvmet_fc_ls_disconnect(struct nvmet_fc_tgtport *tgtport,
>   
>   	memset(acc, 0, sizeof(*acc));
>   
> -	if (iod->rqstdatalen < sizeof(struct fcnvme_ls_disconnect_assoc_rqst))
> -		ret = VERR_DISCONN_LEN;
> -	else if (rqst->desc_list_len !=
> -			fcnvme_lsdesc_len(
> -				sizeof(struct fcnvme_ls_disconnect_assoc_rqst)))
> -		ret = VERR_DISCONN_RQST_LEN;
> -	else if (rqst->associd.desc_tag != cpu_to_be32(FCNVME_LSDESC_ASSOC_ID))
> -		ret = VERR_ASSOC_ID;
> -	else if (rqst->associd.desc_len !=
> -			fcnvme_lsdesc_len(
> -				sizeof(struct fcnvme_lsdesc_assoc_id)))
> -		ret = VERR_ASSOC_ID_LEN;
> -	else if (rqst->discon_cmd.desc_tag !=
> -			cpu_to_be32(FCNVME_LSDESC_DISCONN_CMD))
> -		ret = VERR_DISCONN_CMD;
> -	else if (rqst->discon_cmd.desc_len !=
> -			fcnvme_lsdesc_len(
> -				sizeof(struct fcnvme_lsdesc_disconn_cmd)))
> -		ret = VERR_DISCONN_CMD_LEN;
> -	/*
> -	 * As the standard changed on the LS, check if old format and scope
> -	 * something other than Association (e.g. 0).
> -	 */
> -	else if (rqst->discon_cmd.rsvd8[0])
> -		ret = VERR_DISCONN_SCOPE;
> -	else {
> +	ret = nvmefc_vldt_lsreq_discon_assoc(iod->rqstdatalen, rqst);
> +	if (!ret) {
>   		/* match an active association */
>   		assoc = nvmet_fc_find_target_assoc(tgtport,
>   				be64_to_cpu(rqst->associd.association_id));
> 

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  parent reply	other threads:[~2020-03-26 16:41 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-05 18:37 [PATCH 00/29] nvme-fc/nvmet-fc: Add FC-NVME-2 disconnect association support James Smart
2020-02-05 18:37 ` [PATCH 01/29] nvme-fc: Sync header to FC-NVME-2 rev 1.08 James Smart
2020-02-28 20:36   ` Sagi Grimberg
2020-03-06  8:16   ` Hannes Reinecke
2020-03-26 16:10   ` Himanshu Madhani
2020-02-05 18:37 ` [PATCH 02/29] nvmet-fc: fix typo in comment James Smart
2020-02-28 20:36   ` Sagi Grimberg
2020-03-06  8:17   ` Hannes Reinecke
2020-03-26 16:10   ` Himanshu Madhani
2020-02-05 18:37 ` [PATCH 03/29] nvme-fc and nvmet-fc: revise LLDD api for LS reception and LS request James Smart
2020-02-28 20:38   ` Sagi Grimberg
2020-03-06  8:19   ` Hannes Reinecke
2020-03-26 16:16   ` Himanshu Madhani
2020-02-05 18:37 ` [PATCH 04/29] nvme-fc nvmet_fc nvme_fcloop: adapt code to changed names in api header James Smart
2020-02-28 20:40   ` Sagi Grimberg
2020-03-06  8:21   ` Hannes Reinecke
2020-03-26 16:26   ` Himanshu Madhani
2020-02-05 18:37 ` [PATCH 05/29] lpfc: " James Smart
2020-02-28 20:40   ` Sagi Grimberg
2020-03-06  8:25   ` Hannes Reinecke
2020-03-26 16:30   ` Himanshu Madhani
2020-02-05 18:37 ` [PATCH 06/29] nvme-fcloop: Fix deallocation of working context James Smart
2020-02-28 20:43   ` Sagi Grimberg
2020-03-06  8:34   ` Hannes Reinecke
2020-03-26 16:35   ` Himanshu Madhani
2020-02-05 18:37 ` [PATCH 07/29] nvme-fc nvmet-fc: refactor for common LS definitions James Smart
2020-03-06  8:35   ` Hannes Reinecke
2020-03-26 16:36   ` Himanshu Madhani
2020-02-05 18:37 ` [PATCH 08/29] nvmet-fc: Better size LS buffers James Smart
2020-02-28 21:04   ` Sagi Grimberg
2020-03-06  8:36   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 09/29] nvme-fc: Ensure private pointers are NULL if no data James Smart
2020-02-28 21:05   ` Sagi Grimberg
2020-03-06  8:44   ` Hannes Reinecke
2020-03-26 16:39   ` Himanshu Madhani
2020-02-05 18:37 ` [PATCH 10/29] nvmefc: Use common definitions for LS names, formatting, and validation James Smart
2020-03-06  8:44   ` Hannes Reinecke
2020-03-26 16:41   ` Himanshu Madhani [this message]
2020-02-05 18:37 ` [PATCH 11/29] nvme-fc: convert assoc_active flag to atomic James Smart
2020-02-28 21:08   ` Sagi Grimberg
2020-03-06  8:47   ` Hannes Reinecke
2020-03-26 19:16   ` Himanshu Madhani
2020-02-05 18:37 ` [PATCH 12/29] nvme-fc: Add Disconnect Association Rcv support James Smart
2020-03-06  9:00   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 13/29] nvmet-fc: add LS failure messages James Smart
2020-03-06  9:01   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 14/29] nvmet-fc: perform small cleanups on unneeded checks James Smart
2020-03-06  9:01   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 15/29] nvmet-fc: track hostport handle for associations James Smart
2020-03-06  9:02   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 16/29] nvmet-fc: rename ls_list to ls_rcv_list James Smart
2020-03-06  9:03   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 17/29] nvmet-fc: Add Disconnect Association Xmt support James Smart
2020-03-06  9:04   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 18/29] nvme-fcloop: refactor to enable target to host LS James Smart
2020-03-06  9:06   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 19/29] nvme-fcloop: add target to host LS request support James Smart
2020-03-06  9:07   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 20/29] lpfc: Refactor lpfc nvme headers James Smart
2020-03-06  9:18   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 21/29] lpfc: Refactor nvmet_rcv_ctx to create lpfc_async_xchg_ctx James Smart
2020-03-06  9:19   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 22/29] lpfc: Commonize lpfc_async_xchg_ctx state and flag definitions James Smart
2020-03-06  9:19   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 23/29] lpfc: Refactor NVME LS receive handling James Smart
2020-03-06  9:20   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 24/29] lpfc: Refactor Send LS Request support James Smart
2020-03-06  9:20   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 25/29] lpfc: Refactor Send LS Abort support James Smart
2020-03-06  9:21   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 26/29] lpfc: Refactor Send LS Response support James Smart
2020-03-06  9:21   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 27/29] lpfc: nvme: Add Receive LS Request and Send LS Response support to nvme James Smart
2020-03-06  9:23   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 28/29] lpfc: nvmet: Add support for NVME LS request hosthandle James Smart
2020-03-06  9:23   ` Hannes Reinecke
2020-02-05 18:37 ` [PATCH 29/29] lpfc: nvmet: Add Send LS Request and Abort LS Request support James Smart
2020-03-06  9:24   ` Hannes Reinecke
2020-03-06  9:26 ` [PATCH 00/29] nvme-fc/nvmet-fc: Add FC-NVME-2 disconnect association support Hannes Reinecke
2020-03-31 14:29 ` 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=b51800ea-4e17-0468-29fa-2463cf494a0f@oracle.com \
    --to=himanshu.madhani@oracle.com \
    --cc=jsmart2021@gmail.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=martin.petersen@oracle.com \
    /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).