mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Max Gurtovoy <maxg@mellanox.com>
To: Johannes Thumshirn <jthumshirn@suse.de>,
	Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
	Keith Busch <keith.busch@intel.com>
Cc: Hannes Reinecke <hare@suse.de>,
	Linux NVMe Mailinglist <linux-nvme@lists.infradead.org>,
	Linux Kernel Mailinglist <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1 4/7] nvme: get list of namespace descriptors
Date: Wed, 31 May 2017 22:13:41 +0300	[thread overview]
Message-ID: <60cf348d-45cb-5bd1-9f75-7b9e22f30826@mellanox.com> (raw)
In-Reply-To: <f51d09c4e22189e8979a92a46faa98778034afe6.1496237370.git.jthumshirn@suse.de>



On 5/31/2017 4:32 PM, Johannes Thumshirn wrote:
> If a target identifies itself as NVMe 1.3 compliant, try to get the
> list of Namespace Identification Descriptors and populate the UUID,
> NGUID and EUI64 fileds in the NVMe namespace structure with these
> values.
>
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>  drivers/nvme/host/core.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/nvme/host/nvme.h |  1 +
>  2 files changed, 89 insertions(+)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 7b254be16887..9acbf56c8796 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -643,6 +643,71 @@ int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id)
>  	return error;
>  }
>
> +static void nvme_parse_ns_descs(struct nvme_ns *ns, void *ns_nid)
> +{
> +	struct nvme_ns_nid *cur;
> +	const u8 *p;
> +	int pos = 0;
> +	int len;
> +
> +	p = (u8 *)ns_nid;
> +
> +	for (;;) {
> +		cur = (struct nvme_ns_nid *)p;
> +
> +		switch (cur->nidl) {
> +		case 0:
> +			return;
> +		case 8:
> +		case 16:

consider using the length defines from <linux/nvme.h> instead of 8/16,
it's more intuitive code this way.
Actually, to be safer, you can check the length inside the second 
switch/case per case.

> +			break;
> +		default:
> +			dev_warn(ns->ctrl->dev,
> +				 "Target returned bogus Namespace Identification Descriptor length: %d\n",
> +				 cur->nidl);
> +			return;
> +
> +		}
> +
> +		switch (cur->nidt) {
> +		case NVME_NIDT_EUI64:
> +			len = NVME_NIDT_EUI64_LEN;
> +			memcpy(ns->eui, cur->nid, len);
> +			break;
> +		case NVME_NIDT_NGUID:
> +			len = NVME_NIDT_NGUID_LEN;
> +			memcpy(ns->nguid, cur->nid, len);
> +			break;
> +		case NVME_NIDT_UUID:
> +			len = NVME_NIDT_UUID_LEN;
> +			memcpy(ns->uuid, cur->nid, len);
> +			break;
> +		default:
> +			dev_warn(ns->ctrl->dev,
> +				 "Invalid Namespace Identification Descriptor Type: %d\n",
> +				 cur->nidt);
> +			return;
> +		}
> +
> +		pos += sizeof(struct nvme_ns_nid) + len;
> +		if (pos >= SZ_4K)
> +			return;
> +		p += pos;
> +	}
> +}
> +

  reply	other threads:[~2017-05-31 19:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-31 13:32 [PATCH v1 0/7] Implement NVMe Namespace Descriptor Identification Johannes Thumshirn
2017-05-31 13:32 ` [PATCH v1 1/7] nvme: rename uuid to nguid in nvme_ns Johannes Thumshirn
2017-06-01  6:33   ` Christoph Hellwig
2017-05-31 13:32 ` [PATCH v1 2/7] nvmet: add uuid field to nvme_ns and populate via configfs Johannes Thumshirn
2017-06-01  6:34   ` Christoph Hellwig
2017-05-31 13:32 ` [PATCH v1 3/7] nvmet: implement namespace identify descriptor list Johannes Thumshirn
2017-06-01  6:42   ` Christoph Hellwig
2017-05-31 13:32 ` [PATCH v1 4/7] nvme: get list of namespace descriptors Johannes Thumshirn
2017-05-31 19:13   ` Max Gurtovoy [this message]
2017-06-01  6:49   ` Christoph Hellwig
2017-05-31 13:32 ` [PATCH v1 5/7] nvme: provide UUID value to userspace Johannes Thumshirn
2017-06-01  6:49   ` Christoph Hellwig
2017-05-31 13:32 ` [PATCH v1 6/7] nvme: change magic 4096 to SZ_4K Johannes Thumshirn
2017-06-01  6:50   ` Christoph Hellwig
2017-05-31 13:32 ` [PATCH v1 7/7] nvmet: allow overriding the NVMe VS via configfs Johannes Thumshirn
2017-06-01  6:52   ` Christoph Hellwig
2017-06-01  6:59     ` Hannes Reinecke

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=60cf348d-45cb-5bd1-9f75-7b9e22f30826@mellanox.com \
    --to=maxg@mellanox.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jthumshirn@suse.de \
    --cc=keith.busch@intel.com \
    --cc=linux-kernel@vger.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

all inboxes | Powered by JetHome®